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