diff options
author | 2024-02-21 10:47:12 +0000 | |
---|---|---|
committer | 2024-05-01 06:31:45 +0000 | |
commit | 2f2af05a3e7197f78d8b48c6ba8c89bf1b1dc139 (patch) | |
tree | 44d942f7b1a5fb54da045040465a9e0c585a87a6 | |
parent | 97edda89554c47d487af108dfc6a80592d23e9de (diff) |
Add/Modify log metrics for generalised PhotoPicker
Added new UIEvent logs in `PhotoPickerUiEventLogger` class for
generalised photopicker. All profiles other than personal and work, will
be visible as unknown profiles on log metrics dashboard.
Bug: b/318339948
Test: `make statsd_testdrive
$ANDROID_HOST_OUT/bin/statsd_testdrive -terse -one 90 260 > logfile.txt`
Merged-In: Ifc5f0d437eba4f5c7180f353a3ede6548985604e
Change-Id: Ifc5f0d437eba4f5c7180f353a3ede6548985604e
(cherry picked from commit 5127ad3f1f1015338b47851c9cafd41c0810c3f8)
Merged-In: Ifc5f0d437eba4f5c7180f353a3ede6548985604e
3 files changed, 134 insertions, 6 deletions
diff --git a/src/com/android/providers/media/photopicker/metrics/PhotoPickerUiEventLogger.java b/src/com/android/providers/media/photopicker/metrics/PhotoPickerUiEventLogger.java index e127e0599..6e2158dca 100644 --- a/src/com/android/providers/media/photopicker/metrics/PhotoPickerUiEventLogger.java +++ b/src/com/android/providers/media/photopicker/metrics/PhotoPickerUiEventLogger.java @@ -32,6 +32,8 @@ public class PhotoPickerUiEventLogger { PHOTO_PICKER_OPEN_PERSONAL_PROFILE(942), @UiEvent(doc = "Photo picker opened in work profile") PHOTO_PICKER_OPEN_WORK_PROFILE(943), + @UiEvent(doc = "Photo picker opened in unknown profile") + PHOTO_PICKER_OPEN_UNKNOWN_PROFILE(1691), @UiEvent(doc = "Photo picker opened via GET_CONTENT intent") PHOTO_PICKER_OPEN_GET_CONTENT(1080), @UiEvent(doc = "Photo picker opened in half screen") @@ -54,10 +56,14 @@ public class PhotoPickerUiEventLogger { PHOTO_PICKER_CANCEL_WORK_PROFILE(1125), @UiEvent(doc = "Photo picker cancelled in personal profile") PHOTO_PICKER_CANCEL_PERSONAL_PROFILE(1126), + @UiEvent(doc = "Photo picker cancelled in unknown profile") + PHOTO_PICKER_CANCEL_UNKNOWN_PROFILE(1692), @UiEvent(doc = "Confirmed selection in Photo picker in work profile") PHOTO_PICKER_CONFIRM_WORK_PROFILE(1127), @UiEvent(doc = "Confirmed selection in Photo picker in personal profile") PHOTO_PICKER_CONFIRM_PERSONAL_PROFILE(1128), + @UiEvent(doc = "Confirmed selection in Photo picker in unknown profile") + PHOTO_PICKER_CONFIRM_UNKNOWN_PROFILE(1693), @UiEvent(doc = "Photo picker opened with an active cloud provider") PHOTO_PICKER_CLOUD_PROVIDER_ACTIVE(1198), @UiEvent(doc = "Clicked the mute / unmute button in a photo picker video preview") @@ -66,10 +72,15 @@ public class PhotoPickerUiEventLogger { PHOTO_PICKER_PREVIEW_ALL_SELECTED(1414), @UiEvent(doc = "Photo picker opened with the 'switch profile' button visible and enabled") PHOTO_PICKER_PROFILE_SWITCH_BUTTON_ENABLED(1415), + @UiEvent(doc = "Photo picker opened with the 'switch profile menu' button visible") + PHOTO_PICKER_PROFILE_SWITCH_MENU_BUTTON_VISIBLE(1694), @UiEvent(doc = "Photo picker opened with the 'switch profile' button visible but disabled") PHOTO_PICKER_PROFILE_SWITCH_BUTTON_DISABLED(1416), + @UiEvent(doc = "Clicked the 'switch profile' button in photo picker") PHOTO_PICKER_PROFILE_SWITCH_BUTTON_CLICK(1417), + @UiEvent(doc = "Clicked the 'switch profile menu' button in photo picker") + PHOTO_PICKER_PROFILE_SWITCH_MENU_BUTTON_CLICK(1695), @UiEvent(doc = "Exited photo picker by swiping down") PHOTO_PICKER_EXIT_SWIPE_DOWN(1420), @UiEvent(doc = "Back pressed in photo picker") @@ -172,6 +183,21 @@ public class PhotoPickerUiEventLogger { instanceId); } + /** + * Log metrics to notify that the picker has opened in unknown profile + * @param instanceId an identifier for the current picker session + * @param callingUid the uid of the app initiating the picker launch + * @param callingPackage the package name of the app initiating the picker launch + */ + public void logPickerOpenUnknown(InstanceId instanceId, int callingUid, + String callingPackage) { + logger.logWithInstanceId( + PhotoPickerEvent.PHOTO_PICKER_OPEN_UNKNOWN_PROFILE, + callingUid, + callingPackage, + instanceId); + } + public void logPickerOpenViaGetContent(InstanceId instanceId, int callingUid, String callingPackage) { logger.logWithInstanceId( @@ -327,6 +353,19 @@ public class PhotoPickerUiEventLogger { } /** + * Log metrics to notify that user has confirmed selection in unknown profile + */ + public void logPickerConfirmUnknown(InstanceId instanceId, int callingUid, + String callingPackage, int countOfItemsConfirmed) { + logger.logWithInstanceIdAndPosition( + PhotoPickerEvent.PHOTO_PICKER_CONFIRM_UNKNOWN_PROFILE, + callingUid, + callingPackage, + instanceId, + countOfItemsConfirmed); + } + + /** * Log metrics to notify that user has cancelled picker (without any selection) in personal * profile */ @@ -353,6 +392,19 @@ public class PhotoPickerUiEventLogger { } /** + * Log metrics to notify that user has cancelled picker (without any selection) in unknown + * profile + */ + public void logPickerCancelUnknown(InstanceId instanceId, int callingUid, + String callingPackage) { + logger.logWithInstanceId( + PhotoPickerEvent.PHOTO_PICKER_CANCEL_UNKNOWN_PROFILE, + callingUid, + callingPackage, + instanceId); + } + + /** * Log metrics to notify that the picker has opened with an active cloud provider * @param instanceId an identifier for the current picker session * @param cloudProviderUid the uid of the cloud provider app @@ -394,6 +446,15 @@ public class PhotoPickerUiEventLogger { } /** + * Log metrics to notify that the 'switch profile menu' button is visible + * @param instanceId an identifier for the current picker session + */ + public void logProfileSwitchMenuButtonVisible(InstanceId instanceId) { + logWithInstance( + PhotoPickerEvent.PHOTO_PICKER_PROFILE_SWITCH_MENU_BUTTON_VISIBLE, instanceId); + } + + /** * Log metrics to notify that the 'switch profile' button is visible but disabled * @param instanceId an identifier for the current picker session */ @@ -410,6 +471,14 @@ public class PhotoPickerUiEventLogger { } /** + * Log metrics to notify that the user has clicked the 'switch profile menu' button + * @param instanceId an identifier for the current picker session + */ + public void logProfileSwitchMenuButtonClick(InstanceId instanceId) { + logWithInstance(PhotoPickerEvent.PHOTO_PICKER_PROFILE_SWITCH_MENU_BUTTON_CLICK, instanceId); + } + + /** * Log metrics to notify that the user has cancelled the current session by swiping down * @param instanceId an identifier for the current picker session */ diff --git a/src/com/android/providers/media/photopicker/ui/TabFragment.java b/src/com/android/providers/media/photopicker/ui/TabFragment.java index 151d1455c..4a51b26b4 100644 --- a/src/com/android/providers/media/photopicker/ui/TabFragment.java +++ b/src/com/android/providers/media/photopicker/ui/TabFragment.java @@ -347,7 +347,20 @@ public abstract class TabFragment extends Fragment { if (crossProfileAllowed != null) { crossProfileAllowed.observe(this, crossProfileAllowedStatus -> { setUpProfileButtonAndProfileMenuButton(); - // Todo(b/318339948): need to put log metrics like present above; + if (mIsProfileButtonVisible) { + boolean isDisabled = true; + UserId userIdToSwitch = getUserToSwitchFromProfileButton(); + if (userIdToSwitch != null) { + isDisabled = !canSwitchToUser(userIdToSwitch); + } + if (isDisabled) { + mPickerViewModel.logProfileSwitchButtonDisabled(); + } else { + mPickerViewModel.logProfileSwitchButtonEnabled(); + } + } else if (mIsProfileMenuButtonVisible) { + mPickerViewModel.logProfileSwitchMenuButtonVisible(); + } }); } @@ -508,6 +521,7 @@ public abstract class TabFragment extends Fragment { @RequiresApi(Build.VERSION_CODES.S) private void onClickProfileMenuButton(View view) { + mPickerViewModel.logProfileSwitchMenuButtonClick(); initialiseProfileMenuWindow(); View profileMenuView = LayoutInflater.from(requireContext()).inflate( R.layout.profile_menu_layout, null); @@ -717,8 +731,7 @@ public abstract class TabFragment extends Fragment { @RequiresApi(Build.VERSION_CODES.S) private void onClickProfileButtonGeneric() { - // todo add logs like above - + mPickerViewModel.logProfileSwitchButtonClick(); UserId userIdToSwitch = getUserToSwitchFromProfileButton(); if (userIdToSwitch != null) { if (canSwitchToUser(userIdToSwitch)) { diff --git a/src/com/android/providers/media/photopicker/viewmodel/PickerViewModel.java b/src/com/android/providers/media/photopicker/viewmodel/PickerViewModel.java index 588d31cb8..e4bc122d5 100644 --- a/src/com/android/providers/media/photopicker/viewmodel/PickerViewModel.java +++ b/src/com/android/providers/media/photopicker/viewmodel/PickerViewModel.java @@ -39,6 +39,7 @@ import static com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_ import static com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_EXPANDED; import android.annotation.SuppressLint; +import android.app.ActivityManager; import android.app.Application; import android.content.ContentResolver; import android.content.Context; @@ -1183,9 +1184,19 @@ public class PickerViewModel extends AndroidViewModel { */ public void logPickerOpened(int callingUid, String callingPackage, String intentAction) { if (mConfigStore.isPrivateSpaceInPhotoPickerEnabled() && SdkLevel.isAtLeastS()) { + UserManagerState userManagerState = getUserManagerState(); + if (userManagerState.getCurrentUserProfileId().getIdentifier() + == ActivityManager.getCurrentUser()) { + mLogger.logPickerOpenPersonal(mInstanceId, callingUid, callingPackage); + } else if (userManagerState.isManagedUserProfile( + userManagerState.getCurrentUserProfileId())) { + mLogger.logPickerOpenWork(mInstanceId, callingUid, callingPackage); + } else { + mLogger.logPickerOpenUnknown(mInstanceId, callingUid, callingPackage); + } return; } - //Todo(b/318614654): need to refactor + if (getUserIdManager().isManagedUserSelected()) { mLogger.logPickerOpenWork(mInstanceId, callingUid, callingPackage); } else { @@ -1280,9 +1291,21 @@ public class PickerViewModel extends AndroidViewModel { */ public void logPickerConfirm(int callingUid, String callingPackage, int countOfItemsConfirmed) { if (mConfigStore.isPrivateSpaceInPhotoPickerEnabled() && SdkLevel.isAtLeastS()) { + UserManagerState userManagerState = getUserManagerState(); + if (userManagerState.getCurrentUserProfileId().getIdentifier() + == ActivityManager.getCurrentUser()) { + mLogger.logPickerConfirmPersonal(mInstanceId, callingUid, callingPackage, + countOfItemsConfirmed); + } else if (userManagerState.isManagedUserProfile( + userManagerState.getCurrentUserProfileId())) { + mLogger.logPickerConfirmWork(mInstanceId, callingUid, callingPackage, + countOfItemsConfirmed); + } else { + mLogger.logPickerConfirmUnknown( + mInstanceId, callingUid, callingPackage, countOfItemsConfirmed); + } return; } - //Todo(b/318614654): need to refactor if (getUserIdManager().isManagedUserSelected()) { mLogger.logPickerConfirmWork(mInstanceId, callingUid, callingPackage, countOfItemsConfirmed); @@ -1297,9 +1320,18 @@ public class PickerViewModel extends AndroidViewModel { */ public void logPickerCancel(int callingUid, String callingPackage) { if (mConfigStore.isPrivateSpaceInPhotoPickerEnabled() && SdkLevel.isAtLeastS()) { + UserManagerState userManagerState = getUserManagerState(); + if (userManagerState.getCurrentUserProfileId().getIdentifier() + == ActivityManager.getCurrentUser()) { + mLogger.logPickerCancelPersonal(mInstanceId, callingUid, callingPackage); + } else if (userManagerState.isManagedUserProfile( + userManagerState.getCurrentUserProfileId())) { + mLogger.logPickerCancelWork(mInstanceId, callingUid, callingPackage); + } else { + mLogger.logPickerCancelUnknown(mInstanceId, callingUid, callingPackage); + } return; } - //Todo(b/318614654): need to refactor if (getUserIdManager().isManagedUserSelected()) { mLogger.logPickerCancelWork(mInstanceId, callingUid, callingPackage); } else { @@ -1338,6 +1370,13 @@ public class PickerViewModel extends AndroidViewModel { } /** + * Log metrics to notify that the 'switch profile menu' button is visible + */ + public void logProfileSwitchMenuButtonVisible() { + mLogger.logProfileSwitchMenuButtonVisible(mInstanceId); + } + + /** * Log metrics to notify that the user has clicked the 'switch profile' button */ public void logProfileSwitchButtonClick() { @@ -1345,6 +1384,13 @@ public class PickerViewModel extends AndroidViewModel { } /** + * Log metrics to notify that the user has clicked the 'switch profile menu ' button + */ + public void logProfileSwitchMenuButtonClick() { + mLogger.logProfileSwitchMenuButtonClick(mInstanceId); + } + + /** * Log metrics to notify that the user has cancelled the current session by swiping down */ public void logSwipeDownExit() { |