diff options
| author | Dianne Hackborn <hackbod@google.com> | 2010-10-15 18:52:33 -0700 |
|---|---|---|
| committer | Dianne Hackborn <hackbod@google.com> | 2010-10-15 18:52:33 -0700 |
| commit | 8143be8d0348e4918ccc75e0a44e617c295da2fc (patch) | |
| tree | 941bd2184afa097a1e9adc9967d359f23c3162c4 | |
| parent | 24277fdb61ce6133e31c7ef3e99bd4fc1314f0ac (diff) | |
| download | android_development-8143be8d0348e4918ccc75e0a44e617c295da2fc.tar.gz android_development-8143be8d0348e4918ccc75e0a44e617c295da2fc.tar.bz2 android_development-8143be8d0348e4918ccc75e0a44e617c295da2fc.zip | |
Update device admin example to wipe SD card.
Change-Id: I224006f284916761578e3d04b208828f80ea3cb6
| -rw-r--r-- | samples/ApiDemos/res/layout/device_admin_sample.xml | 14 | ||||
| -rw-r--r-- | samples/ApiDemos/res/values/strings.xml | 1 | ||||
| -rw-r--r-- | samples/ApiDemos/src/com/example/android/apis/app/DeviceAdminSample.java | 23 |
3 files changed, 29 insertions, 9 deletions
diff --git a/samples/ApiDemos/res/layout/device_admin_sample.xml b/samples/ApiDemos/res/layout/device_admin_sample.xml index 2827c010b..16b08ce5d 100644 --- a/samples/ApiDemos/res/layout/device_admin_sample.xml +++ b/samples/ApiDemos/res/layout/device_admin_sample.xml @@ -99,19 +99,25 @@ </LinearLayout> + <Button android:id="@+id/force_lock" + android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_weight="0" + android:text="@string/force_lock"> + </Button> + <LinearLayout android:orientation="horizontal" android:gravity="center" android:layout_width="match_parent" android:layout_height="wrap_content"> - <Button android:id="@+id/force_lock" + <Button android:id="@+id/wipe_data" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0" - android:text="@string/force_lock"> + android:text="@string/wipe_data"> </Button> - <Button android:id="@+id/wipe_data" + <Button android:id="@+id/wipe_all_data" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0" - android:text="@string/wipe_data"> + android:text="@string/wipe_all_data"> </Button> </LinearLayout> diff --git a/samples/ApiDemos/res/values/strings.xml b/samples/ApiDemos/res/values/strings.xml index 949e91a94..4e61b8f05 100644 --- a/samples/ApiDemos/res/values/strings.xml +++ b/samples/ApiDemos/res/values/strings.xml @@ -479,6 +479,7 @@ <string name="max_failed_pw_hint">Password Attempts Wipe Data</string> <string name="force_lock">Force Lock</string> <string name="wipe_data">Wipe Data</string> + <string name="wipe_all_data">Wipe All Data</string> <string name="timeout_hint">Max screen timeout</string> <string name="set_timeout_label">Set Timeout</string> diff --git a/samples/ApiDemos/src/com/example/android/apis/app/DeviceAdminSample.java b/samples/ApiDemos/src/com/example/android/apis/app/DeviceAdminSample.java index f7ee2d73c..b3fc2f98a 100644 --- a/samples/ApiDemos/src/com/example/android/apis/app/DeviceAdminSample.java +++ b/samples/ApiDemos/src/com/example/android/apis/app/DeviceAdminSample.java @@ -128,6 +128,7 @@ public class DeviceAdminSample extends DeviceAdminReceiver { Button mForceLockButton; Button mWipeDataButton; + Button mWipeAllDataButton; private Button mTimeoutButton; @@ -208,6 +209,8 @@ public class DeviceAdminSample extends DeviceAdminReceiver { mForceLockButton.setOnClickListener(mForceLockListener); mWipeDataButton = (Button)findViewById(R.id.wipe_data); mWipeDataButton.setOnClickListener(mWipeDataListener); + mWipeAllDataButton = (Button)findViewById(R.id.wipe_all_data); + mWipeAllDataButton.setOnClickListener(mWipeDataListener); mTimeout = (EditText) findViewById(R.id.timeout); mTimeoutButton = (Button) findViewById(R.id.set_timeout); @@ -226,6 +229,7 @@ public class DeviceAdminSample extends DeviceAdminReceiver { mResetPasswordButton.setEnabled(true); mForceLockButton.setEnabled(true); mWipeDataButton.setEnabled(true); + mWipeAllDataButton.setEnabled(true); } else { mEnableButton.setEnabled(true); mDisableButton.setEnabled(false); @@ -236,6 +240,7 @@ public class DeviceAdminSample extends DeviceAdminReceiver { mResetPasswordButton.setEnabled(false); mForceLockButton.setEnabled(false); mWipeDataButton.setEnabled(false); + mWipeAllDataButton.setEnabled(false); } } @@ -372,7 +377,7 @@ public class DeviceAdminSample extends DeviceAdminReceiver { }; private OnClickListener mWipeDataListener = new OnClickListener() { - public void onClick(View v) { + public void onClick(final View v) { if (mAM.isUserAMonkey()) { // Don't trust monkeys to do the right thing! AlertDialog.Builder builder = new AlertDialog.Builder(Controller.this); @@ -386,14 +391,22 @@ public class DeviceAdminSample extends DeviceAdminReceiver { builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { AlertDialog.Builder builder = new AlertDialog.Builder(Controller.this); - builder.setMessage("This is not a test. " - + "This WILL erase all of your data! " - + "Are you really absolutely sure?"); + if (v == mWipeAllDataButton) { + builder.setMessage("This is not a test. " + + "This WILL erase all of your data, " + + "including external storage! " + + "Are you really absolutely sure?"); + } else { + builder.setMessage("This is not a test. " + + "This WILL erase all of your data! " + + "Are you really absolutely sure?"); + } builder.setPositiveButton("BOOM!", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { boolean active = mDPM.isAdminActive(mDeviceAdminSample); if (active) { - mDPM.wipeData(0); + mDPM.wipeData(v == mWipeAllDataButton + ? DevicePolicyManager.WIPE_EXTERNAL_STORAGE : 0); } } }); |
