1 /* 2 * Copyright (C) 2017 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 package com.android.wallpaper.module; 17 18 import static android.stats.style.StyleEnums.EFFECT_APPLIED_OFF; 19 import static android.stats.style.StyleEnums.EFFECT_APPLIED_ON_FAILED; 20 import static android.stats.style.StyleEnums.EFFECT_APPLIED_ON_SUCCESS; 21 import static android.stats.style.StyleEnums.EFFECT_PREFERENCE_UNSPECIFIED; 22 23 import android.content.Intent; 24 25 import androidx.annotation.IntDef; 26 27 /** 28 * Interface for logging user events in the wallpaper picker. 29 */ 30 public interface UserEventLogger { 31 32 int ROTATION_STATUS_NOT_ATTEMPTED = 0; 33 int ROTATION_STATUS_FAILED = 5; 34 35 int WALLPAPER_SET_RESULT_SUCCESS = 0; 36 int WALLPAPER_SET_RESULT_FAILURE = 1; 37 int DAILY_WALLPAPER_UPDATE_RESULT_SUCCESS = 0; 38 int DAILY_WALLPAPER_UPDATE_RESULT_FAILURE_LOAD_METADATA = 1; 39 int DAILY_WALLPAPER_UPDATE_RESULT_FAILURE_LOAD_BITMAP = 2; 40 int DAILY_WALLPAPER_UPDATE_RESULT_FAILURE_SET_WALLPAPER = 3; 41 int DAILY_WALLPAPER_UPDATE_RESULT_FAILURE_CRASH = 4; 42 int WALLPAPER_SET_FAILURE_REASON_OTHER = 0; 43 int WALLPAPER_SET_FAILURE_REASON_OOM = 1; 44 int DAILY_WALLPAPER_UPDATE_CRASH_GENERIC = 0; 45 int DAILY_WALLPAPER_UPDATE_CRASH_OOM = 1; 46 int DAILY_WALLPAPER_METADATA_FAILURE_UNKNOWN = 0; 47 int DAILY_WALLPAPER_METADATA_FAILURE_NO_CONNECTION = 1; 48 int DAILY_WALLPAPER_METADATA_FAILURE_PARSE_ERROR = 2; 49 int DAILY_WALLPAPER_METADATA_FAILURE_SERVER_ERROR = 3; 50 int DAILY_WALLPAPER_METADATA_FAILURE_TIMEOUT = 4; 51 logResumed(boolean provisioned, boolean wallpaper)52 void logResumed(boolean provisioned, boolean wallpaper); 53 logStopped()54 void logStopped(); 55 logAppLaunched(Intent launchSource)56 void logAppLaunched(Intent launchSource); 57 logDailyRefreshTurnedOn()58 void logDailyRefreshTurnedOn(); 59 logCurrentWallpaperPreviewed()60 void logCurrentWallpaperPreviewed(); 61 logActionClicked(String collectionId, int actionLabelResId)62 void logActionClicked(String collectionId, int actionLabelResId); 63 logIndividualWallpaperSelected(String collectionId)64 void logIndividualWallpaperSelected(String collectionId); 65 logCategorySelected(String collectionId)66 void logCategorySelected(String collectionId); 67 68 /** 69 * Logs the behavior of tapping live wallpaper info page. 70 * 71 * @param collectionId wallpaper category. 72 * @param wallpaperId wallpaper id. 73 */ logLiveWallpaperInfoSelected(String collectionId, String wallpaperId)74 void logLiveWallpaperInfoSelected(String collectionId, String wallpaperId); 75 76 /** 77 * Logs the behavior of tapping live wallpaper customize page. 78 * 79 * @param collectionId wallpaper category. 80 * @param wallpaperId wallpaper id. 81 */ logLiveWallpaperCustomizeSelected(String collectionId, String wallpaperId)82 void logLiveWallpaperCustomizeSelected(String collectionId, String wallpaperId); 83 84 /** 85 * Log current existing snapshot data. 86 */ logSnapshot()87 void logSnapshot(); 88 89 /** 90 * Logs the behavior when applying wallpaper. 91 * 92 * @param collectionId wallpaper category. 93 * @param wallpaperId wallpaper id. 94 * @param effects effects set with wallpaper. 95 */ logWallpaperSet(String collectionId, String wallpaperId, String effects)96 void logWallpaperSet(String collectionId, String wallpaperId, String effects); 97 logWallpaperSetResult(@allpaperSetResult int result)98 void logWallpaperSetResult(@WallpaperSetResult int result); 99 100 /** 101 * Logs that a particular failure to set an individual wallpaper occurred for the given reason. 102 */ logWallpaperSetFailureReason(@allpaperSetFailureReason int reason)103 void logWallpaperSetFailureReason(@WallpaperSetFailureReason int reason); 104 105 /** 106 * Logs the number of daily rotations that occurred in the last week if daily rotation has 107 * been enabled for at least a week. 108 */ logNumDailyWallpaperRotationsInLastWeek()109 void logNumDailyWallpaperRotationsInLastWeek(); 110 111 /** 112 * Logs the number of daily rotations that occurred during the previous day (24 hour period 113 * midnight to midnight) if daily rotation has been enabled at least since midnight yesterday. 114 */ logNumDailyWallpaperRotationsPreviousDay()115 void logNumDailyWallpaperRotationsPreviousDay(); 116 117 /** 118 * Logs given the hour of day that a successful "daily wallpaper" rotation occurred. 119 * 120 * @param hour An hour from 0 to 23. 121 */ logDailyWallpaperRotationHour(int hour)122 void logDailyWallpaperRotationHour(int hour); 123 124 /** 125 * Logs whether the image file for the daily wallpaper "rotating image wallpaper" is successfully 126 * decoded as a bitmap. 127 * 128 * @param decodes Whether the decode succeeded. 129 */ logDailyWallpaperDecodes(boolean decodes)130 void logDailyWallpaperDecodes(boolean decodes); 131 132 /** 133 * Logs the last-known status of daily wallpapers on the device. 134 */ logDailyWallpaperRotationStatus(int status)135 void logDailyWallpaperRotationStatus(int status); 136 137 /** 138 * Logs the result of an operation to update the daily wallpaper. 139 */ logDailyWallpaperSetNextWallpaperResult(@ailyWallpaperUpdateResult int result)140 void logDailyWallpaperSetNextWallpaperResult(@DailyWallpaperUpdateResult int result); 141 142 /** 143 * Logs that a particular crash occurred when trying to set the next wallpaper in a daily 144 * rotation. 145 */ logDailyWallpaperSetNextWallpaperCrash(@ailyWallpaperUpdateCrash int crash)146 void logDailyWallpaperSetNextWallpaperCrash(@DailyWallpaperUpdateCrash int crash); 147 148 /** 149 * Logs that the request for metadata for the next wallpaper in a daily rotation failed for the 150 * given reason. 151 */ logDailyWallpaperMetadataRequestFailure(@ailyWallpaperMetadataFailureReason int reason)152 void logDailyWallpaperMetadataRequestFailure(@DailyWallpaperMetadataFailureReason int reason); 153 154 /** 155 * Logs that the "refresh daily wallpaper" button was clicked. 156 */ logRefreshDailyWallpaperButtonClicked()157 void logRefreshDailyWallpaperButtonClicked(); 158 159 /** 160 * Logs the number of consecutive days that daily rotation was attempted but failed. 161 */ logNumDaysDailyRotationFailed(int days)162 void logNumDaysDailyRotationFailed(int days); 163 164 /** 165 * Logs the number of consecutive days that daily rotation was not attempted but should have been 166 * attempted ("network conditions not met" doesn't count). 167 */ logNumDaysDailyRotationNotAttempted(int days)168 void logNumDaysDailyRotationNotAttempted(int days); 169 170 /** 171 * Logs that the StandalonePreviewActivity was launched. 172 */ logStandalonePreviewLaunched()173 void logStandalonePreviewLaunched(); 174 175 /** 176 * Logs whether the image URI passed to StandalonePreviewActivity came properly preconfigured with 177 * read permissions. 178 */ logStandalonePreviewImageUriHasReadPermission(boolean isReadPermissionGranted)179 void logStandalonePreviewImageUriHasReadPermission(boolean isReadPermissionGranted); 180 181 /** 182 * Logs whether the user approved the runtime dialog to grant this app READ_MEDIA_IMAGES 183 * permission in order to open an image URI. 184 */ logStandalonePreviewStorageDialogApproved(boolean isApproved)185 void logStandalonePreviewStorageDialogApproved(boolean isApproved); 186 187 /** 188 * Logs the presentation mode of the current wallpaper. 189 */ logWallpaperPresentationMode()190 void logWallpaperPresentationMode(); 191 192 /** 193 * Logs that the app was restored from a backup set. 194 */ logRestored()195 void logRestored(); 196 197 /** 198 * Logs the action related to effect. 199 */ logEffectApply(String effect, @EffectStatus int status, long timeElapsedMillis, int resultCode)200 void logEffectApply(String effect, @EffectStatus int status, long timeElapsedMillis, 201 int resultCode); 202 203 /** 204 * Logs the effect probe result. 205 */ logEffectProbe(String effect, @EffectStatus int status)206 void logEffectProbe(String effect, @EffectStatus int status); 207 208 /** 209 * Possible results of a "set wallpaper" operation. 210 */ 211 @IntDef({ 212 WALLPAPER_SET_RESULT_SUCCESS, 213 WALLPAPER_SET_RESULT_FAILURE}) 214 @interface WallpaperSetResult { 215 } 216 217 /** 218 * Possible results of an operation to set the next wallpaper in a daily rotation. 219 */ 220 @IntDef({ 221 DAILY_WALLPAPER_UPDATE_RESULT_SUCCESS, 222 DAILY_WALLPAPER_UPDATE_RESULT_FAILURE_LOAD_METADATA, 223 DAILY_WALLPAPER_UPDATE_RESULT_FAILURE_LOAD_BITMAP, 224 DAILY_WALLPAPER_UPDATE_RESULT_FAILURE_SET_WALLPAPER, 225 DAILY_WALLPAPER_UPDATE_RESULT_FAILURE_CRASH}) 226 @interface DailyWallpaperUpdateResult { 227 } 228 229 /** 230 * Possible reasons setting an individual wallpaper failed. 231 */ 232 @IntDef({ 233 WALLPAPER_SET_FAILURE_REASON_OTHER, 234 WALLPAPER_SET_FAILURE_REASON_OOM}) 235 @interface WallpaperSetFailureReason { 236 } 237 238 /** 239 * Possible crash types of a crashing failed "set next wallpaper" operation when daily rotation 240 * is enabled and trying to set the next wallpaper. 241 */ 242 @IntDef({ 243 DAILY_WALLPAPER_UPDATE_CRASH_GENERIC, 244 DAILY_WALLPAPER_UPDATE_CRASH_OOM}) 245 @interface DailyWallpaperUpdateCrash { 246 } 247 248 /** 249 * Possible reasons for a request for "next wallpaper" metadata in a daily rotation to fail. 250 */ 251 @IntDef({ 252 DAILY_WALLPAPER_METADATA_FAILURE_UNKNOWN, 253 DAILY_WALLPAPER_METADATA_FAILURE_NO_CONNECTION, 254 DAILY_WALLPAPER_METADATA_FAILURE_PARSE_ERROR, 255 DAILY_WALLPAPER_METADATA_FAILURE_SERVER_ERROR, 256 DAILY_WALLPAPER_METADATA_FAILURE_TIMEOUT}) 257 @interface DailyWallpaperMetadataFailureReason { 258 } 259 260 /** 261 * Possible actions for cinematic effect. 262 */ 263 @IntDef({ 264 EFFECT_PREFERENCE_UNSPECIFIED, 265 EFFECT_APPLIED_ON_SUCCESS, 266 EFFECT_APPLIED_ON_FAILED, 267 EFFECT_APPLIED_OFF 268 }) 269 @interface EffectStatus { 270 } 271 } 272