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

Commit f132a8d7 authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Get WallpaperInfo for current user

Secondary user's WallpaperInfo would always be null otherwise.

Test: manual, switch between users with different live wallpapers
Change-Id: I32d5e04281aa38b00f5350569ef86b5d74de8f07
Fixes: 110275658
parent 7f6641b8
Loading
Loading
Loading
Loading
+16 −4
Original line number Diff line number Diff line
@@ -996,17 +996,29 @@ public class WallpaperManager {
    }

    /**
     * If the current wallpaper is a live wallpaper component, return the
     * information about that wallpaper.  Otherwise, if it is a static image,
     * simply return null.
     * Returns the information about the wallpaper if the current wallpaper is
     * a live wallpaper component. Otherwise, if the wallpaper is a static image,
     * this returns null.
     */
    public WallpaperInfo getWallpaperInfo() {
        return getWallpaperInfo(mContext.getUserId());
    }

    /**
     * Returns the information about the wallpaper if the current wallpaper is
     * a live wallpaper component. Otherwise, if the wallpaper is a static image,
     * this returns null.
     *
     * @param userId Owner of the wallpaper.
     * @hide
     */
    public WallpaperInfo getWallpaperInfo(int userId) {
        try {
            if (sGlobals.mService == null) {
                Log.w(TAG, "WallpaperService not running");
                throw new RuntimeException(new DeadSystemException());
            } else {
                return sGlobals.mService.getWallpaperInfo(mContext.getUserId());
                return sGlobals.mService.getWallpaperInfo(userId);
            }
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
+5 −3
Original line number Diff line number Diff line
@@ -509,7 +509,7 @@ public class StatusBar extends SystemUI implements DemoMode,
    protected NotificationLockscreenUserManager mLockscreenUserManager;
    protected NotificationRemoteInputManager mRemoteInputManager;

    private BroadcastReceiver mWallpaperChangedReceiver = new BroadcastReceiver() {
    private final BroadcastReceiver mWallpaperChangedReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            WallpaperManager wallpaperManager = context.getSystemService(WallpaperManager.class);
@@ -517,7 +517,7 @@ public class StatusBar extends SystemUI implements DemoMode,
                Log.w(TAG, "WallpaperManager not available");
                return;
            }
            WallpaperInfo info = wallpaperManager.getWallpaperInfo();
            WallpaperInfo info = wallpaperManager.getWallpaperInfo(UserHandle.USER_CURRENT);
            final boolean supportsAmbientMode = info != null &&
                    info.getSupportsAmbientMode();

@@ -705,7 +705,8 @@ public class StatusBar extends SystemUI implements DemoMode,

        // Make sure we always have the most current wallpaper info.
        IntentFilter wallpaperChangedFilter = new IntentFilter(Intent.ACTION_WALLPAPER_CHANGED);
        mContext.registerReceiver(mWallpaperChangedReceiver, wallpaperChangedFilter);
        mContext.registerReceiverAsUser(mWallpaperChangedReceiver, UserHandle.ALL,
                wallpaperChangedFilter, null /* broadcastPermission */, null /* scheduler */);
        mWallpaperChangedReceiver.onReceive(mContext, null);

        mLockscreenUserManager.setUpWithPresenter(this, mEntryManager);
@@ -3135,6 +3136,7 @@ public class StatusBar extends SystemUI implements DemoMode,
        updateNotificationViews();
        mMediaManager.clearCurrentMediaNotification();
        setLockscreenUser(newUserId);
        mWallpaperChangedReceiver.onReceive(mContext, null);
    }

    @Override