Merge "Add restart to GlobalActions." into nyc-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
c7d6af6cd0
@@ -484,6 +484,7 @@ public interface WindowManagerPolicy {
|
|||||||
public void switchInputMethod(boolean forwardDirection);
|
public void switchInputMethod(boolean forwardDirection);
|
||||||
|
|
||||||
public void shutdown(boolean confirm);
|
public void shutdown(boolean confirm);
|
||||||
|
public void reboot(boolean confirm);
|
||||||
public void rebootSafeMode(boolean confirm);
|
public void rebootSafeMode(boolean confirm);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
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
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
|
android:width="24.0dp"
|
||||||
android:src="@drawable/ic_lock_power_off_alpha"
|
android:height="24.0dp"
|
||||||
android:tint="?attr/colorControlNormal" />
|
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>
|
||||||
|
|||||||
28
core/res/res/drawable/ic_restart.xml
Normal file
28
core/res/res/drawable/ic_restart.xml
Normal file
@@ -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>
|
||||||
@@ -2071,9 +2071,11 @@
|
|||||||
"bugreport" = Take bug report, if available
|
"bugreport" = Take bug report, if available
|
||||||
"silent" = silent mode
|
"silent" = silent mode
|
||||||
"users" = list of users
|
"users" = list of users
|
||||||
|
"restart" = restart device
|
||||||
-->
|
-->
|
||||||
<string-array translatable="false" name="config_globalActionsList">
|
<string-array translatable="false" name="config_globalActionsList">
|
||||||
<item>power</item>
|
<item>power</item>
|
||||||
|
<item>restart</item>
|
||||||
<item>bugreport</item>
|
<item>bugreport</item>
|
||||||
<item>users</item>
|
<item>users</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|||||||
@@ -482,6 +482,10 @@
|
|||||||
<!-- label for item that turns off power in phone options dialog -->
|
<!-- label for item that turns off power in phone options dialog -->
|
||||||
<string name="global_action_power_off">Power off</string>
|
<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 -->
|
<!-- label for item that generates a bug report in the phone options dialog -->
|
||||||
<string name="global_action_bug_report">Bug report</string>
|
<string name="global_action_bug_report">Bug report</string>
|
||||||
|
|
||||||
|
|||||||
@@ -1589,6 +1589,7 @@
|
|||||||
<java-symbol type="string" name="bugreport_title" />
|
<java-symbol type="string" name="bugreport_title" />
|
||||||
<java-symbol type="string" name="faceunlock_multiple_failures" />
|
<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_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_off_status" />
|
||||||
<java-symbol type="string" name="global_actions_airplane_mode_on_status" />
|
<java-symbol type="string" name="global_actions_airplane_mode_on_status" />
|
||||||
<java-symbol type="string" name="global_actions_toggle_airplane_mode" />
|
<java-symbol type="string" name="global_actions_toggle_airplane_mode" />
|
||||||
@@ -2680,4 +2681,7 @@
|
|||||||
|
|
||||||
<!-- Default first user restrictions -->
|
<!-- Default first user restrictions -->
|
||||||
<java-symbol type="array" name="config_defaultFirstUserRestrictions" />
|
<java-symbol type="array" name="config_defaultFirstUserRestrictions" />
|
||||||
|
|
||||||
|
<java-symbol type="drawable" name="ic_restart" />
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -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_LOCKDOWN = "lockdown";
|
||||||
private static final String GLOBAL_ACTION_KEY_VOICEASSIST = "voiceassist";
|
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_ASSIST = "assist";
|
||||||
|
private static final String GLOBAL_ACTION_KEY_RESTART = "restart";
|
||||||
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final WindowManagerFuncs mWindowManagerFuncs;
|
private final WindowManagerFuncs mWindowManagerFuncs;
|
||||||
@@ -298,6 +299,8 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
|
|||||||
mItems.add(getVoiceAssistAction());
|
mItems.add(getVoiceAssistAction());
|
||||||
} else if (GLOBAL_ACTION_KEY_ASSIST.equals(actionKey)) {
|
} else if (GLOBAL_ACTION_KEY_ASSIST.equals(actionKey)) {
|
||||||
mItems.add(getAssistAction());
|
mItems.add(getAssistAction());
|
||||||
|
} else if (GLOBAL_ACTION_KEY_RESTART.equals(actionKey)) {
|
||||||
|
mItems.add(new RestartAction());
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "Invalid global action key " + actionKey);
|
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 {
|
private class BugReportAction extends SinglePressAction implements LongPressAction {
|
||||||
|
|
||||||
public BugReportAction() {
|
public BugReportAction() {
|
||||||
|
|||||||
@@ -5721,6 +5721,12 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
ShutdownThread.shutdown(mContext, PowerManager.SHUTDOWN_USER_REQUESTED, confirm);
|
ShutdownThread.shutdown(mContext, PowerManager.SHUTDOWN_USER_REQUESTED, confirm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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.
|
// Called by window manager policy. Not exposed externally.
|
||||||
@Override
|
@Override
|
||||||
public void rebootSafeMode(boolean confirm) {
|
public void rebootSafeMode(boolean confirm) {
|
||||||
|
|||||||
Reference in New Issue
Block a user