- 重启图标:frameworks/base/core/res/res/drawable-hdpi/ic_lock_power_reboot_alpha.png
- frameworks/base/core/res/res/drawable/ic_lock_power_reboot.xml
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
+ android:src="@drawable/ic_lock_power_reboot_alpha"
+ android:tint="?attr/colorControlNormal" />
- frameworks/base/core/res/res/values/config.xml
<string-array translatable="false" name="config_globalActionsList">
<item>power</item>
+ <item>reboot</item><!-- mh.mmi add reboot -->
<item>bugreport</item>
<item>users</item>
</string-array>
- frameworks/base/core/res/res/values/public.xml
<public type="string" name="fingerprint_icon_content_description" />
+ <!-- mh.mmi reboot icon -->
+ <public type="drawable" name="ic_lock_power_reboot" id="0x010800b4" />
- frameworks/base/services/core/java/com/android/server/policy/GlobalActions.java
import java.util.List;
+import android.os.IPowerManager;///mh.mmi
/**
* Helper to show the global actions dialog. Each item is an {@link Action} that
* may show depending on whether the keyguard is showing, and whether the device
@@ -93,6 +95,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
/* Valid settings for global actions keys.
* see config.xml config_globalActionList */
private static final String GLOBAL_ACTION_KEY_POWER = "power";
+ private static final String GLOBAL_ACTION_KEY_REBOOT = "reboot";///mh.mmi
private static final String GLOBAL_ACTION_KEY_AIRPLANE = "airplane";
private static final String GLOBAL_ACTION_KEY_BUGREPORT = "bugreport";
private static final String GLOBAL_ACTION_KEY_SILENT = "silent";
@@ -273,6 +276,8 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
}
if (GLOBAL_ACTION_KEY_POWER.equals(actionKey)) {
mItems.add(new PowerAction());
+ } else if (GLOBAL_ACTION_KEY_REBOOT.equals(actionKey)) {///mh.mmi
+ mItems.add(new RebootAction());
} else if (GLOBAL_ACTION_KEY_AIRPLANE.equals(actionKey)) {
mItems.add(mAirplaneModeOn);
} else if (GLOBAL_ACTION_KEY_BUGREPORT.equals(actionKey)) {
@@ -366,6 +371,37 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
mWindowManagerFuncs.shutdown(false /* confirm */);
}
}
+
+ ///mh.mmi start
+ private final class RebootAction extends SinglePressAction {
+
+ private RebootAction() {
+ super(com.android.internal.R.drawable.ic_lock_power_reboot, R.string.factorytest_reboot);
+ }
+
+ @Override
+ public boolean showDuringKeyguard() {
+ return true;
+ }
+
+ @Override
+ public boolean showBeforeProvisioning() {
+ return true;
+ }
+
+ @Override
+ public void onPress() {
+ try {
+ IPowerManager pm = IPowerManager.Stub.asInterface(ServiceManager.getService(Context.POWER_SERVICE));
+ pm.reboot(true, null, false);
+ }
+ catch (RemoteException e) {
+ Log.e(TAG, "PowerManager service died!", e);
+ return;
+ }
+ }
+ }
+ ///mh.end
private Action getBugReportAction() {
return new SinglePressAction(com.android.internal.R.drawable.ic_lock_bugreport,
文章来源地址https://www.toymoban.com/news/detail-682489.html
文章来源:https://www.toymoban.com/news/detail-682489.html
到了这里,关于Android 6.0长按电源键添加重启菜单的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!