Long press the power key and add the restart menu in the pop-up Global actions dialog box, as shown below:
If you need to add the restart menu to restart your phone, follow these steps:
1,Add tags in alpsrameworksasecore es esaluesstrings. xml:
Reboot
The string resource used to display the restart menu item. If you need to add an identifier for another language, add the corresponding resource under res folder of another replaceable resource.
Note: to ensure that the resource file can be compiled, add the resource to symbols. xml synchronously.
2,Add the icon to alpsrameworksasecore es esdrawable-hdpi:
Zzzzz_ic_lock_power_reboot.png
3,In alpsrameworksasepolicysrccomandroidinternalpolicyimplGlobalActions. java
Add the following to the createDialog () function in the file:
Private GlobalActionsDialog createDialog (){
......
MItems = new ArrayList ();
// First: power off
MItems. add (......);
//////////////////////////////////////// //// Added for reboot items start
MItems. add (
New SinglePressAction (
Com. android. internal. R. zzzzz_ic_lock_power_reboot,
R. string. zzzzz_global_action_power_reboot ){
Public void onPress (){
MWindowManagerFuncs. reboot (true );
}
Public boolean onLongPress (){
MWindowManagerFuncs. rebootSafeMode (true );
Return true;
}
Public boolean showDuringKeyguard (){
Return true;
}
Public boolean showBeforeProvisioning (){
Return true;
}
});
/// // Added end
// Next: airplane mode
MItems. add (mAirplaneModeOn );
......
}
4,In the frameworksasecorejavaandroidiewWindowManagerPolicy. java file, find the interface Definition of WindowManagerFuncs and add the following function declaration:
Public interface WindowManagerFuncs {
Public void reboot (boolean confirm );
}
5,In FrameworksaseservicesjavacomandroidserverwmWindowManagerService. java, because it implements the WindowManagerFuncs interface, you need to add the reboot () function implementation body to the file.
Find the shutdown () function and add the reboot () function after it. The function content is as follows:
// Called by window manager policy. Not exposed externally.
@ Override
Public void reboot (boolean confirm ){
ShutdownThread. reboot (mContext, confirm );
}