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.logging 17 18 import android.content.Intent 19 import android.stats.style.StyleEnums 20 import androidx.annotation.IntDef 21 import com.android.wallpaper.module.WallpaperPersister 22 import com.android.wallpaper.module.WallpaperPersister.Destination 23 24 /** Interface for logging user events in the wallpaper picker. */ 25 interface UserEventLogger { 26 27 /** Logs the current snapshot data, e.g. the currently-set home and lock screen wallpapers. */ logSnapshotnull28 fun logSnapshot() 29 30 /** Logs when the app is launched */ 31 fun logAppLaunched(launchSource: Intent) 32 33 /** Logs the event when applying a wallpaper. */ 34 fun logWallpaperApplied( 35 collectionId: String?, 36 wallpaperId: String?, 37 effects: String?, 38 @SetWallpaperEntryPoint setWallpaperEntryPoint: Int, 39 @WallpaperDestination destination: Int, 40 ) 41 42 /** Logs the action related to effect. */ 43 fun logEffectApply( 44 effect: String, 45 @EffectStatus status: Int, 46 timeElapsedMillis: Long, 47 resultCode: Int, 48 ) 49 50 /** Logs the effect probe result. */ 51 fun logEffectProbe(effect: String, @EffectStatus status: Int) 52 53 /** Logs the effect foreground download event. */ 54 fun logEffectForegroundDownload( 55 effect: String, 56 @EffectStatus status: Int, 57 timeElapsedMillis: Long, 58 ) 59 60 /** Logs the event when reset is applied. */ 61 fun logResetApplied() 62 63 /** Logs when clicking the explore button in the wallpaper information dialog. */ 64 fun logWallpaperExploreButtonClicked() 65 66 /** 67 * Possible actions for cinematic effect. These actions would be used for effect apply, effect 68 * probe, effect download. 69 */ 70 @IntDef( 71 StyleEnums.EFFECT_PREFERENCE_UNSPECIFIED, 72 StyleEnums.EFFECT_APPLIED_ON_SUCCESS, 73 StyleEnums.EFFECT_APPLIED_ON_FAILED, 74 StyleEnums.EFFECT_APPLIED_OFF, 75 StyleEnums.EFFECT_APPLIED_ABORTED, 76 StyleEnums.EFFECT_APPLIED_STARTED 77 ) 78 @Retention(AnnotationRetention.SOURCE) 79 annotation class EffectStatus 80 81 /** 82 * Possible actions for cinematic effect. These actions would be used for effect apply, effect 83 * probe, effect download. 84 */ 85 @IntDef( 86 StyleEnums.SET_WALLPAPER_ENTRY_POINT_UNSPECIFIED, 87 StyleEnums.SET_WALLPAPER_ENTRY_POINT_WALLPAPER_PREVIEW, 88 StyleEnums.SET_WALLPAPER_ENTRY_POINT_WALLPAPER_QUICK_SWITCHER, 89 StyleEnums.SET_WALLPAPER_ENTRY_POINT_LAUNCHER_WALLPAPER_QUICK_SWITCHER, 90 StyleEnums.SET_WALLPAPER_ENTRY_POINT_ROTATION_WALLPAPER, 91 StyleEnums.SET_WALLPAPER_ENTRY_POINT_RESET, 92 StyleEnums.SET_WALLPAPER_ENTRY_POINT_RESTORE, 93 ) 94 @Retention(AnnotationRetention.SOURCE) 95 annotation class SetWallpaperEntryPoint 96 97 @IntDef( 98 StyleEnums.WALLPAPER_DESTINATION_UNSPECIFIED, 99 StyleEnums.WALLPAPER_DESTINATION_HOME_SCREEN, 100 StyleEnums.WALLPAPER_DESTINATION_LOCK_SCREEN, 101 StyleEnums.WALLPAPER_DESTINATION_HOME_AND_LOCK_SCREEN, 102 ) 103 @Retention(AnnotationRetention.SOURCE) 104 annotation class WallpaperDestination 105 106 companion object { 107 @WallpaperDestination 108 fun toWallpaperDestinationForLogging(@Destination destination: Int): Int { 109 return when (destination) { 110 WallpaperPersister.DEST_HOME_SCREEN -> StyleEnums.WALLPAPER_DESTINATION_HOME_SCREEN 111 WallpaperPersister.DEST_LOCK_SCREEN -> StyleEnums.WALLPAPER_DESTINATION_LOCK_SCREEN 112 WallpaperPersister.DEST_BOTH -> 113 StyleEnums.WALLPAPER_DESTINATION_HOME_AND_LOCK_SCREEN 114 else -> StyleEnums.WALLPAPER_DESTINATION_UNSPECIFIED 115 } 116 } 117 } 118 } 119