From 3e0c22f98f61d8570c14c6f7ce49a05c1804d1f9 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Sun, 16 Sep 2012 18:26:11 -0700 Subject: Implement new option for uninstalling over all users. This API is hidden, but we don't try to protect with a permission here because we always go through a UI for the user to verify the operation. Change-Id: I5580bcbe7ca00b8613c0d8523f348ce83b2d5031 --- res/values/strings.xml | 2 ++ src/com/android/packageinstaller/UninstallAppProgress.java | 5 ++++- src/com/android/packageinstaller/UninstallerActivity.java | 10 +++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index d5d1ab52..db43792a 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -111,6 +111,8 @@ Uninstall update %1$s is part of the following app: Do you want to uninstall this app? + Do you want to uninstall this app for all + users? The application and its data will be removed from all users on the device. Do you want to replace this app with the factory version? Uninstalling\u2026 Uninstall finished. diff --git a/src/com/android/packageinstaller/UninstallAppProgress.java b/src/com/android/packageinstaller/UninstallAppProgress.java index 92822b8e..7aa0a2e0 100755 --- a/src/com/android/packageinstaller/UninstallAppProgress.java +++ b/src/com/android/packageinstaller/UninstallAppProgress.java @@ -45,6 +45,7 @@ public class UninstallAppProgress extends Activity implements OnClickListener { private final String TAG="UninstallAppProgress"; private boolean localLOGV = false; private ApplicationInfo mAppInfo; + private boolean mAllUsers; private TextView mStatusTextView; private Button mOkButton; private Button mDeviceManagerButton; @@ -110,6 +111,7 @@ public class UninstallAppProgress extends Activity implements OnClickListener { super.onCreate(icicle); Intent intent = getIntent(); mAppInfo = intent.getParcelableExtra(PackageUtil.INTENT_ATTR_APPLICATION_INFO); + mAllUsers = intent.getBooleanExtra(Intent.EXTRA_UNINSTALL_ALL_USERS, false); initView(); } @@ -158,7 +160,8 @@ public class UninstallAppProgress extends Activity implements OnClickListener { mOkButton.setOnClickListener(this); mOkPanel.setVisibility(View.INVISIBLE); PackageDeleteObserver observer = new PackageDeleteObserver(); - getPackageManager().deletePackage(mAppInfo.packageName, observer, 0); + getPackageManager().deletePackage(mAppInfo.packageName, observer, + mAllUsers ? PackageManager.DELETE_ALL_USERS : 0); } public void onClick(View v) { diff --git a/src/com/android/packageinstaller/UninstallerActivity.java b/src/com/android/packageinstaller/UninstallerActivity.java index 5a312973..93e096eb 100755 --- a/src/com/android/packageinstaller/UninstallerActivity.java +++ b/src/com/android/packageinstaller/UninstallerActivity.java @@ -52,6 +52,7 @@ public class UninstallerActivity extends Activity implements OnClickListener, private boolean localLOGV = false; PackageManager mPm; private ApplicationInfo mAppInfo; + private boolean mAllUsers; private Button mOk; private Button mCancel; @@ -100,6 +101,7 @@ public class UninstallerActivity extends Activity implements OnClickListener, Intent newIntent = new Intent(Intent.ACTION_VIEW); newIntent.putExtra(PackageUtil.INTENT_ATTR_APPLICATION_INFO, mAppInfo); + newIntent.putExtra(Intent.EXTRA_UNINSTALL_ALL_USERS, mAllUsers); if (getIntent().getBooleanExtra(Intent.EXTRA_RETURN_RESULT, false)) { newIntent.putExtra(Intent.EXTRA_RETURN_RESULT, true); newIntent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT); @@ -132,6 +134,8 @@ public class UninstallerActivity extends Activity implements OnClickListener, errFlag = true; } + mAllUsers = intent.getBooleanExtra(Intent.EXTRA_UNINSTALL_ALL_USERS, false); + // The class name may have been specified (e.g. when deleting an app from all apps) String className = packageURI.getFragment(); ActivityInfo activityInfo = null; @@ -157,7 +161,11 @@ public class UninstallerActivity extends Activity implements OnClickListener, confirm.setText(R.string.uninstall_update_text); } else { setTitle(R.string.uninstall_application_title); - confirm.setText(R.string.uninstall_application_text); + if (mAllUsers) { + confirm.setText(R.string.uninstall_application_text_all_users); + } else { + confirm.setText(R.string.uninstall_application_text); + } } // If an activity was specified (e.g. when dragging from All Apps to trash can), -- cgit v1.2.3