summaryrefslogtreecommitdiffstats
path: root/cmds/pm
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2011-01-09 11:59:12 -0800
committerDianne Hackborn <hackbod@google.com>2011-01-09 11:59:12 -0800
commit4f05220d10338b6ad668c87e70cbe7b9914a9047 (patch)
treefe400e54a2fa2ad9dfd09a4f09f8255f22df1171 /cmds/pm
parentbdd8d17d81c4ef41a2ae82c7f73ecff6b48f493e (diff)
parent690d20bb53ba2485f59d128b365eff991d5cc3e6 (diff)
downloadframeworks_base-4f05220d10338b6ad668c87e70cbe7b9914a9047.zip
frameworks_base-4f05220d10338b6ad668c87e70cbe7b9914a9047.tar.gz
frameworks_base-4f05220d10338b6ad668c87e70cbe7b9914a9047.tar.bz2
Merge commit '690d20bb53ba2485f59d128b365eff991d5cc3e6' into manualmerge
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 a236a3c..cc6e739 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;
@@ -811,6 +818,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:
@@ -946,6 +1002,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]");
@@ -991,6 +1048,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("");