• recovery菜单选项,添加风险提示弹框


    修改文件:/vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/applications/manageapplications/RecoveryPrefPreferenceController.java

    +import android.app.AlertDialog;
     import android.content.Context;
     import android.os.Bundle;
     import android.os.PowerManager;
     import android.text.TextUtils;
    -
    +import android.app.AlertDialog;
    +import android.content.DialogInterface;
     import androidx.preference.Preference;
     
     import com.android.settings.core.PreferenceControllerMixin;
    @@ -28,7 +30,7 @@
     
     public class RecoveryPrefPreferenceController extends AbstractPreferenceController
             implements PreferenceControllerMixin {
    -    
    +
         private Context mContext;
     
         public RecoveryPrefPreferenceController(Context context) {
    @@ -40,11 +42,33 @@
         public boolean handlePreferenceTreeClick(Preference preference) {
             if (!TextUtils.equals(preference.getKey(), getPreferenceKey())) {
                 return false;
    +
             }
    -        PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
    -        pm.reboot("recovery");
    -        return true;
    +       
    +        final boolean[] flag = {false}; // 将 flag 变量改为数组形式,并且声明为 final
    +        AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
    +        builder.setMessage("是否继续进入recovery");
    +        builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
    +            @Override
    +            public void onClick(DialogInterface dialog, int which) {
    +                PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
    +                pm.reboot("recovery");
    +                flag[0] = true; // 修改 flag 变量的值
    +                dialog.dismiss(); // 关闭对话框
    +            }
    +        });
    +        builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
    +            @Override
    +            public void onClick(DialogInterface dialog, int which) {
    +                dialog.dismiss();// 关闭对话框
    +            }
    +        });
    +        builder.create().show();
    +        return flag[0];
         }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
  • 相关阅读:
    后端跨域解决方案
    JAVA多线程同步队列SynchronousQueue
    Java各版本发行时间表
    索引的设计原则
    代码随想录算法训练营第23期day32|122.买卖股票的最佳时机II、55. 跳跃游戏、45.跳跃游戏II
    Linux学习的五个台阶
    Linux的简单介绍
    作为程序员,我建议你学会写作
    微信热搜查询易语言代码
    【UVA 12657】移动盒子 Boxes in a Line
  • 原文地址:https://blog.csdn.net/for_syq/article/details/132804816