diff options
author | Joe Onorato <joeo@google.com> | 2011-11-01 21:53:47 -0700 |
---|---|---|
committer | Joe Onorato <joeo@google.com> | 2011-11-01 21:53:47 -0700 |
commit | 8f926be8fbe133a836170546ae19e720e91bc1f2 (patch) | |
tree | 84c1f638166d1c5277bba261e10c059c96891754 /cmds | |
parent | e18aead3e0a0b94fc4a1ef75f0f9459a3221ca80 (diff) | |
download | frameworks_base-8f926be8fbe133a836170546ae19e720e91bc1f2.zip frameworks_base-8f926be8fbe133a836170546ae19e720e91bc1f2.tar.gz frameworks_base-8f926be8fbe133a836170546ae19e720e91bc1f2.tar.bz2 |
Add clear-data command to am to wipe the given package's data.
Change-Id: I2fa5bb6b15f59ae6dc4ae18ab42e849811a2eb81
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" + |