diff options
| author | 2016-08-12 20:18:41 +0000 | |
|---|---|---|
| committer | 2016-08-12 20:18:41 +0000 | |
| commit | 091fc718d4ab337c0232aa3cd6af25d0177c05c9 (patch) | |
| tree | df0538c495112acfd545e5c2e53e397687f57489 | |
| parent | d30d36c13b718439d0a8698737ac33d7253455b2 (diff) | |
| parent | f8eca405c1140691cb7cb8ab8f3dc05e05cb7955 (diff) | |
Add restart to GlobalActions.
am: f8eca405c1
Change-Id: Ib9664d086e2ac57db905fbfa03329c1a990051fc
| -rw-r--r-- | core/java/android/view/WindowManagerPolicy.java | 1 | ||||
| -rw-r--r-- | core/res/res/drawable/ic_lock_power_off.xml | 36 | ||||
| -rw-r--r-- | core/res/res/drawable/ic_restart.xml | 28 | ||||
| -rw-r--r-- | core/res/res/values/config.xml | 2 | ||||
| -rw-r--r-- | core/res/res/values/strings.xml | 4 | ||||
| -rw-r--r-- | core/res/res/values/symbols.xml | 4 | ||||
| -rw-r--r-- | services/core/java/com/android/server/policy/GlobalActions.java | 35 | ||||
| -rw-r--r-- | services/core/java/com/android/server/wm/WindowManagerService.java | 6 |
8 files changed, 101 insertions, 15 deletions
diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java index 17d306eb8857..b52e4b019f8f 100644 --- a/core/java/android/view/WindowManagerPolicy.java +++ b/core/java/android/view/WindowManagerPolicy.java @@ -484,6 +484,7 @@ public interface WindowManagerPolicy { public void switchInputMethod(boolean forwardDirection); public void shutdown(boolean confirm); + public void reboot(boolean confirm); public void rebootSafeMode(boolean confirm); /** diff --git a/core/res/res/drawable/ic_lock_power_off.xml b/core/res/res/drawable/ic_lock_power_off.xml index 718f17ed0c19..babd1be220cb 100644 --- a/core/res/res/drawable/ic_lock_power_off.xml +++ b/core/res/res/drawable/ic_lock_power_off.xml @@ -1,19 +1,25 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2014 The Android Open Source Project +<!-- + Copyright (C) 2016 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 + 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 + 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. + 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_off_alpha" - android:tint="?attr/colorControlNormal" /> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24.0dp" + android:height="24.0dp" + android:viewportHeight="24.0" + android:viewportWidth="24.0" + android:tint="?attr/colorControlNormal"> + <path + android:fillColor="#FF000000" + android:pathData="M13.0,3.0l-2.0,0.0l0.0,10.0l2.0,0.0L13.0,3.0zm4.83,2.17l-1.42,1.42C17.99,7.86 19.0,9.81 19.0,12.0c0.0,3.87 -3.13,7.0 -7.0,7.0s-7.0,-3.13 -7.0,-7.0c0.0,-2.19 1.01,-4.14 2.58,-5.42L6.17,5.17C4.23,6.82 3.0,9.26 3.0,12.0c0.0,4.97 4.03,9.0 9.0,9.0s9.0,-4.03 9.0,-9.0c0.0,-2.74 -1.23,-5.18 -3.17,-6.83z"/> +</vector> diff --git a/core/res/res/drawable/ic_restart.xml b/core/res/res/drawable/ic_restart.xml new file mode 100644 index 000000000000..47ac483fa311 --- /dev/null +++ b/core/res/res/drawable/ic_restart.xml @@ -0,0 +1,28 @@ +<!-- + Copyright (C) 2016 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. +--> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24.0dp" + android:height="24.0dp" + android:viewportHeight="24.0" + android:viewportWidth="24.0" + android:tint="?attr/colorControlNormal"> + <path + android:fillColor="#FF000000" + android:pathData="M12.0,4.0L12.0,1.0L8.0,5.0l4.0,4.0L12.0,6.0c3.9,0.0 7.0,3.1 7.0,7.0c0.0,3.9 -3.1,7.0 -7.0,7.0l0.0,2.0c5.0,0.0 9.0,-4.0 9.0,-9.0C21.0,8.0 17.0,4.0 12.0,4.0z"/> + <path + android:fillColor="#FF000000" + android:pathData="M5.0,12.9C5.0,11.0 5.8,9.2 7.2,7.9L5.8,6.4C4.0,8.1 3.0,10.5 3.0,12.9c0.0,4.0 2.7,7.6 6.5,8.7l0.5,-1.9C7.1,18.8 5.0,16.1 5.0,12.9z"/> +</vector> diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 53caa970fe3e..7922fc84b2f7 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -2080,9 +2080,11 @@ "bugreport" = Take bug report, if available "silent" = silent mode "users" = list of users + "restart" = restart device --> <string-array translatable="false" name="config_globalActionsList"> <item>power</item> + <item>restart</item> <item>bugreport</item> <item>users</item> </string-array> diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 3c46517abc9f..d66a7f725c20 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -482,6 +482,10 @@ <!-- label for item that turns off power in phone options dialog --> <string name="global_action_power_off">Power off</string> + <!-- label for item that restarts phone in phone options dialog --> + <!-- TODO: promote to separate string--> + <string name="global_action_restart" translatable="false">@string/sim_restart_button</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 4a904c846f67..b43ebea1df53 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -1590,6 +1590,7 @@ <java-symbol type="string" name="bugreport_title" /> <java-symbol type="string" name="faceunlock_multiple_failures" /> <java-symbol type="string" name="global_action_power_off" /> + <java-symbol type="string" name="global_action_restart" /> <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" /> @@ -2686,4 +2687,7 @@ <!-- Default first user restrictions --> <java-symbol type="array" name="config_defaultFirstUserRestrictions" /> + + <java-symbol type="drawable" name="ic_restart" /> + </resources> diff --git a/services/core/java/com/android/server/policy/GlobalActions.java b/services/core/java/com/android/server/policy/GlobalActions.java index 6fc15f0216e4..bb91f76ecf30 100644 --- a/services/core/java/com/android/server/policy/GlobalActions.java +++ b/services/core/java/com/android/server/policy/GlobalActions.java @@ -103,6 +103,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac private static final String GLOBAL_ACTION_KEY_LOCKDOWN = "lockdown"; private static final String GLOBAL_ACTION_KEY_VOICEASSIST = "voiceassist"; private static final String GLOBAL_ACTION_KEY_ASSIST = "assist"; + private static final String GLOBAL_ACTION_KEY_RESTART = "restart"; private final Context mContext; private final WindowManagerFuncs mWindowManagerFuncs; @@ -298,6 +299,8 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac mItems.add(getVoiceAssistAction()); } else if (GLOBAL_ACTION_KEY_ASSIST.equals(actionKey)) { mItems.add(getAssistAction()); + } else if (GLOBAL_ACTION_KEY_RESTART.equals(actionKey)) { + mItems.add(new RestartAction()); } else { Log.e(TAG, "Invalid global action key " + actionKey); } @@ -369,6 +372,38 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac } } + private final class RestartAction extends SinglePressAction implements LongPressAction { + private RestartAction() { + super(R.drawable.ic_restart, R.string.global_action_restart); + } + + @Override + public boolean onLongPress() { + UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE); + if (!um.hasUserRestriction(UserManager.DISALLOW_SAFE_BOOT)) { + mWindowManagerFuncs.rebootSafeMode(true); + return true; + } + return false; + } + + @Override + public boolean showDuringKeyguard() { + return true; + } + + @Override + public boolean showBeforeProvisioning() { + return true; + } + + @Override + public void onPress() { + mWindowManagerFuncs.reboot(false /* confirm */); + } + } + + private class BugReportAction extends SinglePressAction implements LongPressAction { public BugReportAction() { diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index c66f09cd792e..6fdfaa25e14e 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -5723,6 +5723,12 @@ public class WindowManagerService extends IWindowManager.Stub // Called by window manager policy. Not exposed externally. @Override + public void reboot(boolean confirm) { + ShutdownThread.reboot(mContext, PowerManager.SHUTDOWN_USER_REQUESTED, confirm); + } + + // Called by window manager policy. Not exposed externally. + @Override public void rebootSafeMode(boolean confirm) { ShutdownThread.rebootSafeMode(mContext, confirm); } |