长按电源键中增加重启和飞行模式选项及显示情景模式(静音、震动、响铃)

1.frameworks/base/services/core/java/com/android/server/policy/GlobalActions.java

private final class PowerAction extends SinglePressAction implements LongPressAction {

.......

}

//add by zjx

private final class RebootAction extends SinglePressAction implements LongPressAction {
        private RebootAction() {
            super(com.mediatek.internal.R.drawable.ic_lock_reboot,
                com.mediatek.internal.R.string.global_action_reboot);
        }


        @Override
        public boolean onLongPress() {
            //mWindowManagerFuncs.rebootSafeMode(true);
            return true;
        }


        @Override
        public boolean showDuringKeyguard() {
            return true;
        }


        @Override
        public boolean showBeforeProvisioning() {
            return true;
        }


        @Override
        public void onPress() {
            // shutdown by making sure radio and power are handled accordingly.
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
                builder.setTitle(com.android.internal.R.string.factorytest_reboot);
                builder.setMessage(com.mediatek.internal.R.string.global_action_reboot_info);
                builder.setNegativeButton(com.android.internal.R.string.cancel, null);
                builder.setPositiveButton(com.android.internal.R.string.yes,
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                PowerManager pm = (PowerManager) mContext
                                            .getSystemService(Context.POWER_SERVICE);
                                    // SPRD: add reboot reason for PhoneInfo
                                    // feature @{
                                    pm.reboot("power_reboot");
                            }
                        });
                AlertDialog dialog = builder.create();
                dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
                dialog.show();
        }
    }

//end by zjx

2.frameworks/base/services/core/java/com/android/server/power/ShutdownThread.java

private static void beginShutdownSequence(Context context) {

...................

//add by zjx

} else {
if(mReboot&&(!mRebootSafeMode)){
pd.setTitle(context.getText(com.android.internal.R.string.factorytest_reboot));
pd.setMessage(context.getText(com.mediatek.internal.R.string.global_action_reboot_message));
}else{
pd.setTitle(context.getText(com.android.internal.R.string.power_off));
pd.setMessage(context.getText(com.android.internal.R.string.shutdown_progress));
}
//
end by zjx

pd.setIndeterminate(true);

        }

}

3.frameworks/base/core/res/res/values/config.xml

<string-array translatable="false" name="config_globalActionsList">

         <item>power</item>

<item>airplane</item>

        <item>bugreport</item>

        <item>users</item>

        <item>silent</item> //显示情景模式

    </string-array>

4,vendor\mediatek\proprietary\frameworks\base\res\res\values\symbols.xml

//add by zjx

  <java-symbol type="drawable" name="ic_lock_reboot" />
    <java-symbol type="string" name="global_action_reboot" />
<java-symbol type="string" name="global_action_reboot_info" />
<java-symbol type="string" name="global_action_reboot_message" />

//end by zjx

5.vendor\mediatek\proprietary\frameworks\base\res\res\values\strings.xml

<string name="global_action_reboot" >Reboot</string>
<string name="global_action_screenshot" >Screenshot</string>
<string name="global_action_reboot_info" >Would you like to reboot your phone now?</string>
<string name="global_action_reboot_message" >Rebooting...</string>

猜你喜欢

转载自blog.csdn.net/zhang_jun_xiang/article/details/52277350