MTK 快速开机 技术详解

时间:2025-04-23 07:58:00

/mirkerson/article/details/21861595

在我们mtk项目中:如何关闭快速开机功能?

①、在device/reallytek/项目配置rlk6737m_65_n/(rlk_projects\cxlite_h3713_a1\)

MTK_IPO_SUPPORT = no  //在配置的宏一定要在**.mk文件中进行转化才能被上层直接使用

②、在device/reallytek/rlk6737m_65_n/中

ifeq ($(strip $(MTK_IPO_SUPPORT)), yes)

  PRODUCT_PROPERTY_OVERRIDES += ro.mtk_ipo_support=1  
endif
//以ro.开头表示系统配置文件,并且表示只能读,即放在这里让我们看一下,让我们知道。PRODUCT_PROPERTY_OVERRIDES是android的一种默认格式

③、在上层某一个java文件中的FeatureOption类中调用MTK_IPO_SUPPORT成员变量判断它的值,从而进一步做如下操作

在./packages/apps/Settings/src/com/android/settings/accessibility/:  中

FeatureOption.MTK_IPO_SUPPORT == false


首先查看Settings里控制开关

01 // 获取当前状态
02 boolean ipoSettingEnabled = (getContentResolver(),
03             .IPO_SETTING,1) == 1;
04 if(mIpoSetting!=null){
05     (ipoSettingEnabled);
06 }
07 //设置新状态
08 boolean isChecked = ((CheckBoxPreference) preference).isChecked();
09 (getContentResolver(), .IPO_SETTING,
10                 isChecked ? 1:0);

全局搜索 .IPO_SETTING ,发现在关机系统里调用了该状态(ShutdownThread.Java

ShutdownThread 里的 checkShutdownFlow 方法

01 // 判断是否不支持该功能 是否需要重启
02 if (FeatureOption.MTK_IPO_SUPPORT == false || mReboot == true) {
03     mShutdownFlow = NORMAL_SHUTDOWN_FLOW;    // 更改状态     
04     return;
05 }
06 boolean isIPOEnabled;
07 try {
08     // 获取当前状态
09     isIPOEnabled = ((),
10         .IPO_SETTING, 1) == 1;
11 catch (NullPointerException ex) {
12     mShutdownFlow = NORMAL_SHUTDOWN_FLOW;
13     return;
14 }
15 if (isIPOEnabled == true) {
16     // 判断系统参数
17     if ("1".equals(("")))
18         mShutdownFlow = NORMAL_SHUTDOWN_FLOW;
19     else
20         mShutdownFlow = IPO_SHUTDOWN_FLOW;
21 else {
22         mShutdownFlow = NORMAL_SHUTDOWN_FLOW;
23 }
24 return;

以上函数如果正常进入快速关机模式 
mShutdownFlow = IPO_SHUTDOWN_FLOW

关机流程会调用 (mContext, true);

ShutdownThread 里的 shutdown 方法

01 bConfirmForAnimation = confirm;
02 if (confirm) {
03     if (mDialog == null) {
04         mDialog = new (context)
05         .setIcon(.ic_dialog_alert)
06         .setTitle(.power_off)
07         .setMessage(.shutdown_confirm)
08         .setPositiveButton(, new () {
09             public void onClick(DialogInterface dialog, int which) {
10                 //确认关机 检查状态
11                 beginShutdownSequence(context);
12                 if (mDialog != null) {
13                     mDialog = null;
14                 }
15             }
16         })
17         .setNegativeButton(, new () {
18             public void onClick(DialogInterface dialog, int which) {
19                 synchronized (sIsStartedGuard) {
20                     sIsStarted = false;
21                 }
22                 if (mDialog != null) {
23                     mDialog = null;
24                 }
25             }
26         })
27         .create();
28         (false);
29         ().setType(
30              .TYPE_KEYGUARD_DIALOG);
31         ().addFlags(
32              .FLAG_DIM_BEHIND);
33     }
34     if (!()) {
35         ();
36     }
37 else {
38     beginShutdownSequence(context);
39 }

ShutdownThread 里的 beginShutdownSequence 方法

1 if (mShutdownFlow == IPO_SHUTDOWN_FLOW) {
2      checkShutdownFlow();
3      synchronized (mShutdownThreadSync) {
4          ();
5      }
6  }

ShutdownThread 里的 run 方法

01 public void run() {
02     checkShutdownFlow();
03     while (mShutdownFlow == IPO_SHUTDOWN_FLOW) {
04         (mContext);
05         running();
06     }
07     if (mShutdownFlow != IPO_SHUTDOWN_FLOW) {
08         running();
09     }
10 }

adb logcat -s “ShutdownThread”

01 --------- beginning of /dev/log/system
02 --------- beginning of /dev/log/main
03 D/ShutdownThread(  189): !!! Request to shutdown !!!
04 D/ShutdownThread(  189): Notifying thread to start radio shutdown
05 D/ShutdownThread(  189): PowerOff dialog doesn't exist. Create it first
06 D/ShutdownThread(  189): ShutdownThread exists already
07 D/ShutdownThread(  189): checkShutdownFlow: IPO_Support=true mReboot=false
08 D/ShutdownThread(  189): checkShutdownFlow: isIPOEnabled=true mShutdownFlow=1
09 D/ShutdownThread(  189): shutdown acquire partial WakeLock 2
10 I/ShutdownThread(  189): Sending shutdown broadcast...
11 I/ShutdownThread(  189): Waiting for Bluetooth and Radio...
12 I/ShutdownThread(  189): Radio and Bluetooth shutdown complete.
13 I/ShutdownThread(  189): Shutting down MountService
14 W/ShutdownThread(  189): Result code 0 from
15 I/ShutdownThread(  189): Performing ipo low-level shutdown...

ShutdownManager 里的 saveStates 方法

1 //保存wifi状态

ShutdownThread 里的 running 方法

1 //广播全局事件 .ACTION_SHUTDOWN_IPO
2 //关闭蓝牙
3 //关闭Radio
4 //关闭MountService
5 (mContext);

ShutdownManager 里的 shutdown 方法

1 mPowerManager = (PowerManager)("power");
2 (());
3 ......
4 ("""ipod");
5 Intent intent = new Intent("");
6 ("_black_mode"true);
7 (intent);

adb logcat -s “ShutdownManager”

01 --------- beginning of /dev/log/system
02 --------- beginning of /dev/log/main
03 I/ShutdownManager(  189): btState: false
04 I/ShutdownManager(  189): saveStates: wifi:0, airplaneModeState: 0
05 V/ShutdownManager(  189): Current Wallpaper = null
06 V/ShutdownManager(  189): Current IME:
07 I/ShutdownManager(  189): accessibility is disabled
08 I/ShutdownManager(  189): killProcess (IME):
09 I/ShutdownManager(  189): forceStopPackage:
10 V/ShutdownManager(  189): process =
11 I/ShutdownManager(  189): forceStopPackage:
12 I/ShutdownManager(  189): forceStopPackage:
13 I/ShutdownManager(  189): forceStopPackage:
14 I/ShutdownManager(  189): forceStopPackage:
15 I/ShutdownManager(  189): forceStopPackage:
16 I/ShutdownManager(  189): forceStopPackage:
17 I/ShutdownManager(  189): forceStopPackage:
18 I/ShutdownManager(  189): forceStopPackage:
19 I/ShutdownManager(  189): forceStopPackage:
20 V/ShutdownManager(  189): uid-process =
21 I/ShutdownManager(  189): forceStopPackage:
22 I/ShutdownManager(  189): forceStopPackage:
23 V/ShutdownManager(  189): uid-process =
24 I/ShutdownManager(  189): forceStopPackage:

ActivityManagerPlus 接收到关机广播

adb logcat -s “ActivityManagerPlus”

1 --------- beginning of /dev/log/system
2 --------- beginning of /dev/log/main
3 I/ActivityManagerPlus(  189): Receive:
4 Intent { act=.ACTION_SHUTDOWN_IPO }
5 I/ActivityManagerPlus(  189): finished
6 I/ActivityManagerPlus(  189): Receive:
7 Intent { act= (has  extras) }
8 I/ActivityManagerPlus(  189): createIPOWin

ActivityManagerPlus 里的 createIPOWin 方法 关机调用

01 Window win = (context);
02 (2016);
03 (10241024);
04 (-1, -1);
05 (1);
06 params = ();
07 ("IPOWindow");
08 24;
09 WindowManagerImpl wm = (WindowManagerImpl)("window");
10 view = ();
11 (view, params);

ActivityManagerPlus 里的 removeIPOWin 方法 开机调用

1 WindowManagerImpl wm = (WindowManagerImpl)("window");
2 (view);

底层实现 
mediatek/source/external/ipod/