diff options
Diffstat (limited to 'cmds')
-rw-r--r-- | cmds/am/src/com/android/commands/am/Am.java | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java index 96c2d2b..d8b2286 100644 --- a/cmds/am/src/com/android/commands/am/Am.java +++ b/cmds/am/src/com/android/commands/am/Am.java @@ -28,6 +28,7 @@ import android.content.ComponentName; import android.content.Context; import android.content.IIntentReceiver; import android.content.Intent; +import android.content.pm.IPackageDataObserver; import android.content.pm.IPackageManager; import android.content.pm.ResolveInfo; import android.net.Uri; @@ -109,6 +110,8 @@ public class Am { runStartService(); } else if (op.equals("force-stop")) { runForceStop(); + } else if (op.equals("clear-data")) { + runClearData(); } else if (op.equals("instrument")) { runInstrument(); } else if (op.equals("broadcast")) { @@ -499,6 +502,31 @@ public class Am { mAm.forceStopPackage(nextArgRequired()); } + class ClearUserDataObserver extends IPackageDataObserver.Stub { + public int status = -1; + + public void onRemoveCompleted(final String packageName, final boolean succeeded) { + synchronized (this) { + status = succeeded ? 0 : 1; + notify(); + } + } + } + + private void runClearData() throws Exception { + ClearUserDataObserver observer = new ClearUserDataObserver(); + mAm.clearApplicationUserData(nextArgRequired(), observer); + synchronized (observer) { + while (observer.status < 0) { + try { + observer.wait(); + } catch (InterruptedException ex) { + } + } + } + System.exit(observer.status); + } + private void sendBroadcast() throws Exception { Intent intent = makeIntent(); IntentReceiver receiver = new IntentReceiver(); @@ -1194,6 +1222,7 @@ public class Am { " [--R COUNT] [-S] <INTENT>\n" + " am startservice <INTENT>\n" + " am force-stop <PACKAGE>\n" + + " am clear-data <PACKAGE>\n" + " am broadcast <INTENT>\n" + " am instrument [-r] [-e <NAME> <VALUE>] [-p <FILE>] [-w]\n" + " [--no-window-animation] <COMPONENT>\n" + @@ -1217,6 +1246,8 @@ public class Am { "\n" + "am force-stop: force stop everything associated with <PACKAGE>.\n" + "\n" + + "am clear-data: clear the user data associated with <PACKAGE>.\n" + + "\n" + "am broadcast: send a broadcast Intent.\n" + "\n" + "am instrument: start an Instrumentation. Typically this target <COMPONENT>\n" + |