Loading packages/SystemUI/res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -2330,4 +2330,7 @@ </plurals> <!-- Text for the quick setting tile for sensor privacy [CHAR LIMIT=30] --> <string name="sensor_privacy_mode">Sensors off</string> <!-- Name for device services grouping system uid apps in Ongoing Privacy Dialog [CHAR_LIMIT=NONE] --> <string name="device_services">Device Services</string> </resources> packages/SystemUI/src/com/android/systemui/privacy/OngoingPrivacyDialog.kt +2 −2 Original line number Diff line number Diff line Loading @@ -106,12 +106,12 @@ class OngoingPrivacyDialog constructor( val appName = item.findViewById(R.id.app_name) as TextView val icons = item.findViewById(R.id.icons) as LinearLayout var lp = LinearLayout.LayoutParams(iconSize, iconSize).apply { val lp = LinearLayout.LayoutParams(iconSize, iconSize).apply { gravity = Gravity.CENTER_VERTICAL marginStart = iconMargin } app.icon?.let { app.icon.let { appIcon.setImageDrawable(it) } Loading packages/SystemUI/src/com/android/systemui/privacy/PrivacyItem.kt +1 −1 Original line number Diff line number Diff line Loading @@ -44,7 +44,7 @@ data class PrivacyApplication(val packageName: String, val context: Context) return applicationName.compareTo(other.applicationName) } var icon: Drawable? = null var icon: Drawable = context.getDrawable(android.R.drawable.sym_def_app_icon) var applicationName: String init { Loading packages/SystemUI/src/com/android/systemui/privacy/PrivacyItemController.kt +5 −1 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import com.android.internal.annotations.VisibleForTesting import com.android.systemui.Dependency import com.android.systemui.appops.AppOpItem import com.android.systemui.appops.AppOpsController import com.android.systemui.R class PrivacyItemController(val context: Context, val callback: Callback) { Loading @@ -41,15 +42,17 @@ class PrivacyItemController(val context: Context, val callback: Callback) { Intent.ACTION_MANAGED_PROFILE_ADDED, Intent.ACTION_MANAGED_PROFILE_REMOVED) const val TAG = "PrivacyItemController" const val SYSTEM_UID = 1000 } private var privacyList = emptyList<PrivacyItem>() private val appOpsController = Dependency.get(AppOpsController::class.java) private val userManager = context.getSystemService(UserManager::class.java) private var currentUserIds = emptyList<Int>() private val bgHandler = Handler(Dependency.get(Dependency.BG_LOOPER)) private val uiHandler = Dependency.get(Dependency.MAIN_HANDLER) private var listening = false val systemApp = PrivacyApplication(context.getString(R.string.device_services), context) private val notifyChanges = Runnable { callback.privacyChanged(privacyList) Loading Loading @@ -126,6 +129,7 @@ class PrivacyItemController(val context: Context, val callback: Callback) { AppOpsManager.OP_RECORD_AUDIO -> PrivacyType.TYPE_MICROPHONE else -> return null } if (appOpItem.uid == SYSTEM_UID) return PrivacyItem(type, systemApp) val app = PrivacyApplication(appOpItem.packageName, context) return PrivacyItem(type, app) } Loading packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyItemControllerTest.kt +21 −2 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.testing.AndroidTestingRunner import android.testing.TestableLooper import android.testing.TestableLooper.RunWithLooper import com.android.systemui.Dependency import com.android.systemui.R import com.android.systemui.SysuiTestCase import com.android.systemui.appops.AppOpItem import com.android.systemui.appops.AppOpsController Loading Loading @@ -56,6 +57,10 @@ class PrivacyItemControllerTest : SysuiTestCase() { companion object { val CURRENT_USER_ID = ActivityManager.getCurrentUser() val TEST_UID = CURRENT_USER_ID * UserHandle.PER_USER_RANGE const val SYSTEM_UID = 1000 const val TEST_PACKAGE_NAME = "test" const val DEVICE_SERVICES_STRING = "Device services" const val TAG = "PrivacyItemControllerTest" fun <T> capture(argumentCaptor: ArgumentCaptor<T>): T = argumentCaptor.capture() } Loading @@ -81,6 +86,8 @@ class PrivacyItemControllerTest : SysuiTestCase() { mDependency.injectTestDependency(Dependency.BG_LOOPER, testableLooper.looper) mDependency.injectTestDependency(Dependency.MAIN_HANDLER, Handler(testableLooper.looper)) mContext.addMockSystemService(UserManager::class.java, userManager) mContext.getOrCreateTestableResources().addOverride(R.string.device_services, DEVICE_SERVICES_STRING) doReturn(listOf(object : UserInfo() { init { Loading Loading @@ -110,8 +117,8 @@ class PrivacyItemControllerTest : SysuiTestCase() { @Test fun testDistinctItems() { doReturn(listOf(AppOpItem(AppOpsManager.OP_CAMERA, CURRENT_USER_ID, "", 0), AppOpItem(AppOpsManager.OP_CAMERA, CURRENT_USER_ID, "", 1))) doReturn(listOf(AppOpItem(AppOpsManager.OP_CAMERA, TEST_UID, "", 0), AppOpItem(AppOpsManager.OP_CAMERA, TEST_UID, "", 1))) .`when`(appOpsController).getActiveAppOpsForUser(anyInt()) privacyItemController.setListening(true) Loading @@ -120,6 +127,18 @@ class PrivacyItemControllerTest : SysuiTestCase() { assertEquals(1, argCaptor.value.size) } @Test fun testSystemApps() { doReturn(listOf(AppOpItem(AppOpsManager.OP_COARSE_LOCATION, SYSTEM_UID, TEST_PACKAGE_NAME, 0))).`when`(appOpsController).getActiveAppOpsForUser(anyInt()) privacyItemController.setListening(true) testableLooper.processAllMessages() verify(callback).privacyChanged(capture(argCaptor)) assertEquals(1, argCaptor.value.size) assertEquals(context.getString(R.string.device_services), argCaptor.value[0].application.applicationName) } @Test fun testRegisterReceiver_allUsers() { val spiedContext = spy(mContext) Loading Loading
packages/SystemUI/res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -2330,4 +2330,7 @@ </plurals> <!-- Text for the quick setting tile for sensor privacy [CHAR LIMIT=30] --> <string name="sensor_privacy_mode">Sensors off</string> <!-- Name for device services grouping system uid apps in Ongoing Privacy Dialog [CHAR_LIMIT=NONE] --> <string name="device_services">Device Services</string> </resources>
packages/SystemUI/src/com/android/systemui/privacy/OngoingPrivacyDialog.kt +2 −2 Original line number Diff line number Diff line Loading @@ -106,12 +106,12 @@ class OngoingPrivacyDialog constructor( val appName = item.findViewById(R.id.app_name) as TextView val icons = item.findViewById(R.id.icons) as LinearLayout var lp = LinearLayout.LayoutParams(iconSize, iconSize).apply { val lp = LinearLayout.LayoutParams(iconSize, iconSize).apply { gravity = Gravity.CENTER_VERTICAL marginStart = iconMargin } app.icon?.let { app.icon.let { appIcon.setImageDrawable(it) } Loading
packages/SystemUI/src/com/android/systemui/privacy/PrivacyItem.kt +1 −1 Original line number Diff line number Diff line Loading @@ -44,7 +44,7 @@ data class PrivacyApplication(val packageName: String, val context: Context) return applicationName.compareTo(other.applicationName) } var icon: Drawable? = null var icon: Drawable = context.getDrawable(android.R.drawable.sym_def_app_icon) var applicationName: String init { Loading
packages/SystemUI/src/com/android/systemui/privacy/PrivacyItemController.kt +5 −1 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import com.android.internal.annotations.VisibleForTesting import com.android.systemui.Dependency import com.android.systemui.appops.AppOpItem import com.android.systemui.appops.AppOpsController import com.android.systemui.R class PrivacyItemController(val context: Context, val callback: Callback) { Loading @@ -41,15 +42,17 @@ class PrivacyItemController(val context: Context, val callback: Callback) { Intent.ACTION_MANAGED_PROFILE_ADDED, Intent.ACTION_MANAGED_PROFILE_REMOVED) const val TAG = "PrivacyItemController" const val SYSTEM_UID = 1000 } private var privacyList = emptyList<PrivacyItem>() private val appOpsController = Dependency.get(AppOpsController::class.java) private val userManager = context.getSystemService(UserManager::class.java) private var currentUserIds = emptyList<Int>() private val bgHandler = Handler(Dependency.get(Dependency.BG_LOOPER)) private val uiHandler = Dependency.get(Dependency.MAIN_HANDLER) private var listening = false val systemApp = PrivacyApplication(context.getString(R.string.device_services), context) private val notifyChanges = Runnable { callback.privacyChanged(privacyList) Loading Loading @@ -126,6 +129,7 @@ class PrivacyItemController(val context: Context, val callback: Callback) { AppOpsManager.OP_RECORD_AUDIO -> PrivacyType.TYPE_MICROPHONE else -> return null } if (appOpItem.uid == SYSTEM_UID) return PrivacyItem(type, systemApp) val app = PrivacyApplication(appOpItem.packageName, context) return PrivacyItem(type, app) } Loading
packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyItemControllerTest.kt +21 −2 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.testing.AndroidTestingRunner import android.testing.TestableLooper import android.testing.TestableLooper.RunWithLooper import com.android.systemui.Dependency import com.android.systemui.R import com.android.systemui.SysuiTestCase import com.android.systemui.appops.AppOpItem import com.android.systemui.appops.AppOpsController Loading Loading @@ -56,6 +57,10 @@ class PrivacyItemControllerTest : SysuiTestCase() { companion object { val CURRENT_USER_ID = ActivityManager.getCurrentUser() val TEST_UID = CURRENT_USER_ID * UserHandle.PER_USER_RANGE const val SYSTEM_UID = 1000 const val TEST_PACKAGE_NAME = "test" const val DEVICE_SERVICES_STRING = "Device services" const val TAG = "PrivacyItemControllerTest" fun <T> capture(argumentCaptor: ArgumentCaptor<T>): T = argumentCaptor.capture() } Loading @@ -81,6 +86,8 @@ class PrivacyItemControllerTest : SysuiTestCase() { mDependency.injectTestDependency(Dependency.BG_LOOPER, testableLooper.looper) mDependency.injectTestDependency(Dependency.MAIN_HANDLER, Handler(testableLooper.looper)) mContext.addMockSystemService(UserManager::class.java, userManager) mContext.getOrCreateTestableResources().addOverride(R.string.device_services, DEVICE_SERVICES_STRING) doReturn(listOf(object : UserInfo() { init { Loading Loading @@ -110,8 +117,8 @@ class PrivacyItemControllerTest : SysuiTestCase() { @Test fun testDistinctItems() { doReturn(listOf(AppOpItem(AppOpsManager.OP_CAMERA, CURRENT_USER_ID, "", 0), AppOpItem(AppOpsManager.OP_CAMERA, CURRENT_USER_ID, "", 1))) doReturn(listOf(AppOpItem(AppOpsManager.OP_CAMERA, TEST_UID, "", 0), AppOpItem(AppOpsManager.OP_CAMERA, TEST_UID, "", 1))) .`when`(appOpsController).getActiveAppOpsForUser(anyInt()) privacyItemController.setListening(true) Loading @@ -120,6 +127,18 @@ class PrivacyItemControllerTest : SysuiTestCase() { assertEquals(1, argCaptor.value.size) } @Test fun testSystemApps() { doReturn(listOf(AppOpItem(AppOpsManager.OP_COARSE_LOCATION, SYSTEM_UID, TEST_PACKAGE_NAME, 0))).`when`(appOpsController).getActiveAppOpsForUser(anyInt()) privacyItemController.setListening(true) testableLooper.processAllMessages() verify(callback).privacyChanged(capture(argCaptor)) assertEquals(1, argCaptor.value.size) assertEquals(context.getString(R.string.device_services), argCaptor.value[0].application.applicationName) } @Test fun testRegisterReceiver_allUsers() { val spiedContext = spy(mContext) Loading