From b2eef6a2f2dfb9c24a6572aa10e8ccb0e36ef26b Mon Sep 17 00:00:00 2001 From: fusionjack Date: Wed, 15 Nov 2017 21:21:31 -0500 Subject: [crdroid][11.0] base: Add Reboot/Recovery QS Tile This squashed the following commits: Author: Pranav Vashi Date: Sun Nov 10 11:51:46 2019 +0530 RebootTile: Make default state inactive Signed-off-by: Pranav Vashi Author: Pranav Vashi Date: Thu May 3 03:45:46 2018 +0530 Extend reboot tile to add power off Signed-off-by: Pranav Vashi Change-Id: I0531b85c3a20ecacc71a9bf02872b2cc1b0a5be9 Author: Pranav Vashi Date: Sun Feb 11 10:59:39 2018 +0530 RebootTile: Fix gradient message display for reboot to recovery Signed-off-by: Pranav Vashi Author: fusionjack Date: Wed Nov 15 21:21:31 2017 -0500 Add Reboot/Recovery QS Tile Vectorized Reboot/Recovery QS tile drawables Alex Cruz - Resized but reused the power menu reboot icon to keep things uniformed - Created a recovery vector that fits the same style too mydongistiny: Updated priv-app whitelist to fix boot Change-Id: I0762ffb2b3ddf8c833662a237bde20581e8cc614 Signed-off-by: Pranav Vashi Change-Id: Ie99133e566a48d797edf98962380071c739e76ad --- data/etc/com.android.systemui.xml | 2 + packages/SystemUI/AndroidManifest.xml | 4 + packages/SystemUI/res/drawable/ic_qs_poweroff.xml | 25 +++++ packages/SystemUI/res/drawable/ic_qs_reboot.xml | 32 ++++++ .../res/drawable/ic_qs_reboot_recovery.xml | 61 +++++++++++ packages/SystemUI/res/values/cm_strings.xml | 5 + packages/SystemUI/res/values/config.xml | 2 +- .../systemui/qs/tileimpl/QSFactoryImpl.java | 8 +- .../com/android/systemui/qs/tiles/RebootTile.java | 112 +++++++++++++++++++++ .../src/metrics_constants/metrics_constants.proto | 3 + 10 files changed, 252 insertions(+), 2 deletions(-) create mode 100644 packages/SystemUI/res/drawable/ic_qs_poweroff.xml create mode 100644 packages/SystemUI/res/drawable/ic_qs_reboot.xml create mode 100644 packages/SystemUI/res/drawable/ic_qs_reboot_recovery.xml create mode 100644 packages/SystemUI/src/com/android/systemui/qs/tiles/RebootTile.java 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 @@ + + 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 @@ + + + + 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 @@ + + + + + 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 @@ + + + + + + + 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 @@ + + + + + + + + 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 @@ To unpin this screen, touch & hold Back button + + + Reboot + Recovery + Power off 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 @@ - 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 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 mVolumeTileProvider; private final Provider mVpnTileProvider; private final Provider mAntiFlickerTileProvider; + private final Provider mRebootTileProvider; private final Lazy mQsHostLazy; @@ -142,7 +144,8 @@ public class QSFactoryImpl implements QSFactory { Provider usbTetherTileProvider, Provider volumeTileProvider, Provider vpnTileProvider, - Provider antiFlickerTileProvider) { + Provider antiFlickerTileProvider, + Provider 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 { + + 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; } } -- cgit v1.2.3