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

Commit 02a850b6 authored by Aurélien Pomini's avatar Aurélien Pomini Committed by Android (Google) Code Review
Browse files

Merge "Adapt WallpaperDataParser for lock screen engines"

parents 4c566496 73728241
Loading
Loading
Loading
Loading
+28 −10
Original line number Diff line number Diff line
@@ -74,13 +74,17 @@ class WallpaperDataParser {
    private final WallpaperCropper mWallpaperCropper;
    private final Context mContext;

    // Temporary feature flag. TODO(b/197814683) remove
    private final boolean mEnableSeparateLockScreenEngine;

    WallpaperDataParser(Context context, WallpaperDisplayHelper wallpaperDisplayHelper,
            WallpaperCropper wallpaperCropper) {
            WallpaperCropper wallpaperCropper, boolean enableSeparateLockScreenEngine) {
        mContext = context;
        mWallpaperDisplayHelper = wallpaperDisplayHelper;
        mWallpaperCropper = wallpaperCropper;
        mImageWallpaper = ComponentName.unflattenFromString(
                context.getResources().getString(R.string.image_wallpaper_component));
        mEnableSeparateLockScreenEngine = enableSeparateLockScreenEngine;
    }

    private JournaledFile makeJournaledFile(int userId) {
@@ -138,9 +142,17 @@ class WallpaperDataParser {
        FileInputStream stream = null;
        File file = journal.chooseForRead();

        boolean migrateFromOld = wallpaper == null;

        // don't reuse the wallpaper objects in the new version
        if (mEnableSeparateLockScreenEngine) {
            wallpaper = null;
            lockWallpaper = null;
        }

        if (wallpaper == null) {
            // Do this once per boot
            migrateFromOld();
            if (migrateFromOld) migrateFromOld();
            wallpaper = new WallpaperData(userId, FLAG_SYSTEM);
            wallpaper.allowBackup = true;
            if (!wallpaper.cropExists()) {
@@ -164,19 +176,25 @@ class WallpaperDataParser {
                type = parser.next();
                if (type == XmlPullParser.START_TAG) {
                    String tag = parser.getName();
                    if ("wp".equals(tag)) {
                        // Common to system + lock wallpapers
                        parseWallpaperAttributes(parser, wallpaper, keepDimensionHints);
                    if ("wp".equals(tag)
                            || ("kwp".equals(tag) && mEnableSeparateLockScreenEngine)) {

                        if ("kwp".equals(tag) && lockWallpaper == null) {
                            lockWallpaper = new WallpaperData(userId, FLAG_LOCK);
                        }
                        WallpaperData wallpaperToParse =
                                "wp".equals(tag) ? wallpaper : lockWallpaper;

                        parseWallpaperAttributes(parser, wallpaperToParse, keepDimensionHints);

                        // A system wallpaper might also be a live wallpaper
                        String comp = parser.getAttributeValue(null, "component");
                        wallpaper.nextWallpaperComponent = comp != null
                        wallpaperToParse.nextWallpaperComponent = comp != null
                                ? ComponentName.unflattenFromString(comp)
                                : null;
                        if (wallpaper.nextWallpaperComponent == null
                                || "android".equals(wallpaper.nextWallpaperComponent
                        if (wallpaperToParse.nextWallpaperComponent == null
                                || "android".equals(wallpaperToParse.nextWallpaperComponent
                                .getPackageName())) {
                            wallpaper.nextWallpaperComponent = mImageWallpaper;
                            wallpaperToParse.nextWallpaperComponent = mImageWallpaper;
                        }

                        if (DEBUG) {
+2 −2
Original line number Diff line number Diff line
@@ -1599,14 +1599,14 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
        dm.registerDisplayListener(mDisplayListener, null /* handler */);
        mWallpaperDisplayHelper = new WallpaperDisplayHelper(dm, mWindowManagerInternal);
        mWallpaperCropper = new WallpaperCropper(mWallpaperDisplayHelper);
        mWallpaperDataParser = new WallpaperDataParser(
                mContext, mWallpaperDisplayHelper, mWallpaperCropper);
        mActivityManager = mContext.getSystemService(ActivityManager.class);
        mMonitor = new MyPackageMonitor();
        mColorsChangedListeners = new SparseArray<>();

        mEnableSeparateLockScreenEngine = mContext.getResources().getBoolean(
                R.bool.config_independentLockscreenLiveWallpaper);
        mWallpaperDataParser = new WallpaperDataParser(mContext, mWallpaperDisplayHelper,
                mWallpaperCropper, mEnableSeparateLockScreenEngine);
        if (DEBUG) {
            Slog.v(TAG, "Separate lock screen engine enabled: " + mEnableSeparateLockScreenEngine);
        }