首页 > 其他 > 详细

客制化“*#0*#”恢复出厂设置

时间:2014-05-09 16:43:02      阅读:497      评论:0      收藏:0      [点我收藏+]


客制化“*#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

客制化“*#0*#”恢复出厂设置

原文:http://www.cnblogs.com/plpdan/p/3708834.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!