Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a5f192f7 authored by Kunhung Li's avatar Kunhung Li Committed by Android (Google) Code Review
Browse files

Merge changes from topic "snapshot_migration" into tm-dev

* changes:
  Add logSnapshot() function
  Refactor getCollectionIdHashCode()
parents 54664258 0c05e3d3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ public class DefaultCustomizationInjector extends BaseWallpaperInjector
    @Override
    public synchronized ThemesUserEventLogger getUserEventLogger(Context context) {
        if (mUserEventLogger == null) {
            mUserEventLogger = new StatsLogUserEventLogger();
            mUserEventLogger = new StatsLogUserEventLogger(context);
        }
        return mUserEventLogger;
    }
+69 −26
Original line number Diff line number Diff line
@@ -38,8 +38,10 @@ import static com.android.wallpaper.util.LaunchSourceUtils.LAUNCH_SOURCE_TIPS;
import static com.android.wallpaper.util.LaunchSourceUtils.WALLPAPER_LAUNCH_SOURCE;

import android.app.WallpaperManager;
import android.content.Context;
import android.content.Intent;
import android.stats.style.StyleEnums;
import android.text.TextUtils;

import androidx.annotation.Nullable;

@@ -47,7 +49,11 @@ import com.android.customization.model.clock.Clockface;
import com.android.customization.model.grid.GridOption;
import com.android.customization.model.theme.ThemeBundle;
import com.android.systemui.shared.system.SysUiStatsLog;
import com.android.wallpaper.module.Injector;
import com.android.wallpaper.module.InjectorProvider;
import com.android.wallpaper.module.NoOpUserEventLogger;
import com.android.wallpaper.module.WallpaperPreferences;
import com.android.wallpaper.module.WallpaperStatusChecker;

import java.util.Map;
import java.util.Objects;
@@ -58,52 +64,63 @@ import java.util.Objects;
public class StatsLogUserEventLogger extends NoOpUserEventLogger implements ThemesUserEventLogger {

    private static final String TAG = "StatsLogUserEventLogger";
    private final Context mContext;
    private final WallpaperPreferences mPreferences;
    private final WallpaperStatusChecker mWallpaperStatusChecker;

    public StatsLogUserEventLogger(Context appContext) {
        mContext = appContext;
        Injector injector = InjectorProvider.getInjector();
        mPreferences = injector.getPreferences(appContext);
        mWallpaperStatusChecker = injector.getWallpaperStatusChecker();
    }

    @Override
    public void logAppLaunched(Intent launchSource) {
        SysUiStatsLog.write(STYLE_UI_CHANGED, STYLE_UICHANGED__ACTION__APP_LAUNCHED,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, getAppLaunchSource(launchSource), 0, 0);
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, getAppLaunchSource(launchSource), 0, 0,
                0, 0, 0, 0, 0);
    }

    @Override
    public void logResumed(boolean provisioned, boolean wallpaper) {
        SysUiStatsLog.write(STYLE_UI_CHANGED, StyleEnums.ONRESUME,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    }

    @Override
    public void logStopped() {
        SysUiStatsLog.write(STYLE_UI_CHANGED, StyleEnums.ONSTOP,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    }

    @Override
    public void logActionClicked(String collectionId, int actionLabelResId) {
        SysUiStatsLog.write(STYLE_UI_CHANGED, StyleEnums.WALLPAPER_EXPLORE, 0, 0, 0, 0, 0,
                getCollectionIdHashCode(collectionId), 0, 0, 0, 0, 0, 0, 0);
                getIdHashCode(collectionId), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    }

    @Override
    public void logIndividualWallpaperSelected(String collectionId) {
        SysUiStatsLog.write(STYLE_UI_CHANGED, StyleEnums.WALLPAPER_SELECT, 0, 0, 0, 0, 0,
                getCollectionIdHashCode(collectionId), 0, 0, 0, 0, 0, 0, 0);
                getIdHashCode(collectionId), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    }

    @Override
    public void logCategorySelected(String collectionId) {
        SysUiStatsLog.write(STYLE_UI_CHANGED, StyleEnums.WALLPAPER_OPEN_CATEGORY,
                0, 0, 0, 0, 0,
                getCollectionIdHashCode(collectionId),
                0, 0, 0, 0, 0, 0, 0);
                getIdHashCode(collectionId),
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    }

    @Override
    public void logLiveWallpaperInfoSelected(String collectionId, @Nullable String wallpaperId) {
        SysUiStatsLog.write(STYLE_UI_CHANGED, StyleEnums.LIVE_WALLPAPER_INFO_SELECT,
                0, 0, 0, 0, 0,
                getCollectionIdHashCode(collectionId),
                wallpaperId != null ? wallpaperId.hashCode() : 0,
                0, 0, 0, 0, 0, 0);
                getIdHashCode(collectionId),
                getIdHashCode(wallpaperId),
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    }

    @Override
@@ -111,9 +128,33 @@ public class StatsLogUserEventLogger extends NoOpUserEventLogger implements Them
            @Nullable String wallpaperId) {
        SysUiStatsLog.write(STYLE_UI_CHANGED, StyleEnums.LIVE_WALLPAPER_CUSTOMIZE_SELECT,
                0, 0, 0, 0, 0,
                getCollectionIdHashCode(collectionId),
                wallpaperId != null ? wallpaperId.hashCode() : 0,
                0, 0, 0, 0, 0, 0);
                getIdHashCode(collectionId),
                getIdHashCode(wallpaperId),
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    }

    @Override
    public void logSnapshot() {
        final boolean isLockWallpaperSet = mWallpaperStatusChecker.isLockWallpaperSet(mContext);
        final String homeCollectionId = mPreferences.getHomeWallpaperCollectionId();
        final String homeRemoteId = mPreferences.getHomeWallpaperRemoteId();
        String homeWallpaperId = TextUtils.isEmpty(homeRemoteId)
                ? mPreferences.getHomeWallpaperServiceName() : homeRemoteId;
        String lockCollectionId = isLockWallpaperSet ? mPreferences.getLockWallpaperCollectionId()
                : homeCollectionId;
        String lockWallpaperId = isLockWallpaperSet ? mPreferences.getLockWallpaperRemoteId()
                : homeWallpaperId;

        SysUiStatsLog.write(STYLE_UI_CHANGED, StyleEnums.SNAPSHOT,
                0, 0, 0, 0, 0,
                getIdHashCode(homeCollectionId),
                getIdHashCode(homeWallpaperId),
                0, 0, 0, 0, 0, 0,
                getIdHashCode(lockCollectionId),
                getIdHashCode(lockWallpaperId),
                mPreferences.getFirstLaunchDateSinceSetup(),
                mPreferences.getFirstWallpaperApplyDateSinceSetup(),
                mPreferences.getAppLaunchCount());
    }

    @Override
@@ -121,15 +162,17 @@ public class StatsLogUserEventLogger extends NoOpUserEventLogger implements Them
            @Nullable String effects) {
        SysUiStatsLog.write(STYLE_UI_CHANGED, StyleEnums.WALLPAPER_APPLIED,
                0, 0, 0, 0, 0,
                getCollectionIdHashCode(collectionId),
                wallpaperId != null ? wallpaperId.hashCode() : 0,
                0, 0, 0, 0, 0, effects != null ? effects.hashCode() : 0);
                getIdHashCode(collectionId),
                getIdHashCode(wallpaperId),
                0, 0, 0, 0, 0, effects != null ? effects.hashCode() : 0,
                0, 0, 0, 0, 0);
    }

    @Override
    public void logEffectApply(String effect, @EffectStatus int status) {
        SysUiStatsLog.write(STYLE_UI_CHANGED, StyleEnums.WALLPAPER_EFFECT_APPLIED,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, status, effect != null ? effect.hashCode() : 0);
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, status, effect != null ? effect.hashCode() : 0,
                0, 0, 0, 0, 0);
    }

    @Nullable
@@ -144,7 +187,7 @@ public class StatsLogUserEventLogger extends NoOpUserEventLogger implements Them
                Objects.hashCode(getThemePackage(theme, OVERLAY_CATEGORY_COLOR)),
                Objects.hashCode(getThemePackage(theme,OVERLAY_CATEGORY_FONT)),
                Objects.hashCode(getThemePackage(theme, OVERLAY_CATEGORY_SHAPE)),
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    }

    @Override
@@ -153,7 +196,7 @@ public class StatsLogUserEventLogger extends NoOpUserEventLogger implements Them
                Objects.hashCode(getThemePackage(theme, OVERLAY_CATEGORY_COLOR)),
                Objects.hashCode(getThemePackage(theme,OVERLAY_CATEGORY_FONT)),
                Objects.hashCode(getThemePackage(theme, OVERLAY_CATEGORY_SHAPE)),
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    }

    @Override
@@ -161,7 +204,7 @@ public class StatsLogUserEventLogger extends NoOpUserEventLogger implements Them
        SysUiStatsLog.write(STYLE_UI_CHANGED, action,
                0, 0, 0, 0, 0, 0, 0,
                colorIndex,
                0, 0, 0, 0, 0);
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    }

    @Override
@@ -169,7 +212,7 @@ public class StatsLogUserEventLogger extends NoOpUserEventLogger implements Them
        SysUiStatsLog.write(STYLE_UI_CHANGED, StyleEnums.PICKER_SELECT,
                0, 0, 0,
                Objects.hashCode(clock.getId()),
                0, 0, 0, 0, 0, 0, 0, 0, 0);
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    }

    @Override
@@ -177,7 +220,7 @@ public class StatsLogUserEventLogger extends NoOpUserEventLogger implements Them
        SysUiStatsLog.write(STYLE_UI_CHANGED, StyleEnums.PICKER_APPLIED,
                0, 0, 0,
                Objects.hashCode(clock.getId()),
                0, 0, 0, 0, 0, 0, 0, 0, 0);
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    }

    @Override
@@ -185,7 +228,7 @@ public class StatsLogUserEventLogger extends NoOpUserEventLogger implements Them
        SysUiStatsLog.write(STYLE_UI_CHANGED, StyleEnums.PICKER_SELECT,
                0, 0, 0, 0,
                grid.cols,
                0, 0, 0, 0, 0, 0, 0, 0);
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    }

    @Override
@@ -193,7 +236,7 @@ public class StatsLogUserEventLogger extends NoOpUserEventLogger implements Them
        SysUiStatsLog.write(STYLE_UI_CHANGED, StyleEnums.PICKER_APPLIED,
                0, 0, 0, 0,
                grid.cols,
                0, 0, 0, 0, 0, 0, 0, 0);
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    }

    private int getAppLaunchSource(Intent launchSource) {
@@ -225,7 +268,7 @@ public class StatsLogUserEventLogger extends NoOpUserEventLogger implements Them
        }
    }

    private int getCollectionIdHashCode(String collectionId) {
        return collectionId != null ? collectionId.hashCode() : 0;
    private int getIdHashCode(String id) {
        return id != null ? id.hashCode() : 0;
    }
}