summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:06:00 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:06:00 -0800
commit092149c8a75237c476a917d57c48f8b8cd51f0f0 (patch)
tree43bd01dcf05cefc4b0a8334ba7571c35f53341f2 /src
parent088073e6787fca4bfc68d6b04a5e887a03faf745 (diff)
downloadandroid_packages_apps_PackageInstaller-092149c8a75237c476a917d57c48f8b8cd51f0f0.tar.gz
android_packages_apps_PackageInstaller-092149c8a75237c476a917d57c48f8b8cd51f0f0.tar.bz2
android_packages_apps_PackageInstaller-092149c8a75237c476a917d57c48f8b8cd51f0f0.zip
Code drop from //branches/cupcake/...@124589
Diffstat (limited to 'src')
-rwxr-xr-xsrc/com/android/packageinstaller/InstallAppConfirmation.java27
-rwxr-xr-xsrc/com/android/packageinstaller/InstallAppDone.java41
-rwxr-xr-xsrc/com/android/packageinstaller/InstallAppProgress.java29
-rw-r--r--src/com/android/packageinstaller/PackageInstallerActivity.java180
-rw-r--r--src/com/android/packageinstaller/PackageUtil.java16
-rwxr-xr-xsrc/com/android/packageinstaller/UninstallAppProgress.java19
-rwxr-xr-xsrc/com/android/packageinstaller/UninstallerActivity.java2
7 files changed, 184 insertions, 130 deletions
diff --git a/src/com/android/packageinstaller/InstallAppConfirmation.java b/src/com/android/packageinstaller/InstallAppConfirmation.java
index eebe8b59..fe7126b9 100755
--- a/src/com/android/packageinstaller/InstallAppConfirmation.java
+++ b/src/com/android/packageinstaller/InstallAppConfirmation.java
@@ -20,10 +20,13 @@ import com.android.packageinstaller.R;
import java.util.ArrayList;
import android.widget.AppSecurityPermissions;
import android.app.Activity;
+import android.content.pm.PackageManager;
+import android.content.pm.PackageParser;
import android.content.pm.PermissionInfo;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager.NameNotFoundException;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
@@ -78,11 +81,25 @@ public class InstallAppConfirmation extends Activity implements View.OnClickList
if(desc != null) {
((TextView)findViewById(R.id.security_settings_desc)).setText(desc);
}
- //set permissions
- AppSecurityPermissions asp = new AppSecurityPermissions(this);
- asp.setSecurityPermissionsView(mPkgURI);
- LinearLayout securityList = (LinearLayout) mContentView.findViewById(R.id.security_settings_list);
- securityList.addView(asp.getPermissionsView());
+
+
+ LinearLayout permsView = (LinearLayout) mContentView.findViewById(
+ R.id.permissions_section);
+ boolean permVisible = false;
+ PackageParser.Package pkg = PackageUtil.getPackageInfo(mPkgURI);
+ if(pkg != null) {
+ AppSecurityPermissions asp = new AppSecurityPermissions(this, pkg);
+ if(asp.getPermissionCount() > 0) {
+ permVisible = true;
+ permsView.setVisibility(View.VISIBLE);
+ LinearLayout securityList = (LinearLayout) permsView.findViewById(
+ R.id.security_settings_list);
+ securityList.addView(asp.getPermissionsView());
+ }
+ }
+ if(!permVisible){
+ permsView.setVisibility(View.GONE);
+ }
mOk = (Button)findViewById(R.id.ok_button);
mCancel = (Button)findViewById(R.id.cancel_button);
mOk.setOnClickListener(this);
diff --git a/src/com/android/packageinstaller/InstallAppDone.java b/src/com/android/packageinstaller/InstallAppDone.java
index 6e21e6e9..554ed2db 100755
--- a/src/com/android/packageinstaller/InstallAppDone.java
+++ b/src/com/android/packageinstaller/InstallAppDone.java
@@ -20,6 +20,8 @@ import com.android.packageinstaller.R;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
+import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
@@ -50,6 +52,7 @@ public class InstallAppDone extends Activity implements View.OnClickListener {
Intent intent = getIntent();
mAppInfo = intent.getParcelableExtra(PackageUtil.INTENT_ATTR_APPLICATION_INFO);
installFlag = intent.getBooleanExtra(PackageUtil.INTENT_ATTR_INSTALL_STATUS, true);
+ if(localLOGV) Log.i(TAG, "installFlag="+installFlag);
initView();
}
@@ -57,25 +60,37 @@ public class InstallAppDone extends Activity implements View.OnClickListener {
requestWindowFeature(Window.FEATURE_NO_TITLE);
String unknown = getString(R.string.unknown);
setContentView(R.layout.install_done);
- //initialize views
+ // Initialize views
PackageUtil.initAppSnippet(this, mAppInfo, R.id.app_snippet);
TextView centerText = (TextView)findViewById(R.id.center_text);
- if(installFlag) {
- centerText.setText(getString(R.string.install_done));
- } else {
- centerText.setText(R.string.install_failed);
- }
mDoneButton = (Button)findViewById(R.id.done_button);
- mDoneButton.setOnClickListener(this);
mLaunchButton = (Button)findViewById(R.id.launch_button);
- //enable or disable launch buton
- mLaunchIntent = PackageUtil.getLaunchIntentForPackage(this,
- mAppInfo.packageName);
- if(mLaunchIntent != null) {
- mLaunchButton.setOnClickListener(this);
+ int centerTextDrawableId;
+ int centerTextLabel;
+ if(installFlag) {
+ mLaunchButton.setVisibility(View.VISIBLE);
+ centerTextDrawableId = R.drawable.button_indicator_finish;
+ centerTextLabel = R.string.install_done;
+ // Enable or disable launch button
+ mLaunchIntent = PackageUtil.getLaunchIntentForPackage(this,
+ mAppInfo.packageName);
+ if(mLaunchIntent != null) {
+ mLaunchButton.setOnClickListener(this);
+ } else {
+ mLaunchButton.setEnabled(false);
+ }
} else {
- mLaunchButton.setEnabled(false);
+ centerTextDrawableId = com.android.internal.R.drawable.ic_bullet_key_permission;
+ centerTextLabel = R.string.install_failed;
+ mLaunchButton.setVisibility(View.INVISIBLE);
}
+ Drawable centerTextDrawable = getResources().getDrawable(centerTextDrawableId);
+ centerTextDrawable.setBounds(0, 0,
+ centerTextDrawable.getIntrinsicWidth(),
+ centerTextDrawable.getIntrinsicHeight());
+ centerText.setCompoundDrawables(centerTextDrawable, null, null, null);
+ centerText.setText(getString(centerTextLabel));
+ mDoneButton.setOnClickListener(this);
}
public void onClick(View v) {
diff --git a/src/com/android/packageinstaller/InstallAppProgress.java b/src/com/android/packageinstaller/InstallAppProgress.java
index c75ba106..da1044c9 100755
--- a/src/com/android/packageinstaller/InstallAppProgress.java
+++ b/src/com/android/packageinstaller/InstallAppProgress.java
@@ -21,6 +21,9 @@ import android.app.Activity;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.IPackageInstallObserver;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
@@ -35,7 +38,8 @@ import android.widget.TextView;
* when the user tries
* to install an application bundled as an apk file. The result of the application install
* is indicated in the result code that gets set to the corresponding installation status
- * codes defined in PackageManager
+ * codes defined in PackageManager. If the package being installed already exists,
+ * the existing package is replaced with the new one.
*/
public class InstallAppProgress extends Activity {
private final String TAG="InstallAppProgress";
@@ -45,7 +49,6 @@ public class InstallAppProgress extends Activity {
private ProgressBar mProgressBar;
private final int INSTALL_COMPLETE = 1;
private Handler mHandler = new Handler() {
- public static final String TAG = "InstallAppProgress.Handler";
public void handleMessage(Message msg) {
switch (msg.what) {
case INSTALL_COMPLETE:
@@ -76,12 +79,6 @@ public class InstallAppProgress extends Activity {
}
void setResultAndFinish(int retCode) {
- try {
- Log.i(TAG, "Sleeping for 5 seconds to display screen");
- Thread.sleep(5*1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
Intent data = new Intent();
setResult(retCode);
finish();
@@ -97,7 +94,21 @@ public class InstallAppProgress extends Activity {
installTextView.setText(R.string.installing);
mProgressBar = (ProgressBar) findViewById(R.id.progress_bar);
mProgressBar.setIndeterminate(true);
+ // Set flag to replace package if already existing
+ int installFlags = 0;
+ PackageManager pm = getPackageManager();
+ try {
+ PackageInfo pi = pm.getPackageInfo(mAppInfo.packageName,
+ PackageManager.GET_UNINSTALLED_PACKAGES);
+ if(pi != null) {
+ installFlags |= PackageManager.REPLACE_EXISTING_PACKAGE;
+ }
+ } catch (NameNotFoundException e) {
+ }
+ if((installFlags & PackageManager.REPLACE_EXISTING_PACKAGE )!= 0) {
+ Log.w(TAG, "Replacing package:"+mAppInfo.packageName);
+ }
PackageInstallObserver observer = new PackageInstallObserver();
- getPackageManager().installPackage(mPackageURI, observer, 0);
+ pm.installPackage(mPackageURI, observer, installFlags);
}
}
diff --git a/src/com/android/packageinstaller/PackageInstallerActivity.java b/src/com/android/packageinstaller/PackageInstallerActivity.java
index a1be9169..9bdcee56 100644
--- a/src/com/android/packageinstaller/PackageInstallerActivity.java
+++ b/src/com/android/packageinstaller/PackageInstallerActivity.java
@@ -22,17 +22,14 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.util.ArrayList;
-
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
-import android.content.pm.ApplicationInfo;
+import android.content.DialogInterface.OnCancelListener;
import android.content.pm.IPackageDataObserver;
import android.content.pm.PackageManager;
import android.content.pm.PackageParser;
-import android.content.pm.PermissionInfo;
import android.net.Uri;
import android.os.Bundle;
import android.os.FileUtils;
@@ -40,38 +37,40 @@ import android.os.Handler;
import android.os.Message;
import android.os.RemoteException;
import android.provider.Settings;
-import android.text.Html;
import android.util.Log;
import android.view.Window;
import android.content.pm.IPackageDeleteObserver;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.content.pm.PackageParser.Package;
-public class PackageInstallerActivity extends Activity {
+/*
+ * This activity is launched when a new application is installed via side loading
+ * The package is first parsed and the user is notified of parse errors via a dialog.
+ * If the package is successfully parsed, the user is notified to turn on the install unknown
+ * applications setting. A memory check is made at this point and the user is notified of out
+ * of memory conditions if any. If the package is already existing on the device,
+ * a confirmation dialog (to replace the existing package) is presented to the user.
+ * Based on the user response the package is then installed by launching InstallAppConfirm
+ * sub activity. All state transitions are handled in this activity
+ */
+public class PackageInstallerActivity extends Activity implements OnCancelListener {
private static final int INSTALL_INITIAL=0;
private static final int INSTALL_CONFIRM=1;
private static final int INSTALL_PROGRESS=2;
private static final int INSTALL_DONE=3;
private static final String TAG = "PackageInstaller";
private Uri mPackageURI;
- private boolean localLOGV = true;
+ private boolean localLOGV = false;
private int mCurrentState = INSTALL_INITIAL;
PackageManager mPm;
- private Package mPkgInfo;
+ private PackageParser.Package mPkgInfo;
private File mTmpFile;
private Uri mPackageUri;
- private static final int DELETE_COMPLETE=1;
private static final int SUCCEEDED=1;
private static final int FAILED=0;
- private static final int FREE_SPACE = 2;
+ private static final int HANDLER_BASE_MSG_IDX = 0;
+ private static final int FREE_SPACE = HANDLER_BASE_MSG_IDX+1;
private Handler mHandler = new Handler() {
- public static final String TAG = "PackageInstallerActivity.Handler";
public void handleMessage(Message msg) {
switch (msg.what) {
- case DELETE_COMPLETE:
- //finish the activity posting result
- startInstallConfirm();
- break;
case FREE_SPACE:
if(msg.arg1 == SUCCEEDED) {
makeTempCopyAndInstall();
@@ -124,15 +123,15 @@ public class PackageInstallerActivity extends Activity {
.setMessage(R.string.dlg_app_replacement_statement)
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
- replacePackage();
+ startInstallConfirm();
}})
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Log.i(TAG, "Canceling installation");
finish();
}})
- .setCancelable(false)
- .show();
+ .setOnCancelListener(this)
+ .show();
}
@@ -142,20 +141,37 @@ public class PackageInstallerActivity extends Activity {
*/
private void displayUnknowAppsDialog() {
new AlertDialog.Builder(this)
- .setTitle(R.string.unknown_apps_dlg_title)
- .setMessage(R.string.unknown_apps_dlg_text)
- .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- Log.i(TAG, "Finishing off activity so that user can navigate to settings manually");
- finish();
- }})
- .setPositiveButton(R.string.settings, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- Log.i(TAG, "Launching settings");
- launchSettingsAppAndFinish();
+ .setTitle(R.string.unknown_apps_dlg_title)
+ .setMessage(R.string.unknown_apps_dlg_text)
+ .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ Log.i(TAG, "Finishing off activity so that user can navigate to settings manually");
+ finish();
}})
- .setCancelable(false)
- .show();
+ .setPositiveButton(R.string.settings, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ Log.i(TAG, "Launching settings");
+ launchSettingsAppAndFinish();
+ }
+ })
+ .setOnCancelListener(this)
+ .show();
+ }
+
+ /*
+ * Utility method to display a dialog indicating a parse error when parsing the package
+ */
+ private void displayPackageErrorDialog() {
+ new AlertDialog.Builder(this)
+ .setTitle(R.string.Parse_error_dlg_title)
+ .setMessage(R.string.Parse_error_dlg_text)
+ .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ finish();
+ }
+ })
+ .setOnCancelListener(this)
+ .show();
}
/*
@@ -168,27 +184,28 @@ public class PackageInstallerActivity extends Activity {
appTitle.toString());
new AlertDialog.Builder(this)
- .setTitle(R.string.out_of_space_dlg_title)
- .setMessage(dlgText)
- .setPositiveButton(R.string.manage_applications, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- //launch manage applications
- Intent intent = new Intent("android.intent.action.MANAGE_PACKAGE_STORAGE");
- startActivity(intent);
- finish();
- }})
- .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- Log.i(TAG, "Canceling installation");
- finish();
- }})
- .setCancelable(false)
- .show();
+ .setTitle(R.string.out_of_space_dlg_title)
+ .setMessage(dlgText)
+ .setPositiveButton(R.string.manage_applications, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ //launch manage applications
+ Intent intent = new Intent("android.intent.action.MANAGE_PACKAGE_STORAGE");
+ startActivity(intent);
+ finish();
+ }
+ })
+ .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ Log.i(TAG, "Canceling installation");
+ finish();
+ }
+ })
+ .setOnCancelListener(this)
+ .show();
}
private class PkgDataObserver extends IPackageDataObserver.Stub {
- public void onRemoveCompleted(String packageName, boolean succeeded)
- throws RemoteException {
+ public void onRemoveCompleted(String packageName, boolean succeeded) {
Message msg = mHandler.obtainMessage(FREE_SPACE);
msg.arg1 = succeeded?SUCCEEDED:FAILED;
mHandler.sendMessage(msg);
@@ -210,8 +227,8 @@ public class PackageInstallerActivity extends Activity {
}
private boolean isInstallingUnknownAppsAllowed() {
- return Settings.System.getInt(getContentResolver(),
- Settings.System.INSTALL_NON_MARKET_APPS, 0) > 0;
+ return Settings.Secure.getInt(getContentResolver(),
+ Settings.Secure.INSTALL_NON_MARKET_APPS, 0) > 0;
}
private File createTempPackageFile(String filePath) {
@@ -254,9 +271,13 @@ public class PackageInstallerActivity extends Activity {
return;
}
mPackageURI = Uri.parse("file://"+mTmpFile.getPath());
- //check out of space condition. display dialog if necessary
- if(PackageUtil.isPackageAlreadyInstalled(this, mPkgInfo.applicationInfo.packageName)) {
- displayReplaceAppDialog();
+ // Check if package is already installed. display confirmation dialog if replacing pkg
+ boolean alreadyInstalled = PackageUtil.isPackageAlreadyInstalled(this,
+ mPkgInfo.applicationInfo.packageName);
+ if(alreadyInstalled) {
+ if(localLOGV) Log.i(TAG, "Replacing existing package:"+
+ mPkgInfo.applicationInfo.packageName);
+ displayReplaceAppDialog();
} else {
startInstallConfirm();
}
@@ -269,9 +290,10 @@ public class PackageInstallerActivity extends Activity {
final Intent intent = getIntent();
mPackageURI = intent.getData();
mPkgInfo = PackageUtil.getPackageInfo(mPackageURI);
+ // Check for parse errors
if(mPkgInfo == null) {
Log.w(TAG, "Parse error when parsing manifest. Discontinuing installation");
- finish();
+ displayPackageErrorDialog();
return;
}
mPm = getPackageManager();
@@ -294,39 +316,38 @@ public class PackageInstallerActivity extends Activity {
checkOutOfSpace(size);
}
- class PackageDeleteObserver extends IPackageDeleteObserver.Stub {
- public void packageDeleted(boolean succeeded) throws RemoteException {
- Message msg = mHandler.obtainMessage(DELETE_COMPLETE);
- msg.arg1 = succeeded?SUCCEEDED:FAILED;
- mHandler.sendMessage(msg);
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ // Delete the temporary file if it still exists
+ if (mTmpFile != null) {
+ deleteFile(mTmpFile.getName());
}
}
-
-
- void replacePackage() {
- PackageDeleteObserver observer = new PackageDeleteObserver();
- mPm.deletePackage(mPkgInfo.applicationInfo.packageName, observer,
- PackageManager.DONT_DELETE_DATA);
- }
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
boolean finish = true;
+ boolean removeTmpFile = false;
switch(requestCode) {
case INSTALL_CONFIRM:
- if(resultCode == RESULT_OK) {
+ if (resultCode == RESULT_OK) {
finish = false;
- mCurrentState = INSTALL_CONFIRM;
+ mCurrentState = INSTALL_PROGRESS;
startInstallProgress();
+ } else {
+ removeTmpFile = true;
}
break;
case INSTALL_PROGRESS:
boolean ok = false;
finish = false;
mCurrentState = INSTALL_DONE;
- if(resultCode == PackageManager.INSTALL_SUCCEEDED) {
+ if (resultCode == PackageManager.INSTALL_SUCCEEDED) {
ok = true;
}
+ // Now that the package is installed just delete the temp file
+ removeTmpFile = true;
//start the next screen to show final status of installation
startInstallDone(ok);
break;
@@ -336,13 +357,18 @@ public class PackageInstallerActivity extends Activity {
default:
break;
}
- if(finish) {
- if(mTmpFile != null) {
- deleteFile(mTmpFile.getName());
- }
+ if ((removeTmpFile) && (mTmpFile != null)) {
+ deleteFile(mTmpFile.getName());
+ }
+ if (finish) {
//finish off this activity to return to the previous activity that launched it
- Log.i(TAG, "Finishing off activity");
+ if (localLOGV) Log.i(TAG, "Finishing off activity");
finish();
}
}
+
+ // Generic handling when pressing back key
+ public void onCancel(DialogInterface dialog) {
+ finish();
+ }
}
diff --git a/src/com/android/packageinstaller/PackageUtil.java b/src/com/android/packageinstaller/PackageUtil.java
index f7819a48..6dc782de 100644
--- a/src/com/android/packageinstaller/PackageUtil.java
+++ b/src/com/android/packageinstaller/PackageUtil.java
@@ -27,14 +27,9 @@ import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageParser;
import android.content.pm.ResolveInfo;
-import android.content.pm.PackageParser.Package;
-import android.content.res.AssetManager;
-import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.util.DisplayMetrics;
-import android.util.Log;
-import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
@@ -60,7 +55,7 @@ public class PackageUtil {
File sourceFile = new File(archiveFilePath);
DisplayMetrics metrics = new DisplayMetrics();
metrics.setToDefaults();
- Package pkg = packageParser.parsePackage(sourceFile, archiveFilePath, metrics, 0);
+ PackageParser.Package pkg = packageParser.parsePackage(sourceFile, archiveFilePath, metrics, 0);
if (pkg == null) {
return null;
}
@@ -70,7 +65,7 @@ public class PackageUtil {
/*
* Utility method to get package information for a given packageURI
*/
- public static Package getPackageInfo(Uri packageURI) {
+ public static PackageParser.Package getPackageInfo(Uri packageURI) {
final String archiveFilePath = packageURI.getPath();
PackageParser packageParser = new PackageParser(archiveFilePath);
File sourceFile = new File(archiveFilePath);
@@ -83,7 +78,7 @@ public class PackageUtil {
* Utility method to get application label from package manager for a given context
*/
public static CharSequence getApplicationLabel(Context context, ApplicationInfo appInfo) {
- CharSequence appName = context.getPackageManager().getApplicationLabel(appInfo);
+ CharSequence appName = appInfo.loadLabel(context.getPackageManager());
if(appName == null) {
appName = context.getString(R.string.unknown);
}
@@ -94,7 +89,7 @@ public class PackageUtil {
* Utility method to getApplicationIcon from package manager for a given context
*/
public static Drawable getApplicationIcon(Context context, ApplicationInfo appInfo) {
- return context.getPackageManager().getApplicationIcon(appInfo);
+ return appInfo.loadIcon(context.getPackageManager());
}
/*
@@ -111,7 +106,8 @@ public class PackageUtil {
}
public static boolean isPackageAlreadyInstalled(Activity context, String pkgName) {
- List<PackageInfo> installedList = context.getPackageManager().getInstalledPackages(0);
+ 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);
diff --git a/src/com/android/packageinstaller/UninstallAppProgress.java b/src/com/android/packageinstaller/UninstallAppProgress.java
index 44a9802e..6b30118b 100755
--- a/src/com/android/packageinstaller/UninstallAppProgress.java
+++ b/src/com/android/packageinstaller/UninstallAppProgress.java
@@ -16,7 +16,6 @@
*/
package com.android.packageinstaller;
-import com.android.packageinstaller.R;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
@@ -24,8 +23,8 @@ import android.content.pm.IPackageDeleteObserver;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
-import android.util.Log;
import android.view.Window;
+import android.view.ViewDebug;
import android.widget.ProgressBar;
import android.widget.TextView;
@@ -40,12 +39,10 @@ public class UninstallAppProgress extends Activity {
private final String TAG="UninstallAppProgress";
private boolean localLOGV = false;
private ApplicationInfo mAppInfo;
- private ProgressBar mProgressBar;
private final int UNINSTALL_COMPLETE = 1;
public final static int SUCCEEDED=1;
public final static int FAILED=0;
private Handler mHandler = new Handler() {
- public static final String TAG = "UninstallAppProgress.Handler";
public void handleMessage(Message msg) {
switch (msg.what) {
case UNINSTALL_COMPLETE:
@@ -72,30 +69,22 @@ public class UninstallAppProgress extends Activity {
msg.arg1 = succeeded?SUCCEEDED:FAILED;
mHandler.sendMessage(msg);
}
- };
+ }
void setResultAndFinish(int retCode) {
- try {
- Log.i(TAG, "Sleeping for some time to display screen");
- Thread.sleep(5*1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- Intent data = new Intent();
setResult(retCode);
finish();
}
public void initView() {
- String unknown = getString(R.string.unknown);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.op_progress);
//initialize views
PackageUtil.initAppSnippet(this, mAppInfo, R.id.app_snippet);
TextView installTextView = (TextView)findViewById(R.id.center_text);
installTextView.setText(R.string.uninstalling);
- mProgressBar = (ProgressBar) findViewById(R.id.progress_bar);
- mProgressBar.setIndeterminate(true);
+ final ProgressBar progressBar = (ProgressBar) findViewById(R.id.progress_bar);
+ progressBar.setIndeterminate(true);
PackageDeleteObserver observer = new PackageDeleteObserver();
getPackageManager().deletePackage(mAppInfo.packageName, observer, 0);
}
diff --git a/src/com/android/packageinstaller/UninstallerActivity.java b/src/com/android/packageinstaller/UninstallerActivity.java
index fa1c7afc..b80f8ef1 100755
--- a/src/com/android/packageinstaller/UninstallerActivity.java
+++ b/src/com/android/packageinstaller/UninstallerActivity.java
@@ -100,7 +100,7 @@ public class UninstallerActivity extends Activity implements OnClickListener {
mPm = getPackageManager();
boolean errFlag = false;
try {
- mAppInfo = mPm.getApplicationInfo(packageName, 0);
+ mAppInfo = mPm.getApplicationInfo(packageName, PackageManager.GET_UNINSTALLED_PACKAGES);
} catch (NameNotFoundException e) {
errFlag = true;
}