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 logWallpaperSet(String collectionId, String wallpaperId)63 void logWallpaperSet(String collectionId, String wallpaperId); 64 logWallpaperSetResult(@allpaperSetResult int result)65 void logWallpaperSetResult(@WallpaperSetResult int result); 66 67 /** 68 * Logs that a particular failure to set an individual wallpaper occurred for the given reason. 69 */ logWallpaperSetFailureReason(@allpaperSetFailureReason int reason)70 void logWallpaperSetFailureReason(@WallpaperSetFailureReason int reason); 71 72 /** 73 * Logs the number of daily rotations that occurred in the last week if daily rotation has 74 * been enabled for at least a week. 75 */ logNumDailyWallpaperRotationsInLastWeek()76 void logNumDailyWallpaperRotationsInLastWeek(); 77 78 /** 79 * Logs the number of daily rotations that occurred during the previous day (24 hour period 80 * midnight to midnight) if daily rotation has been enabled at least since midnight yesterday. 81 */ logNumDailyWallpaperRotationsPreviousDay()82 void logNumDailyWallpaperRotationsPreviousDay(); 83 84 /** 85 * Logs given the hour of day that a successful "daily wallpaper" rotation occurred. 86 * 87 * @param hour An hour from 0 to 23. 88 */ logDailyWallpaperRotationHour(int hour)89 void logDailyWallpaperRotationHour(int hour); 90 91 /** 92 * Logs whether the image file for the daily wallpaper "rotating image wallpaper" is successfully 93 * decoded as a bitmap. 94 * 95 * @param decodes Whether the decode succeeded. 96 */ logDailyWallpaperDecodes(boolean decodes)97 void logDailyWallpaperDecodes(boolean decodes); 98 99 /** 100 * Logs the last-known status of daily wallpapers on the device. 101 */ logDailyWallpaperRotationStatus(int status)102 void logDailyWallpaperRotationStatus(int status); 103 104 /** 105 * Logs the result of an operation to update the daily wallpaper. 106 */ logDailyWallpaperSetNextWallpaperResult(@ailyWallpaperUpdateResult int result)107 void logDailyWallpaperSetNextWallpaperResult(@DailyWallpaperUpdateResult int result); 108 109 /** 110 * Logs that a particular crash occurred when trying to set the next wallpaper in a daily 111 * rotation. 112 */ logDailyWallpaperSetNextWallpaperCrash(@ailyWallpaperUpdateCrash int crash)113 void logDailyWallpaperSetNextWallpaperCrash(@DailyWallpaperUpdateCrash int crash); 114 115 /** 116 * Logs that the request for metadata for the next wallpaper in a daily rotation failed for the 117 * given reason. 118 */ logDailyWallpaperMetadataRequestFailure(@ailyWallpaperMetadataFailureReason int reason)119 void logDailyWallpaperMetadataRequestFailure(@DailyWallpaperMetadataFailureReason int reason); 120 121 /** 122 * Logs that the "refresh daily wallpaper" button was clicked. 123 */ logRefreshDailyWallpaperButtonClicked()124 void logRefreshDailyWallpaperButtonClicked(); 125 126 /** 127 * Logs the number of consecutive days that daily rotation was attempted but failed. 128 */ logNumDaysDailyRotationFailed(int days)129 void logNumDaysDailyRotationFailed(int days); 130 131 /** 132 * Logs the number of consecutive days that daily rotation was not attempted but should have been 133 * attempted ("network conditions not met" doesn't count). 134 */ logNumDaysDailyRotationNotAttempted(int days)135 void logNumDaysDailyRotationNotAttempted(int days); 136 137 /** 138 * Logs that the StandalonePreviewActivity was launched. 139 */ logStandalonePreviewLaunched()140 void logStandalonePreviewLaunched(); 141 142 /** 143 * Logs whether the image URI passed to StandalonePreviewActivity came properly preconfigured with 144 * read permissions. 145 */ logStandalonePreviewImageUriHasReadPermission(boolean isReadPermissionGranted)146 void logStandalonePreviewImageUriHasReadPermission(boolean isReadPermissionGranted); 147 148 /** 149 * Logs whether the user approved the runtime dialog to grant this app READ_EXTERNAL_STORAGE 150 * permission in order to open an image URI. 151 */ logStandalonePreviewStorageDialogApproved(boolean isApproved)152 void logStandalonePreviewStorageDialogApproved(boolean isApproved); 153 154 /** 155 * Logs the presentation mode of the current wallpaper. 156 */ logWallpaperPresentationMode()157 void logWallpaperPresentationMode(); 158 159 /** 160 * Logs that the app was restored from a backup set. 161 */ logRestored()162 void logRestored(); 163 164 /** 165 * Possible results of a "set wallpaper" operation. 166 */ 167 @IntDef({ 168 WALLPAPER_SET_RESULT_SUCCESS, 169 WALLPAPER_SET_RESULT_FAILURE}) 170 @interface WallpaperSetResult { 171 } 172 173 /** 174 * Possible results of an operation to set the next wallpaper in a daily rotation. 175 */ 176 @IntDef({ 177 DAILY_WALLPAPER_UPDATE_RESULT_SUCCESS, 178 DAILY_WALLPAPER_UPDATE_RESULT_FAILURE_LOAD_METADATA, 179 DAILY_WALLPAPER_UPDATE_RESULT_FAILURE_LOAD_BITMAP, 180 DAILY_WALLPAPER_UPDATE_RESULT_FAILURE_SET_WALLPAPER, 181 DAILY_WALLPAPER_UPDATE_RESULT_FAILURE_CRASH}) 182 @interface DailyWallpaperUpdateResult { 183 } 184 185 /** 186 * Possible reasons setting an individual wallpaper failed. 187 */ 188 @IntDef({ 189 WALLPAPER_SET_FAILURE_REASON_OTHER, 190 WALLPAPER_SET_FAILURE_REASON_OOM}) 191 @interface WallpaperSetFailureReason { 192 } 193 194 /** 195 * Possible crash types of a crashing failed "set next wallpaper" operation when daily rotation 196 * is enabled and trying to set the next wallpaper. 197 */ 198 @IntDef({ 199 DAILY_WALLPAPER_UPDATE_CRASH_GENERIC, 200 DAILY_WALLPAPER_UPDATE_CRASH_OOM}) 201 @interface DailyWallpaperUpdateCrash { 202 } 203 204 /** 205 * Possible reasons for a request for "next wallpaper" metadata in a daily rotation to fail. 206 */ 207 @IntDef({ 208 DAILY_WALLPAPER_METADATA_FAILURE_UNKNOWN, 209 DAILY_WALLPAPER_METADATA_FAILURE_NO_CONNECTION, 210 DAILY_WALLPAPER_METADATA_FAILURE_PARSE_ERROR, 211 DAILY_WALLPAPER_METADATA_FAILURE_SERVER_ERROR, 212 DAILY_WALLPAPER_METADATA_FAILURE_TIMEOUT}) 213 @interface DailyWallpaperMetadataFailureReason { 214 } 215 } 216