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

Commit af79fd6a authored by Chris Poultney's avatar Chris Poultney Committed by Android (Google) Code Review
Browse files

Merge "Change timing of wallpaper changed intent and add destination" into main

parents f4dca525 efc5b0f5
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -298,6 +298,14 @@ public class WallpaperManager {
    public static final String EXTRA_FROM_FOREGROUND_APP =
            "android.service.wallpaper.extra.FROM_FOREGROUND_APP";

    /**
     * Extra passed on {@link Intent.ACTION_WALLPAPER_CHANGED} indicating if wallpaper was set from
     * a foreground app.
     * @hide
     */
    public static final String EXTRA_WHICH_WALLPAPER_CHANGED =
            "android.service.wallpaper.extra.WHICH_WALLPAPER_CHANGED";

    /**
     * The different screen orientations. {@link #getOrientation} provides their exact definition.
     * This is only used internally by the framework and the WallpaperBackupAgent.
+8 −0
Original line number Diff line number Diff line
package: "android.app"
container: "system"

flag {
  name: "remove_next_wallpaper_component"
  namespace: "systemui"
  description: "Remove deprecated field WallpaperData#nextWallpaperComponent. Only effective after rebooting."
  bug: "365991991"
}

flag {
  name: "fix_wallpaper_changed"
  namespace: "systemui"
  description: "Fixes timing of wallpaper changed notification and adds extra information. Only effective after rebooting."
  bug: "369814294"
}
+33 −4
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static android.Manifest.permission.INTERACT_ACROSS_USERS_FULL;
import static android.Manifest.permission.MANAGE_EXTERNAL_STORAGE;
import static android.Manifest.permission.READ_WALLPAPER_INTERNAL;
import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND;
import static android.app.Flags.fixWallpaperChanged;
import static android.app.Flags.removeNextWallpaperComponent;
import static android.app.WallpaperManager.COMMAND_REAPPLY;
import static android.app.WallpaperManager.FLAG_LOCK;
@@ -349,8 +350,11 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
                            if (DEBUG) {
                                Slog.d(TAG, "publish system wallpaper changed!");
                            }
                            notifyWallpaperComplete(wallpaper);
                            if (fixWallpaperChanged()) {
                                notifyWallpaperChanged(wallpaper);
                            }
                        }
                    };

                    // If this was the system wallpaper, rebind...
@@ -369,8 +373,11 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
                            if (DEBUG) {
                                Slog.d(TAG, "publish lock wallpaper changed!");
                            }
                            notifyWallpaperComplete(wallpaper);
                            if (fixWallpaperChanged()) {
                                notifyWallpaperChanged(wallpaper);
                            }
                        }
                    };

                    wallpaper.mBindSource = BindSource.SET_STATIC;
@@ -403,8 +410,11 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
        }
    }

    private void notifyWallpaperChanged(WallpaperData wallpaper) {
        // Publish completion *after* we've persisted the changes
    /*
     * Calls wallpaper setComplete methods. Called for static wallpapers after the wallpaper is set
     * and changes are persisted.
     */
    private void notifyWallpaperComplete(WallpaperData wallpaper) {
        if (wallpaper.setComplete != null) {
            try {
                wallpaper.setComplete.onWallpaperChanged();
@@ -1787,6 +1797,9 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
                    switchWallpaper(systemWallpaper, null);
                    // TODO(b/278261563): call notifyCallbacksLocked inside switchWallpaper
                    notifyCallbacksLocked(systemWallpaper);
                    if (fixWallpaperChanged()) {
                        notifyWallpaperChanged(systemWallpaper);
                    }
                }
                if (mLockWallpaperWaitingForUnlock) {
                    final WallpaperData lockWallpaper =
@@ -1794,6 +1807,9 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
                    lockWallpaper.mBindSource = BindSource.SWITCH_WALLPAPER_UNLOCK_USER;
                    switchWallpaper(lockWallpaper, null);
                    notifyCallbacksLocked(lockWallpaper);
                    if (fixWallpaperChanged()) {
                        notifyWallpaperChanged(lockWallpaper);
                    }
                }

                // Make sure that the SELinux labeling of all the relevant files is correct.
@@ -3248,6 +3264,9 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
                    }
                    newWallpaper.wallpaperId = makeWallpaperIdLocked();
                    notifyCallbacksLocked(newWallpaper);
                    if (fixWallpaperChanged()) {
                        notifyWallpaperChanged(newWallpaper);
                    }
                    shouldNotifyColors = true;
                    if (offloadColorExtraction()) {
                        shouldNotifyColors = false;
@@ -3625,8 +3644,18 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
        }
        wallpaper.callbacks.finishBroadcast();

        if (!fixWallpaperChanged()) {
            final Intent intent = new Intent(Intent.ACTION_WALLPAPER_CHANGED);
            intent.putExtra(WallpaperManager.EXTRA_FROM_FOREGROUND_APP,
                    wallpaper.fromForegroundApp);
            mContext.sendBroadcastAsUser(intent, new UserHandle(mCurrentUserId));
        }
    }

    private void notifyWallpaperChanged(WallpaperData wallpaper) {
        final Intent intent = new Intent(Intent.ACTION_WALLPAPER_CHANGED);
        intent.putExtra(WallpaperManager.EXTRA_FROM_FOREGROUND_APP, wallpaper.fromForegroundApp);
        intent.putExtra(WallpaperManager.EXTRA_WHICH_WALLPAPER_CHANGED, wallpaper.mWhich);
        mContext.sendBroadcastAsUser(intent, new UserHandle(mCurrentUserId));
    }