码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2014-05-09 16:45:03      阅读:417      评论:0      收藏:0      [点我收藏+]

标签:android   java   tar   ext   c   int   


客制化“*#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*#”恢复出厂设置

标签:android   java   tar   ext   c   int   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!