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

Commit 429d99ff authored by Chris Poultney's avatar Chris Poultney Committed by Automerger Merge Worker
Browse files

Merge "Lock screen lwp: fix wallpaper dimming" into udc-dev am: d5b96755

parents e85133a8 d5b96755
Loading
Loading
Loading
Loading
+50 −21
Original line number Diff line number Diff line
@@ -2745,8 +2745,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
    }

    /**
     * Sets wallpaper dim amount for the calling UID. This only applies to FLAG_SYSTEM wallpaper as
     * the lock screen does not have a wallpaper component, so we use mWallpaperMap.
     * Sets wallpaper dim amount for the calling UID. This applies to all destinations (home, lock)
     * with an active wallpaper engine.
     *
     * @param dimAmount Dim amount which would be blended with the system default dimming.
     */
@@ -2756,8 +2756,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
    }

    /**
     * Sets wallpaper dim amount for a given UID. This only applies to FLAG_SYSTEM wallpaper as the
     * lock screen does not have a wallpaper component, so we use mWallpaperMap.
     * Sets wallpaper dim amount for the calling UID. This applies to all destinations (home, lock)
     * with an active wallpaper engine.
     *
     * @param uid Caller UID that wants to set the wallpaper dim amount
     * @param dimAmount Dim amount where 0f reverts any dimming applied by the caller (fully bright)
@@ -2786,6 +2786,33 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
                    lockWallpaper.mWallpaperDimAmount = maxDimAmount;
                }

                if (mIsLockscreenLiveWallpaperEnabled) {
                    boolean changed = false;
                    for (WallpaperData wp : getActiveWallpapers()) {
                        if (wp != null && wp.connection != null) {
                            wp.connection.forEachDisplayConnector(connector -> {
                                if (connector.mEngine != null) {
                                    try {
                                        connector.mEngine.applyDimming(maxDimAmount);
                                    } catch (RemoteException e) {
                                        Slog.w(TAG,
                                                "Can't apply dimming on wallpaper display "
                                                        + "connector",
                                                e);
                                    }
                                }
                            });
                            // Need to extract colors again to re-calculate dark hints after
                            // applying dimming.
                            wp.mIsColorExtractedFromDim = true;
                            notifyWallpaperColorsChanged(wp, wp.mWhich);
                            changed = true;
                        }
                    }
                    if (changed) {
                        saveSettingsLocked(wallpaper.userId);
                    }
                } else {
                    if (wallpaper.connection != null) {
                        wallpaper.connection.forEachDisplayConnector(connector -> {
                            if (connector.mEngine != null) {
@@ -2793,7 +2820,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
                                    connector.mEngine.applyDimming(maxDimAmount);
                                } catch (RemoteException e) {
                                    Slog.w(TAG,
                                        "Can't apply dimming on wallpaper display connector", e);
                                            "Can't apply dimming on wallpaper display connector",
                                            e);
                                }
                            }
                        });
@@ -2808,6 +2836,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
                        saveSettingsLocked(wallpaper.userId);
                    }
                }
            }
        } finally {
            Binder.restoreCallingIdentity(ident);
        }