Merge "Improve log of paused items in PrivacyItemController" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
c9b449e79d
@@ -179,12 +179,16 @@ class PrivacyDialogController(
|
||||
}
|
||||
uiExecutor.execute {
|
||||
val elements = filterAndSelect(items)
|
||||
val d = dialogProvider.makeDialog(context, elements, this::startActivity)
|
||||
d.setShowForAllUsers(true)
|
||||
d.addOnDismissListener(onDialogDismissed)
|
||||
d.show()
|
||||
privacyLogger.logShowDialogContents(elements)
|
||||
dialog = d
|
||||
if (elements.isNotEmpty()) {
|
||||
val d = dialogProvider.makeDialog(context, elements, this::startActivity)
|
||||
d.setShowForAllUsers(true)
|
||||
d.addOnDismissListener(onDialogDismissed)
|
||||
d.show()
|
||||
privacyLogger.logShowDialogContents(elements)
|
||||
dialog = d
|
||||
} else {
|
||||
Log.w(TAG, "Trying to show empty dialog")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ data class PrivacyItem(
|
||||
val paused: Boolean = false
|
||||
) {
|
||||
val log = "(${privacyType.logName}, ${application.packageName}(${application.uid}), " +
|
||||
"$timeStampElapsed)"
|
||||
"$timeStampElapsed, paused=$paused)"
|
||||
}
|
||||
|
||||
data class PrivacyApplication(val packageName: String, val uid: Int)
|
||||
|
||||
@@ -116,6 +116,12 @@ class PrivacyLogger @Inject constructor(
|
||||
})
|
||||
}
|
||||
|
||||
fun logEmptyDialog() {
|
||||
log(LogLevel.WARNING, {}, {
|
||||
"Trying to show an empty dialog"
|
||||
})
|
||||
}
|
||||
|
||||
fun logPrivacyDialogDismissed() {
|
||||
log(LogLevel.INFO, {}, {
|
||||
"Privacy dialog dismissed"
|
||||
|
||||
@@ -179,14 +179,27 @@ class PrivacyDialogControllerTest : SysuiTestCase() {
|
||||
|
||||
@Test
|
||||
fun testShowDialogShowsDialog() {
|
||||
val usage = createMockPermGroupUsage()
|
||||
`when`(permissionManager.getIndicatorAppOpUsageData(anyBoolean())).thenReturn(listOf(usage))
|
||||
|
||||
controller.showDialog(context)
|
||||
exhaustExecutors()
|
||||
|
||||
verify(dialog).show()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDontShowEmptyDialog() {
|
||||
controller.showDialog(context)
|
||||
exhaustExecutors()
|
||||
|
||||
verify(dialog, never()).show()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testHideDialogDismissesDialogIfShown() {
|
||||
val usage = createMockPermGroupUsage()
|
||||
`when`(permissionManager.getIndicatorAppOpUsageData(anyBoolean())).thenReturn(listOf(usage))
|
||||
controller.showDialog(context)
|
||||
exhaustExecutors()
|
||||
|
||||
@@ -202,6 +215,8 @@ class PrivacyDialogControllerTest : SysuiTestCase() {
|
||||
|
||||
@Test
|
||||
fun testHideDialogNoopAfterDismissed() {
|
||||
val usage = createMockPermGroupUsage()
|
||||
`when`(permissionManager.getIndicatorAppOpUsageData(anyBoolean())).thenReturn(listOf(usage))
|
||||
controller.showDialog(context)
|
||||
exhaustExecutors()
|
||||
|
||||
@@ -214,6 +229,8 @@ class PrivacyDialogControllerTest : SysuiTestCase() {
|
||||
|
||||
@Test
|
||||
fun testShowForAllUsers() {
|
||||
val usage = createMockPermGroupUsage()
|
||||
`when`(permissionManager.getIndicatorAppOpUsageData(anyBoolean())).thenReturn(listOf(usage))
|
||||
controller.showDialog(context)
|
||||
|
||||
exhaustExecutors()
|
||||
@@ -439,7 +456,7 @@ class PrivacyDialogControllerTest : SysuiTestCase() {
|
||||
controller.showDialog(context)
|
||||
exhaustExecutors()
|
||||
|
||||
assertThat(dialogProvider.list).isEmpty()
|
||||
verify(dialog, never()).show()
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -467,11 +484,13 @@ class PrivacyDialogControllerTest : SysuiTestCase() {
|
||||
controller.showDialog(context)
|
||||
exhaustExecutors()
|
||||
|
||||
assertThat(dialogProvider.list).isEmpty()
|
||||
verify(dialog, never()).show()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testStartActivityCorrectIntent() {
|
||||
val usage = createMockPermGroupUsage()
|
||||
`when`(permissionManager.getIndicatorAppOpUsageData(anyBoolean())).thenReturn(listOf(usage))
|
||||
controller.showDialog(context)
|
||||
exhaustExecutors()
|
||||
|
||||
@@ -488,6 +507,8 @@ class PrivacyDialogControllerTest : SysuiTestCase() {
|
||||
|
||||
@Test
|
||||
fun testStartActivityCorrectIntent_enterpriseUser() {
|
||||
val usage = createMockPermGroupUsage()
|
||||
`when`(permissionManager.getIndicatorAppOpUsageData(anyBoolean())).thenReturn(listOf(usage))
|
||||
controller.showDialog(context)
|
||||
exhaustExecutors()
|
||||
|
||||
@@ -501,6 +522,8 @@ class PrivacyDialogControllerTest : SysuiTestCase() {
|
||||
|
||||
@Test
|
||||
fun testStartActivitySuccess() {
|
||||
val usage = createMockPermGroupUsage()
|
||||
`when`(permissionManager.getIndicatorAppOpUsageData(anyBoolean())).thenReturn(listOf(usage))
|
||||
controller.showDialog(context)
|
||||
exhaustExecutors()
|
||||
|
||||
@@ -514,6 +537,8 @@ class PrivacyDialogControllerTest : SysuiTestCase() {
|
||||
|
||||
@Test
|
||||
fun testStartActivityFailure() {
|
||||
val usage = createMockPermGroupUsage()
|
||||
`when`(permissionManager.getIndicatorAppOpUsageData(anyBoolean())).thenReturn(listOf(usage))
|
||||
controller.showDialog(context)
|
||||
exhaustExecutors()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user