Merge "Controls - Use new privacy setting" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
20e75f17e5
@@ -9514,6 +9514,20 @@ public final class Settings {
|
||||
public static final String POWER_MENU_LOCKED_SHOW_CONTENT =
|
||||
"power_menu_locked_show_content";
|
||||
|
||||
/**
|
||||
* Whether home controls should be accessible from the lockscreen
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static final String LOCKSCREEN_SHOW_CONTROLS = "lockscreen_show_controls";
|
||||
|
||||
/**
|
||||
* Whether wallet should be accessible from the lockscreen
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static final String LOCKSCREEN_SHOW_WALLET = "lockscreen_show_wallet";
|
||||
|
||||
/**
|
||||
* Specifies whether the web action API is enabled.
|
||||
*
|
||||
|
||||
@@ -190,5 +190,7 @@ public class SecureSettings {
|
||||
Settings.Secure.ACCESSIBILITY_FLOATING_MENU_FADE_ENABLED,
|
||||
Settings.Secure.NOTIFICATION_BUBBLES,
|
||||
Settings.Secure.LOCATION_TIME_ZONE_DETECTION_ENABLED,
|
||||
Settings.Secure.LOCKSCREEN_SHOW_CONTROLS,
|
||||
Settings.Secure.LOCKSCREEN_SHOW_WALLET,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -146,6 +146,8 @@ public class SecureSettingsValidators {
|
||||
VALIDATORS.put(Secure.QS_TILES, TILE_LIST_VALIDATOR);
|
||||
VALIDATORS.put(Secure.CONTROLS_ENABLED, BOOLEAN_VALIDATOR);
|
||||
VALIDATORS.put(Secure.POWER_MENU_LOCKED_SHOW_CONTENT, BOOLEAN_VALIDATOR);
|
||||
VALIDATORS.put(Secure.LOCKSCREEN_SHOW_CONTROLS, BOOLEAN_VALIDATOR);
|
||||
VALIDATORS.put(Secure.LOCKSCREEN_SHOW_WALLET, BOOLEAN_VALIDATOR);
|
||||
VALIDATORS.put(Secure.DOZE_ENABLED, BOOLEAN_VALIDATOR);
|
||||
VALIDATORS.put(Secure.DOZE_ALWAYS_ON, BOOLEAN_VALIDATOR);
|
||||
VALIDATORS.put(Secure.DOZE_PICK_UP_GESTURE, BOOLEAN_VALIDATOR);
|
||||
|
||||
@@ -3547,7 +3547,7 @@ public class SettingsProvider extends ContentProvider {
|
||||
}
|
||||
|
||||
private final class UpgradeController {
|
||||
private static final int SETTINGS_VERSION = 202;
|
||||
private static final int SETTINGS_VERSION = 203;
|
||||
|
||||
private final int mUserId;
|
||||
|
||||
@@ -5130,6 +5130,27 @@ public class SettingsProvider extends ContentProvider {
|
||||
currentVersion = 202;
|
||||
}
|
||||
|
||||
if (currentVersion == 202) {
|
||||
// Version 202: Power menu has been removed, and the privacy setting
|
||||
// has been split into two for wallet and controls
|
||||
final SettingsState secureSettings = getSecureSettingsLocked(userId);
|
||||
final Setting showLockedContent = secureSettings.getSettingLocked(
|
||||
Secure.POWER_MENU_LOCKED_SHOW_CONTENT);
|
||||
if (!showLockedContent.isNull()) {
|
||||
String currentValue = showLockedContent.getValue();
|
||||
|
||||
secureSettings.insertSettingOverrideableByRestoreLocked(
|
||||
Secure.LOCKSCREEN_SHOW_CONTROLS,
|
||||
currentValue, null /* tag */, false /* makeDefault */,
|
||||
SettingsState.SYSTEM_PACKAGE_NAME);
|
||||
secureSettings.insertSettingOverrideableByRestoreLocked(
|
||||
Secure.LOCKSCREEN_SHOW_WALLET,
|
||||
currentValue, null /* tag */, false /* makeDefault */,
|
||||
SettingsState.SYSTEM_PACKAGE_NAME);
|
||||
}
|
||||
currentVersion = 203;
|
||||
}
|
||||
|
||||
// vXXX: Add new settings above this point.
|
||||
|
||||
if (currentVersion != newVersion) {
|
||||
|
||||
@@ -51,7 +51,6 @@ class ControlsComponent @Inject constructor(
|
||||
private val userTracker: UserTracker,
|
||||
private val secureSettings: SecureSettings
|
||||
) {
|
||||
|
||||
private val contentResolver: ContentResolver
|
||||
get() = context.contentResolver
|
||||
|
||||
@@ -66,7 +65,7 @@ class ControlsComponent @Inject constructor(
|
||||
init {
|
||||
if (featureEnabled) {
|
||||
secureSettings.registerContentObserver(
|
||||
Settings.Secure.getUriFor(Settings.Secure.POWER_MENU_LOCKED_SHOW_CONTENT),
|
||||
Settings.Secure.getUriFor(Settings.Secure.LOCKSCREEN_SHOW_CONTROLS),
|
||||
false, /* notifyForDescendants */
|
||||
showWhileLockedObserver
|
||||
)
|
||||
@@ -116,7 +115,7 @@ class ControlsComponent @Inject constructor(
|
||||
|
||||
private fun updateShowWhileLocked() {
|
||||
canShowWhileLockedSetting = secureSettings.getInt(
|
||||
Settings.Secure.POWER_MENU_LOCKED_SHOW_CONTENT, 0) != 0
|
||||
Settings.Secure.LOCKSCREEN_SHOW_CONTROLS, 0) != 0
|
||||
}
|
||||
|
||||
enum class Visibility {
|
||||
|
||||
@@ -40,6 +40,7 @@ import com.android.systemui.plugins.statusbar.StatusBarStateController
|
||||
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 java.util.concurrent.atomic.AtomicBoolean
|
||||
import javax.inject.Inject
|
||||
|
||||
@@ -52,7 +53,8 @@ class DeviceControlsTile @Inject constructor(
|
||||
statusBarStateController: StatusBarStateController,
|
||||
activityStarter: ActivityStarter,
|
||||
qsLogger: QSLogger,
|
||||
private val controlsComponent: ControlsComponent
|
||||
private val controlsComponent: ControlsComponent,
|
||||
private val keyguardStateController: KeyguardStateController
|
||||
) : QSTileImpl<QSTile.State>(
|
||||
host,
|
||||
backgroundLooper,
|
||||
@@ -101,11 +103,15 @@ class DeviceControlsTile @Inject constructor(
|
||||
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
putExtra(ControlsUiController.EXTRA_ANIMATE, true)
|
||||
}
|
||||
|
||||
val animationController = view?.let {
|
||||
ActivityLaunchAnimator.Controller.fromView(it)
|
||||
if (keyguardStateController.isUnlocked()) {
|
||||
val animationController = view?.let {
|
||||
ActivityLaunchAnimator.Controller.fromView(it)
|
||||
}
|
||||
mActivityStarter.startActivity(i, true /* dismissShade */, animationController)
|
||||
} else {
|
||||
mHost.collapsePanels()
|
||||
mContext.startActivity(i)
|
||||
}
|
||||
mActivityStarter.startActivity(i, true /* dismissShade */, animationController)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ class ControlsComponentTest : SysuiTestCase() {
|
||||
`when`(lockPatternUtils.getStrongAuthForUser(anyInt()))
|
||||
.thenReturn(STRONG_AUTH_NOT_REQUIRED)
|
||||
`when`(keyguardStateController.isUnlocked()).thenReturn(false)
|
||||
`when`(secureSettings.getInt(eq(Settings.Secure.POWER_MENU_LOCKED_SHOW_CONTENT), anyInt()))
|
||||
`when`(secureSettings.getInt(eq(Settings.Secure.LOCKSCREEN_SHOW_CONTROLS), anyInt()))
|
||||
.thenReturn(0)
|
||||
val component = setupComponent(true)
|
||||
|
||||
@@ -127,7 +127,7 @@ class ControlsComponentTest : SysuiTestCase() {
|
||||
`when`(lockPatternUtils.getStrongAuthForUser(anyInt()))
|
||||
.thenReturn(STRONG_AUTH_NOT_REQUIRED)
|
||||
`when`(keyguardStateController.isUnlocked()).thenReturn(false)
|
||||
`when`(secureSettings.getInt(eq(Settings.Secure.POWER_MENU_LOCKED_SHOW_CONTENT), anyInt()))
|
||||
`when`(secureSettings.getInt(eq(Settings.Secure.LOCKSCREEN_SHOW_CONTROLS), anyInt()))
|
||||
.thenReturn(1)
|
||||
val component = setupComponent(true)
|
||||
|
||||
@@ -136,7 +136,7 @@ class ControlsComponentTest : SysuiTestCase() {
|
||||
|
||||
@Test
|
||||
fun testFeatureEnabledAndCanShowWhileUnlockedVisibility() {
|
||||
`when`(secureSettings.getInt(eq(Settings.Secure.POWER_MENU_LOCKED_SHOW_CONTENT), anyInt()))
|
||||
`when`(secureSettings.getInt(eq(Settings.Secure.LOCKSCREEN_SHOW_CONTROLS), anyInt()))
|
||||
.thenReturn(0)
|
||||
`when`(lockPatternUtils.getStrongAuthForUser(anyInt()))
|
||||
.thenReturn(STRONG_AUTH_NOT_REQUIRED)
|
||||
|
||||
@@ -39,6 +39,7 @@ import com.android.systemui.plugins.ActivityStarter
|
||||
import com.android.systemui.plugins.statusbar.StatusBarStateController
|
||||
import com.android.systemui.qs.QSHost
|
||||
import com.android.systemui.qs.logging.QSLogger
|
||||
import com.android.systemui.statusbar.policy.KeyguardStateController
|
||||
import com.android.systemui.util.mockito.any
|
||||
import com.android.systemui.util.mockito.capture
|
||||
import com.android.systemui.util.mockito.eq
|
||||
@@ -87,6 +88,8 @@ class DeviceControlsTileTest : SysuiTestCase() {
|
||||
private lateinit var serviceInfo: ControlsServiceInfo
|
||||
@Mock
|
||||
private lateinit var uiEventLogger: UiEventLogger
|
||||
@Mock
|
||||
private lateinit var keyguardStateController: KeyguardStateController
|
||||
@Captor
|
||||
private lateinit var listingCallbackCaptor:
|
||||
ArgumentCaptor<ControlsListingController.ControlsListingCallback>
|
||||
@@ -109,7 +112,8 @@ class DeviceControlsTileTest : SysuiTestCase() {
|
||||
`when`(qsHost.context).thenReturn(spiedContext)
|
||||
`when`(qsHost.uiEventLogger).thenReturn(uiEventLogger)
|
||||
`when`(controlsComponent.isEnabled()).thenReturn(true)
|
||||
secureSettings.putInt(Settings.Secure.POWER_MENU_LOCKED_SHOW_CONTENT, 1)
|
||||
`when`(keyguardStateController.isUnlocked()).thenReturn(true)
|
||||
secureSettings.putInt(Settings.Secure.LOCKSCREEN_SHOW_CONTROLS, 1)
|
||||
|
||||
setupControlsComponent()
|
||||
|
||||
@@ -306,7 +310,8 @@ class DeviceControlsTileTest : SysuiTestCase() {
|
||||
statusBarStateController,
|
||||
activityStarter,
|
||||
qsLogger,
|
||||
controlsComponent
|
||||
controlsComponent,
|
||||
keyguardStateController
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user