summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/api/current.txt3
-rw-r--r--core/api/system-current.txt1
-rw-r--r--core/java/android/app/IWallpaperManager.aidl11
-rw-r--r--core/java/android/app/WallpaperManager.java138
-rw-r--r--core/java/android/service/wallpaper/IWallpaperEngine.aidl1
-rw-r--r--core/java/android/service/wallpaper/WallpaperService.java37
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java6
-rw-r--r--services/core/java/com/android/server/wallpaper/WallpaperManagerService.java44
8 files changed, 177 insertions, 64 deletions
diff --git a/core/api/current.txt b/core/api/current.txt
index dc9d7d5dd1ab..fd78bbd24d2c 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -7273,6 +7273,7 @@ package android.app {
method @RequiresPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE) public android.os.ParcelFileDescriptor getWallpaperFile(int);
method public int getWallpaperId(int);
method public android.app.WallpaperInfo getWallpaperInfo();
+ method @Nullable public android.app.WallpaperInfo getWallpaperInfo(int);
method public boolean hasResourceWallpaper(@RawRes int);
method public boolean isSetWallpaperAllowed();
method public boolean isWallpaperSupported();
@@ -40011,6 +40012,7 @@ package android.service.wallpaper {
method public int getDesiredMinimumWidth();
method @Nullable public android.content.Context getDisplayContext();
method public android.view.SurfaceHolder getSurfaceHolder();
+ method public int getWallpaperFlags();
method public boolean isPreview();
method public boolean isVisible();
method public void notifyColorsChanged();
@@ -40027,6 +40029,7 @@ package android.service.wallpaper {
method @MainThread public void onSurfaceRedrawNeeded(android.view.SurfaceHolder);
method @MainThread public void onTouchEvent(android.view.MotionEvent);
method @MainThread public void onVisibilityChanged(boolean);
+ method @MainThread public void onWallpaperFlagsChanged(int);
method @MainThread public void onZoomChanged(@FloatRange(from=0.0f, to=1.0f) float);
method public void setOffsetNotificationsEnabled(boolean);
method public void setTouchEventsEnabled(boolean);
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index 46c49ce4acb8..fbb35163cfad 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -1121,6 +1121,7 @@ package android.app {
method @FloatRange(from=0.0f, to=1.0f) @RequiresPermission(android.Manifest.permission.SET_WALLPAPER_DIM_AMOUNT) public float getWallpaperDimAmount();
method public void setDisplayOffset(android.os.IBinder, int, int);
method @RequiresPermission(android.Manifest.permission.SET_WALLPAPER_COMPONENT) public boolean setWallpaperComponent(android.content.ComponentName);
+ method @RequiresPermission(android.Manifest.permission.SET_WALLPAPER_COMPONENT) public boolean setWallpaperComponentWithFlags(@NonNull android.content.ComponentName, int);
method @RequiresPermission(android.Manifest.permission.SET_WALLPAPER_DIM_AMOUNT) public void setWallpaperDimAmount(@FloatRange(from=0.0f, to=1.0f) float);
}
diff --git a/core/java/android/app/IWallpaperManager.aidl b/core/java/android/app/IWallpaperManager.aidl
index 167de463ad17..b1ed152e3344 100644
--- a/core/java/android/app/IWallpaperManager.aidl
+++ b/core/java/android/app/IWallpaperManager.aidl
@@ -50,9 +50,10 @@ interface IWallpaperManager {
IWallpaperManagerCallback completion, int userId);
/**
- * Set the live wallpaper. This only affects the system wallpaper.
+ * Set the live wallpaper.
*/
- void setWallpaperComponentChecked(in ComponentName name, in String callingPackage, int userId);
+ void setWallpaperComponentChecked(in ComponentName name, in String callingPackage, int which,
+ int userId);
/**
* Set the live wallpaper. This only affects the system wallpaper.
@@ -89,6 +90,12 @@ interface IWallpaperManager {
WallpaperInfo getWallpaperInfo(int userId);
/**
+ * If the current wallpaper for destination `which` is a live wallpaper component, return the
+ * information about that wallpaper. Otherwise, if it is a static image, simply return null.
+ */
+ WallpaperInfo getWallpaperInfoWithFlags(int which, int userId);
+
+ /**
* Clear the system wallpaper.
*/
void clearWallpaper(in String callingPackage, int which, int userId);
diff --git a/core/java/android/app/WallpaperManager.java b/core/java/android/app/WallpaperManager.java
index 6f1737aa6660..b9a7186dcd2e 100644
--- a/core/java/android/app/WallpaperManager.java
+++ b/core/java/android/app/WallpaperManager.java
@@ -67,7 +67,6 @@ import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import android.os.StrictMode;
import android.os.SystemProperties;
-import android.service.wallpaper.WallpaperService;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.ArraySet;
@@ -521,10 +520,7 @@ public class WallpaperManager {
}
WallpaperColors getWallpaperColors(int which, int userId, int displayId) {
- if (which != FLAG_LOCK && which != FLAG_SYSTEM) {
- throw new IllegalArgumentException(
- "Must request colors for exactly one kind of wallpaper");
- }
+ checkExactlyOneWallpaperFlagSet(which);
try {
return mService.getWallpaperColors(which, userId, displayId);
@@ -857,9 +853,7 @@ public class WallpaperManager {
throw new RuntimeException(new DeadSystemException());
}
- if (which != FLAG_SYSTEM && which != FLAG_LOCK) {
- throw new IllegalArgumentException("Must request exactly one kind of wallpaper");
- }
+ checkExactlyOneWallpaperFlagSet(which);
Resources resources = mContext.getResources();
horizontalAlignment = Math.max(0, Math.min(1, horizontalAlignment));
@@ -1115,6 +1109,19 @@ public class WallpaperManager {
}
/**
+ * Like {@link #getDrawable()} but returns a Bitmap.
+ *
+ * @param hardware Asks for a hardware backed bitmap.
+ * @param which Specifies home or lock screen
+ * @see Bitmap.Config#HARDWARE
+ * @hide
+ */
+ @Nullable
+ public Bitmap getBitmap(boolean hardware, @SetWallpaperFlags int which) {
+ return getBitmapAsUser(mContext.getUserId(), hardware, which);
+ }
+
+ /**
* Like {@link #getDrawable()} but returns a Bitmap for the provided user.
*
* @hide
@@ -1125,6 +1132,17 @@ public class WallpaperManager {
}
/**
+ * Like {@link #getDrawable()} but returns a Bitmap for the provided user.
+ *
+ * @param which Specifies home or lock screen
+ * @hide
+ */
+ public Bitmap getBitmapAsUser(int userId, boolean hardware, @SetWallpaperFlags int which) {
+ final ColorManagementProxy cmProxy = getColorManagementProxy();
+ return sGlobals.peekWallpaperBitmap(mContext, true, which, userId, hardware, cmProxy);
+ }
+
+ /**
* Peek the dimensions of system wallpaper of the user without decoding it.
*
* @return the dimensions of system wallpaper
@@ -1281,9 +1299,7 @@ public class WallpaperManager {
*/
@UnsupportedAppUsage
public ParcelFileDescriptor getWallpaperFile(@SetWallpaperFlags int which, int userId) {
- if (which != FLAG_SYSTEM && which != FLAG_LOCK) {
- throw new IllegalArgumentException("Must request exactly one kind of wallpaper");
- }
+ checkExactlyOneWallpaperFlagSet(which);
if (sGlobals.mService == null) {
Log.w(TAG, "WallpaperService not running");
@@ -1333,16 +1349,7 @@ public class WallpaperManager {
* @hide
*/
public WallpaperInfo getWallpaperInfoForUser(int userId) {
- try {
- if (sGlobals.mService == null) {
- Log.w(TAG, "WallpaperService not running");
- throw new RuntimeException(new DeadSystemException());
- } else {
- return sGlobals.mService.getWallpaperInfo(userId);
- }
- } catch (RemoteException e) {
- throw e.rethrowFromSystemServer();
- }
+ return getWallpaperInfo(FLAG_SYSTEM, userId);
}
/**
@@ -1353,10 +1360,10 @@ public class WallpaperManager {
* @param which Specifies wallpaper to request (home or lock).
* @throws IllegalArgumentException if {@code which} is not exactly one of
* {{@link #FLAG_SYSTEM},{@link #FLAG_LOCK}}.
- * @hide
*/
+ @Nullable
public WallpaperInfo getWallpaperInfo(@SetWallpaperFlags int which) {
- return getWallpaperInfo();
+ return getWallpaperInfo(which, mContext.getUserId());
}
/**
@@ -1371,7 +1378,17 @@ public class WallpaperManager {
* @hide
*/
public WallpaperInfo getWallpaperInfo(@SetWallpaperFlags int which, int userId) {
- return getWallpaperInfoForUser(userId);
+ checkExactlyOneWallpaperFlagSet(which);
+ try {
+ if (sGlobals.mService == null) {
+ Log.w(TAG, "WallpaperService not running");
+ throw new RuntimeException(new DeadSystemException());
+ } else {
+ return sGlobals.mService.getWallpaperInfoWithFlags(which, userId);
+ }
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
}
/**
@@ -2012,7 +2029,10 @@ public class WallpaperManager {
}
/**
- * Set the live wallpaper.
+ * Set the implementation of {@link android.service.wallpaper.WallpaperService} used to render
+ * wallpaper, usually in order to set a live wallpaper.
+ *
+ * @param name Name of the component to use.
*
* @hide
*/
@@ -2080,43 +2100,72 @@ public class WallpaperManager {
}
/**
- * Set the live wallpaper.
+ * Set the implementation of {@link android.service.wallpaper.WallpaperService} used to render
+ * wallpaper, usually in order to set a live wallpaper.
*
* This can only be called by packages with android.permission.SET_WALLPAPER_COMPONENT
* permission. The caller must hold the INTERACT_ACROSS_USERS_FULL permission to change
* another user's wallpaper.
*
+ * @param name Name of the component to use.
+ * @param userId User for whom the component should be set.
+ *
* @hide
*/
@RequiresPermission(android.Manifest.permission.SET_WALLPAPER_COMPONENT)
@UnsupportedAppUsage
public boolean setWallpaperComponent(ComponentName name, int userId) {
- if (sGlobals.mService == null) {
- Log.w(TAG, "WallpaperService not running");
- throw new RuntimeException(new DeadSystemException());
- }
- try {
- sGlobals.mService.setWallpaperComponentChecked(name, mContext.getOpPackageName(),
- userId);
- return true;
- } catch (RemoteException e) {
- throw e.rethrowFromSystemServer();
- }
+ return setWallpaperComponentWithFlags(name, FLAG_SYSTEM | FLAG_LOCK, userId);
}
/**
- * Set the live wallpaper for the given screen(s).
+ * Set the implementation of {@link android.service.wallpaper.WallpaperService} used to render
+ * wallpaper, usually in order to set a live wallpaper, for a given wallpaper destination.
*
* This can only be called by packages with android.permission.SET_WALLPAPER_COMPONENT
* permission. The caller must hold the INTERACT_ACROSS_USERS_FULL permission to change
* another user's wallpaper.
*
+ * @param name Name of the component to use.
+ * @param which Specifies wallpaper destination (home and/or lock).
+ *
* @hide
*/
+ @SystemApi
@RequiresPermission(android.Manifest.permission.SET_WALLPAPER_COMPONENT)
public boolean setWallpaperComponentWithFlags(@NonNull ComponentName name,
@SetWallpaperFlags int which) {
- return setWallpaperComponent(name);
+ return setWallpaperComponentWithFlags(name, which, mContext.getUserId());
+ }
+
+ /**
+ * Set the implementation of {@link android.service.wallpaper.WallpaperService} used to render
+ * wallpaper, usually in order to set a live wallpaper, for a given wallpaper destination.
+ *
+ * This can only be called by packages with android.permission.SET_WALLPAPER_COMPONENT
+ * permission. The caller must hold the INTERACT_ACROSS_USERS_FULL permission to change
+ * another user's wallpaper.
+ *
+ * @param name Name of the component to use.
+ * @param which Specifies wallpaper destination (home and/or lock).
+ * @param userId User for whom the component should be set.
+ *
+ * @hide
+ */
+ @RequiresPermission(android.Manifest.permission.SET_WALLPAPER_COMPONENT)
+ public boolean setWallpaperComponentWithFlags(@NonNull ComponentName name,
+ @SetWallpaperFlags int which, int userId) {
+ if (sGlobals.mService == null) {
+ Log.w(TAG, "WallpaperManagerService not running");
+ throw new RuntimeException(new DeadSystemException());
+ }
+ try {
+ sGlobals.mService.setWallpaperComponentChecked(name, mContext.getOpPackageName(),
+ which, userId);
+ return true;
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
}
/**
@@ -2440,6 +2489,13 @@ public class WallpaperManager {
return mCmProxy;
}
+ private static void checkExactlyOneWallpaperFlagSet(@SetWallpaperFlags int which) {
+ if (which == FLAG_SYSTEM || which == FLAG_LOCK) {
+ return;
+ }
+ throw new IllegalArgumentException("Must specify exactly one kind of wallpaper");
+ }
+
/**
* A hidden class to help {@link Globals#getCurrentWallpaperLocked} handle color management.
* @hide
@@ -2519,7 +2575,7 @@ public class WallpaperManager {
*
* @param colors Wallpaper color info, {@code null} when not available.
* @param which A combination of {@link #FLAG_LOCK} and {@link #FLAG_SYSTEM}
- * @see WallpaperService.Engine#onComputeColors()
+ * @see android.service.wallpaper.WallpaperService.Engine#onComputeColors()
*/
void onColorsChanged(@Nullable WallpaperColors colors, int which);
@@ -2531,7 +2587,7 @@ public class WallpaperManager {
* @param colors Wallpaper color info, {@code null} when not available.
* @param which A combination of {@link #FLAG_LOCK} and {@link #FLAG_SYSTEM}
* @param userId Owner of the wallpaper
- * @see WallpaperService.Engine#onComputeColors()
+ * @see android.service.wallpaper.WallpaperService.Engine#onComputeColors()
* @hide
*/
default void onColorsChanged(@Nullable WallpaperColors colors, int which, int userId) {
diff --git a/core/java/android/service/wallpaper/IWallpaperEngine.aidl b/core/java/android/service/wallpaper/IWallpaperEngine.aidl
index 93d4def2180e..a41401b73747 100644
--- a/core/java/android/service/wallpaper/IWallpaperEngine.aidl
+++ b/core/java/android/service/wallpaper/IWallpaperEngine.aidl
@@ -47,4 +47,5 @@ interface IWallpaperEngine {
oneway void addLocalColorsAreas(in List<RectF> regions);
SurfaceControl mirrorSurfaceControl();
oneway void applyDimming(float dimAmount);
+ oneway void setWallpaperFlags(int which);
}
diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java
index 007478a25016..aebd91a0be2f 100644
--- a/core/java/android/service/wallpaper/WallpaperService.java
+++ b/core/java/android/service/wallpaper/WallpaperService.java
@@ -166,6 +166,7 @@ public abstract class WallpaperService extends Service {
private static final int MSG_SCALE_PREVIEW = 10110;
private static final int MSG_REPORT_SHOWN = 10150;
private static final int MSG_UPDATE_DIMMING = 10200;
+ private static final int MSG_WALLPAPER_FLAGS_CHANGED = 10210;
private static final List<Float> PROHIBITED_STEPS = Arrays.asList(0f, Float.POSITIVE_INFINITY,
Float.NEGATIVE_INFINITY);
@@ -486,6 +487,13 @@ public abstract class WallpaperService extends Service {
}
/**
+ * Returns the current wallpaper flags indicating which screen this Engine is rendering to.
+ */
+ @SetWallpaperFlags public int getWallpaperFlags() {
+ return mIWallpaperEngine.mWhich;
+ }
+
+ /**
* Convenience for {@link WallpaperManager#getDesiredMinimumWidth()
* WallpaperManager.getDesiredMinimumWidth()}, returning the width
* that the system would like this wallpaper to run in.
@@ -795,6 +803,16 @@ public abstract class WallpaperService extends Service {
}
/**
+ * Called when the current wallpaper flags change.
+ *
+ * @param which The new flag value
+ * @see #getWallpaperFlags()
+ */
+ @MainThread
+ public void onWallpaperFlagsChanged(@SetWallpaperFlags int which) {
+ }
+
+ /**
* Called when the zoom level of the wallpaper changed.
* This method will be called with the initial zoom level when the surface is created.
*
@@ -2195,11 +2213,12 @@ public abstract class WallpaperService extends Service {
private final AtomicBoolean mDetached = new AtomicBoolean();
Engine mEngine;
+ @SetWallpaperFlags int mWhich;
IWallpaperEngineWrapper(WallpaperService context,
IWallpaperConnection conn, IBinder windowToken,
int windowType, boolean isPreview, int reqWidth, int reqHeight, Rect padding,
- int displayId) {
+ int displayId, @SetWallpaperFlags int which) {
mWallpaperManager = getSystemService(WallpaperManager.class);
mCaller = new HandlerCaller(context, context.getMainLooper(), this, true);
mConnection = conn;
@@ -2210,6 +2229,7 @@ public abstract class WallpaperService extends Service {
mReqHeight = reqHeight;
mDisplayPadding.set(padding);
mDisplayId = displayId;
+ mWhich = which;
// Create a display context before onCreateEngine.
mDisplayManager = getSystemService(DisplayManager.class);
@@ -2240,6 +2260,16 @@ public abstract class WallpaperService extends Service {
}
@Override
+ public void setWallpaperFlags(@SetWallpaperFlags int which) {
+ if (which == mWhich) {
+ return;
+ }
+ mWhich = which;
+ Message msg = mCaller.obtainMessageI(MSG_WALLPAPER_FLAGS_CHANGED, which);
+ mCaller.sendMessage(msg);
+ }
+
+ @Override
public void setInAmbientMode(boolean inAmbientDisplay, long animationDuration)
throws RemoteException {
Message msg = mCaller.obtainMessageIO(DO_IN_AMBIENT_MODE, inAmbientDisplay ? 1 : 0,
@@ -2459,6 +2489,9 @@ public abstract class WallpaperService extends Service {
reportShown();
Trace.endSection();
} break;
+ case MSG_WALLPAPER_FLAGS_CHANGED: {
+ mEngine.onWallpaperFlagsChanged(message.arg1);
+ } break;
default :
Log.w(TAG, "Unknown message type " + message.what);
}
@@ -2483,7 +2516,7 @@ public abstract class WallpaperService extends Service {
int displayId, @SetWallpaperFlags int which) {
Trace.beginSection("WPMS.ServiceWrapper.attach");
mEngineWrapper = new IWallpaperEngineWrapper(mTarget, conn, windowToken,
- windowType, isPreview, reqWidth, reqHeight, padding, displayId);
+ windowType, isPreview, reqWidth, reqHeight, padding, displayId, which);
Trace.endSection();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
index eefceb794607..5efd4603500f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
@@ -241,6 +241,8 @@ import com.android.wm.shell.bubbles.Bubbles;
import com.android.wm.shell.startingsurface.SplashscreenContentDrawer;
import com.android.wm.shell.startingsurface.StartingSurface;
+import dagger.Lazy;
+
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.List;
@@ -251,8 +253,6 @@ import java.util.concurrent.Executor;
import javax.inject.Inject;
import javax.inject.Named;
-import dagger.Lazy;
-
/**
* A class handling initialization and coordination between some of the key central surfaces in
* System UI: The notification shade, the keyguard (lockscreen), and the status bar.
@@ -4204,7 +4204,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
Log.wtf(TAG, "WallpaperManager not supported");
return;
}
- WallpaperInfo info = mWallpaperManager.getWallpaperInfo(UserHandle.USER_CURRENT);
+ WallpaperInfo info = mWallpaperManager.getWallpaperInfoForUser(UserHandle.USER_CURRENT);
mWallpaperController.onWallpaperInfoUpdated(info);
final boolean deviceSupportsAodWallpaper = mContext.getResources().getBoolean(
diff --git a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
index c875f4af9c8b..5d084616bfea 100644
--- a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
+++ b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
@@ -270,11 +270,12 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
+ " sys=" + sysWallpaperChanged
+ " lock=" + lockWallpaperChanged
+ " imagePending=" + wallpaper.imageWallpaperPending
- + " whichPending=0x" + Integer.toHexString(wallpaper.whichPending)
+ + " mWhich=0x" + Integer.toHexString(wallpaper.mWhich)
+ " written=" + written);
}
if (moved && lockWallpaperChanged) {
+ // TODO(b/253507223) Start lock screen WallpaperService
// We just migrated sys -> lock to preserve imagery for an impending
// new system-only wallpaper. Tell keyguard about it and make sure it
// has the right SELinux label.
@@ -329,8 +330,10 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
false, wallpaper, callback);
notifyColorsWhich |= FLAG_SYSTEM;
}
+ // TODO(b/253507223) Start lock screen WallpaperService if only lock
+ // screen wp changed
if (lockWallpaperChanged
- || (wallpaper.whichPending & FLAG_LOCK) != 0) {
+ || (wallpaper.mWhich & FLAG_LOCK) != 0) {
if (DEBUG) {
Slog.i(TAG, "Lock-relevant wallpaper changed");
}
@@ -609,7 +612,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
if (DEBUG) {
Slog.v(TAG, "Generating crop for new wallpaper(s): 0x"
- + Integer.toHexString(wallpaper.whichPending)
+ + Integer.toHexString(wallpaper.mWhich)
+ " to " + wallpaper.cropFile.getName()
+ " crop=(" + cropHint.width() + 'x' + cropHint.height()
+ ") dim=(" + wpData.mWidth + 'x' + wpData.mHeight + ')');
@@ -922,10 +925,9 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
boolean imageWallpaperPending;
/**
- * Which new wallpapers are being written; mirrors the 'which'
- * selector bit field to setWallpaper().
+ * Which wallpaper is set. Flag values are from {@link SetWallpaperFlags}.
*/
- int whichPending;
+ int mWhich;
/**
* Callback once the set + crop is finished
@@ -1166,7 +1168,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
try {
connection.mService.attach(connection, mToken, TYPE_WALLPAPER, false,
wpdData.mWidth, wpdData.mHeight,
- wpdData.mPadding, mDisplayId, FLAG_SYSTEM | FLAG_LOCK);
+ wpdData.mPadding, mDisplayId, mWallpaper.mWhich);
} catch (RemoteException e) {
Slog.w(TAG, "Failed attaching wallpaper on display", e);
if (wallpaper != null && !wallpaper.wallpaperUpdating
@@ -2415,13 +2417,19 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
@Override
public WallpaperInfo getWallpaperInfo(int userId) {
+ return getWallpaperInfoWithFlags(FLAG_SYSTEM, userId);
+ }
+
+ @Override
+ public WallpaperInfo getWallpaperInfoWithFlags(@SetWallpaperFlags int which, int userId) {
final boolean allow =
hasPermission(READ_WALLPAPER_INTERNAL) || hasPermission(QUERY_ALL_PACKAGES);
if (allow) {
userId = ActivityManager.handleIncomingUser(Binder.getCallingPid(),
Binder.getCallingUid(), userId, false, true, "getWallpaperInfo", null);
synchronized (mLock) {
- WallpaperData wallpaper = mWallpaperMap.get(userId);
+ WallpaperData wallpaper = (which == FLAG_LOCK) ? mLockWallpaperMap.get(userId)
+ : mWallpaperMap.get(userId);
if (wallpaper != null && wallpaper.connection != null) {
return wallpaper.connection.mInfo;
}
@@ -2870,7 +2878,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
ParcelFileDescriptor pfd = updateWallpaperBitmapLocked(name, wallpaper, extras);
if (pfd != null) {
wallpaper.imageWallpaperPending = true;
- wallpaper.whichPending = which;
+ wallpaper.mWhich = which;
wallpaper.setComplete = completion;
wallpaper.fromForegroundApp = fromForegroundApp;
wallpaper.cropHint.set(cropHint);
@@ -2901,6 +2909,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
lockWP.allowBackup = sysWP.allowBackup;
lockWP.primaryColors = sysWP.primaryColors;
lockWP.mWallpaperDimAmount = sysWP.mWallpaperDimAmount;
+ lockWP.mWhich = FLAG_LOCK;
// Migrate the bitmap files outright; no need to copy
try {
@@ -2953,25 +2962,27 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
@Override
public void setWallpaperComponentChecked(ComponentName name, String callingPackage,
- int userId) {
+ @SetWallpaperFlags int which, int userId) {
if (isWallpaperSupported(callingPackage) && isSetWallpaperAllowed(callingPackage)) {
- setWallpaperComponent(name, userId);
+ setWallpaperComponent(name, which, userId);
}
}
// ToDo: Remove this version of the function
@Override
public void setWallpaperComponent(ComponentName name) {
- setWallpaperComponent(name, UserHandle.getCallingUserId());
+ setWallpaperComponent(name, UserHandle.getCallingUserId(), FLAG_SYSTEM);
}
- private void setWallpaperComponent(ComponentName name, int userId) {
+ private void setWallpaperComponent(ComponentName name, @SetWallpaperFlags int which,
+ int userId) {
userId = ActivityManager.handleIncomingUser(getCallingPid(), getCallingUid(), userId,
false /* all */, true /* full */, "changing live wallpaper", null /* pkg */);
checkPermission(android.Manifest.permission.SET_WALLPAPER_COMPONENT);
- int which = FLAG_SYSTEM;
+ // TODO(b/253507223) Use passed destination and properly start lock screen LWP
+ int legacyWhich = FLAG_SYSTEM;
boolean shouldNotifyColors = false;
WallpaperData wallpaper;
@@ -2999,11 +3010,12 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
// New live wallpaper is also a lock wallpaper if nothing is set
if (mLockWallpaperMap.get(userId) == null) {
- which |= FLAG_LOCK;
+ legacyWhich |= FLAG_LOCK;
}
try {
wallpaper.imageWallpaperPending = false;
+ wallpaper.mWhich = which;
boolean same = changingToSame(name, wallpaper);
if (bindWallpaperComponentLocked(name, false, true, wallpaper, null)) {
if (!same) {
@@ -3032,7 +3044,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
}
if (shouldNotifyColors) {
- notifyWallpaperColorsChanged(wallpaper, which);
+ notifyWallpaperColorsChanged(wallpaper, legacyWhich);
notifyWallpaperColorsChanged(mFallbackWallpaper, FLAG_SYSTEM);
}
}