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

Commit 8befa939 authored by Roman Birg's avatar Roman Birg
Browse files

Fix some keyguard wallpaper issues



Partial cherry pick of Change-Id:
I0bf7d5ffdf8972cf10ba1a90ae9c5d3f9a6a9aab

- Cache wallpaper in PhoneStatusBar so we don't query it every time
  media meta data tries to update

- Don't crash if service isn't connected yet, return null

Change-Id: I8f0c8a53b634db5ffd27be3975b7b2db1b35bbfb
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>
parent f86cf254
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -354,6 +354,10 @@ public class WallpaperManager {
        }

        private Bitmap getCurrentKeyguardWallpaperLocked(Context context) {
            if (mService == null) {
                Log.w(TAG, "WallpaperService not running");
                return null;
            }
            try {
                Bundle params = new Bundle();
                ParcelFileDescriptor fd = mService.getKeyguardWallpaper(this, params);
+17 −8
Original line number Diff line number Diff line
@@ -348,6 +348,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
    private long mKeyguardFadingAwayDelay;
    private long mKeyguardFadingAwayDuration;

    private Bitmap mKeyguardWallpaper;

    int mKeyguardMaxNotificationCount;

    boolean mExpandedVisible;
@@ -809,6 +811,11 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
                    Settings.Global.getUriFor(SETTING_HEADS_UP_TICKER), true,
                    mHeadsUpObserver);
        }

        WallpaperManager wallpaperManager = (WallpaperManager) mContext.getSystemService(
                Context.WALLPAPER_SERVICE);
        mKeyguardWallpaper = wallpaperManager.getKeyguardBitmap();

        mUnlockMethodCache = UnlockMethodCache.getInstance(mContext);
        mUnlockMethodCache.addListener(this);
        startKeyguard();
@@ -1938,11 +1945,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,

        // apply user lockscreen image
        if (mMediaMetadata == null && backdropBitmap == null) {
            WallpaperManager wm = (WallpaperManager)
                    mContext.getSystemService(Context.WALLPAPER_SERVICE);
            if (wm != null) {
                backdropBitmap = wm.getKeyguardBitmap();
            }
            backdropBitmap = mKeyguardWallpaper;
        }

        final boolean hasBackdrop = backdropBitmap != null;
@@ -3294,6 +3297,9 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
                    updateMediaMetaData(true);
                }
            } else if (Intent.ACTION_KEYGUARD_WALLPAPER_CHANGED.equals(action)) {
                WallpaperManager wm = (WallpaperManager) mContext.getSystemService(
                        Context.WALLPAPER_SERVICE);
                mKeyguardWallpaper = wm.getKeyguardBitmap();
                updateMediaMetaData(true);
            }
        }
@@ -3360,6 +3366,11 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
    public void userSwitched(int newUserId) {
        super.userSwitched(newUserId);
        if (MULTIUSER_DEBUG) mNotificationPanelDebugText.setText("USER " + newUserId);
        WallpaperManager wm = (WallpaperManager)
                mContext.getSystemService(Context.WALLPAPER_SERVICE);
        mKeyguardWallpaper = null;
        wm.forgetLoadedKeyguardWallpaper();

        animateCollapsePanels();
        updatePublicMode();
        updateNotifications();
@@ -3367,9 +3378,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
        setControllerUsers();
        mAssistManager.onUserSwitched(newUserId);

        WallpaperManager wm = (WallpaperManager)
                mContext.getSystemService(Context.WALLPAPER_SERVICE);
        wm.forgetLoadedKeyguardWallpaper();
        mKeyguardWallpaper = wm.getKeyguardBitmap();
        updateMediaMetaData(true);
    }