给客户恢复出厂设置的调用接口

原理就是创建一个广播接收者,接收到广播执行恢复出厂设置的方法就可以了,以下为创建的广播接收者以及恢复出厂设置的代码:

diff --git a/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/RestoreReceiver.java b/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/RestoreReceiver.java
new file mode 100755
index 00000000000..4f468f80209
--- /dev/null
+++ b/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/RestoreReceiver.java
@@ -0,0 +1,47 @@
+package com.android.systemui;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.hardware.radio.V1_2.CellIdentityOperatorNames;
+import android.media.AudioManager;
+import android.os.PowerManager;
+import android.util.Log;
+
+import android.os.ServiceManager;
+import com.android.internal.statusbar.IStatusBarService;
+import android.os.RemoteException;

+public class RestoreReceiver extends BroadcastReceiver {
+
+    public static String Action_Restore_Setting="action_restore";
+
+    public  void regiserRecevier(Context context){
+        IntentFilter filter=new IntentFilter();
+        filter.addAction(Action_Restore_Setting);
+        context.registerReceiver(this,filter);
+    }
+
+    @Override
+    public void onReceive(Context context, Intent intent) {
+        Log.d("swl","action:"+intent.getAction());
+        if(Action_Restore_Setting.equals(intent.getAction())){
+               master_clear(context);
+        }
+
+    }
+    private void master_clear(Context context) {
+        Intent intent = new Intent(Intent.ACTION_MASTER_CLEAR);
+        intent.setPackage("android");
+        intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
+        intent.putExtra(Intent.EXTRA_REASON, "MasterClearConfirm");
+        intent.putExtra(Intent.EXTRA_WIPE_EXTERNAL_STORAGE, true);
+        context.sendBroadcast(intent);
+
+    }
+
+}

下面是注册广播:

diff --git a/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/SystemUIApplication.java b/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/SystemUIApplication.java
old mode 100644
new mode 100755
index 4ff5c1d7d20..2968c2c677b
--- a/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/SystemUIApplication.java
+++ b/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/SystemUIApplication.java
@@ -74,6 +74,9 @@ public class SystemUIApplication extends Application implements
         TimingsTraceLog log = new TimingsTraceLog("SystemUIBootTiming",
                 Trace.TRACE_TAG_APP);
         log.traceBegin("DependencyInjection");
+               //swl add 
+               new RestoreReceiver().regiserRecevier(getApplicationContext());
+               //end
         mContextAvailableCallback.onContextAvailable(this);
         mRootComponent = SystemUIFactory.getInstance().getRootComponent();
         mComponentHelper = mRootComponent.getContextComponentHelper();

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值