1 /* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.providers.media.photopicker.metrics; 18 19 import com.android.internal.logging.InstanceId; 20 import com.android.internal.logging.UiEvent; 21 import com.android.internal.logging.UiEventLogger; 22 import com.android.providers.media.metrics.MPUiEventLoggerImpl; 23 24 public class PhotoPickerUiEventLogger { 25 26 enum PhotoPickerEvent implements UiEventLogger.UiEventEnum { 27 @UiEvent(doc = "Photo picker opened in personal profile") 28 PHOTO_PICKER_OPEN_PERSONAL_PROFILE(942), 29 @UiEvent(doc = "Photo picker opened in work profile") 30 PHOTO_PICKER_OPEN_WORK_PROFILE(943), 31 @UiEvent(doc = "Photo picker opened via GET_CONTENT intent") 32 PHOTO_PICKER_OPEN_GET_CONTENT(1080), 33 @UiEvent(doc = "Photo picker opened in half screen") 34 PHOTO_PICKER_OPEN_HALF_SCREEN(1166), 35 @UiEvent(doc = "Photo picker opened in full screen") 36 PHOTO_PICKER_OPEN_FULL_SCREEN(1167), 37 @UiEvent(doc = "Photo picker opened in single select mode") 38 PHOTO_PICKER_OPEN_SINGLE_SELECT(1168), 39 @UiEvent(doc = "Photo picker opened in multi select mode") 40 PHOTO_PICKER_OPEN_MULTI_SELECT(1169), 41 @UiEvent(doc = "Photo picker opened with the filter to show all images") 42 PHOTO_PICKER_FILTER_ALL_IMAGES(1170), 43 @UiEvent(doc = "Photo picker opened with the filter to show all videos") 44 PHOTO_PICKER_FILTER_ALL_VIDEOS(1171), 45 @UiEvent(doc = "Photo picker opened with some other specific filter") 46 PHOTO_PICKER_FILTER_OTHER(1172), 47 @UiEvent(doc = "DocumentsUi opened by clicking on Browse in Photo picker") 48 PHOTO_PICKER_BROWSE_DOCUMENTSUI(1085), 49 @UiEvent(doc = "Photo picker cancelled in work profile") 50 PHOTO_PICKER_CANCEL_WORK_PROFILE(1125), 51 @UiEvent(doc = "Photo picker cancelled in personal profile") 52 PHOTO_PICKER_CANCEL_PERSONAL_PROFILE(1126), 53 @UiEvent(doc = "Confirmed selection in Photo picker in work profile") 54 PHOTO_PICKER_CONFIRM_WORK_PROFILE(1127), 55 @UiEvent(doc = "Confirmed selection in Photo picker in personal profile") 56 PHOTO_PICKER_CONFIRM_PERSONAL_PROFILE(1128), 57 @UiEvent(doc = "Photo picker opened with an active cloud provider") 58 PHOTO_PICKER_CLOUD_PROVIDER_ACTIVE(1198), 59 @UiEvent(doc = "User changed the active Photo picker cloud provider") 60 PHOTO_PICKER_CLOUD_PROVIDER_CHANGED(1135), 61 @UiEvent(doc = "Photo Picker uri is queried with an unknown column") 62 PHOTO_PICKER_QUERY_UNKNOWN_COLUMN(1227); 63 64 private final int mId; 65 PhotoPickerEvent(int id)66 PhotoPickerEvent(int id) { 67 mId = id; 68 } 69 70 @Override getId()71 public int getId() { 72 return mId; 73 } 74 } 75 76 private UiEventLogger logger; 77 PhotoPickerUiEventLogger()78 public PhotoPickerUiEventLogger() { 79 logger = new MPUiEventLoggerImpl(); 80 } 81 logPickerOpenPersonal(InstanceId instanceId, int callingUid, String callingPackage)82 public void logPickerOpenPersonal(InstanceId instanceId, int callingUid, 83 String callingPackage) { 84 logger.logWithInstanceId( 85 PhotoPickerEvent.PHOTO_PICKER_OPEN_PERSONAL_PROFILE, 86 callingUid, 87 callingPackage, 88 instanceId); 89 } 90 logPickerOpenWork(InstanceId instanceId, int callingUid, String callingPackage)91 public void logPickerOpenWork(InstanceId instanceId, int callingUid, 92 String callingPackage) { 93 logger.logWithInstanceId( 94 PhotoPickerEvent.PHOTO_PICKER_OPEN_WORK_PROFILE, 95 callingUid, 96 callingPackage, 97 instanceId); 98 } 99 logPickerOpenViaGetContent(InstanceId instanceId, int callingUid, String callingPackage)100 public void logPickerOpenViaGetContent(InstanceId instanceId, int callingUid, 101 String callingPackage) { 102 logger.logWithInstanceId( 103 PhotoPickerEvent.PHOTO_PICKER_OPEN_GET_CONTENT, 104 callingUid, 105 callingPackage, 106 instanceId); 107 } 108 109 /** 110 * Log metrics to notify that the picker has opened in half screen 111 * @param instanceId an identifier for the current picker session 112 * @param callingUid the uid of the app initiating the picker launch 113 * @param callingPackage the package name of the app initiating the picker launch 114 */ logPickerOpenInHalfScreen(InstanceId instanceId, int callingUid, String callingPackage)115 public void logPickerOpenInHalfScreen(InstanceId instanceId, int callingUid, 116 String callingPackage) { 117 logger.logWithInstanceId( 118 PhotoPickerEvent.PHOTO_PICKER_OPEN_HALF_SCREEN, 119 callingUid, 120 callingPackage, 121 instanceId); 122 } 123 124 /** 125 * Log metrics to notify that the picker has opened in full screen 126 * @param instanceId an identifier for the current picker session 127 * @param callingUid the uid of the app initiating the picker launch 128 * @param callingPackage the package name of the app initiating the picker launch 129 */ logPickerOpenInFullScreen(InstanceId instanceId, int callingUid, String callingPackage)130 public void logPickerOpenInFullScreen(InstanceId instanceId, int callingUid, 131 String callingPackage) { 132 logger.logWithInstanceId( 133 PhotoPickerEvent.PHOTO_PICKER_OPEN_FULL_SCREEN, 134 callingUid, 135 callingPackage, 136 instanceId); 137 } 138 139 /** 140 * Log metrics to notify that the picker has opened in single select mode 141 * @param instanceId an identifier for the current picker session 142 * @param callingUid the uid of the app initiating the picker launch 143 * @param callingPackage the package name of the app initiating the picker launch 144 */ logPickerOpenInSingleSelect(InstanceId instanceId, int callingUid, String callingPackage)145 public void logPickerOpenInSingleSelect(InstanceId instanceId, int callingUid, 146 String callingPackage) { 147 logger.logWithInstanceId( 148 PhotoPickerEvent.PHOTO_PICKER_OPEN_SINGLE_SELECT, 149 callingUid, 150 callingPackage, 151 instanceId); 152 } 153 154 /** 155 * Log metrics to notify that the picker has opened in multi select mode 156 * @param instanceId an identifier for the current picker session 157 * @param callingUid the uid of the app initiating the picker launch 158 * @param callingPackage the package name of the app initiating the picker launch 159 */ logPickerOpenInMultiSelect(InstanceId instanceId, int callingUid, String callingPackage)160 public void logPickerOpenInMultiSelect(InstanceId instanceId, int callingUid, 161 String callingPackage) { 162 logger.logWithInstanceId( 163 PhotoPickerEvent.PHOTO_PICKER_OPEN_MULTI_SELECT, 164 callingUid, 165 callingPackage, 166 instanceId); 167 } 168 169 /** 170 * Log metrics to notify that the picker has opened with the filter to show all images 171 * @param instanceId an identifier for the current picker session 172 * @param callingUid the uid of the app initiating the picker launch 173 * @param callingPackage the package name of the app initiating the picker launch 174 */ logPickerOpenWithFilterAllImages(InstanceId instanceId, int callingUid, String callingPackage)175 public void logPickerOpenWithFilterAllImages(InstanceId instanceId, int callingUid, 176 String callingPackage) { 177 logger.logWithInstanceId( 178 PhotoPickerEvent.PHOTO_PICKER_FILTER_ALL_IMAGES, 179 callingUid, 180 callingPackage, 181 instanceId); 182 } 183 184 /** 185 * Log metrics to notify that the picker has opened with the filter to show all videos 186 * @param instanceId an identifier for the current picker session 187 * @param callingUid the uid of the app initiating the picker launch 188 * @param callingPackage the package name of the app initiating the picker launch 189 */ logPickerOpenWithFilterAllVideos(InstanceId instanceId, int callingUid, String callingPackage)190 public void logPickerOpenWithFilterAllVideos(InstanceId instanceId, int callingUid, 191 String callingPackage) { 192 logger.logWithInstanceId( 193 PhotoPickerEvent.PHOTO_PICKER_FILTER_ALL_VIDEOS, 194 callingUid, 195 callingPackage, 196 instanceId); 197 } 198 199 /** 200 * Log metrics to notify that the picker has opened with a specific filter, other than the ones 201 * tracked explicitly 202 * @param instanceId an identifier for the current picker session 203 * @param callingUid the uid of the app initiating the picker launch 204 * @param callingPackage the package name of the app initiating the picker launch 205 */ logPickerOpenWithAnyOtherFilter(InstanceId instanceId, int callingUid, String callingPackage)206 public void logPickerOpenWithAnyOtherFilter(InstanceId instanceId, int callingUid, 207 String callingPackage) { 208 logger.logWithInstanceId( 209 PhotoPickerEvent.PHOTO_PICKER_FILTER_OTHER, 210 callingUid, 211 callingPackage, 212 instanceId); 213 } 214 215 /** 216 * Log metrics to notify that user has clicked on "Browse..." in Photo picker overflow menu. 217 * This UI click even opens DocumentsUi. 218 */ logBrowseToDocumentsUi(InstanceId instanceId, int callingUid, String callingPackage)219 public void logBrowseToDocumentsUi(InstanceId instanceId, int callingUid, 220 String callingPackage) { 221 logger.logWithInstanceId( 222 PhotoPickerEvent.PHOTO_PICKER_BROWSE_DOCUMENTSUI, 223 callingUid, 224 callingPackage, 225 instanceId); 226 } 227 228 /** 229 * Log metrics to notify that user has confirmed selection in personal profile 230 */ logPickerConfirmPersonal(InstanceId instanceId, int callingUid, String callingPackage, int countOfItemsConfirmed)231 public void logPickerConfirmPersonal(InstanceId instanceId, int callingUid, 232 String callingPackage, int countOfItemsConfirmed) { 233 logger.logWithInstanceIdAndPosition( 234 PhotoPickerEvent.PHOTO_PICKER_CONFIRM_PERSONAL_PROFILE, 235 callingUid, 236 callingPackage, 237 instanceId, 238 countOfItemsConfirmed); 239 } 240 241 /** 242 * Log metrics to notify that user has confirmed selection in work profile 243 */ logPickerConfirmWork(InstanceId instanceId, int callingUid, String callingPackage, int countOfItemsConfirmed)244 public void logPickerConfirmWork(InstanceId instanceId, int callingUid, 245 String callingPackage, int countOfItemsConfirmed) { 246 logger.logWithInstanceIdAndPosition( 247 PhotoPickerEvent.PHOTO_PICKER_CONFIRM_WORK_PROFILE, 248 callingUid, 249 callingPackage, 250 instanceId, 251 countOfItemsConfirmed); 252 } 253 254 /** 255 * Log metrics to notify that user has cancelled picker (without any selection) in personal 256 * profile 257 */ logPickerCancelPersonal(InstanceId instanceId, int callingUid, String callingPackage)258 public void logPickerCancelPersonal(InstanceId instanceId, int callingUid, 259 String callingPackage) { 260 logger.logWithInstanceId( 261 PhotoPickerEvent.PHOTO_PICKER_CANCEL_PERSONAL_PROFILE, 262 callingUid, 263 callingPackage, 264 instanceId); 265 } 266 267 /** 268 * Log metrics to notify that user has cancelled picker (without any selection) in work 269 * profile 270 */ logPickerCancelWork(InstanceId instanceId, int callingUid, String callingPackage)271 public void logPickerCancelWork(InstanceId instanceId, int callingUid, 272 String callingPackage) { 273 logger.logWithInstanceId( 274 PhotoPickerEvent.PHOTO_PICKER_CANCEL_WORK_PROFILE, 275 callingUid, 276 callingPackage, 277 instanceId); 278 } 279 280 /** 281 * Log metrics to notify that the picker has opened with an active cloud provider 282 * @param instanceId an identifier for the current picker session 283 * @param cloudProviderUid the uid of the cloud provider app 284 * @param cloudProviderPackage the package name of the cloud provider app 285 */ logPickerOpenWithActiveCloudProvider(InstanceId instanceId, int cloudProviderUid, String cloudProviderPackage)286 public void logPickerOpenWithActiveCloudProvider(InstanceId instanceId, int cloudProviderUid, 287 String cloudProviderPackage) { 288 logger.logWithInstanceId( 289 PhotoPickerEvent.PHOTO_PICKER_CLOUD_PROVIDER_ACTIVE, 290 cloudProviderUid, 291 cloudProviderPackage, 292 instanceId); 293 } 294 295 /** 296 * Log metrics to notify that the user has changed the active cloud provider 297 * @param cloudProviderUid new active cloud provider uid 298 * @param cloudProviderPackage new active cloud provider package name 299 */ logPickerCloudProviderChanged(int cloudProviderUid, String cloudProviderPackage)300 public void logPickerCloudProviderChanged(int cloudProviderUid, String cloudProviderPackage) { 301 logger.log(PhotoPickerEvent.PHOTO_PICKER_CLOUD_PROVIDER_CHANGED, cloudProviderUid, 302 cloudProviderPackage); 303 } 304 305 /** 306 * Log metrics to notify that a picker uri was queried for an unknown column (that is not 307 * supported yet) 308 * @param callingUid the uid of the app initiating the picker query 309 * @param callingPackage the package name of the app initiating the picker query 310 * 311 * TODO(b/251425380): Move non-UI events out of PhotoPickerUiEventLogger 312 */ logPickerQueriedWithUnknownColumn(int callingUid, String callingPackage)313 public void logPickerQueriedWithUnknownColumn(int callingUid, String callingPackage) { 314 logger.log(PhotoPickerEvent.PHOTO_PICKER_QUERY_UNKNOWN_COLUMN, 315 callingUid, 316 callingPackage); 317 } 318 } 319