summaryrefslogtreecommitdiffstats
path: root/src/com/android/packageinstaller/PackageUtil.java
diff options
context:
space:
mode:
authorSuchi Amalapurapu <asuchitra@google.com>2010-03-11 10:54:44 -0800
committerSuchi Amalapurapu <asuchitra@google.com>2010-03-11 14:29:54 -0800
commit9ab50f3655afed4f9266402a03d3235d94220397 (patch)
treea0755e70e683d841fee32be90d94636cfc9b038c /src/com/android/packageinstaller/PackageUtil.java
parentdc7d3d29d2d058e795ab7650a611027d981e4a71 (diff)
downloadandroid_packages_apps_PackageInstaller-9ab50f3655afed4f9266402a03d3235d94220397.tar.gz
android_packages_apps_PackageInstaller-9ab50f3655afed4f9266402a03d3235d94220397.tar.bz2
android_packages_apps_PackageInstaller-9ab50f3655afed4f9266402a03d3235d94220397.zip
Remove memory checks in side loading ui
Move dialog for insufficient storage as a post-install error handle dialog Change-Id: I419b1dc233e01fc91e29d1274bae17d5bd63a60d
Diffstat (limited to 'src/com/android/packageinstaller/PackageUtil.java')
-rw-r--r--src/com/android/packageinstaller/PackageUtil.java57
1 files changed, 38 insertions, 19 deletions
diff --git a/src/com/android/packageinstaller/PackageUtil.java b/src/com/android/packageinstaller/PackageUtil.java
index 3d40f7de..45c42890 100644
--- a/src/com/android/packageinstaller/PackageUtil.java
+++ b/src/com/android/packageinstaller/PackageUtil.java
@@ -115,9 +115,44 @@ public class PackageUtil {
* @param appInfo ApplicationInfo object of package whose resources are to be loaded
* @param snippetId view id of app snippet view
*/
- public static View initSnippetForNewApp(Activity pContext, ApplicationInfo appInfo,
- int snippetId, Uri packageURI) {
+ public static View initSnippetForNewApp(Activity pContext, AppSnippet as,
+ int snippetId) {
View appSnippet = pContext.findViewById(snippetId);
+ ((ImageView)appSnippet.findViewById(R.id.app_icon)).setImageDrawable(as.icon);
+ ((TextView)appSnippet.findViewById(R.id.app_name)).setText(as.label);
+ return appSnippet;
+ }
+
+ public static boolean isPackageAlreadyInstalled(Activity context, String pkgName) {
+ List<PackageInfo> installedList = context.getPackageManager().getInstalledPackages(
+ PackageManager.GET_UNINSTALLED_PACKAGES);
+ int installedListSize = installedList.size();
+ for(int i = 0; i < installedListSize; i++) {
+ PackageInfo tmp = installedList.get(i);
+ if(pkgName.equalsIgnoreCase(tmp.packageName)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ static public class AppSnippet {
+ CharSequence label;
+ Drawable icon;
+ public AppSnippet(CharSequence label, Drawable icon) {
+ this.label = label;
+ this.icon = icon;
+ }
+ }
+ /*
+ * Utility method to load application label
+ *
+ * @param pContext context of package that can load the resources
+ * @param appInfo ApplicationInfo object of package whose resources are to be loaded
+ * @param snippetId view id of app snippet view
+ */
+ public static AppSnippet getAppSnippet(Activity pContext, ApplicationInfo appInfo,
+ Uri packageURI) {
final String archiveFilePath = packageURI.getPath();
Resources pRes = pContext.getResources();
AssetManager assmgr = new AssetManager();
@@ -148,22 +183,6 @@ public class PackageUtil {
if (icon == null) {
icon = pContext.getPackageManager().getDefaultActivityIcon();
}
- ((ImageView)appSnippet.findViewById(R.id.app_icon)).setImageDrawable(icon);
- ((TextView)appSnippet.findViewById(R.id.app_name)).setText(label);
- return appSnippet;
- }
-
- public static boolean isPackageAlreadyInstalled(Activity context, String pkgName) {
- List<PackageInfo> installedList = context.getPackageManager().getInstalledPackages(
- PackageManager.GET_UNINSTALLED_PACKAGES);
- int installedListSize = installedList.size();
- for(int i = 0; i < installedListSize; i++) {
- PackageInfo tmp = installedList.get(i);
- if(pkgName.equalsIgnoreCase(tmp.packageName)) {
- return true;
- }
-
- }
- return false;
+ return new PackageUtil.AppSnippet(label, icon);
}
}