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

Commit f4ee1623 authored by Yasin Kilicdere's avatar Yasin Kilicdere Committed by Android (Google) Code Review
Browse files

Merge "Code refactor. Move null check into detachWallpaperLocked in WPMS." into main

parents d6ab40bc ea950792
Loading
Loading
Loading
Loading
+8 −17
Original line number Original line Diff line number Diff line
@@ -341,8 +341,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub


                    // If this was the system wallpaper, rebind...
                    // If this was the system wallpaper, rebind...
                    wallpaper.mBindSource = BindSource.SET_STATIC;
                    wallpaper.mBindSource = BindSource.SET_STATIC;
                    bindWallpaperComponentLocked(mImageWallpaper, true, false, wallpaper,
                    bindWallpaperComponentLocked(mImageWallpaper, true, false, wallpaper, callback);
                            callback);
                }
                }


                if (lockWallpaperChanged) {
                if (lockWallpaperChanged) {
@@ -369,11 +368,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
                    if (DEBUG) {
                    if (DEBUG) {
                        Slog.v(TAG, "Lock screen wallpaper changed to same as home");
                        Slog.v(TAG, "Lock screen wallpaper changed to same as home");
                    }
                    }
                    final WallpaperData lockedWallpaper = mLockWallpaperMap.get(
                    detachWallpaperLocked(mLockWallpaperMap.get(mWallpaper.userId));
                            mWallpaper.userId);
                    if (lockedWallpaper != null) {
                        detachWallpaperLocked(lockedWallpaper);
                    }
                    clearWallpaperBitmaps(mWallpaper.userId, FLAG_LOCK);
                    clearWallpaperBitmaps(mWallpaper.userId, FLAG_LOCK);
                    mLockWallpaperMap.remove(wallpaper.userId);
                    mLockWallpaperMap.remove(wallpaper.userId);
                }
                }
@@ -1697,7 +1692,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
        sWallpaperType.forEach((type, filename) -> {
        sWallpaperType.forEach((type, filename) -> {
            final File record = new File(getWallpaperDir(userID), filename);
            final File record = new File(getWallpaperDir(userID), filename);
            if (record.exists()) {
            if (record.exists()) {
                Slog.w(TAG, "User:" + userID + ", wallpaper tyep = " + type
                Slog.w(TAG, "User:" + userID + ", wallpaper type = " + type
                        + ", wallpaper fail detect!! reset to default wallpaper");
                        + ", wallpaper fail detect!! reset to default wallpaper");
                clearWallpaperBitmaps(userID, type);
                clearWallpaperBitmaps(userID, type);
                record.delete();
                record.delete();
@@ -1794,12 +1789,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
                    systemWallpaper.wallpaperObserver.startWatching();
                    systemWallpaper.wallpaperObserver.startWatching();
                }
                }
                if (Flags.reorderWallpaperDuringUserSwitch()) {
                if (Flags.reorderWallpaperDuringUserSwitch()) {
                    if (mLastLockWallpaper != null) {
                    detachWallpaperLocked(mLastLockWallpaper);
                    detachWallpaperLocked(mLastLockWallpaper);
                    }
                    if (mLastWallpaper != null) {
                    detachWallpaperLocked(mLastWallpaper);
                    detachWallpaperLocked(mLastWallpaper);
                    }
                    if (lockWallpaper == systemWallpaper)  {
                    if (lockWallpaper == systemWallpaper)  {
                        switchWallpaper(systemWallpaper, reply);
                        switchWallpaper(systemWallpaper, reply);
                    } else {
                    } else {
@@ -3403,10 +3394,10 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
        boolean homeUpdated = (newWallpaper.mWhich & FLAG_SYSTEM) != 0;
        boolean homeUpdated = (newWallpaper.mWhich & FLAG_SYSTEM) != 0;
        boolean lockUpdated = (newWallpaper.mWhich & FLAG_LOCK) != 0;
        boolean lockUpdated = (newWallpaper.mWhich & FLAG_LOCK) != 0;
        boolean systemWillBecomeLock = newWallpaper.mSystemWasBoth && !lockUpdated;
        boolean systemWillBecomeLock = newWallpaper.mSystemWasBoth && !lockUpdated;
        if (mLastWallpaper != null && homeUpdated && !systemWillBecomeLock) {
        if (homeUpdated && !systemWillBecomeLock) {
            detachWallpaperLocked(mLastWallpaper);
            detachWallpaperLocked(mLastWallpaper);
        }
        }
        if (mLastLockWallpaper != null && lockUpdated) {
        if (lockUpdated) {
            detachWallpaperLocked(mLastLockWallpaper);
            detachWallpaperLocked(mLastLockWallpaper);
        }
        }
    }
    }
@@ -3414,7 +3405,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
    // Frees up all rendering resources used by the given wallpaper so that the WallpaperData object
    // Frees up all rendering resources used by the given wallpaper so that the WallpaperData object
    // can be reused: detaches Engine, unbinds WallpaperService, etc.
    // can be reused: detaches Engine, unbinds WallpaperService, etc.
    private void detachWallpaperLocked(WallpaperData wallpaper) {
    private void detachWallpaperLocked(WallpaperData wallpaper) {
        if (wallpaper.connection != null) {
        if (wallpaper != null && wallpaper.connection != null) {
            if (DEBUG) {
            if (DEBUG) {
                Slog.v(TAG, "Detaching wallpaper: " + wallpaper);
                Slog.v(TAG, "Detaching wallpaper: " + wallpaper);
            }
            }