summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/etc/com.android.systemui.xml2
-rw-r--r--packages/SystemUI/AndroidManifest.xml4
-rw-r--r--packages/SystemUI/res/drawable/ic_qs_poweroff.xml25
-rw-r--r--packages/SystemUI/res/drawable/ic_qs_reboot.xml32
-rw-r--r--packages/SystemUI/res/drawable/ic_qs_reboot_recovery.xml61
-rw-r--r--packages/SystemUI/res/values/cm_strings.xml5
-rw-r--r--packages/SystemUI/res/values/config.xml2
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSFactoryImpl.java8
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/RebootTile.java112
-rw-r--r--proto/src/metrics_constants/metrics_constants.proto3
10 files changed, 252 insertions, 2 deletions
diff --git a/data/etc/com.android.systemui.xml b/data/etc/com.android.systemui.xml
index 7af1de6a6cac..a9517d7696b8 100644
--- a/data/etc/com.android.systemui.xml
+++ b/data/etc/com.android.systemui.xml
@@ -49,6 +49,8 @@
<permission name="android.permission.READ_NETWORK_USAGE_HISTORY"/>
<permission name="android.permission.READ_PRIVILEGED_PHONE_STATE"/>
<permission name="android.permission.REAL_GET_TASKS"/>
+ <permission name="android.permission.REBOOT"/>
+ <permission name="android.permission.RECOVERY"/>
<permission name="android.permission.REQUEST_NETWORK_SCORES"/>
<permission name="android.permission.RECEIVE_MEDIA_RESOURCE_USAGE"/>
<permission name="android.permission.START_ACTIVITIES_FROM_BACKGROUND" />
diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml
index 402ddda34b56..8338f264ec13 100644
--- a/packages/SystemUI/AndroidManifest.xml
+++ b/packages/SystemUI/AndroidManifest.xml
@@ -275,6 +275,10 @@
<!-- Asus Long screenshot -->
<uses-permission android:name="com.asus.stitchimage.permission.EXPORTED_FOR_ASUS_APPS"/>
+ <!-- Reboot tile -->
+ <uses-permission android:name="android.permission.REBOOT" />
+ <uses-permission android:name="android.permission.RECOVERY" />
+
<protected-broadcast android:name="com.android.settingslib.action.REGISTER_SLICE_RECEIVER" />
<protected-broadcast android:name="com.android.settingslib.action.UNREGISTER_SLICE_RECEIVER" />
<protected-broadcast android:name="com.android.settings.flashlight.action.FLASHLIGHT_CHANGED" />
diff --git a/packages/SystemUI/res/drawable/ic_qs_poweroff.xml b/packages/SystemUI/res/drawable/ic_qs_poweroff.xml
new file mode 100644
index 000000000000..06d17b62ed5c
--- /dev/null
+++ b/packages/SystemUI/res/drawable/ic_qs_poweroff.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2018-2020 crDroid Android 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:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M16.56,5.44L15.11,6.89C16.84,7.94 18,9.83 18,12A6,6 0 0,1 12,18A6,6 0 0,1 6,12C6,9.83 7.16,7.94 8.88,6.88L7.44,5.44C5.36,6.88 4,9.28 4,12A8,8 0 0,0 12,20A8,8 0 0,0 20,12C20,9.28 18.64,6.88 16.56,5.44M13,3H11V13H13" />
+</vector>
diff --git a/packages/SystemUI/res/drawable/ic_qs_reboot.xml b/packages/SystemUI/res/drawable/ic_qs_reboot.xml
new file mode 100644
index 000000000000..34367afc7452
--- /dev/null
+++ b/packages/SystemUI/res/drawable/ic_qs_reboot.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="512.000000dp"
+ android:height="512.000000dp"
+ android:viewportWidth="512.000000"
+ android:viewportHeight="512.000000">
+ <group
+ android:translateY="512.000000"
+ android:scaleX="0.100000"
+ android:scaleY="-0.100000">
+ <path
+ android:fillColor="#ffffff"
+ android:strokeWidth="1"
+ android:pathData="M2143 4428 l-411 -422 99 -106 c54 -58
+243 -251 419 -430 l319 -325 1 318 c0 271 2 318 15 323 19 8 210 -13
+300 -33 315 -68 612 -249 815 -498 203 -248 317 -539 338 -860 31
+-471 -114 -870 -433 -1191 -232 -233 -483 -363 -804 -415 -64 -10
+-142 -19 -173 -19 l-58 0 0 -217 0 -216 123 6 c533 28 1045 303 1378
+742 253 332 399 769 399 1195 0 273 -69 587 -186 837 -202 436 -575
+792 -1010 967 -187 74 -481 136 -648 136 l-56 0 0 315 c0 173 -4 315
+-8 315 -4 0 -193 -190 -419 -422z" />
+ <path
+ android:fillColor="#ffffff"
+ android:strokeWidth="1"
+ android:pathData="M1195 3628 c-241 -260 -403 -581 -482
+-956 -25 -118 -27 -145 -27 -372 0 -250 2 -273 48 -471 26 -109 94
+-294 146 -400 203 -404 505 -709 885 -894 112 -54 270 -114 279 -105
+4 5 43 148 86 319 11 41 17 78 14 82 -2 4 -21 13 -42 20 -60 20 -195
+84 -268 129 -233 141 -443 368 -565 612 -288 572 -200 1254 221 1710
+l71 78 -146 160 c-80 88 -148 160 -150 160 -2 0 -33 -33 -70 -72z" />
+ </group>
+</vector>
diff --git a/packages/SystemUI/res/drawable/ic_qs_reboot_recovery.xml b/packages/SystemUI/res/drawable/ic_qs_reboot_recovery.xml
new file mode 100644
index 000000000000..34154878d507
--- /dev/null
+++ b/packages/SystemUI/res/drawable/ic_qs_reboot_recovery.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="512.000000dp"
+ android:height="512.000000dp"
+ android:viewportWidth="512.000000"
+ android:viewportHeight="512.000000">
+ <group
+ android:translateY="512.000000"
+ android:scaleX="0.100000"
+ android:scaleY="-0.100000">
+ <path
+ android:fillColor="#ffffff"
+ android:strokeWidth="1"
+ android:pathData="M2143 4428 l-411 -422 99 -106 c54 -58
+243 -251 419 -430 l319 -325 1 318 c0 271 2 318 15 323 19 8 210 -13
+300 -33 315 -68 612 -249 815 -498 203 -248 317 -539 338 -860 31
+-471 -114 -870 -433 -1191 -232 -233 -483 -363 -804 -415 -64 -10
+-142 -19 -173 -19 l-58 0 0 -217 0 -216 123 6 c533 28 1045 303 1378
+742 253 332 399 769 399 1195 0 273 -69 587 -186 837 -202 436 -575
+792 -1010 967 -187 74 -481 136 -648 136 l-56 0 0 315 c0 173 -4 315
+-8 315 -4 0 -193 -190 -419 -422z" />
+ <path
+ android:fillColor="#ffffff"
+ android:strokeWidth="1"
+ android:pathData="M1195 3628 c-241 -260 -403 -581 -482
+-956 -25 -118 -27 -145 -27 -372 0 -250 2 -273 48 -471 26 -109 94
+-294 146 -400 203 -404 505 -709 885 -894 112 -54 270 -114 279 -105
+4 5 43 148 86 319 11 41 17 78 14 82 -2 4 -21 13 -42 20 -60 20 -195
+84 -268 129 -233 141 -443 368 -565 612 -288 572 -200 1254 221 1710
+l71 78 -146 160 c-80 88 -148 160 -150 160 -2 0 -33 -33 -70 -72z" />
+ <path
+ android:fillColor="#ffffff"
+ android:strokeWidth="1"
+ android:pathData="M2701 3307 c-21 -57 -100 -284 -103
+-296 -3 -10 -23 -15 -71 -16 -78 -3 -68 -14 -156 175 -30 63 -59 118
+-64 121 -5 4 -39 -9 -76 -28 -36 -19 -66 -33 -66 -32 0 1 -40 -18 -90
+-42 -49 -23 -92 -44 -95 -44 -29 -8 -62 -28 -66 -39 -3 -8 15 -59 41
+-113 27 -54 58 -121 70 -148 l23 -50 -35 -35 c-19 -19 -38 -42 -41
+-51 -6 -15 -29 -9 -172 42 -91 32 -168 59 -171 59 -10 0 -151 -401
+-146 -414 3 -7 76 -38 164 -68 143 -50 158 -57 159 -79 1 -13 3 -49 5
+-79 2 -30 -1 -55 -6 -56 -6 0 -59 -25 -120 -54 -60 -30 -112 -54 -115
+-55 -3 0 -19 -9 -37 -18 l-32 -17 16 -37 c8 -21 38 -85 66 -143 28
+-58 52 -107 52 -110 3 -14 56 -109 64 -114 5 -4 12 -2 16 4 5 8 54 34
+85 45 3 1 32 15 65 31 33 15 62 29 65 29 3 1 23 10 45 22 l40 21 46
+-42 46 -41 -59 -164 c-32 -90 -57 -165 -55 -167 1 -2 97 -36 212 -77
+l210 -75 56 159 c31 88 59 163 63 166 3 4 36 8 72 9 l65 3 56 -117
+c30 -64 63 -136 73 -158 10 -23 22 -44 27 -47 5 -3 44 12 86 33 43 22
+78 39 80 38 7 -2 237 115 237 122 0 4 -21 49 -46 101 -56 113 -104
+218 -104 225 0 2 17 22 39 43 21 20 40 43 42 49 3 7 62 -9 169 -48 91
+-32 168 -56 171 -52 11 12 148 406 144 413 -3 4 -78 32 -167 64 l-163
+57 0 64 c0 54 3 64 20 70 11 3 22 7 25 8 3 1 55 27 115 56 61 30 112
+55 115 56 21 4 40 19 40 30 0 8 -22 61 -49 117 -27 56 -68 141 -91
+190 -23 48 -46 87 -51 87 -9 0 -167 -73 -250 -116 -26 -13 -51 -24
+-56 -24 -6 0 -34 22 -63 49 l-52 49 57 162 c32 91 54 165 49 169 -5 5
+-29 15 -54 24 -25 8 -116 40 -203 71 -157 55 -158 55 -166 33z m-3
+-795 c103 -51 164 -142 165 -247 1 -80 -5 -135 -14 -135 -4 0 -11 -12
+-17 -27 -20 -57 -101 -130 -162 -148 -3 -1 -17 -7 -31 -13 -55 -23
+-185 3 -252 50 -86 59 -127 144 -124 255 2 83 20 130 75 199 76 96
+240 126 360 66z" />
+ </group>
+</vector>
diff --git a/packages/SystemUI/res/values/cm_strings.xml b/packages/SystemUI/res/values/cm_strings.xml
index dd306c2c51ee..534aa85b276d 100644
--- a/packages/SystemUI/res/values/cm_strings.xml
+++ b/packages/SystemUI/res/values/cm_strings.xml
@@ -133,4 +133,9 @@
<!-- Notify use that they are in Lock-to-app (for devices without navbar)-->
<string name="screen_pinning_toast_no_navbar">To unpin this screen, touch &amp; hold Back button</string>
+
+ <!-- Reboot/Recovery/PowerOff QS tile -->
+ <string name="quick_settings_reboot_label">Reboot</string>
+ <string name="quick_settings_reboot_recovery_label">Recovery</string>
+ <string name="quick_settings_poweroff_label">Power off</string>
</resources>
diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml
index 367fe72d4da7..d4c113b82153 100644
--- a/packages/SystemUI/res/values/config.xml
+++ b/packages/SystemUI/res/values/config.xml
@@ -114,7 +114,7 @@
<!-- Tiles native to System UI. Order should match "quick_settings_tiles_default" -->
<string name="quick_settings_tiles_stock" translatable="false">
- wifi,cell,battery,dnd,flashlight,rotation,bt,airplane,nfc,location,hotspot,inversion,saver,dark,work,cast,night,screenrecord,reverse,ambient_display,aod,caffeine,heads_up,livedisplay,powershare,profiles,reading_mode,sync,usb_tether,volume_panel,vpn,anti_flicker
+ wifi,cell,battery,dnd,flashlight,rotation,bt,airplane,nfc,location,hotspot,inversion,saver,dark,work,cast,night,screenrecord,reverse,ambient_display,aod,caffeine,heads_up,livedisplay,powershare,profiles,reading_mode,sync,usb_tether,volume_panel,vpn,anti_flicker,reboot
</string>
<!-- The tiles to display in QuickSettings -->
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSFactoryImpl.java b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSFactoryImpl.java
index 47b9c7bec0d7..ac0c18744a8e 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSFactoryImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSFactoryImpl.java
@@ -49,6 +49,7 @@ import com.android.systemui.qs.tiles.NightDisplayTile;
import com.android.systemui.qs.tiles.PowerShareTile;
import com.android.systemui.qs.tiles.ProfilesTile;
import com.android.systemui.qs.tiles.ReadingModeTile;
+import com.android.systemui.qs.tiles.RebootTile;
import com.android.systemui.qs.tiles.RotationLockTile;
import com.android.systemui.qs.tiles.ScreenRecordTile;
import com.android.systemui.qs.tiles.SyncTile;
@@ -105,6 +106,7 @@ public class QSFactoryImpl implements QSFactory {
private final Provider<VolumeTile> mVolumeTileProvider;
private final Provider<VpnTile> mVpnTileProvider;
private final Provider<AntiFlickerTile> mAntiFlickerTileProvider;
+ private final Provider<RebootTile> mRebootTileProvider;
private final Lazy<QSHost> mQsHostLazy;
@@ -142,7 +144,8 @@ public class QSFactoryImpl implements QSFactory {
Provider<UsbTetherTile> usbTetherTileProvider,
Provider<VolumeTile> volumeTileProvider,
Provider<VpnTile> vpnTileProvider,
- Provider<AntiFlickerTile> antiFlickerTileProvider) {
+ Provider<AntiFlickerTile> antiFlickerTileProvider,
+ Provider<RebootTile> rebootTileProvider) {
mQsHostLazy = qsHostLazy;
mWifiTileProvider = wifiTileProvider;
mBluetoothTileProvider = bluetoothTileProvider;
@@ -177,6 +180,7 @@ public class QSFactoryImpl implements QSFactory {
mVolumeTileProvider = volumeTileProvider;
mVpnTileProvider = vpnTileProvider;
mAntiFlickerTileProvider = antiFlickerTileProvider;
+ mRebootTileProvider = rebootTileProvider;
}
public QSTile createTile(String tileSpec) {
@@ -255,6 +259,8 @@ public class QSFactoryImpl implements QSFactory {
return mVpnTileProvider.get();
case "anti_flicker":
return mAntiFlickerTileProvider.get();
+ case "reboot":
+ return mRebootTileProvider.get();
}
// Custom tiles
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/RebootTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/RebootTile.java
new file mode 100644
index 000000000000..19055c65847f
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/RebootTile.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2019 crDroid Android 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.
+ */
+
+package com.android.systemui.qs.tiles;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.Handler;
+import android.os.PowerManager;
+import android.service.quicksettings.Tile;
+
+import com.android.internal.logging.MetricsLogger;
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.systemui.R;
+import com.android.systemui.plugins.qs.QSTile.BooleanState;
+import com.android.systemui.qs.QSHost;
+import com.android.systemui.qs.tileimpl.QSTileImpl;
+
+import javax.inject.Inject;
+
+public class RebootTile extends QSTileImpl<BooleanState> {
+
+ private int mRebootToRecovery = 0;
+
+ @Inject
+ public RebootTile(QSHost host) {
+ super(host);
+ }
+
+ @Override
+ public BooleanState newTileState() {
+ return new BooleanState();
+ }
+
+ @Override
+ public void handleClick() {
+ if (mRebootToRecovery == 0) {
+ mRebootToRecovery = 1;
+ } else if (mRebootToRecovery == 1) {
+ mRebootToRecovery = 2;
+ } else {
+ mRebootToRecovery = 0;
+ }
+ refreshState();
+ }
+
+ @Override
+ protected void handleLongClick() {
+ mHost.collapsePanels();
+ Handler handler = new Handler();
+ handler.postDelayed(new Runnable() {
+ public void run() {
+ PowerManager pm =
+ (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
+ if (mRebootToRecovery == 1) {
+ pm.rebootCustom(PowerManager.REBOOT_RECOVERY);
+ } else if (mRebootToRecovery == 2) {
+ pm.shutdown(false, pm.SHUTDOWN_USER_REQUESTED, false);
+ } else {
+ pm.reboot("");
+ }
+ }
+ }, 500);
+ }
+
+ @Override
+ public Intent getLongClickIntent() {
+ return null;
+ }
+
+ @Override
+ public CharSequence getTileLabel() {
+ return mContext.getString(R.string.quick_settings_reboot_label);
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return MetricsEvent.CUSTOM;
+ }
+
+ @Override
+ protected void handleUpdateState(BooleanState state, Object arg) {
+ if (mRebootToRecovery == 1) {
+ state.label = mContext.getString(R.string.quick_settings_reboot_recovery_label);
+ state.icon = ResourceIcon.get(R.drawable.ic_qs_reboot_recovery);
+ } else if (mRebootToRecovery == 2) {
+ state.label = mContext.getString(R.string.quick_settings_poweroff_label);
+ state.icon = ResourceIcon.get(R.drawable.ic_qs_poweroff);
+ } else {
+ state.label = mContext.getString(R.string.quick_settings_reboot_label);
+ state.icon = ResourceIcon.get(R.drawable.ic_qs_reboot);
+ }
+ state.state = Tile.STATE_INACTIVE;
+ }
+
+ @Override
+ public void handleSetListening(boolean listening) {
+ }
+}
diff --git a/proto/src/metrics_constants/metrics_constants.proto b/proto/src/metrics_constants/metrics_constants.proto
index 3f712dd1492f..1f94261c639b 100644
--- a/proto/src/metrics_constants/metrics_constants.proto
+++ b/proto/src/metrics_constants/metrics_constants.proto
@@ -7435,5 +7435,8 @@ message MetricsEvent {
// ---- End Q Constants, all Q constants go above this line ----
// Add new aosp constants above this line.
// END OF AOSP CONSTANTS
+
+ // CUSTOM Metrics
+ CUSTOM = 2772;
}
}