Perform master clear via Intent broadcast, rather than using ICheckinService.
This commit is contained in:
@@ -60,35 +60,12 @@ public class MasterClear extends Activity {
|
|||||||
*/
|
*/
|
||||||
private Button.OnClickListener mFinalClickListener = new Button.OnClickListener() {
|
private Button.OnClickListener mFinalClickListener = new Button.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
|
||||||
if (Utils.isMonkeyRunning()) {
|
if (Utils.isMonkeyRunning()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ICheckinService service =
|
sendBroadcast(new Intent("android.intent.action.MASTER_CLEAR"));
|
||||||
ICheckinService.Stub.asInterface(ServiceManager.getService("checkin"));
|
// Intent handling is asynchronous -- assume it will happen soon.
|
||||||
if (service != null) {
|
|
||||||
try {
|
|
||||||
// This RPC should never return
|
|
||||||
service.masterClear();
|
|
||||||
} catch (android.os.RemoteException e) {
|
|
||||||
// Intentionally blank - there's nothing we can do here
|
|
||||||
Log.w("MasterClear", "Unable to invoke ICheckinService.masterClear()");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Log.w("MasterClear", "Unable to locate ICheckinService");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If we reach this point, the master clear didn't happen -- the
|
|
||||||
* service might have been unregistered with the ServiceManager,
|
|
||||||
* the RPC might have thrown an exception, or for some reason
|
|
||||||
* the implementation of masterClear() may have returned instead
|
|
||||||
* of resetting the device.
|
|
||||||
*/
|
|
||||||
new AlertDialog.Builder(MasterClear.this)
|
|
||||||
.setMessage(getText(R.string.master_clear_failed))
|
|
||||||
.setPositiveButton(getText(android.R.string.ok), null)
|
|
||||||
.show();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -32,8 +32,6 @@ import android.content.Intent;
|
|||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.location.LocationManager;
|
import android.location.LocationManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.ICheckinService;
|
|
||||||
import android.os.ServiceManager;
|
|
||||||
import android.os.SystemProperties;
|
import android.os.SystemProperties;
|
||||||
import android.preference.CheckBoxPreference;
|
import android.preference.CheckBoxPreference;
|
||||||
import android.preference.ListPreference;
|
import android.preference.ListPreference;
|
||||||
@@ -444,26 +442,9 @@ public class SecuritySettings extends PreferenceActivity {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (button == DialogInterface.BUTTON_POSITIVE) {
|
if (button == DialogInterface.BUTTON_POSITIVE) {
|
||||||
// Perform action
|
Intent intent = new Intent("android.intent.action.MASTER_CLEAR");
|
||||||
// Reboot and toggle Encrypted File Systems
|
intent.putExtra("enableEFS", mWillEnableEncryptedFS);
|
||||||
ICheckinService service =
|
sendBroadcast(intent);
|
||||||
ICheckinService.Stub.asInterface(ServiceManager.getService("checkin"));
|
|
||||||
if (service != null) {
|
|
||||||
try {
|
|
||||||
// This RPC should never return
|
|
||||||
if (mWillEnableEncryptedFS) {
|
|
||||||
service.masterClearAndToggleEFS(true);
|
|
||||||
} else {
|
|
||||||
service.masterClearAndToggleEFS(false);
|
|
||||||
}
|
|
||||||
} catch (android.os.RemoteException e) {
|
|
||||||
// Intentionally blank - there's nothing we can do here
|
|
||||||
Log.w("SecuritySettings",
|
|
||||||
"Unable to invoke ICheckinService.masterClearAndToggleEFS()");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Log.w("SecuritySettings", "Unable to locate ICheckinService");
|
|
||||||
}
|
|
||||||
updatePreferences(mState);
|
updatePreferences(mState);
|
||||||
} else if (button == DialogInterface.BUTTON_NEGATIVE) {
|
} else if (button == DialogInterface.BUTTON_NEGATIVE) {
|
||||||
// Cancel action
|
// Cancel action
|
||||||
|
Reference in New Issue
Block a user