DivestOS/Patches/LineageOS-19.1/android_frameworks_base/0032-tile_restrictions.patch

672 lines
29 KiB
Diff
Raw Normal View History

From 6f7cde6351b1ba2fb0513d713ad20d42e7f18745 Mon Sep 17 00:00:00 2001
From: Danny Lin <danny@kdrag0n.dev>
Date: Tue, 5 Oct 2021 21:01:09 -0700
Subject: [PATCH] SystemUI: Require unlocking to use sensitive QS tiles
- Airplane mode
- Battery saver
- Bluetooth
- Cellular
- DataSaver
- Internet
- Hotspot
- NFC
- Rotation lock
- Wi-Fi
- Work mode
This is the same idea as the following commits from GrapheneOS, but
simplified to reduce changes made to each individual QS tile:
commit 45670099ed63c9fbde6ff1bd13d27b674416d21d
Author: inthewaves <inthewaves@pm.me>
Date: Thu Sep 10 17:22:41 2020 -0700
require unlocking to use work mode tile
commit 4b7c9559dfba84e10142fcd53b3edac9c75b0748
Author: inthewaves <inthewaves@pm.me>
Date: Thu Sep 10 17:21:16 2020 -0700
require unlocking to use battery saver tile
commit f45c24a4728531441c60320eda0a4fce4285de06
Author: inthewaves <inthewaves@pm.me>
Date: Thu Sep 10 17:19:36 2020 -0700
require unlocking to use cellular quick tile
commit c18f6f868aee5b8f27fcc1966089f814f9f89ab2
Author: inthewaves <inthewaves@pm.me>
Date: Thu Sep 10 17:15:46 2020 -0700
require unlocking to use hotspot quick tile
commit 442c94e1ee499eed467863362f8eb62bb88027a4
Author: inthewaves <inthewaves@pm.me>
Date: Thu Sep 10 17:13:58 2020 -0700
require unlocking to use data saver quick tile
commit cf84259708f9bf650c8494e16025725b1bfa5e23
Author: inthewaves <inthewaves@pm.me>
Date: Thu Sep 10 17:11:58 2020 -0700
require unlocking to use rotation lock quick tile
commit 61eb5a6392c53e4d44cb91cdb4df27c3055ef439
Author: inthewaves <inthewaves@pm.me>
Date: Thu Sep 10 17:08:33 2020 -0700
require unlocking to use Wi-Fi quick tile
commit ad122f0a5a46e2445b5866d3ff83fdc7623b76f6
Author: inthewaves <inthewaves@pm.me>
Date: Thu Sep 10 17:05:18 2020 -0700
require unlocking to use airplane mode quick tile
commit a3686b6f905fb734b3a4f6db545e8a3ef3fc3cc7
Author: inthewaves <inthewaves@pm.me>
Date: Thu Sep 10 17:02:20 2020 -0700
require unlocking to use Bluetooth quick tile
commit 3046535a40f53835eb0b57d4c12a29828ba90f30
Author: inthewaves <inthewaves@pm.me>
Date: Thu Sep 10 16:47:59 2020 -0700
require unlocking to use NFC quick tile
commit 991e4579ad329df28a6e18bb0de8a5368d91bb73
Author: flawedworld <flawedworld@flawed.world>
Date: Thu Dec 9 16:24:47 2021 +0000
SystemUI: Require unlocking to use Internet quick tile
---
.../systemui/qs/tiles/AirplaneModeTile.java | 14 +++--
.../systemui/qs/tiles/BatterySaverTile.java | 14 +++--
.../systemui/qs/tiles/BluetoothTile.java | 14 +++--
.../systemui/qs/tiles/CellularTile.java | 14 +++--
.../systemui/qs/tiles/DataSaverTile.java | 14 +++--
.../systemui/qs/tiles/HotspotTile.java | 14 +++--
.../systemui/qs/tiles/InternetTile.java | 13 +++--
.../android/systemui/qs/tiles/NfcTile.java | 14 +++--
.../systemui/qs/tiles/RotationLockTile.java | 14 +++--
.../android/systemui/qs/tiles/SecureQSTile.kt | 58 +++++++++++++++++++
.../android/systemui/qs/tiles/WifiTile.java | 14 +++--
.../systemui/qs/tiles/WorkModeTile.java | 14 +++--
12 files changed, 167 insertions(+), 44 deletions(-)
create mode 100644 packages/SystemUI/src/com/android/systemui/qs/tiles/SecureQSTile.kt
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/AirplaneModeTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/AirplaneModeTile.java
index 22cd6f86b165..f76966030528 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/AirplaneModeTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/AirplaneModeTile.java
@@ -48,13 +48,14 @@
import com.android.systemui.qs.QSHost;
import com.android.systemui.qs.logging.QSLogger;
import com.android.systemui.qs.tileimpl.QSTileImpl;
+import com.android.systemui.statusbar.policy.KeyguardStateController;
import javax.inject.Inject;
import dagger.Lazy;
/** Quick settings tile: Airplane mode **/
-public class AirplaneModeTile extends QSTileImpl<BooleanState> {
+public class AirplaneModeTile extends SecureQSTile<BooleanState> {
private final Icon mIcon = ResourceIcon.get(com.android.internal.R.drawable.ic_qs_airplane);
private final GlobalSetting mSetting;
private final BroadcastDispatcher mBroadcastDispatcher;
@@ -73,10 +74,11 @@ public AirplaneModeTile(
ActivityStarter activityStarter,
QSLogger qsLogger,
BroadcastDispatcher broadcastDispatcher,
- Lazy<ConnectivityManager> lazyConnectivityManager
+ Lazy<ConnectivityManager> lazyConnectivityManager,
+ KeyguardStateController keyguardStateController
) {
super(host, backgroundLooper, mainHandler, falsingManager, metricsLogger,
- statusBarStateController, activityStarter, qsLogger);
+ statusBarStateController, activityStarter, qsLogger, keyguardStateController);
mBroadcastDispatcher = broadcastDispatcher;
mLazyConnectivityManager = lazyConnectivityManager;
@@ -95,7 +97,11 @@ public BooleanState newTileState() {
}
@Override
- public void handleClick(@Nullable View view) {
+ protected void handleClick(@Nullable View view, boolean keyguardShowing) {
+ if (checkKeyguard(view, keyguardShowing)) {
+ return;
+ }
+
boolean airplaneModeEnabled = mState.value;
MetricsLogger.action(mContext, getMetricsCategory(), !airplaneModeEnabled);
if (!airplaneModeEnabled && TelephonyProperties.in_ecm_mode().orElse(false)) {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/BatterySaverTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/BatterySaverTile.java
index e3024fa0eddc..f68572bc3e75 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/BatterySaverTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/BatterySaverTile.java
@@ -40,11 +40,12 @@
import com.android.systemui.qs.logging.QSLogger;
import com.android.systemui.qs.tileimpl.QSTileImpl;
import com.android.systemui.statusbar.policy.BatteryController;
+import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.util.settings.SecureSettings;
import javax.inject.Inject;
-public class BatterySaverTile extends QSTileImpl<BooleanState> implements
+public class BatterySaverTile extends SecureQSTile<BooleanState> implements
BatteryController.BatteryStateChangeCallback {
private final BatteryController mBatteryController;
@@ -69,10 +70,11 @@ public BatterySaverTile(
ActivityStarter activityStarter,
QSLogger qsLogger,
BatteryController batteryController,
- SecureSettings secureSettings
+ SecureSettings secureSettings,
+ KeyguardStateController keyguardStateController
) {
super(host, backgroundLooper, mainHandler, falsingManager, metricsLogger,
- statusBarStateController, activityStarter, qsLogger);
+ statusBarStateController, activityStarter, qsLogger, keyguardStateController);
mBatteryController = batteryController;
mBatteryController.observe(getLifecycle(), this);
int currentUser = host.getUserContext().getUserId();
@@ -123,7 +125,11 @@ public Intent getLongClickIntent() {
}
@Override
- protected void handleClick(@Nullable View view) {
+ protected void handleClick(@Nullable View view, boolean keyguardShowing) {
+ if (checkKeyguard(view, keyguardShowing)) {
+ return;
+ }
+
if (getState().state == Tile.STATE_UNAVAILABLE) {
return;
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java
index 65b6617c5a25..7c24a8c9c10e 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java
@@ -53,6 +53,7 @@
import com.android.systemui.qs.logging.QSLogger;
import com.android.systemui.qs.tileimpl.QSTileImpl;
import com.android.systemui.statusbar.policy.BluetoothController;
+import com.android.systemui.statusbar.policy.KeyguardStateController;
import java.util.ArrayList;
import java.util.Collection;
@@ -61,7 +62,7 @@
import javax.inject.Inject;
/** Quick settings tile: Bluetooth **/
-public class BluetoothTile extends QSTileImpl<BooleanState> {
+public class BluetoothTile extends SecureQSTile<BooleanState> {
private static final Intent BLUETOOTH_SETTINGS = new Intent(Settings.ACTION_BLUETOOTH_SETTINGS);
private final BluetoothController mController;
@@ -77,10 +78,11 @@ public BluetoothTile(
StatusBarStateController statusBarStateController,
ActivityStarter activityStarter,
QSLogger qsLogger,
- BluetoothController bluetoothController
+ BluetoothController bluetoothController,
+ KeyguardStateController keyguardStateController
) {
super(host, backgroundLooper, mainHandler, falsingManager, metricsLogger,
- statusBarStateController, activityStarter, qsLogger);
+ statusBarStateController, activityStarter, qsLogger, keyguardStateController);
mController = bluetoothController;
mDetailAdapter = (BluetoothDetailAdapter) createDetailAdapter();
mController.observe(getLifecycle(), mCallback);
@@ -97,7 +99,11 @@ public BooleanState newTileState() {
}
@Override
- protected void handleClick(@Nullable View view) {
+ protected void handleClick(@Nullable View view, boolean keyguardShowing) {
+ if (checkKeyguard(view, keyguardShowing)) {
+ return;
+ }
+
// Secondary clicks are header clicks, just toggle.
final boolean isEnabled = mState.value;
// Immediately enter transient enabling state when turning bluetooth on.
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java
index e5601f29af0b..e7ed5575e302 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java
@@ -62,11 +62,12 @@
import com.android.systemui.statusbar.connectivity.NetworkController;
import com.android.systemui.statusbar.connectivity.SignalCallback;
import com.android.systemui.statusbar.phone.SystemUIDialog;
+import com.android.systemui.statusbar.policy.KeyguardStateController;
import javax.inject.Inject;
/** Quick settings tile: Cellular **/
-public class CellularTile extends QSTileImpl<SignalState> {
+public class CellularTile extends SecureQSTile<SignalState> {
private static final String ENABLE_SETTINGS_DATA_PLAN = "enable.settings.data.plan";
private final NetworkController mController;
@@ -85,10 +86,11 @@ public CellularTile(
StatusBarStateController statusBarStateController,
ActivityStarter activityStarter,
QSLogger qsLogger,
- NetworkController networkController
+ NetworkController networkController,
+ KeyguardStateController keyguardStateController
) {
super(host, backgroundLooper, mainHandler, falsingManager, metricsLogger,
- statusBarStateController, activityStarter, qsLogger);
+ statusBarStateController, activityStarter, qsLogger, keyguardStateController);
mController = networkController;
mDataController = mController.getMobileDataController();
mDetailAdapter = new CellularDetailAdapter();
@@ -119,7 +121,11 @@ public Intent getLongClickIntent() {
}
@Override
- protected void handleClick(@Nullable View view) {
+ protected void handleClick(@Nullable View view, boolean keyguardShowing) {
+ if (checkKeyguard(view, keyguardShowing)) {
+ return;
+ }
+
if (getState().state == Tile.STATE_UNAVAILABLE) {
return;
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/DataSaverTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/DataSaverTile.java
index a2577d6e7f60..591d31889491 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/DataSaverTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/DataSaverTile.java
@@ -40,10 +40,11 @@
import com.android.systemui.qs.tileimpl.QSTileImpl;
import com.android.systemui.statusbar.phone.SystemUIDialog;
import com.android.systemui.statusbar.policy.DataSaverController;
+import com.android.systemui.statusbar.policy.KeyguardStateController;
import javax.inject.Inject;
-public class DataSaverTile extends QSTileImpl<BooleanState> implements
+public class DataSaverTile extends SecureQSTile<BooleanState> implements
DataSaverController.Listener{
private final DataSaverController mDataSaverController;
@@ -60,10 +61,11 @@ public DataSaverTile(
ActivityStarter activityStarter,
QSLogger qsLogger,
DataSaverController dataSaverController,
- DialogLaunchAnimator dialogLaunchAnimator
+ DialogLaunchAnimator dialogLaunchAnimator,
+ KeyguardStateController keyguardStateController
) {
super(host, backgroundLooper, mainHandler, falsingManager, metricsLogger,
- statusBarStateController, activityStarter, qsLogger);
+ statusBarStateController, activityStarter, qsLogger, keyguardStateController);
mDataSaverController = dataSaverController;
mDialogLaunchAnimator = dialogLaunchAnimator;
mDataSaverController.observe(getLifecycle(), this);
@@ -79,7 +81,11 @@ public Intent getLongClickIntent() {
return new Intent(Settings.ACTION_DATA_SAVER_SETTINGS);
}
@Override
- protected void handleClick(@Nullable View view) {
+ protected void handleClick(@Nullable View view, boolean keyguardShowing) {
+ if (checkKeyguard(view, keyguardShowing)) {
+ return;
+ }
+
if (mState.value
|| Prefs.getBoolean(mContext, Prefs.Key.QS_DATA_SAVER_DIALOG_SHOWN, false)) {
// Do it right away.
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java
index 87edc2cf8bac..04742b53321c 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java
@@ -42,11 +42,12 @@
import com.android.systemui.qs.tileimpl.QSTileImpl;
import com.android.systemui.statusbar.policy.DataSaverController;
import com.android.systemui.statusbar.policy.HotspotController;
+import com.android.systemui.statusbar.policy.KeyguardStateController;
import javax.inject.Inject;
/** Quick settings tile: Hotspot **/
-public class HotspotTile extends QSTileImpl<BooleanState> {
+public class HotspotTile extends SecureQSTile<BooleanState> {
private final Icon mEnabledStatic = ResourceIcon.get(R.drawable.ic_hotspot);
@@ -67,10 +68,11 @@ public HotspotTile(
ActivityStarter activityStarter,
QSLogger qsLogger,
HotspotController hotspotController,
- DataSaverController dataSaverController
+ DataSaverController dataSaverController,
+ KeyguardStateController keyguardStateController
) {
super(host, backgroundLooper, mainHandler, falsingManager, metricsLogger,
- statusBarStateController, activityStarter, qsLogger);
+ statusBarStateController, activityStarter, qsLogger, keyguardStateController);
mHotspotController = hotspotController;
mDataSaverController = dataSaverController;
mHotspotController.observe(this, mCallbacks);
@@ -108,7 +110,11 @@ public BooleanState newTileState() {
}
@Override
- protected void handleClick(@Nullable View view) {
+ protected void handleClick(@Nullable View view, boolean keyguardShowing) {
+ if (checkKeyguard(view, keyguardShowing)) {
+ return;
+ }
+
final boolean isEnabled = mState.value;
if (!isEnabled && mDataSaverController.isDataSaverEnabled()) {
return;
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/InternetTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/InternetTile.java
index cd81b4a11703..61be4e7ccd40 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/InternetTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/InternetTile.java
@@ -53,6 +53,7 @@
import com.android.systemui.qs.logging.QSLogger;
import com.android.systemui.qs.tileimpl.QSTileImpl;
import com.android.systemui.qs.tiles.dialog.InternetDialogFactory;
+import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.statusbar.connectivity.AccessPointController;
import com.android.systemui.statusbar.connectivity.IconState;
import com.android.systemui.statusbar.connectivity.MobileDataIndicators;
@@ -67,7 +68,7 @@
import javax.inject.Inject;
/** Quick settings tile: Internet **/
-public class InternetTile extends QSTileImpl<SignalState> {
+public class InternetTile extends SecureQSTile<SignalState> {
private static final Intent WIFI_SETTINGS = new Intent(Settings.ACTION_WIFI_SETTINGS);
protected final NetworkController mController;
@@ -92,10 +93,11 @@ public InternetTile(
QSLogger qsLogger,
NetworkController networkController,
AccessPointController accessPointController,
- InternetDialogFactory internetDialogFactory
+ InternetDialogFactory internetDialogFactory,
+ KeyguardStateController keyguardStateController
) {
super(host, backgroundLooper, mainHandler, falsingManager, metricsLogger,
- statusBarStateController, activityStarter, qsLogger);
+ statusBarStateController, activityStarter, qsLogger, keyguardStateController);
mInternetDialogFactory = internetDialogFactory;
mHandler = mainHandler;
mController = networkController;
@@ -122,7 +124,10 @@ public Intent getLongClickIntent() {
}
@Override
- protected void handleClick(@Nullable View view) {
+ protected void handleClick(@Nullable View view, boolean keyguardShowing) {
+ if (checkKeyguard(view, keyguardShowing)) {
+ return;
+ }
mHandler.post(() -> mInternetDialogFactory.create(true,
mAccessPointController.canConfigMobileData(),
mAccessPointController.canConfigWifi(), view));
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/NfcTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/NfcTile.java
index b9bc0e5ca814..1bd913ea9496 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/NfcTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/NfcTile.java
@@ -45,11 +45,12 @@
import com.android.systemui.qs.QSHost;
import com.android.systemui.qs.logging.QSLogger;
import com.android.systemui.qs.tileimpl.QSTileImpl;
+import com.android.systemui.statusbar.policy.KeyguardStateController;
import javax.inject.Inject;
/** Quick settings tile: Enable/Disable NFC **/
-public class NfcTile extends QSTileImpl<BooleanState> {
+public class NfcTile extends SecureQSTile<BooleanState> {
private static final String NFC = "nfc";
private final Icon mIcon = ResourceIcon.get(R.drawable.ic_qs_nfc);
@@ -69,10 +70,11 @@ public NfcTile(
StatusBarStateController statusBarStateController,
ActivityStarter activityStarter,
QSLogger qsLogger,
- BroadcastDispatcher broadcastDispatcher
+ BroadcastDispatcher broadcastDispatcher,
+ KeyguardStateController keyguardStateController
) {
super(host, backgroundLooper, mainHandler, falsingManager, metricsLogger,
- statusBarStateController, activityStarter, qsLogger);
+ statusBarStateController, activityStarter, qsLogger, keyguardStateController);
mBroadcastDispatcher = broadcastDispatcher;
}
@@ -114,7 +116,11 @@ public Intent getLongClickIntent() {
}
@Override
- protected void handleClick(@Nullable View view) {
+ protected void handleClick(@Nullable View view, boolean keyguardShowing) {
+ if (checkKeyguard(view, keyguardShowing)) {
+ return;
+ }
+
if (getAdapter() == null) {
return;
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/RotationLockTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/RotationLockTile.java
index 0bbb5bdd851a..c28d09f80f74 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/RotationLockTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/RotationLockTile.java
@@ -40,13 +40,14 @@
import com.android.systemui.qs.QSHost;
import com.android.systemui.qs.logging.QSLogger;
import com.android.systemui.qs.tileimpl.QSTileImpl;
+import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.statusbar.policy.RotationLockController;
import com.android.systemui.statusbar.policy.RotationLockController.RotationLockControllerCallback;
import javax.inject.Inject;
/** Quick settings tile: Rotation **/
-public class RotationLockTile extends QSTileImpl<BooleanState> {
+public class RotationLockTile extends SecureQSTile<BooleanState> {
private final Icon mIcon = ResourceIcon.get(com.android.internal.R.drawable.ic_qs_auto_rotate);
private final RotationLockController mController;
@@ -61,10 +62,11 @@ public RotationLockTile(
StatusBarStateController statusBarStateController,
ActivityStarter activityStarter,
QSLogger qsLogger,
- RotationLockController rotationLockController
+ RotationLockController rotationLockController,
+ KeyguardStateController keyguardStateController
) {
super(host, backgroundLooper, mainHandler, falsingManager, metricsLogger,
- statusBarStateController, activityStarter, qsLogger);
+ statusBarStateController, activityStarter, qsLogger, keyguardStateController);
mController = rotationLockController;
mController.observe(this, mCallback);
}
@@ -80,7 +82,11 @@ public Intent getLongClickIntent() {
}
@Override
- protected void handleClick(@Nullable View view) {
+ protected void handleClick(@Nullable View view, boolean keyguardShowing) {
+ if (checkKeyguard(view, keyguardShowing)) {
+ return;
+ }
+
final boolean newState = !mState.value;
mController.setRotationLocked(!newState);
refreshState(newState);
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/SecureQSTile.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/SecureQSTile.kt
new file mode 100644
index 000000000000..30a5461fbb59
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/SecureQSTile.kt
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+package com.android.systemui.qs.tiles
+
+import android.os.Handler
+import android.os.Looper
+import android.view.View
+import com.android.systemui.plugins.qs.QSTile
+import com.android.systemui.qs.QSHost
+import com.android.systemui.plugins.FalsingManager
+import com.android.internal.logging.MetricsLogger
+import com.android.systemui.plugins.ActivityStarter
+import com.android.systemui.plugins.statusbar.StatusBarStateController
+import com.android.systemui.qs.logging.QSLogger
+import com.android.systemui.statusbar.policy.KeyguardStateController
+import com.android.systemui.qs.tileimpl.QSTileImpl
+
+internal abstract class SecureQSTile<TState : QSTile.State> protected constructor(
+ host: QSHost, backgroundLooper: Looper, mainHandler: Handler, falsingManager: FalsingManager,
+ metricsLogger: MetricsLogger, statusBarStateController: StatusBarStateController,
+ activityStarter: ActivityStarter, qsLogger: QSLogger,
+ private val mKeyguard: KeyguardStateController,
+) : QSTileImpl<TState>(
+ host, backgroundLooper, mainHandler, falsingManager, metricsLogger, statusBarStateController,
+ activityStarter, qsLogger,
+) {
+ abstract override fun newTileState(): TState
+
+ protected abstract fun handleClick(view: View?, keyguardShowing: Boolean)
+
+ override fun handleClick(view: View?) {
+ handleClick(view, mKeyguard.isMethodSecure && mKeyguard.isShowing)
+ }
+
+ protected fun checkKeyguard(view: View?, keyguardShowing: Boolean): Boolean {
+ return if (keyguardShowing) {
+ mActivityStarter.postQSRunnableDismissingKeyguard {
+ handleClick(view, false)
+ }
+ true
+ } else {
+ false
+ }
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java
index e79ca0c93212..89cebab4fda4 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java
@@ -58,6 +58,7 @@
import com.android.systemui.statusbar.connectivity.SignalCallback;
import com.android.systemui.statusbar.connectivity.WifiIcons;
import com.android.systemui.statusbar.connectivity.WifiIndicators;
+import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.wifitrackerlib.WifiEntry;
import java.util.List;
@@ -65,7 +66,7 @@
import javax.inject.Inject;
/** Quick settings tile: Wifi **/
-public class WifiTile extends QSTileImpl<SignalState> {
+public class WifiTile extends SecureQSTile<SignalState> {
private static final Intent WIFI_SETTINGS = new Intent(Settings.ACTION_WIFI_SETTINGS);
protected final NetworkController mController;
@@ -87,10 +88,11 @@ public WifiTile(
ActivityStarter activityStarter,
QSLogger qsLogger,
NetworkController networkController,
- AccessPointController accessPointController
+ AccessPointController accessPointController,
+ KeyguardStateController keyguardStateController
) {
super(host, backgroundLooper, mainHandler, falsingManager, metricsLogger,
- statusBarStateController, activityStarter, qsLogger);
+ statusBarStateController, activityStarter, qsLogger, keyguardStateController);
mController = networkController;
mWifiController = accessPointController;
mDetailAdapter = (WifiDetailAdapter) createDetailAdapter();
@@ -133,7 +135,11 @@ public Intent getLongClickIntent() {
}
@Override
- protected void handleClick(@Nullable View view) {
+ protected void handleClick(@Nullable View view, boolean keyguardShowing) {
+ if (checkKeyguard(view, keyguardShowing)) {
+ return;
+ }
+
// Secondary clicks are header clicks, just toggle.
mState.copyTo(mStateBeforeClick);
boolean wifiEnabled = mState.value;
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/WorkModeTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/WorkModeTile.java
index 8df8c63702c3..7fc1726632ea 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/WorkModeTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/WorkModeTile.java
@@ -39,11 +39,12 @@
import com.android.systemui.qs.logging.QSLogger;
import com.android.systemui.qs.tileimpl.QSTileImpl;
import com.android.systemui.statusbar.phone.ManagedProfileController;
+import com.android.systemui.statusbar.policy.KeyguardStateController;
import javax.inject.Inject;
/** Quick settings tile: Work profile on/off */
-public class WorkModeTile extends QSTileImpl<BooleanState> implements
+public class WorkModeTile extends SecureQSTile<BooleanState> implements
ManagedProfileController.Callback {
private final Icon mIcon = ResourceIcon.get(R.drawable.stat_sys_managed_profile_status);
@@ -59,10 +60,11 @@ public WorkModeTile(
StatusBarStateController statusBarStateController,
ActivityStarter activityStarter,
QSLogger qsLogger,
- ManagedProfileController managedProfileController
+ ManagedProfileController managedProfileController,
+ KeyguardStateController keyguardStateController
) {
super(host, backgroundLooper, mainHandler, falsingManager, metricsLogger,
- statusBarStateController, activityStarter, qsLogger);
+ statusBarStateController, activityStarter, qsLogger, keyguardStateController);
mProfileController = managedProfileController;
mProfileController.observe(getLifecycle(), this);
}
@@ -78,7 +80,11 @@ public Intent getLongClickIntent() {
}
@Override
- public void handleClick(@Nullable View view) {
+ protected void handleClick(@Nullable View view, boolean keyguardShowing) {
+ if (checkKeyguard(view, keyguardShowing)) {
+ return;
+ }
+
mProfileController.setWorkModeEnabled(!mState.value);
}