summaryrefslogtreecommitdiffstats
path: root/cmds/pm
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2010-12-22 14:03:29 -0800
committerDianne Hackborn <hackbod@google.com>2010-12-22 16:31:44 -0800
commit690d20bb53ba2485f59d128b365eff991d5cc3e6 (patch)
treedc9e90632571711a17a963e39d04fa85613cdc11 /cmds/pm
parent3ce86481cbde92e2cb6fe3a46cbedd8b2a5c4b48 (diff)
downloadframeworks_base-690d20bb53ba2485f59d128b365eff991d5cc3e6.zip
frameworks_base-690d20bb53ba2485f59d128b365eff991d5cc3e6.tar.gz
frameworks_base-690d20bb53ba2485f59d128b365eff991d5cc3e6.tar.bz2
Fix issue # 3227963: SecurityException: Neither user 10023 nor...
...current process has android.permission.WAKE_LOCK When updating a system app, we would actually uninstall the package of the system app, which also meant removing its uid...! It was just luck that we would get the same uid when installing the update after that. During that time, if anyone tried to do anything related to that uid, it would be unknown. This change tweaks how we go about replacing system apps by making it more like normal apps -- to make this work, if we need to disable the system app, we generate a new PackageSetting from the current system app and replace it into our data structures, so we can update that without trashing the current correct information about the (still actually there) system app. Also fixed a problem where we were not killing the currently running app before installing, like we do when updating a normal application. And fixed a problem where we were not deleting the /data .apk when uninstalling a system app update. And added a new option to the "pm" command to clear the data associated with an app. Change-Id: I0e879677849aa42950a3c360bf78ad820e87674b
Diffstat (limited to 'cmds/pm')
-rw-r--r--cmds/pm/src/com/android/commands/pm/Pm.java59
1 files changed, 59 insertions, 0 deletions
diff --git a/cmds/pm/src/com/android/commands/pm/Pm.java b/cmds/pm/src/com/android/commands/pm/Pm.java
index 311dc38..326e2c8 100644
--- a/cmds/pm/src/com/android/commands/pm/Pm.java
+++ b/cmds/pm/src/com/android/commands/pm/Pm.java
@@ -18,9 +18,11 @@ package com.android.commands.pm;
import com.android.internal.content.PackageHelper;
+import android.app.ActivityManagerNative;
import android.content.ComponentName;
import android.content.pm.ApplicationInfo;
import android.content.pm.FeatureInfo;
+import android.content.pm.IPackageDataObserver;
import android.content.pm.IPackageDeleteObserver;
import android.content.pm.IPackageInstallObserver;
import android.content.pm.IPackageManager;
@@ -100,6 +102,11 @@ public final class Pm {
return;
}
+ if ("clear".equals(op)) {
+ runClear();
+ return;
+ }
+
if ("enable".equals(op)) {
runSetEnabledSetting(PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
return;
@@ -809,6 +816,55 @@ public final class Pm {
return obs.result;
}
+ class ClearDataObserver extends IPackageDataObserver.Stub {
+ boolean finished;
+ boolean result;
+
+ @Override
+ public void onRemoveCompleted(String packageName, boolean succeeded) throws RemoteException {
+ synchronized (this) {
+ finished = true;
+ result = succeeded;
+ notifyAll();
+ }
+ }
+
+ }
+
+ private void runClear() {
+ String pkg = nextArg();
+ if (pkg == null) {
+ System.err.println("Error: no package specified");
+ showUsage();
+ return;
+ }
+
+ ClearDataObserver obs = new ClearDataObserver();
+ try {
+ if (!ActivityManagerNative.getDefault().clearApplicationUserData(pkg, obs)) {
+ System.err.println("Failed");
+ }
+
+ synchronized (obs) {
+ while (!obs.finished) {
+ try {
+ obs.wait();
+ } catch (InterruptedException e) {
+ }
+ }
+ }
+
+ if (obs.result) {
+ System.err.println("Success");
+ } else {
+ System.err.println("Failed");
+ }
+ } catch (RemoteException e) {
+ System.err.println(e.toString());
+ System.err.println(PM_NOT_RUNNING_ERR);
+ }
+ }
+
private static String enabledSettingToString(int state) {
switch (state) {
case PackageManager.COMPONENT_ENABLED_STATE_DEFAULT:
@@ -944,6 +1000,7 @@ public final class Pm {
System.err.println(" pm path PACKAGE");
System.err.println(" pm install [-l] [-r] [-t] [-i INSTALLER_PACKAGE_NAME] [-s] [-f] PATH");
System.err.println(" pm uninstall [-k] PACKAGE");
+ System.err.println(" pm clear PACKAGE");
System.err.println(" pm enable PACKAGE_OR_COMPONENT");
System.err.println(" pm disable PACKAGE_OR_COMPONENT");
System.err.println(" pm setInstallLocation [0/auto] [1/internal] [2/external]");
@@ -986,6 +1043,8 @@ public final class Pm {
System.err.println(" -k: keep the data and cache directories around.");
System.err.println("after the package removal.");
System.err.println("");
+ System.err.println("The clear command deletes all data associated with a package.");
+ System.err.println("");
System.err.println("The enable and disable commands change the enabled state of");
System.err.println("a given package or component (written as \"package/class\").");
System.err.println("");