客制化“*#0*#”恢复出厂设置
packages/apps/Dialer/src/com/android/dialer/SpecialCharSequenceMgr.java
private static final String MMI_RESET_PHONE = "*#0*#";
public static final
String FORMAT_AND_FACTORY_RESET =
"com.android.internal.os.storage.FORMAT_AND_FACTORY_RESET";
public static boolean handleIMEIDisplay(Context context, String input,
boolean useSystemWindow) {
if
(input.equals(MMI_IMEI_DISPLAY))
{
TelephonyManager telephonyManager = ((TelephonyManager)
context.getSystemService(
Context.TELEPHONY_SERVICE));
int phoneType =
telephonyManager.getCurrentPhoneType();
if (phoneType == TelephonyManager.PHONE_TYPE_GSM)
{
showIMEIPanel(context, useSystemWindow,
telephonyManager);
return
true;
}
else if (phoneType == TelephonyManager.PHONE_TYPE_CDMA)
{
showMEIDPanel(context, useSystemWindow,
telephonyManager);
return
true;
}
} else if
(input.equals(MMI_RESET_PHONE)) { //Redmine5775 shengjun modify 20140421
end
final Context mContext =
context;
AlertDialog.Builder builder = new
AlertDialog.Builder(mContext);
builder.setTitle("确定要恢复出厂设置吗?");
builder.setPositiveButton("确定", new
android.content.DialogInterface.OnClickListener()
{
public void onClick(android.content.DialogInterface dialog, int which)
{
android.content.Intent intent = new
android.content.Intent(FORMAT_AND_FACTORY_RESET);
intent.setComponent(new android.content.ComponentName("android",
"com.android.internal.os.storage.ExternalStorageFormatter"));
mContext.startService(intent);
}
});
builder.setNegativeButton("取消",
null);
builder.create().show();
return true;
}
//Redmine5775 shengjun modify
20140421 end
return
false;
}
最后在AndroidManifest.xml中还要添加权限
<uses-permission
android:name="android.permission.MASTER_CLEAR" />
客制化“*#0*#”恢复出厂设置,布布扣,bubuko.com
原文:http://www.cnblogs.com/plpdan/p/3708834.html