http://blog.youkuaiyun.com/mirkerson/article/details/21861595
在我们mtk项目中:如何关闭快速开机功能?
①、在device/reallytek/项目配置rlk6737m_65_n/ProjectConfig.mk(rlk_projects\cxlite_h3713_a1\ProjectConfig.mk)
MTK_IPO_SUPPORT = no //在ProjectConfig.mk配置的宏一定要在**.mk文件中进行转化才能被上层直接使用
②、在device/reallytek/rlk6737m_65_n/device.mk中
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/AccessibilitySettings.java: 中
FeatureOption.MTK_IPO_SUPPORT ==
false
首先查看Settings里控制开关
02 | boolean ipoSettingEnabled = Settings.System.getInt(getContentResolver(), |
03 | Settings.System.IPO_SETTING, 1 ) == 1 ; |
04 | if (mIpoSetting!= null ){ |
05 | mIpoSetting.setChecked(ipoSettingEnabled); |
08 | boolean isChecked = ((CheckBoxPreference) preference).isChecked(); |
09 | Settings.System.putInt(getContentResolver(), Settings.System.IPO_SETTING, |
全局搜索 Settings.System.IPO_SETTING ,发现在关机系统里调用了该状态(ShutdownThread.Java)
ShutdownThread 里的 checkShutdownFlow 方法
02 | if (FeatureOption.MTK_IPO_SUPPORT == false || mReboot == true ) { |
03 | mShutdownFlow = NORMAL_SHUTDOWN_FLOW; |
09 | isIPOEnabled = Settings.System.getInt(sInstance.mContext.getContentResolver(), |
10 | Settings.System.IPO_SETTING, 1 ) == 1 ; |
11 | } catch (NullPointerException ex) { |
12 | mShutdownFlow = NORMAL_SHUTDOWN_FLOW; |
15 | if (isIPOEnabled == true ) { |
17 | if ( "1" .equals(SystemProperties.get( "sys.ipo.battlow" ))) |
18 | mShutdownFlow = NORMAL_SHUTDOWN_FLOW; |
20 | mShutdownFlow = IPO_SHUTDOWN_FLOW; |
22 | mShutdownFlow = NORMAL_SHUTDOWN_FLOW; |
以上函数如果正常进入快速关机模式
mShutdownFlow = IPO_SHUTDOWN_FLOW
关机流程会调用 ShutdownThread.shutdown(mContext, true);
ShutdownThread 里的 shutdown 方法
01 | bConfirmForAnimation = confirm; |
03 | if (mDialog == null ) { |
04 | mDialog = new AlertDialog.Builder(context) |
05 | .setIcon(android.R.drawable.ic_dialog_alert) |
06 | .setTitle(com.android.internal.R.string.power_off) |
07 | .setMessage(com.android.internal.R.string.shutdown_confirm) |
08 | .setPositiveButton(com.android.internal.R.string.yes, new DialogInterface.OnClickListener() { |
09 | public void onClick(DialogInterface dialog, int which) { |
11 | beginShutdownSequence(context); |
12 | if (mDialog != null ) { |
17 | .setNegativeButton(com.android.internal.R.string.no, new DialogInterface.OnClickListener() { |
18 | public void onClick(DialogInterface dialog, int which) { |
19 | synchronized (sIsStartedGuard) { |
22 | if (mDialog != null ) { |
28 | mDialog.setCancelable( false ); |
29 | mDialog.getWindow().setType( |
30 | WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG); |
31 | mDialog.getWindow().addFlags( |
32 | WindowManager.LayoutParams.FLAG_DIM_BEHIND); |
34 | if (!mDialog.isShowing()) { |
38 | beginShutdownSequence(context); |
ShutdownThread 里的 beginShutdownSequence 方法
1 | if (mShutdownFlow == IPO_SHUTDOWN_FLOW) { |
3 | synchronized (mShutdownThreadSync) { |
4 | mShutdownThreadSync.notify(); |
ShutdownThread 里的 run 方法
03 | while (mShutdownFlow == IPO_SHUTDOWN_FLOW) { |
04 | stMgr.saveStates(mContext); |
07 | if (mShutdownFlow != IPO_SHUTDOWN_FLOW) { |
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 MountService.shutdown |
15 | I/ShutdownThread( 189 ): Performing ipo low-level shutdown... |
ShutdownManager 里的 saveStates 方法
ShutdownThread 里的 running 方法
5 | stMgr.shutdown(mContext); |
ShutdownManager 里的 shutdown 方法
1 | mPowerManager = (PowerManager)context.getSystemService( "power" ); |
2 | mPowerManager.goToSleep(SystemClock.uptimeMillis()); |
4 | SystemProperties.set( "ctl.start" , "ipod" ); |
5 | Intent intent = new Intent( "android.intent.action.black.mode" ); |
6 | intent.putExtra( "_black_mode" , true ); |
7 | context.sendBroadcast(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: com.android.inputmethod.pinyin |
07 | I/ShutdownManager( 189 ): accessibility is disabled |
08 | I/ShutdownManager( 189 ): killProcess (IME): com.android.inputmethod.pinyin |
09 | I/ShutdownManager( 189 ): forceStopPackage: com.cooliris.media |
10 | V/ShutdownManager( 189 ): process = com.android.settings |
11 | I/ShutdownManager( 189 ): forceStopPackage: com.android.settings |
12 | I/ShutdownManager( 189 ): forceStopPackage: com.mediatek.launcherplus |
13 | I/ShutdownManager( 189 ): forceStopPackage: com.android.mms |
14 | I/ShutdownManager( 189 ): forceStopPackage: android.process.media |
15 | I/ShutdownManager( 189 ): forceStopPackage: android.process.media |
16 | I/ShutdownManager( 189 ): forceStopPackage: android.process.media |
17 | I/ShutdownManager( 189 ): forceStopPackage: com.mediatek.moreapp |
18 | I/ShutdownManager( 189 ): forceStopPackage: com.mediatek.omacp |
19 | I/ShutdownManager( 189 ): forceStopPackage: com.android.email |
20 | V/ShutdownManager( 189 ): uid-process = com.mediatek.mdlogger |
21 | I/ShutdownManager( 189 ): forceStopPackage: com.android.providers.calendar |
22 | I/ShutdownManager( 189 ): forceStopPackage: com.android.deskclock |
23 | V/ShutdownManager( 189 ): uid-process = com.android.ActivityNetwork |
24 | I/ShutdownManager( 189 ): forceStopPackage: com.mediatek.weather |
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=android.intent.action.ACTION_SHUTDOWN_IPO } |
5 | I/ActivityManagerPlus( 189 ): finished |
6 | I/ActivityManagerPlus( 189 ): Receive: |
7 | Intent { act=android.intent.action.black.mode (has extras) } |
8 | I/ActivityManagerPlus( 189 ): createIPOWin |
ActivityManagerPlus 里的 createIPOWin 方法 关机调用
01 | Window win = PolicyManager.makeNewWindow(context); |
03 | win.setFlags( 1024 , 1024 ); |
04 | win.setLayout(- 1 , - 1 ); |
05 | win.requestFeature( 1 ); |
06 | android.view.WindowManager.LayoutParams params = win.getAttributes(); |
07 | params.setTitle( "IPOWindow" ); |
09 | WindowManagerImpl wm = (WindowManagerImpl)context.getSystemService( "window" ); |
10 | view = win.getDecorView(); |
11 | wm.addView(view, params); |
ActivityManagerPlus 里的 removeIPOWin 方法 开机调用
1 | WindowManagerImpl wm = (WindowManagerImpl)context.getSystemService( "window" ); |
底层实现
mediatek/source/external/ipod/