1 /* 2 * Copyright (C) 2019 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.testing; 17 18 import com.android.wallpaper.module.UserEventLogger; 19 import com.android.wallpaper.module.WallpaperPersister.WallpaperPosition; 20 21 /** 22 * Test implementation of {@link UserEventLogger}. 23 */ 24 public class TestUserEventLogger implements UserEventLogger { 25 26 private int mNumDailyRefreshTurnedOnEvents; 27 private int mNumCurrentWallpaperPreviewedEvents; 28 private int mNumActionClickedEvents; 29 private int mNumIndividualWallpaperSelectedEvents; 30 private int mNumCategorySelectedEvents; 31 private int mNumWallpaperSetEvents; 32 private int mNumWallpaperSetResultEvents; 33 private String mLastCollectionId; 34 private String mLastWallpaperId; 35 @WallpaperSetResult 36 private int mLastWallpaperSetResult; 37 private int mLastDailyRotationHour; 38 private int mNum1DayActiveLogs; 39 private int mNum7DayActiveLogs; 40 private int mNum14DayActiveLogs; 41 private int mNum28DayActiveLogs; 42 private int mLastDailyWallpaperRotationStatus; 43 private int mNumDaysDailyRotationFailed; 44 private int mNumDaysDailyRotationNotAttempted; 45 private int mLastDailyWallpaperUpdateResult; 46 private int mStandalonePreviewLaunches; 47 private int mNumRestores; 48 @WallpaperPosition 49 private int mWallpaperPosition; 50 TestUserEventLogger()51 public TestUserEventLogger() { 52 mLastDailyRotationHour = -1; 53 mLastDailyWallpaperRotationStatus = -1; 54 mNumDaysDailyRotationFailed = -1; 55 mNumDaysDailyRotationNotAttempted = -1; 56 } 57 58 @Override logResumed(boolean provisioned, boolean wallpaper)59 public void logResumed(boolean provisioned, boolean wallpaper) { 60 61 } 62 63 @Override logStopped()64 public void logStopped() { 65 66 } 67 68 @Override logAppLaunched()69 public void logAppLaunched() { 70 // Do nothing. 71 } 72 73 @Override logDailyRefreshTurnedOn()74 public void logDailyRefreshTurnedOn() { 75 mNumDailyRefreshTurnedOnEvents++; 76 } 77 getNumDailyRefreshTurnedOnEvents()78 public int getNumDailyRefreshTurnedOnEvents() { 79 return mNumDailyRefreshTurnedOnEvents; 80 } 81 82 @Override logCurrentWallpaperPreviewed()83 public void logCurrentWallpaperPreviewed() { 84 mNumCurrentWallpaperPreviewedEvents++; 85 } 86 87 @Override logActionClicked(String collectionId, int actionLabelResId)88 public void logActionClicked(String collectionId, int actionLabelResId) { 89 mNumActionClickedEvents++; 90 mLastCollectionId = collectionId; 91 } 92 getNumCurrentWallpaperPreviewedEvents()93 public int getNumCurrentWallpaperPreviewedEvents() { 94 return mNumCurrentWallpaperPreviewedEvents; 95 } 96 getNumActionClickedEvents()97 public int getNumActionClickedEvents() { 98 return mNumActionClickedEvents; 99 } 100 101 @Override logIndividualWallpaperSelected(String collectionId)102 public void logIndividualWallpaperSelected(String collectionId) { 103 mNumIndividualWallpaperSelectedEvents++; 104 mLastCollectionId = collectionId; 105 } 106 getNumIndividualWallpaperSelectedEvents()107 public int getNumIndividualWallpaperSelectedEvents() { 108 return mNumIndividualWallpaperSelectedEvents; 109 } 110 111 @Override logCategorySelected(String collectionId)112 public void logCategorySelected(String collectionId) { 113 mNumCategorySelectedEvents++; 114 mLastCollectionId = collectionId; 115 } 116 117 @Override logLiveWallpaperInfoSelected(String collectionId, String wallpaperId)118 public void logLiveWallpaperInfoSelected(String collectionId, String wallpaperId) { 119 // No-op 120 } 121 122 @Override logLiveWallpaperCustomizeSelected(String collectionId, String wallpaperId)123 public void logLiveWallpaperCustomizeSelected(String collectionId, String wallpaperId) { 124 // No-op 125 } 126 getNumCategorySelectedEvents()127 public int getNumCategorySelectedEvents() { 128 return mNumCategorySelectedEvents; 129 } 130 131 @Override logWallpaperSet(String collectionId, String wallpaperId)132 public void logWallpaperSet(String collectionId, String wallpaperId) { 133 mNumWallpaperSetEvents++; 134 mLastCollectionId = collectionId; 135 mLastWallpaperId = wallpaperId; 136 } 137 138 @Override logWallpaperSetResult(@allpaperSetResult int result)139 public void logWallpaperSetResult(@WallpaperSetResult int result) { 140 mNumWallpaperSetResultEvents++; 141 mLastWallpaperSetResult = result; 142 } 143 144 @Override logWallpaperSetFailureReason(@allpaperSetFailureReason int reason)145 public void logWallpaperSetFailureReason(@WallpaperSetFailureReason int reason) { 146 // No-op 147 } 148 149 150 @Override logNumDailyWallpaperRotationsInLastWeek()151 public void logNumDailyWallpaperRotationsInLastWeek() { 152 // No-op 153 } 154 155 @Override logNumDailyWallpaperRotationsPreviousDay()156 public void logNumDailyWallpaperRotationsPreviousDay() { 157 // No-op 158 } 159 160 @Override logDailyWallpaperRotationHour(int hour)161 public void logDailyWallpaperRotationHour(int hour) { 162 mLastDailyRotationHour = hour; 163 } 164 165 @Override logDailyWallpaperDecodes(boolean decodes)166 public void logDailyWallpaperDecodes(boolean decodes) { 167 // No-op 168 } 169 170 @Override logRefreshDailyWallpaperButtonClicked()171 public void logRefreshDailyWallpaperButtonClicked() { 172 // No-op 173 } 174 175 @Override logDailyWallpaperRotationStatus(int status)176 public void logDailyWallpaperRotationStatus(int status) { 177 mLastDailyWallpaperRotationStatus = status; 178 } 179 180 @Override logDailyWallpaperSetNextWallpaperResult(@ailyWallpaperUpdateResult int result)181 public void logDailyWallpaperSetNextWallpaperResult(@DailyWallpaperUpdateResult int result) { 182 mLastDailyWallpaperUpdateResult = result; 183 } 184 185 @Override logDailyWallpaperSetNextWallpaperCrash(@ailyWallpaperUpdateCrash int crash)186 public void logDailyWallpaperSetNextWallpaperCrash(@DailyWallpaperUpdateCrash int crash) { 187 // No-op 188 } 189 190 @Override logNumDaysDailyRotationFailed(int days)191 public void logNumDaysDailyRotationFailed(int days) { 192 mNumDaysDailyRotationFailed = days; 193 } 194 195 @Override logDailyWallpaperMetadataRequestFailure( @ailyWallpaperMetadataFailureReason int reason)196 public void logDailyWallpaperMetadataRequestFailure( 197 @DailyWallpaperMetadataFailureReason int reason) { 198 // No-op 199 } 200 201 @Override logNumDaysDailyRotationNotAttempted(int days)202 public void logNumDaysDailyRotationNotAttempted(int days) { 203 mNumDaysDailyRotationNotAttempted = days; 204 } 205 206 @Override logStandalonePreviewLaunched()207 public void logStandalonePreviewLaunched() { 208 mStandalonePreviewLaunches++; 209 } 210 211 @Override logStandalonePreviewImageUriHasReadPermission(boolean isReadPermissionGranted)212 public void logStandalonePreviewImageUriHasReadPermission(boolean isReadPermissionGranted) { 213 // No-op 214 } 215 216 @Override logStandalonePreviewStorageDialogApproved(boolean isApproved)217 public void logStandalonePreviewStorageDialogApproved(boolean isApproved) { 218 // No-op 219 } 220 221 @Override logWallpaperPresentationMode()222 public void logWallpaperPresentationMode() { 223 // No-op 224 } 225 226 @Override logRestored()227 public void logRestored() { 228 mNumRestores++; 229 } 230 getNumWallpaperSetEvents()231 public int getNumWallpaperSetEvents() { 232 return mNumWallpaperSetEvents; 233 } 234 getLastCollectionId()235 public String getLastCollectionId() { 236 return mLastCollectionId; 237 } 238 getLastWallpaperId()239 public String getLastWallpaperId() { 240 return mLastWallpaperId; 241 } 242 getNumWallpaperSetResultEvents()243 public int getNumWallpaperSetResultEvents() { 244 return mNumWallpaperSetResultEvents; 245 } 246 247 @WallpaperSetResult getLastWallpaperSetResult()248 public int getLastWallpaperSetResult() { 249 return mLastWallpaperSetResult; 250 } 251 getLastDailyRotationHour()252 public int getLastDailyRotationHour() { 253 return mLastDailyRotationHour; 254 } 255 getNum1DayActiveLogs()256 public int getNum1DayActiveLogs() { 257 return mNum1DayActiveLogs; 258 } 259 getNum7DayActiveLogs()260 public int getNum7DayActiveLogs() { 261 return mNum7DayActiveLogs; 262 } 263 getNum14DayActiveLogs()264 public int getNum14DayActiveLogs() { 265 return mNum14DayActiveLogs; 266 } 267 getNum28DayActiveLogs()268 public int getNum28DayActiveLogs() { 269 return mNum28DayActiveLogs; 270 } 271 getLastDailyWallpaperRotationStatus()272 public int getLastDailyWallpaperRotationStatus() { 273 return mLastDailyWallpaperRotationStatus; 274 } 275 getNumDaysDailyRotationFailed()276 public int getNumDaysDailyRotationFailed() { 277 return mNumDaysDailyRotationFailed; 278 } 279 getNumDaysDailyRotationNotAttempted()280 public int getNumDaysDailyRotationNotAttempted() { 281 return mNumDaysDailyRotationNotAttempted; 282 } 283 getLastDailyWallpaperUpdateResult()284 public int getLastDailyWallpaperUpdateResult() { 285 return mLastDailyWallpaperUpdateResult; 286 } 287 getStandalonePreviewLaunches()288 public int getStandalonePreviewLaunches() { 289 return mStandalonePreviewLaunches; 290 } 291 getNumRestores()292 public int getNumRestores() { 293 return mNumRestores; 294 } 295 getWallpaperPosition()296 public int getWallpaperPosition() { 297 return mWallpaperPosition; 298 } 299 } 300