SystemUI: Add global reboot option
Add global reboot option when long press power key and confirmation dialog
when user chooses to reboot device.
Change-Id: I23286cb655a4fead8dfc450f08f27d9588e47686
diff --git a/core/res/res/drawable-hdpi/ic_lock_power_reboot_alpha.png b/core/res/res/drawable-hdpi/ic_lock_power_reboot_alpha.png
new file mode 100644
index 0000000..17b4866
--- /dev/null
+++ b/core/res/res/drawable-hdpi/ic_lock_power_reboot_alpha.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_lock_power_reboot_alpha.png b/core/res/res/drawable-mdpi/ic_lock_power_reboot_alpha.png
new file mode 100644
index 0000000..471a41c
--- /dev/null
+++ b/core/res/res/drawable-mdpi/ic_lock_power_reboot_alpha.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/ic_lock_power_reboot_alpha.png b/core/res/res/drawable-xhdpi/ic_lock_power_reboot_alpha.png
new file mode 100644
index 0000000..a786b40
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/ic_lock_power_reboot_alpha.png
Binary files differ
diff --git a/core/res/res/drawable-xxhdpi/ic_lock_power_reboot_alpha.png b/core/res/res/drawable-xxhdpi/ic_lock_power_reboot_alpha.png
new file mode 100644
index 0000000..6072387
--- /dev/null
+++ b/core/res/res/drawable-xxhdpi/ic_lock_power_reboot_alpha.png
Binary files differ
diff --git a/core/res/res/drawable/ic_lock_power_reboot.xml b/core/res/res/drawable/ic_lock_power_reboot.xml
new file mode 100644
index 0000000..82c7927
--- /dev/null
+++ b/core/res/res/drawable/ic_lock_power_reboot.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2014, The Linux Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+
+<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
+ android:src="@drawable/ic_lock_power_reboot_alpha"
+ android:tint="?attr/colorControlNormal" />
+
diff --git a/core/res/res/values-zh-rCN/strings.xml b/core/res/res/values-zh-rCN/strings.xml
index 1d48ec6..39b26b3 100644
--- a/core/res/res/values-zh-rCN/strings.xml
+++ b/core/res/res/values-zh-rCN/strings.xml
@@ -171,12 +171,16 @@
<string name="shutdown_confirm_question" msgid="2906544768881136183">"您要关机吗?"</string>
<string name="reboot_safemode_title" msgid="7054509914500140361">"重新启动并进入安全模式"</string>
<string name="reboot_safemode_confirm" msgid="55293944502784668">"您要重新启动并进入安全模式吗?这样会停用您已安装的所有第三方应用。再次重新启动将恢复这些应用。"</string>
+ <string name="reboot_title">"重启"</string>
+ <string name="reboot_confirm" product="tablet">"您的平板电脑将会重启。"</string>
+ <string name="reboot_confirm" product="default">"您的手机将会重启。"</string>
<string name="recent_tasks_title" msgid="3691764623638127888">"近期任务"</string>
<string name="no_recent_tasks" msgid="8794906658732193473">"最近没有运行任何应用"</string>
<string name="global_actions" product="tablet" msgid="408477140088053665">"平板电脑选项"</string>
<string name="global_actions" product="default" msgid="2406416831541615258">"手机选项"</string>
<string name="global_action_lock" msgid="2844945191792119712">"屏幕锁定"</string>
<string name="global_action_power_off" msgid="4471879440839879722">"关机"</string>
+ <string name="global_action_reboot">"重启"</string>
<string name="global_action_bug_report" msgid="7934010578922304799">"错误报告"</string>
<string name="bugreport_title" msgid="2667494803742548533">"提交错误报告"</string>
<string name="bugreport_message" msgid="398447048750350456">"这会收集有关当前设备状态的信息,并以电子邮件的形式进行发送。从开始生成错误报告到准备好发送需要一点时间,请耐心等待。"</string>
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 4a2c70c..5f04e00 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -391,6 +391,14 @@
This will disable all third party applications you have installed.
They will be restored when you reboot again.</string>
+ <!-- Title of dialog to confirm rebooting. -->
+ <string name="reboot_title">Reboot</string>
+
+ <!-- Reboot Confirmation Dialog. When the user chooses to reboot the device, there will
+ be a confirmation dialog. This is the message. -->
+ <string name="reboot_confirm" product="tablet">Your tablet will reboot.</string>
+ <string name="reboot_confirm" product="default">Your phone will reboot.</string>
+
<!-- Recent Tasks dialog: title
TODO: this should move to SystemUI.apk, but the code for the old
recent dialog is still in the framework
@@ -413,6 +421,9 @@
<!-- label for item that turns off power in phone options dialog -->
<string name="global_action_power_off">Power off</string>
+ <!-- label for item that reboots the phone in phone options dialog -->
+ <string name="global_action_reboot">Reboot</string>
+
<!-- label for item that generates a bug report in the phone options dialog -->
<string name="global_action_bug_report">Bug report</string>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 4cb2acd..0cb1998 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -776,8 +776,10 @@
<java-symbol type="string" name="mobile_redirected_provisioning_url" />
<java-symbol type="string" name="quick_contacts_not_available" />
<java-symbol type="string" name="progress_nomediapresent" />
+ <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="reboot_title" />
<java-symbol type="string" name="relationTypeAssistant" />
<java-symbol type="string" name="relationTypeBrother" />
<java-symbol type="string" name="relationTypeChild" />
@@ -1437,6 +1439,7 @@
<java-symbol type="drawable" name="ic_jog_dial_vibrate_on" />
<java-symbol type="drawable" name="ic_lock_airplane_mode" />
<java-symbol type="drawable" name="ic_lock_airplane_mode_off" />
+ <java-symbol type="drawable" name="ic_lock_power_reboot" />
<java-symbol type="drawable" name="ic_menu_cc" />
<java-symbol type="drawable" name="jog_tab_bar_left_unlock" />
<java-symbol type="drawable" name="jog_tab_bar_right_sound_off" />
@@ -1503,6 +1506,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_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" />
diff --git a/policy/src/com/android/internal/policy/impl/GlobalActions.java b/policy/src/com/android/internal/policy/impl/GlobalActions.java
index 5e0c243..ee72408 100644
--- a/policy/src/com/android/internal/policy/impl/GlobalActions.java
+++ b/policy/src/com/android/internal/policy/impl/GlobalActions.java
@@ -41,6 +41,7 @@
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
+import android.os.IPowerManager;
import android.os.Message;
import android.os.RemoteException;
import android.os.ServiceManager;
@@ -95,6 +96,7 @@
/* 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";
@@ -273,6 +275,8 @@
}
if (GLOBAL_ACTION_KEY_POWER.equals(actionKey)) {
mItems.add(new PowerAction());
+ } else if (GLOBAL_ACTION_KEY_REBOOT.equals(actionKey)) {
+ 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 +370,35 @@
}
}
+ private final class RebootAction extends SinglePressAction {
+ private RebootAction() {
+ super(com.android.internal.R.drawable.ic_lock_power_reboot,
+ R.string.global_action_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;
+ }
+ }
+ }
+
private Action getBugReportAction() {
return new SinglePressAction(com.android.internal.R.drawable.ic_lock_bugreport,
R.string.bugreport_title) {
diff --git a/services/core/java/com/android/server/power/ShutdownThread.java b/services/core/java/com/android/server/power/ShutdownThread.java
index da11387..eafbf16 100644
--- a/services/core/java/com/android/server/power/ShutdownThread.java
+++ b/services/core/java/com/android/server/power/ShutdownThread.java
@@ -121,13 +121,25 @@
}
}
+ boolean showRebootOption = false;
+ String[] defaultActions = context.getResources().getStringArray(
+ com.android.internal.R.array.config_globalActionsList);
+ for (int i = 0; i < defaultActions.length; i++) {
+ if (defaultActions[i].equals("reboot")) {
+ showRebootOption = true;
+ break;
+ }
+ }
final int longPressBehavior = context.getResources().getInteger(
com.android.internal.R.integer.config_longPressOnPowerBehavior);
- final int resourceId = mRebootSafeMode
+ int resourceId = mRebootSafeMode
? 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);
+ if (showRebootOption && !mRebootSafeMode) {
+ resourceId = com.android.internal.R.string.reboot_confirm;
+ }
Log.d(TAG, "Notifying thread to start shutdown longPressBehavior=" + longPressBehavior);
@@ -139,7 +151,9 @@
sConfirmDialog = new AlertDialog.Builder(context)
.setTitle(mRebootSafeMode
? com.android.internal.R.string.reboot_safemode_title
- : com.android.internal.R.string.power_off)
+ : showRebootOption
+ ? com.android.internal.R.string.reboot_title
+ : 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) {