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