Android5.1开关机添加重启选项

--- a/alps/frameworks/base/api/current.txt
+++ b/alps/frameworks/base/api/current.txt
@@ -1536,6 +1536,7 @@ package android {
     field public static final int ic_lock_idle_low_battery = 17301536; // 0x1080020
     field public static final int ic_lock_lock = 17301551; // 0x108002f
     field public static final int ic_lock_power_off = 17301552; // 0x1080030
+    field public static final int ic_lock_power_reboot = 17301662; // 0x108009e
     field public static final int ic_lock_silent_mode = 17301553; // 0x1080031
     field public static final int ic_lock_silent_mode_off = 17301554; // 0x1080032
     field public static final int ic_media_ff = 17301537; // 0x1080021

--- a/alps/frameworks/base/api/system-current.txt
+++ b/alps/frameworks/base/api/system-current.txt
@@ -1610,6 +1610,7 @@ package android {
     field public static final int ic_lock_idle_low_battery = 17301536; // 0x1080020
     field public static final int ic_lock_lock = 17301551; // 0x108002f
     field public static final int ic_lock_power_off = 17301552; // 0x1080030
+    field public static final int ic_lock_power_reboot = 17301662; // 0x108009e
     field public static final int ic_lock_silent_mode = 17301553; // 0x1080031
     field public static final int ic_lock_silent_mode_off = 17301554; // 0x1080032
     field public static final int ic_media_ff = 17301537; // 0x1080021

--- a/alps/frameworks/base/core/java/android/view/WindowManagerPolicy.java
+++ b/alps/frameworks/base/core/java/android/view/WindowManagerPolicy.java
@@ -468,6 +468,7 @@ public interface WindowManagerPolicy {
 
         public void shutdown(boolean confirm);
         public void rebootSafeMode(boolean confirm);
+        public void reboot(String reason, boolean confirm);
 
         /**
          * Return the window manager lock needed to correctly call "Lw" methods.

--- a/alps/frameworks/base/core/res/res/values-zh-rCN/strings.xml
+++ b/alps/frameworks/base/core/res/res/values-zh-rCN/strings.xml
@@ -181,7 +181,7 @@
     <string name="shutdown_confirm" product="tablet" msgid="3385745179555731470">"您的平板电脑会关闭。"</string>
     <string name="shutdown_confirm" product="tv" msgid="476672373995075359">"您的电视即将关闭。"</string>
     <string name="shutdown_confirm" product="watch" msgid="3490275567476369184">"您的手表即将关机。"</string>
-    <string name="shutdown_confirm" product="default" msgid="649792175242821353">"您的手机将会关机。"</string>
+    <string name="shutdown_confirm" product="default" msgid="649792175242821353">"您的设备将会关机。"</string>
     <string name="shutdown_confirm_question" msgid="2906544768881136183">"您要关机吗?"</string>
     <string name="reboot_safemode_title" msgid="7054509914500140361">"重新启动并进入安全模式"</string>
     <string name="reboot_safemode_confirm" msgid="55293944502784668">"您要重新启动并进入安全模式吗?这样会停用您已安装的所有第三方应用。再次重新启动将恢
@@ -1879,4 +1879,8 @@
     <string name="stk_cc_ss_to_dial" msgid="2151304435775557162">"SS 请求已修改为 DIAL 请求。"</string>
     <string name="stk_cc_ss_to_ussd" msgid="3951862188105305589">"SS 请求已修改为 USSD 请求。"</string>
     <string name="stk_cc_ss_to_ss" msgid="5470768854991452695">"SS 请求已修改为新的 SS 请求。"</string>
+
+    <string name="global_action_power_reboot">重启</string>
+    <string name="reboot_confirm">您的设备将会重启。</string>
+    
 </resources>

--- a/alps/frameworks/base/core/res/res/values-zh-rTW/strings.xml
+++ b/alps/frameworks/base/core/res/res/values-zh-rTW/strings.xml
@@ -181,7 +181,7 @@
     <string name="shutdown_confirm" product="tablet" msgid="3385745179555731470">"您的平板電腦將會關機。"</string>
     <string name="shutdown_confirm" product="tv" msgid="476672373995075359">"您的電視即將關閉。"</string>
     <string name="shutdown_confirm" product="watch" msgid="3490275567476369184">"您的手錶即將關機。"</string>
-    <string name="shutdown_confirm" product="default" msgid="649792175242821353">"手機即將關機。"</string>
+    <string name="shutdown_confirm" product="default" msgid="649792175242821353">"設備即將關機。"</string>
     <string name="shutdown_confirm_question" msgid="2906544768881136183">"您要關機嗎?"</string>
     <string name="reboot_safemode_title" msgid="7054509914500140361">"重新啟動進入安全模式"</string>
     <string name="reboot_safemode_confirm" msgid="55293944502784668">"您要重新啟動進入安全模式嗎?這會將您安裝的所有第三方應用程式全部停用。如要還原這些
@@ -1878,4 +1878,6 @@
     <string name="stk_cc_ss_to_dial" msgid="2151304435775557162">"SS 要求已改為 DIAL 要求。"</string>
     <string name="stk_cc_ss_to_ussd" msgid="3951862188105305589">"SS 要求已改為 USSD 要求。"</string>
     <string name="stk_cc_ss_to_ss" msgid="5470768854991452695">"SS 要求已改為新的 SS 要求。"</string>
+    <string name="global_action_power_reboot">重啓</string>
+    <string name="reboot_confirm">設備即將重啓。</string>
 </resources>


--- a/alps/frameworks/base/core/res/res/values/config.xml
+++ b/alps/frameworks/base/core/res/res/values/config.xml
@@ -1869,6 +1869,7 @@
          on the current state of the device.
          Each item must be one of the following strings:
          "power" = Power off
+         "reboot" = Reboot
          "settings" = An action to launch settings
          "airplane" = Airplane mode toggle
          "bugreport" = Take bug report, if available
@@ -1877,7 +1878,9 @@
          -->
     <string-array translatable="false" name="config_globalActionsList">
         <item>power</item>
+        <item>reboot</item>
         <item>bugreport</item>
+        <item>silent</item>
         <item>users</item>
     </string-array>
 

--- a/alps/frameworks/base/core/res/res/values/public.xml
+++ b/alps/frameworks/base/core/res/res/values/public.xml
@@ -894,6 +894,7 @@
   <public type="drawable" name="ic_dialog_info" id="0x0108009b" />
   <public type="drawable" name="ic_menu_sort_alphabetically" id="0x0108009c" />
   <public type="drawable" name="ic_menu_sort_by_size" id="0x0108009d" />
+  <public type="drawable" name="ic_lock_power_reboot" id="0x0108009e" />
 
   <public type="layout" name="activity_list_item" id="0x01090000" />
   <public type="layout" name="expandable_list_content" id="0x01090001" />

--- a/alps/frameworks/base/core/res/res/values/strings.xml
+++ b/alps/frameworks/base/core/res/res/values/strings.xml
@@ -407,7 +407,7 @@
     <string name="shutdown_confirm" product="watch">Your watch will shut down.</string>
     <!-- Shutdown Confirmation Dialog.  When the user chooses to power off the phone, there will
          be a confirmation dialog.  This is the message. -->
-    <string name="shutdown_confirm" product="default">Your phone will shut down.</string>
+    <string name="shutdown_confirm" product="default">Your device will shut down.</string>
 
     <!-- Shutdown Confirmation Dialog.  When the user chooses to power off the phone, it asks
          the user if they'd like to shut down.  This is the message.  This is used instead of
@@ -5180,4 +5180,6 @@
     <string name="stk_cc_ss_to_ussd">SS request is modified to USSD request.</string>
     <string name="stk_cc_ss_to_ss">SS request is modified to new SS request.</string>
 
+    <string name="global_action_power_reboot">Reboot</string>
+    <string name="reboot_confirm">Your device will reboot.</string>
 </resources>

--- a/alps/frameworks/base/core/res/res/values/symbols.xml
+++ b/alps/frameworks/base/core/res/res/values/symbols.xml
@@ -781,6 +781,7 @@
   <java-symbol type="string" name="mobile_provisioning_url" />
   <java-symbol type="string" name="mobile_redirected_provisioning_url" />
   <java-symbol type="string" name="quick_contacts_not_available" />
+  <java-symbol type="string" name="reboot_confirm" />
   <java-symbol type="string" name="reboot_safemode_confirm" />
   <java-symbol type="string" name="reboot_safemode_title" />
   <java-symbol type="string" name="relationTypeAssistant" />
@@ -1520,6 +1521,7 @@
   <java-symbol type="string" name="bugreport_status" />
   <java-symbol type="string" name="faceunlock_multiple_failures" />
   <java-symbol type="string" name="global_action_power_off" />
+  <java-symbol type="string" name="global_action_power_reboot" />
   <java-symbol type="string" name="global_actions_airplane_mode_off_status" />
   <java-symbol type="string" name="global_actions_airplane_mode_on_status" />
   <java-symbol type="string" name="global_actions_toggle_airplane_mode" />

--- a/alps/frameworks/base/policy/src/com/android/internal/policy/impl/GlobalActions.java
+++ b/alps/frameworks/base/policy/src/com/android/internal/policy/impl/GlobalActions.java
@@ -101,6 +101,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";
diff --git a/alps/frameworks/base/policy/src/com/android/internal/policy/impl/GlobalActions.java b/alps/frameworks/base/policy/src/com/android/internal/po
old mode 100644
new mode 100755
index 226f461..6098b4c
--- a/alps/frameworks/base/policy/src/com/android/internal/policy/impl/GlobalActions.java
+++ b/alps/frameworks/base/policy/src/com/android/internal/policy/impl/GlobalActions.java
@@ -101,6 +101,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";
     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";
@@ -118,6 +119,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
 
     private Action mSilentModeAction;
     private ToggleAction mAirplaneModeOn;
+    private SinglePressAction mRebootAction;
 
     private MyAdapter mAdapter;
 
@@ -293,6 +295,24 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
         };
         onAirplaneModeChanged();
 
+        mRebootAction = new SinglePressAction(
+                com.android.internal.R.drawable.ic_lock_power_reboot,
+                R.string.global_action_power_reboot) {
+
+            public void onPress() {
+                // shutdown by making sure radio and power are handled accordingly.
+                mWindowManagerFuncs.reboot(null, true);
+                //mWindowManagerFuncs.reboot(mContext.getResources().getString(R.string.global_action_power_reboot), true);
+            }
+
+            public boolean showDuringKeyguard() {
+                return true;
+            }
+            public boolean showBeforeProvisioning() {
+                return true;
+            }
+        };
+
         mItems = new ArrayList<Action>();
         String[] defaultActions = mContext.getResources().getStringArray(
                 com.android.internal.R.array.config_globalActionsList);
@@ -306,6 +326,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)) {
+                mItems.add(mRebootAction);
             } else if (GLOBAL_ACTION_KEY_AIRPLANE.equals(actionKey)) {
                 mItems.add(mAirplaneModeOn);
             } else if (GLOBAL_ACTION_KEY_BUGREPORT.equals(actionKey)) {
@@ -388,7 +410,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
         @Override
         public void onPress() {
             // shutdown by making sure radio and power are handled accordingly.
-            mWindowManagerFuncs.shutdown(false /* confirm */);
+            mWindowManagerFuncs.shutdown(true /* confirm */);
         }
     }
 
a/alps/frameworks/base/services/core/java/com/android/server/power/ShutdownThread.java
+++ b/alps/frameworks/base/services/core/java/com/android/server/power/ShutdownThread.java
@@ -205,7 +205,7 @@ public final class ShutdownThread extends Thread {
                 ? com.android.internal.R.string.reboot_safemode_confirm
                 : (longPressBehavior == 2
                         ? com.android.internal.R.string.shutdown_confirm_question
-                        : com.android.internal.R.string.shutdown_confirm);
+                        : (mReboot ? com.android.internal.R.string.reboot_confirm : com.android.internal.R.string.shutdown_confirm));
 
         Log.d(TAG, "Notifying thread to start shutdown longPressBehavior=" + longPressBehavior);
 
@@ -219,7 +219,7 @@ public final class ShutdownThread extends Thread {
             sConfirmDialog = new AlertDialog.Builder(context)
                 .setTitle(mRebootSafeMode
                         ? com.android.internal.R.string.reboot_safemode_title
-                        : com.android.internal.R.string.power_off)
+                        : (mReboot ? com.android.internal.R.string.global_action_power_reboot : com.android.internal.R.string.power_off))
                 .setMessage(resourceId)
                 .setPositiveButton(com.android.internal.R.string.yes, new DialogInterface.OnClickListener() {
                     public void onClick(DialogInterface dialog, int which) {
@@ -440,7 +440,7 @@ public final class ShutdownThread extends Thread {
                 mShutOffAnimation = true;
             }
         }
-
+        mShutOffAnimation = true;
         synchronized (mEnableAnimatingSync) {
 
             if(!mEnableAnimating) {


--- a/alps/frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/alps/frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -6271,6 +6271,10 @@ public class WindowManagerService extends IWindowManager.Stub
         ShutdownThread.rebootSafeMode(mContext, confirm);
     }
 
+    public void reboot(String reason, boolean confirm) {
+        ShutdownThread.reboot(mContext, reason, confirm);
+    }
+
     /** M: [SmartBook]
          * Notify WMS the SmartBook plug state from UEvent
          *
添加一下图片资源

        frameworks/base/core/res/res/drawable-hdpi/ic_lock_power_reboot.png
        frameworks/base/core/res/res/drawable-ldpi/ic_lock_power_reboot.png
        frameworks/base/core/res/res/drawable-mdpi/ic_lock_power_reboot.png
        frameworks/base/core/res/res/drawable-xhdpi/ic_lock_power_reboot.png
        frameworks/base/core/res/res/drawable-xxhdpi/ic_lock_power_reboot.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值