[DO NOT MERGE] Revert "Enable mic & camera by default"

This reverts commit b4908e9b88.

Reason for revert: Not needed

Change-Id: I39036d1697804493b92074ee5f40c6779a029aa5
Bug: 162547999
This commit is contained in:
Fabian Kozynski
2020-09-18 16:11:13 +00:00
parent b4908e9b88
commit d3ef31f0c3
3 changed files with 26 additions and 25 deletions

View File

@@ -72,8 +72,6 @@ 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
@@ -83,12 +81,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, DEFAULT_ALL_INDICATORS) ALL_INDICATORS, false)
} }
private fun isMicCameraEnabled(): Boolean { private fun isMicCameraEnabled(): Boolean {
return deviceConfigProxy.getBoolean(DeviceConfig.NAMESPACE_PRIVACY, return deviceConfigProxy.getBoolean(DeviceConfig.NAMESPACE_PRIVACY,
MIC_CAMERA, DEFAULT_MIC_CAMERA) MIC_CAMERA, false)
} }
private var currentUserIds = emptyList<Int>() private var currentUserIds = emptyList<Int>()
@@ -120,13 +118,12 @@ 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, allIndicatorsAvailable = properties.getBoolean(ALL_INDICATORS, false)
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, DEFAULT_MIC_CAMERA) micCameraAvailable = properties.getBoolean(MIC_CAMERA, false)
callbacks.forEach { it.get()?.onFlagMicCameraChanged(micCameraAvailable) } callbacks.forEach { it.get()?.onFlagMicCameraChanged(micCameraAvailable) }
} }
internalUiExecutor.updateListeningState() internalUiExecutor.updateListeningState()

View File

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

View File

@@ -272,7 +272,6 @@ 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),