Android 6.0长按电源键添加重启菜单

  1. 重启图标:frameworks/base/core/res/res/drawable-hdpi/ic_lock_power_reboot_alpha.png
  2. frameworks/base/core/res/res/drawable/ic_lock_power_reboot.xml
+
+
+
+<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
+    android:src="@drawable/ic_lock_power_reboot_alpha"
+    android:tint="?attr/colorControlNormal" />
  1. frameworks/base/core/res/res/values/config.xml
     <string-array translatable="false" name="config_globalActionsList">
         <item>poweritem>
+        <item>rebootitem>
         <item>bugreportitem>
         <item>usersitem>
     string-array>
  1. frameworks/base/core/res/res/values/public.xml
     <public type="string" name="fingerprint_icon_content_description" />
+    
+    <public type="drawable" name="ic_lock_power_reboot" id="0x010800b4" />   
  1. 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,

你可能感兴趣的:(android客制,android)