Merge "Add indicator logging for privacy dialog." into sc-qpr1-dev am: 5710ed9330
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15742005 Change-Id: I2046793b89e96df9dc26050b8b1e000f3e8fc99b
This commit is contained in:
@@ -29,6 +29,7 @@ import android.util.Log
|
||||
import androidx.annotation.MainThread
|
||||
import androidx.annotation.VisibleForTesting
|
||||
import androidx.annotation.WorkerThread
|
||||
import com.android.internal.logging.UiEventLogger
|
||||
import com.android.systemui.appops.AppOpsController
|
||||
import com.android.systemui.dagger.SysUISingleton
|
||||
import com.android.systemui.dagger.qualifiers.Background
|
||||
@@ -67,6 +68,7 @@ class PrivacyDialogController(
|
||||
private val privacyLogger: PrivacyLogger,
|
||||
private val keyguardStateController: KeyguardStateController,
|
||||
private val appOpsController: AppOpsController,
|
||||
private val uiEventLogger: UiEventLogger,
|
||||
@VisibleForTesting private val dialogProvider: DialogProvider
|
||||
) {
|
||||
|
||||
@@ -81,7 +83,8 @@ class PrivacyDialogController(
|
||||
@Main uiExecutor: Executor,
|
||||
privacyLogger: PrivacyLogger,
|
||||
keyguardStateController: KeyguardStateController,
|
||||
appOpsController: AppOpsController
|
||||
appOpsController: AppOpsController,
|
||||
uiEventLogger: UiEventLogger
|
||||
) : this(
|
||||
permissionManager,
|
||||
packageManager,
|
||||
@@ -93,6 +96,7 @@ class PrivacyDialogController(
|
||||
privacyLogger,
|
||||
keyguardStateController,
|
||||
appOpsController,
|
||||
uiEventLogger,
|
||||
defaultDialogProvider
|
||||
)
|
||||
|
||||
@@ -105,6 +109,7 @@ class PrivacyDialogController(
|
||||
private val onDialogDismissed = object : PrivacyDialog.OnDialogDismissed {
|
||||
override fun onDialogDismissed() {
|
||||
privacyLogger.logPrivacyDialogDismissed()
|
||||
uiEventLogger.log(PrivacyDialogEvent.PRIVACY_DIALOG_DISMISSED)
|
||||
dialog = null
|
||||
}
|
||||
}
|
||||
@@ -114,6 +119,8 @@ class PrivacyDialogController(
|
||||
val intent = Intent(Intent.ACTION_MANAGE_APP_PERMISSIONS)
|
||||
intent.putExtra(Intent.EXTRA_PACKAGE_NAME, packageName)
|
||||
intent.putExtra(Intent.EXTRA_USER, UserHandle.of(userId))
|
||||
uiEventLogger.log(PrivacyDialogEvent.PRIVACY_DIALOG_ITEM_CLICKED_TO_APP_SETTINGS,
|
||||
userId, packageName)
|
||||
privacyLogger.logStartSettingsActivityFromDialog(packageName, userId)
|
||||
if (!keyguardStateController.isUnlocked) {
|
||||
// If we are locked, hide the dialog so the user can unlock
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.privacy
|
||||
|
||||
import com.android.internal.logging.UiEvent
|
||||
import com.android.internal.logging.UiEventLogger
|
||||
|
||||
enum class PrivacyDialogEvent(private val _id: Int) : UiEventLogger.UiEventEnum {
|
||||
@UiEvent(doc = "Privacy dialog is clicked by user to go to the app settings page.")
|
||||
PRIVACY_DIALOG_ITEM_CLICKED_TO_APP_SETTINGS(904),
|
||||
|
||||
@UiEvent(doc = "Privacy dialog is dismissed by user.")
|
||||
PRIVACY_DIALOG_DISMISSED(905);
|
||||
|
||||
override fun getId() = _id
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import android.permission.PermGroupUsage
|
||||
import android.permission.PermissionManager
|
||||
import android.testing.AndroidTestingRunner
|
||||
import androidx.test.filters.SmallTest
|
||||
import com.android.internal.logging.UiEventLogger
|
||||
import com.android.systemui.SysuiTestCase
|
||||
import com.android.systemui.appops.AppOpsController
|
||||
import com.android.systemui.plugins.ActivityStarter
|
||||
@@ -54,6 +55,7 @@ import org.mockito.Mockito.`when`
|
||||
import org.mockito.Mockito.atLeastOnce
|
||||
import org.mockito.Mockito.mock
|
||||
import org.mockito.Mockito.never
|
||||
import org.mockito.Mockito.times
|
||||
import org.mockito.Mockito.verify
|
||||
import org.mockito.MockitoAnnotations
|
||||
|
||||
@@ -97,6 +99,8 @@ class PrivacyDialogControllerTest : SysuiTestCase() {
|
||||
private lateinit var activityStartedCaptor: ArgumentCaptor<ActivityStarter.Callback>
|
||||
@Captor
|
||||
private lateinit var intentCaptor: ArgumentCaptor<Intent>
|
||||
@Mock
|
||||
private lateinit var uiEventLogger: UiEventLogger
|
||||
|
||||
private val backgroundExecutor = FakeExecutor(FakeSystemClock())
|
||||
private val uiExecutor = FakeExecutor(FakeSystemClock())
|
||||
@@ -137,6 +141,7 @@ class PrivacyDialogControllerTest : SysuiTestCase() {
|
||||
privacyLogger,
|
||||
keyguardStateController,
|
||||
appOpsController,
|
||||
uiEventLogger,
|
||||
dialogProvider
|
||||
)
|
||||
}
|
||||
@@ -566,6 +571,34 @@ class PrivacyDialogControllerTest : SysuiTestCase() {
|
||||
verify(dialog).show()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testStartActivityLogs() {
|
||||
val usage = createMockPermGroupUsage()
|
||||
`when`(permissionManager.getIndicatorAppOpUsageData(anyBoolean())).thenReturn(listOf(usage))
|
||||
controller.showDialog(context)
|
||||
exhaustExecutors()
|
||||
|
||||
dialogProvider.starter?.invoke(TEST_PACKAGE_NAME, USER_ID)
|
||||
verify(uiEventLogger).log(PrivacyDialogEvent.PRIVACY_DIALOG_ITEM_CLICKED_TO_APP_SETTINGS,
|
||||
USER_ID, TEST_PACKAGE_NAME)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDismissedDialogLogs() {
|
||||
val usage = createMockPermGroupUsage()
|
||||
`when`(permissionManager.getIndicatorAppOpUsageData(anyBoolean())).thenReturn(listOf(usage))
|
||||
controller.showDialog(context)
|
||||
exhaustExecutors()
|
||||
|
||||
verify(dialog).addOnDismissListener(capture(dialogDismissedCaptor))
|
||||
|
||||
dialogDismissedCaptor.value.onDialogDismissed()
|
||||
|
||||
controller.dismissDialog()
|
||||
|
||||
verify(uiEventLogger, times(1)).log(PrivacyDialogEvent.PRIVACY_DIALOG_DISMISSED)
|
||||
}
|
||||
|
||||
private fun exhaustExecutors() {
|
||||
FakeExecutor.exhaustExecutors(backgroundExecutor, uiExecutor)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user