Merge "Enable mic & camera by default" into rvc-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
204479a075
@@ -72,6 +72,8 @@ class PrivacyItemController @Inject constructor(
|
|||||||
private const val ALL_INDICATORS =
|
private const val ALL_INDICATORS =
|
||||||
SystemUiDeviceConfigFlags.PROPERTY_PERMISSIONS_HUB_ENABLED
|
SystemUiDeviceConfigFlags.PROPERTY_PERMISSIONS_HUB_ENABLED
|
||||||
private const val MIC_CAMERA = SystemUiDeviceConfigFlags.PROPERTY_MIC_CAMERA_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
|
@VisibleForTesting
|
||||||
@@ -81,12 +83,12 @@ class PrivacyItemController @Inject constructor(
|
|||||||
|
|
||||||
fun isAllIndicatorsEnabled(): Boolean {
|
fun isAllIndicatorsEnabled(): Boolean {
|
||||||
return deviceConfigProxy.getBoolean(DeviceConfig.NAMESPACE_PRIVACY,
|
return deviceConfigProxy.getBoolean(DeviceConfig.NAMESPACE_PRIVACY,
|
||||||
ALL_INDICATORS, false)
|
ALL_INDICATORS, DEFAULT_ALL_INDICATORS)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isMicCameraEnabled(): Boolean {
|
private fun isMicCameraEnabled(): Boolean {
|
||||||
return deviceConfigProxy.getBoolean(DeviceConfig.NAMESPACE_PRIVACY,
|
return deviceConfigProxy.getBoolean(DeviceConfig.NAMESPACE_PRIVACY,
|
||||||
MIC_CAMERA, false)
|
MIC_CAMERA, DEFAULT_MIC_CAMERA)
|
||||||
}
|
}
|
||||||
|
|
||||||
private var currentUserIds = emptyList<Int>()
|
private var currentUserIds = emptyList<Int>()
|
||||||
@@ -118,12 +120,13 @@ class PrivacyItemController @Inject constructor(
|
|||||||
|
|
||||||
// Running on the ui executor so can iterate on callbacks
|
// Running on the ui executor so can iterate on callbacks
|
||||||
if (properties.keyset.contains(ALL_INDICATORS)) {
|
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) }
|
callbacks.forEach { it.get()?.onFlagAllChanged(allIndicatorsAvailable) }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (properties.keyset.contains(MIC_CAMERA)) {
|
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) }
|
callbacks.forEach { it.get()?.onFlagMicCameraChanged(micCameraAvailable) }
|
||||||
}
|
}
|
||||||
internalUiExecutor.updateListeningState()
|
internalUiExecutor.updateListeningState()
|
||||||
|
|||||||
@@ -96,22 +96,24 @@ class PrivacyItemControllerFlagsTest : SysuiTestCase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testNotListeningByDefault() {
|
fun testNotListeningAllByDefault() {
|
||||||
assertFalse(privacyItemController.allIndicatorsAvailable)
|
assertFalse(privacyItemController.allIndicatorsAvailable)
|
||||||
assertFalse(privacyItemController.micCameraAvailable)
|
}
|
||||||
|
|
||||||
verify(appOpsController, never()).addCallback(any(), any())
|
@Test
|
||||||
|
fun testMicCameraListeningByDefault() {
|
||||||
|
assertTrue(privacyItemController.micCameraAvailable)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testMicCameraChanged() {
|
fun testMicCameraChanged() {
|
||||||
changeMicCamera(true)
|
changeMicCamera(false) // default is true
|
||||||
executor.runAllReady()
|
executor.runAllReady()
|
||||||
|
|
||||||
verify(callback).onFlagMicCameraChanged(true)
|
verify(callback).onFlagMicCameraChanged(false)
|
||||||
verify(callback, never()).onFlagAllChanged(anyBoolean())
|
verify(callback, never()).onFlagAllChanged(anyBoolean())
|
||||||
|
|
||||||
assertTrue(privacyItemController.micCameraAvailable)
|
assertFalse(privacyItemController.micCameraAvailable)
|
||||||
assertFalse(privacyItemController.allIndicatorsAvailable)
|
assertFalse(privacyItemController.allIndicatorsAvailable)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,20 +126,19 @@ class PrivacyItemControllerFlagsTest : SysuiTestCase() {
|
|||||||
verify(callback, never()).onFlagMicCameraChanged(anyBoolean())
|
verify(callback, never()).onFlagMicCameraChanged(anyBoolean())
|
||||||
|
|
||||||
assertTrue(privacyItemController.allIndicatorsAvailable)
|
assertTrue(privacyItemController.allIndicatorsAvailable)
|
||||||
assertFalse(privacyItemController.micCameraAvailable)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testBothChanged() {
|
fun testBothChanged() {
|
||||||
changeAll(true)
|
changeAll(true)
|
||||||
changeMicCamera(true)
|
changeMicCamera(false)
|
||||||
executor.runAllReady()
|
executor.runAllReady()
|
||||||
|
|
||||||
verify(callback, atLeastOnce()).onFlagAllChanged(true)
|
verify(callback, atLeastOnce()).onFlagAllChanged(true)
|
||||||
verify(callback, atLeastOnce()).onFlagMicCameraChanged(true)
|
verify(callback, atLeastOnce()).onFlagMicCameraChanged(false)
|
||||||
|
|
||||||
assertTrue(privacyItemController.allIndicatorsAvailable)
|
assertTrue(privacyItemController.allIndicatorsAvailable)
|
||||||
assertTrue(privacyItemController.micCameraAvailable)
|
assertFalse(privacyItemController.micCameraAvailable)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -156,19 +157,12 @@ class PrivacyItemControllerFlagsTest : SysuiTestCase() {
|
|||||||
verify(appOpsController).addCallback(eq(PrivacyItemController.OPS), any())
|
verify(appOpsController).addCallback(eq(PrivacyItemController.OPS), any())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
fun testAll_listening() {
|
|
||||||
changeAll(true)
|
|
||||||
executor.runAllReady()
|
|
||||||
|
|
||||||
verify(appOpsController).addCallback(eq(PrivacyItemController.OPS), any())
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testAllFalse_notListening() {
|
fun testAllFalse_notListening() {
|
||||||
changeAll(true)
|
changeAll(true)
|
||||||
executor.runAllReady()
|
executor.runAllReady()
|
||||||
changeAll(false)
|
changeAll(false)
|
||||||
|
changeMicCamera(false)
|
||||||
executor.runAllReady()
|
executor.runAllReady()
|
||||||
|
|
||||||
verify(appOpsController).removeCallback(any(), any())
|
verify(appOpsController).removeCallback(any(), any())
|
||||||
@@ -176,8 +170,8 @@ class PrivacyItemControllerFlagsTest : SysuiTestCase() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testSomeListening_stillListening() {
|
fun testSomeListening_stillListening() {
|
||||||
|
// Mic and camera are true by default
|
||||||
changeAll(true)
|
changeAll(true)
|
||||||
changeMicCamera(true)
|
|
||||||
executor.runAllReady()
|
executor.runAllReady()
|
||||||
changeAll(false)
|
changeAll(false)
|
||||||
executor.runAllReady()
|
executor.runAllReady()
|
||||||
@@ -186,7 +180,8 @@ class PrivacyItemControllerFlagsTest : SysuiTestCase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testAllDeleted_stopListening() {
|
fun testAllDeleted_micCameraFalse_stopListening() {
|
||||||
|
changeMicCamera(false)
|
||||||
changeAll(true)
|
changeAll(true)
|
||||||
executor.runAllReady()
|
executor.runAllReady()
|
||||||
changeAll(null)
|
changeAll(null)
|
||||||
@@ -196,13 +191,13 @@ class PrivacyItemControllerFlagsTest : SysuiTestCase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testMicDeleted_stopListening() {
|
fun testMicDeleted_stillListening() {
|
||||||
changeMicCamera(true)
|
changeMicCamera(true)
|
||||||
executor.runAllReady()
|
executor.runAllReady()
|
||||||
changeMicCamera(null)
|
changeMicCamera(null)
|
||||||
executor.runAllReady()
|
executor.runAllReady()
|
||||||
|
|
||||||
verify(appOpsController).removeCallback(any(), any())
|
verify(appOpsController, never()).removeCallback(any(), any())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun changeMicCamera(value: Boolean?) = changeProperty(MIC_CAMERA, value)
|
private fun changeMicCamera(value: Boolean?) = changeProperty(MIC_CAMERA, value)
|
||||||
|
|||||||
@@ -272,6 +272,7 @@ class PrivacyItemControllerTest : SysuiTestCase() {
|
|||||||
@Test
|
@Test
|
||||||
fun testNotListeningWhenIndicatorsDisabled() {
|
fun testNotListeningWhenIndicatorsDisabled() {
|
||||||
changeAll(false)
|
changeAll(false)
|
||||||
|
changeMicCamera(false)
|
||||||
privacyItemController.addCallback(callback)
|
privacyItemController.addCallback(callback)
|
||||||
executor.runAllReady()
|
executor.runAllReady()
|
||||||
verify(appOpsController, never()).addCallback(eq(PrivacyItemController.OPS),
|
verify(appOpsController, never()).addCallback(eq(PrivacyItemController.OPS),
|
||||||
|
|||||||
Reference in New Issue
Block a user