diff options
author | Christopher Tate <ctate@google.com> | 2015-03-10 16:10:10 -0700 |
---|---|---|
committer | Christopher Tate <ctate@google.com> | 2015-03-10 16:13:25 -0700 |
commit | 72d0d86c65a6e02e17332cf9a55675e893087645 (patch) | |
tree | 8bb1c02eafe7f6041a6e02c4d702eebdf667e6d3 | |
parent | 03068ee11a530516dc9c1e5d1ce6edef64ba8861 (diff) | |
download | android_packages_apps_PackageInstaller-72d0d86c65a6e02e17332cf9a55675e893087645.tar.gz android_packages_apps_PackageInstaller-72d0d86c65a6e02e17332cf9a55675e893087645.tar.bz2 android_packages_apps_PackageInstaller-72d0d86c65a6e02e17332cf9a55675e893087645.zip |
Don't crash when cancelling an uninstall of a nonexistent package
We bring up the UI with a friendly "hey this app does not exist" mode,
but in the abort flow we were implicitly assuming that the target app
info was properly initialized, and NPEing. Now we aren't.
Bug 19676670
Change-Id: I017632caa51d0f1b354fdd48ad4867d245357680
-rwxr-xr-x | src/com/android/packageinstaller/UninstallerActivity.java | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/com/android/packageinstaller/UninstallerActivity.java b/src/com/android/packageinstaller/UninstallerActivity.java index 96bc9937..e277d48f 100755 --- a/src/com/android/packageinstaller/UninstallerActivity.java +++ b/src/com/android/packageinstaller/UninstallerActivity.java @@ -141,6 +141,7 @@ public class UninstallerActivity extends Activity { IBinder callback; } + private String mPackageName; private DialogInfo mDialogInfo; @Override @@ -156,8 +157,8 @@ public class UninstallerActivity extends Activity { showAppNotFound(); return; } - final String packageName = packageUri.getEncodedSchemeSpecificPart(); - if (packageName == null) { + mPackageName = packageUri.getEncodedSchemeSpecificPart(); + if (mPackageName == null) { Log.e(TAG, "Invalid package name in URI: " + packageUri); showAppNotFound(); return; @@ -177,14 +178,14 @@ public class UninstallerActivity extends Activity { mDialogInfo.callback = intent.getIBinderExtra(PackageInstaller.EXTRA_CALLBACK); try { - mDialogInfo.appInfo = pm.getApplicationInfo(packageName, + mDialogInfo.appInfo = pm.getApplicationInfo(mPackageName, PackageManager.GET_UNINSTALLED_PACKAGES, mDialogInfo.user.getIdentifier()); } catch (RemoteException e) { Log.e(TAG, "Unable to get packageName. Package manager is dead?"); } if (mDialogInfo.appInfo == null) { - Log.e(TAG, "Invalid packageName: " + packageName); + Log.e(TAG, "Invalid packageName: " + mPackageName); showAppNotFound(); return; } @@ -194,7 +195,7 @@ public class UninstallerActivity extends Activity { if (className != null) { try { mDialogInfo.activityInfo = pm.getActivityInfo( - new ComponentName(packageName, className), 0, + new ComponentName(mPackageName, className), 0, mDialogInfo.user.getIdentifier()); } catch (RemoteException e) { Log.e(TAG, "Unable to get className. Package manager is dead?"); @@ -241,7 +242,7 @@ public class UninstallerActivity extends Activity { final IPackageDeleteObserver2 observer = IPackageDeleteObserver2.Stub.asInterface( mDialogInfo.callback); try { - observer.onPackageDeleted(mDialogInfo.appInfo.packageName, + observer.onPackageDeleted(mPackageName, PackageManager.DELETE_FAILED_ABORTED, "Cancelled by user"); } catch (RemoteException ignored) { } |