Loading packages/SystemUI/src/com/android/systemui/privacy/PrivacyItemController.kt +7 −3 Original line number Diff line number Diff line Loading @@ -61,7 +61,8 @@ class PrivacyItemController @Inject constructor( @VisibleForTesting internal var privacyList = emptyList<PrivacyItem>() get() = field.toList() // Provides a shallow copy of the list @Synchronized get() = field.toList() // Returns a shallow copy of the list @Synchronized set private val userManager = context.getSystemService(UserManager::class.java) private var currentUserIds = emptyList<Int>() Loading @@ -71,7 +72,8 @@ class PrivacyItemController @Inject constructor( private val callbacks = mutableListOf<WeakReference<Callback>>() private val notifyChanges = Runnable { callbacks.forEach { it.get()?.privacyChanged(privacyList) } val list = privacyList callbacks.forEach { it.get()?.privacyChanged(list) } } private val updateListAndNotifyChanges = Runnable { Loading Loading @@ -157,8 +159,10 @@ class PrivacyItemController @Inject constructor( } private fun updatePrivacyList() { privacyList = currentUserIds.flatMap { appOpsController.getActiveAppOpsForUser(it) } val list = currentUserIds.flatMap { appOpsController.getActiveAppOpsForUser(it) } .mapNotNull { toPrivacyItem(it) }.distinct() privacyList = list } private fun toPrivacyItem(appOpItem: AppOpItem): PrivacyItem? { Loading packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyItemControllerTest.kt +3 −2 Original line number Diff line number Diff line Loading @@ -264,7 +264,8 @@ class PrivacyItemControllerTest : SysuiTestCase() { val list = listOf(PrivacyItem(PrivacyType.TYPE_CAMERA, PrivacyApplication("", TEST_UID, mContext))) privacyItemController.privacyList = list assertEquals(list, privacyItemController.privacyList) assertTrue(list !== privacyItemController.privacyList) val privacyList = privacyItemController.privacyList assertEquals(list, privacyList) assertTrue(list !== privacyList) } } No newline at end of file Loading
packages/SystemUI/src/com/android/systemui/privacy/PrivacyItemController.kt +7 −3 Original line number Diff line number Diff line Loading @@ -61,7 +61,8 @@ class PrivacyItemController @Inject constructor( @VisibleForTesting internal var privacyList = emptyList<PrivacyItem>() get() = field.toList() // Provides a shallow copy of the list @Synchronized get() = field.toList() // Returns a shallow copy of the list @Synchronized set private val userManager = context.getSystemService(UserManager::class.java) private var currentUserIds = emptyList<Int>() Loading @@ -71,7 +72,8 @@ class PrivacyItemController @Inject constructor( private val callbacks = mutableListOf<WeakReference<Callback>>() private val notifyChanges = Runnable { callbacks.forEach { it.get()?.privacyChanged(privacyList) } val list = privacyList callbacks.forEach { it.get()?.privacyChanged(list) } } private val updateListAndNotifyChanges = Runnable { Loading Loading @@ -157,8 +159,10 @@ class PrivacyItemController @Inject constructor( } private fun updatePrivacyList() { privacyList = currentUserIds.flatMap { appOpsController.getActiveAppOpsForUser(it) } val list = currentUserIds.flatMap { appOpsController.getActiveAppOpsForUser(it) } .mapNotNull { toPrivacyItem(it) }.distinct() privacyList = list } private fun toPrivacyItem(appOpItem: AppOpItem): PrivacyItem? { Loading
packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyItemControllerTest.kt +3 −2 Original line number Diff line number Diff line Loading @@ -264,7 +264,8 @@ class PrivacyItemControllerTest : SysuiTestCase() { val list = listOf(PrivacyItem(PrivacyType.TYPE_CAMERA, PrivacyApplication("", TEST_UID, mContext))) privacyItemController.privacyList = list assertEquals(list, privacyItemController.privacyList) assertTrue(list !== privacyItemController.privacyList) val privacyList = privacyItemController.privacyList assertEquals(list, privacyList) assertTrue(list !== privacyList) } } No newline at end of file