日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

MTK6577+Android4.0之增加重启功能

發布時間:2023/12/16 Android 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 MTK6577+Android4.0之增加重启功能 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

MTK6577+Android4.0之增加重啟功能

?

長按power按鍵,彈出下圖:


圖1

這里要實現增加Reboot的功能,下面記下要實現所做的修改。

1.?????在長按power按鍵彈出的界面增加Reboot界面

?

首先關機的那個彈出菜單是在

frameworks/base/policy/src/com/android/internal/policy/impl/GlobalActions.java這個文件中的private AlertDialog createDialog(),如下:

? ?

/*** Create the global actions dialog.* @return A new dialog.*/private AlertDialog createDialog() {mSilentModeAction = newSilentModeAction(mAudioManager, mHandler);mAirplaneModeOn = new ToggleAction(R.drawable.ic_lock_airplane_mode,R.drawable.ic_lock_airplane_mode_off,R.string.global_actions_toggle_airplane_mode,R.string.global_actions_airplane_mode_on_status,R.string.global_actions_airplane_mode_off_status) {void onToggle(boolean on) {if (Boolean.parseBoolean(SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE))){mIsWaitingForEcmExit =true;// Launch ECM exit dialogIntent ecmDialogIntent =new Intent(TelephonyIntents.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS,null);ecmDialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);mContext.startActivity(ecmDialogIntent);} else {changeAirplaneModeSystemSetting(on);}}@Overrideprotected voidchangeStateFromPress(boolean buttonOn) {// In ECM mode airplane statecannot be changedif (!(Boolean.parseBoolean(SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE)))) {mState = buttonOn ?State.TurningOn : State.TurningOff;mAirplaneState = mState;}}public boolean showDuringKeyguard(){return true;}public booleanshowBeforeProvisioning() {return false;}//M{public boolean isEnabled() {if(KeyguardUpdateMonitor.dual_sim_setting == 0){Log.e(TAG, "if userunselect the dual sim mode setting on phone starting, the airplane mode can notbe set.");return false; //if user hasnot yet selected any item in the dual_sim_mode_setting dialog on phonestarting, the airplane mode should be disabled.}else {returnsuper.isEnabled();}}//}M};mItems = new ArrayList<Action>();// first: power offmItems.add(new SinglePressAction(com.android.internal.R.drawable.ic_lock_power_off,R.string.global_action_power_off) {public void onPress() {// shutdown by making sureradio and power are handled accordingly.ShutdownThread.shutdown(mContext, true);}public booleanshowDuringKeyguard() {return true;}public booleanshowBeforeProvisioning() {return true;}});// next: airplane modemItems.add(mAirplaneModeOn);// last: silent modeif (SHOW_SILENT_TOGGLE) {mItems.add(mSilentModeAction);}mAdapter = new MyAdapter();final AlertDialog.Builder ab = newAlertDialog.Builder(mContext);ab.setAdapter(mAdapter, this).setInverseBackgroundForced(true);final AlertDialog dialog = ab.create();dialog.getListView().setItemsCanFocus(true);dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG);dialog.setOnDismissListener(this);return dialog; }

上面的代碼在// first: power off和// next: airplane mode之間增加了reboot部分,代碼如下:

// second:reboot,kandi add at 2015.01.21mItems.add(new SinglePressAction(com.android.internal.R.drawable.ic_lock_reboot,R.string.global_action_reboot) {public void onPress() {// shutdown by making sureradio and power are handled accordingly.ShutdownThread.reboot(mContext,null, true);}public booleanshowDuringKeyguard() {return true;}public booleanshowBeforeProvisioning() {return true;}});

此代碼主要闡述下面幾點:

(1)??增加字符串global_action_reboot和圖片資源ic_lock_reboot,這些的定義在后面描述。

(2)??ShutdownThread.reboot(mContext,null, true)此函數是調用

/*** Request a clean shutdown, waiting forsubsystems to clean up their* state etc. Must be called from a Looper thread in whichits UI* is shown.** @param context Context used to displaythe shutdown progress dialog.* @param reason code to pass to the kernel(e.g. "recovery"), or null.* @param confirm true if user confirmationis needed before shutting down.*/public static void reboot(final Contextcontext, String reason, boolean confirm) {mReboot = true;mRebootReason = reason;shutdown(context, confirm); }

reason 如果值為是null,正常重啟;如果是recovery,系統重啟進入recovery mode

confirm true顯示關機提示框,需要用戶;false不顯示提示框,直接關機。


2.?????增加點擊Reboot后的重啟

為了在按下重啟選項之后,能出現”重啟“之類的提示,還需要修改\frameworks\base\core\java\com\android\internal\app\ ShutdownThread.java中的shutdown函數和beginShutdownSequence函數:

?

(1)??shutdown函數

修改之前 final intresourceId = longPressBehavior == 2? com.android.internal.R.string.shutdown_confirm_question : com.android.internal.R.string.shutdown_confirm; 修改之后 final intresourceId = longPressBehavior == 2? com.android.internal.R.string.shutdown_confirm_question: (mReboot ?com.android.internal.R.string.reboot_confirm :com.android.internal.R.string.shutdown_confirm);

(2)??beginShutdownSequence函數

修改之前: pd.setTitle(context.getText(com.android.internal.R.string.power_off)); pd.setMessage(context.getText(com.android.internal.R.string.shutdown_progress));修改之后: if(mReboot){pd.setTitle(context.getText(com.android.internal.R.string.global_action_reboot));pd.setMessage(context.getText(com.android.internal.R.string.reboot_progress));}else{pd.setTitle(context.getText(com.android.internal.R.string.power_off));pd.setMessage(context.getText(com.android.internal.R.string.shutdown_progress));}

3.?????增加字符串和圖片資源

?

(1)??增加字符串

在frameworks/base/core/res/res/values/strings.xml中添加一下字符串:

<stringname="reboot_progress">Reboot...\u2026</string> <stringname="reboot_confirm" product="default">Your phone willReboot.</string> <stringname="reboot_confirm" product="default">Your phone willReboot.</string> <stringname="global_action_reboot">Reboot</string> <stringname="reboot">Reboot2</string>

在\frameworks\base\core\res\res\values\public.xml增加以下字符串

<publictype="drawable" name="ic_menu_sort_by_size"id="0x0108009d" />//已有 <publictype="drawable" name="ic_lock_reboot"id="0x0108009e" />//增加

(2)??增加重啟的圖片資源

把ic_lock_reboot.png拷貝到\frameworks\base\core\res\res\drawable-hdpi目錄下

?

4.?????編譯及升級

./mk r dr,然后單獨升級system.img

轉載于:https://www.cnblogs.com/LoongEmbedded/p/5298300.html

總結

以上是生活随笔為你收集整理的MTK6577+Android4.0之增加重启功能的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。