Merge "Show privacy dialog on secondary user calls" into sc-qpr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
c8e92727b1
@@ -155,7 +155,7 @@ class PrivacyDialogController(
|
||||
val items = usage.mapNotNull {
|
||||
val type = filterType(permGroupToPrivacyType(it.permGroupName))
|
||||
val userInfo = userInfos.firstOrNull { ui -> ui.id == UserHandle.getUserId(it.uid) }
|
||||
userInfo?.let { ui ->
|
||||
if (userInfo != null || it.isPhoneCall) {
|
||||
type?.let { t ->
|
||||
// Only try to get the app name if we actually need it
|
||||
val appName = if (it.isPhoneCall) {
|
||||
@@ -171,10 +171,14 @@ class PrivacyDialogController(
|
||||
it.attribution,
|
||||
it.lastAccess,
|
||||
it.isActive,
|
||||
ui.isManagedProfile,
|
||||
// If there's no user info, we're in a phoneCall in secondary user
|
||||
userInfo?.isManagedProfile ?: false,
|
||||
it.isPhoneCall
|
||||
)
|
||||
}
|
||||
} else {
|
||||
// No matching user or phone call
|
||||
null
|
||||
}
|
||||
}
|
||||
uiExecutor.execute {
|
||||
|
||||
@@ -22,6 +22,7 @@ import android.content.Intent
|
||||
import android.content.pm.ApplicationInfo
|
||||
import android.content.pm.PackageManager
|
||||
import android.content.pm.UserInfo
|
||||
import android.os.Process.SYSTEM_UID
|
||||
import android.os.UserHandle
|
||||
import android.permission.PermGroupUsage
|
||||
import android.permission.PermissionManager
|
||||
@@ -550,6 +551,21 @@ class PrivacyDialogControllerTest : SysuiTestCase() {
|
||||
verify(dialog, never()).dismiss()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testCallOnSecondaryUser() {
|
||||
// Calls happen in
|
||||
val usage = createMockPermGroupUsage(uid = SYSTEM_UID, isPhoneCall = true)
|
||||
`when`(permissionManager.getIndicatorAppOpUsageData(anyBoolean())).thenReturn(listOf(usage))
|
||||
`when`(userTracker.userProfiles).thenReturn(listOf(
|
||||
UserInfo(ENT_USER_ID, "", 0)
|
||||
))
|
||||
|
||||
controller.showDialog(context)
|
||||
exhaustExecutors()
|
||||
|
||||
verify(dialog).show()
|
||||
}
|
||||
|
||||
private fun exhaustExecutors() {
|
||||
FakeExecutor.exhaustExecutors(backgroundExecutor, uiExecutor)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user