Merge "Enable mic & camera by default" into rvc-qpr-dev

This commit is contained in:
TreeHugger Robot
2020-09-15 23:31:54 +00:00
committed by Android (Google) Code Review
3 changed files with 25 additions and 26 deletions

View File

@@ -72,6 +72,8 @@ class PrivacyItemController @Inject constructor(
private const val ALL_INDICATORS =
SystemUiDeviceConfigFlags.PROPERTY_PERMISSIONS_HUB_ENABLED
private const val MIC_CAMERA = SystemUiDeviceConfigFlags.PROPERTY_MIC_CAMERA_ENABLED
private const val DEFAULT_ALL_INDICATORS = false
private const val DEFAULT_MIC_CAMERA = true
}
@VisibleForTesting
@@ -81,12 +83,12 @@ class PrivacyItemController @Inject constructor(
fun isAllIndicatorsEnabled(): Boolean {
return deviceConfigProxy.getBoolean(DeviceConfig.NAMESPACE_PRIVACY,
ALL_INDICATORS, false)
ALL_INDICATORS, DEFAULT_ALL_INDICATORS)
}
private fun isMicCameraEnabled(): Boolean {
return deviceConfigProxy.getBoolean(DeviceConfig.NAMESPACE_PRIVACY,
MIC_CAMERA, false)
MIC_CAMERA, DEFAULT_MIC_CAMERA)
}
private var currentUserIds = emptyList<Int>()
@@ -118,12 +120,13 @@ class PrivacyItemController @Inject constructor(
// Running on the ui executor so can iterate on callbacks
if (properties.keyset.contains(ALL_INDICATORS)) {
allIndicatorsAvailable = properties.getBoolean(ALL_INDICATORS, false)
allIndicatorsAvailable = properties.getBoolean(ALL_INDICATORS,
DEFAULT_ALL_INDICATORS)
callbacks.forEach { it.get()?.onFlagAllChanged(allIndicatorsAvailable) }
}
if (properties.keyset.contains(MIC_CAMERA)) {
micCameraAvailable = properties.getBoolean(MIC_CAMERA, false)
micCameraAvailable = properties.getBoolean(MIC_CAMERA, DEFAULT_MIC_CAMERA)
callbacks.forEach { it.get()?.onFlagMicCameraChanged(micCameraAvailable) }
}
internalUiExecutor.updateListeningState()

View File

@@ -96,22 +96,24 @@ class PrivacyItemControllerFlagsTest : SysuiTestCase() {
}
@Test
fun testNotListeningByDefault() {
fun testNotListeningAllByDefault() {
assertFalse(privacyItemController.allIndicatorsAvailable)
assertFalse(privacyItemController.micCameraAvailable)
}
verify(appOpsController, never()).addCallback(any(), any())
@Test
fun testMicCameraListeningByDefault() {
assertTrue(privacyItemController.micCameraAvailable)
}
@Test
fun testMicCameraChanged() {
changeMicCamera(true)
changeMicCamera(false) // default is true
executor.runAllReady()
verify(callback).onFlagMicCameraChanged(true)
verify(callback).onFlagMicCameraChanged(false)
verify(callback, never()).onFlagAllChanged(anyBoolean())
assertTrue(privacyItemController.micCameraAvailable)
assertFalse(privacyItemController.micCameraAvailable)
assertFalse(privacyItemController.allIndicatorsAvailable)
}
@@ -124,20 +126,19 @@ class PrivacyItemControllerFlagsTest : SysuiTestCase() {
verify(callback, never()).onFlagMicCameraChanged(anyBoolean())
assertTrue(privacyItemController.allIndicatorsAvailable)
assertFalse(privacyItemController.micCameraAvailable)
}
@Test
fun testBothChanged() {
changeAll(true)
changeMicCamera(true)
changeMicCamera(false)
executor.runAllReady()
verify(callback, atLeastOnce()).onFlagAllChanged(true)
verify(callback, atLeastOnce()).onFlagMicCameraChanged(true)
verify(callback, atLeastOnce()).onFlagMicCameraChanged(false)
assertTrue(privacyItemController.allIndicatorsAvailable)
assertTrue(privacyItemController.micCameraAvailable)
assertFalse(privacyItemController.micCameraAvailable)
}
@Test
@@ -156,19 +157,12 @@ class PrivacyItemControllerFlagsTest : SysuiTestCase() {
verify(appOpsController).addCallback(eq(PrivacyItemController.OPS), any())
}
@Test
fun testAll_listening() {
changeAll(true)
executor.runAllReady()
verify(appOpsController).addCallback(eq(PrivacyItemController.OPS), any())
}
@Test
fun testAllFalse_notListening() {
changeAll(true)
executor.runAllReady()
changeAll(false)
changeMicCamera(false)
executor.runAllReady()
verify(appOpsController).removeCallback(any(), any())
@@ -176,8 +170,8 @@ class PrivacyItemControllerFlagsTest : SysuiTestCase() {
@Test
fun testSomeListening_stillListening() {
// Mic and camera are true by default
changeAll(true)
changeMicCamera(true)
executor.runAllReady()
changeAll(false)
executor.runAllReady()
@@ -186,7 +180,8 @@ class PrivacyItemControllerFlagsTest : SysuiTestCase() {
}
@Test
fun testAllDeleted_stopListening() {
fun testAllDeleted_micCameraFalse_stopListening() {
changeMicCamera(false)
changeAll(true)
executor.runAllReady()
changeAll(null)
@@ -196,13 +191,13 @@ class PrivacyItemControllerFlagsTest : SysuiTestCase() {
}
@Test
fun testMicDeleted_stopListening() {
fun testMicDeleted_stillListening() {
changeMicCamera(true)
executor.runAllReady()
changeMicCamera(null)
executor.runAllReady()
verify(appOpsController).removeCallback(any(), any())
verify(appOpsController, never()).removeCallback(any(), any())
}
private fun changeMicCamera(value: Boolean?) = changeProperty(MIC_CAMERA, value)

View File

@@ -272,6 +272,7 @@ class PrivacyItemControllerTest : SysuiTestCase() {
@Test
fun testNotListeningWhenIndicatorsDisabled() {
changeAll(false)
changeMicCamera(false)
privacyItemController.addCallback(callback)
executor.runAllReady()
verify(appOpsController, never()).addCallback(eq(PrivacyItemController.OPS),