summaryrefslogtreecommitdiffstats
path: root/src/com/android/packageinstaller/UninstallerActivity.java
diff options
context:
space:
mode:
authorKenny Guy <kennyguy@google.com>2014-06-03 17:50:38 +0100
committerKenny Guy <kennyguy@google.com>2014-07-10 16:37:55 +0100
commit596ce64f71011e7600ee2be66d977dafb86b9da3 (patch)
treea6f63132b25528b6b0631dabdddc1ec36ee0615c /src/com/android/packageinstaller/UninstallerActivity.java
parent365b378c1770a5bc75da34c2bb26cc48f4c49c5c (diff)
downloadandroid_packages_apps_PackageInstaller-596ce64f71011e7600ee2be66d977dafb86b9da3.tar.gz
android_packages_apps_PackageInstaller-596ce64f71011e7600ee2be66d977dafb86b9da3.tar.bz2
android_packages_apps_PackageInstaller-596ce64f71011e7600ee2be66d977dafb86b9da3.zip
Support uninstalling apps for other profiles.
Allow client to pick which user the package will be removed for, checking its a profile of the current user. Inform user if package is blocked from being removed and let them knows its due to an admin. Add check to stop non owner asking to uninstall for all users. Bug: 14127299 Change-Id: I60504224f5271272a390320a0fa62aa7f5de4e54
Diffstat (limited to 'src/com/android/packageinstaller/UninstallerActivity.java')
-rwxr-xr-xsrc/com/android/packageinstaller/UninstallerActivity.java42
1 files changed, 27 insertions, 15 deletions
diff --git a/src/com/android/packageinstaller/UninstallerActivity.java b/src/com/android/packageinstaller/UninstallerActivity.java
index 1b9bdce9..b64ce6f4 100755
--- a/src/com/android/packageinstaller/UninstallerActivity.java
+++ b/src/com/android/packageinstaller/UninstallerActivity.java
@@ -25,24 +25,20 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
+import android.content.pm.IPackageManager;
import android.content.pm.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.content.pm.ResolveInfo;
-import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.os.UserHandle;
import android.os.UserManager;
import android.util.Log;
-import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
-import android.view.ViewGroup;
-import android.view.Window;
import android.widget.Button;
import android.widget.TextView;
-import java.util.List;
-
/*
* This activity presents UI to uninstall an application. Usually launched with intent
* Intent.ACTION_UNINSTALL_PKG_COMMAND and attribute
@@ -53,10 +49,12 @@ public class UninstallerActivity extends Activity implements OnClickListener,
private static final String TAG = "UninstallerActivity";
private boolean localLOGV = false;
PackageManager mPm;
+ private IPackageManager mIpm;
private ApplicationInfo mAppInfo;
private boolean mAllUsers;
private Button mOk;
private Button mCancel;
+ private UserHandle mUserHandle;
// Dialog identifiers used in showDialog
private static final int DLG_BASE = 0;
@@ -104,6 +102,7 @@ public class UninstallerActivity extends Activity implements OnClickListener,
newIntent.putExtra(PackageUtil.INTENT_ATTR_APPLICATION_INFO,
mAppInfo);
newIntent.putExtra(Intent.EXTRA_UNINSTALL_ALL_USERS, mAllUsers);
+ newIntent.putExtra(Intent.EXTRA_USER, mUserHandle);
if (getIntent().getBooleanExtra(Intent.EXTRA_RETURN_RESULT, false)) {
newIntent.putExtra(Intent.EXTRA_RETURN_RESULT, true);
newIntent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
@@ -128,11 +127,19 @@ public class UninstallerActivity extends Activity implements OnClickListener,
return;
}
+ mUserHandle = intent.getParcelableExtra(Intent.EXTRA_USER);
+ if (mUserHandle == null) {
+ mUserHandle = android.os.Process.myUserHandle();
+ }
+
mPm = getPackageManager();
+ mIpm = IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
+
boolean errFlag = false;
try {
- mAppInfo = mPm.getApplicationInfo(packageName, PackageManager.GET_UNINSTALLED_PACKAGES);
- } catch (NameNotFoundException e) {
+ mAppInfo = mIpm.getApplicationInfo(packageName, PackageManager.GET_UNINSTALLED_PACKAGES,
+ mUserHandle.getIdentifier());
+ } catch (RemoteException e) {
errFlag = true;
}
@@ -143,8 +150,9 @@ public class UninstallerActivity extends Activity implements OnClickListener,
ActivityInfo activityInfo = null;
if (className != null) {
try {
- activityInfo = mPm.getActivityInfo(new ComponentName(packageName, className), 0);
- } catch (NameNotFoundException e) {
+ activityInfo = mIpm.getActivityInfo(new ComponentName(packageName, className), 0,
+ mUserHandle.getIdentifier());
+ } catch (RemoteException e) {
errFlag = true;
}
}
@@ -162,10 +170,14 @@ public class UninstallerActivity extends Activity implements OnClickListener,
setTitle(R.string.uninstall_update_title);
confirm.setText(R.string.uninstall_update_text);
} else {
+ UserManager userManager = (UserManager) getSystemService(Context.USER_SERVICE);
setTitle(R.string.uninstall_application_title);
- if (mAllUsers && ((UserManager)getSystemService(
- Context.USER_SERVICE)).getUsers().size() >= 2) {
+ if (mAllUsers && userManager.getUsers().size() >= 2) {
confirm.setText(R.string.uninstall_application_text_all_users);
+ } else if (!mUserHandle.equals(android.os.Process.myUserHandle())) {
+ String userName = userManager.getUserInfo(mUserHandle.getIdentifier()).name;
+ confirm.setText(String.format(
+ getString(R.string.uninstall_application_text_user), userName));
} else {
confirm.setText(R.string.uninstall_application_text);
}
@@ -184,7 +196,7 @@ public class UninstallerActivity extends Activity implements OnClickListener,
}
View snippetView = findViewById(R.id.uninstall_activity_snippet);
- PackageUtil.initSnippetForInstalledApp(this, mAppInfo, snippetView);
+ PackageUtil.initSnippetForInstalledApp(this, mAppInfo, snippetView, mUserHandle);
//initialize ui elements
mOk = (Button)findViewById(R.id.ok_button);