Merge "Add API to read the current wallpaper's ID" into nyc-dev
This commit is contained in:
@@ -5723,6 +5723,7 @@ package android.app {
|
||||
method public android.graphics.drawable.Drawable getFastDrawable();
|
||||
method public static android.app.WallpaperManager getInstance(android.content.Context);
|
||||
method public android.os.ParcelFileDescriptor getWallpaperFile(int);
|
||||
method public int getWallpaperId(int);
|
||||
method public android.app.WallpaperInfo getWallpaperInfo();
|
||||
method public boolean hasResourceWallpaper(int);
|
||||
method public boolean isWallpaperSettingAllowed();
|
||||
|
||||
@@ -5857,6 +5857,7 @@ package android.app {
|
||||
method public android.graphics.drawable.Drawable getFastDrawable();
|
||||
method public static android.app.WallpaperManager getInstance(android.content.Context);
|
||||
method public android.os.ParcelFileDescriptor getWallpaperFile(int);
|
||||
method public int getWallpaperId(int);
|
||||
method public android.app.WallpaperInfo getWallpaperInfo();
|
||||
method public boolean hasResourceWallpaper(int);
|
||||
method public boolean isWallpaperSettingAllowed();
|
||||
|
||||
@@ -5727,6 +5727,7 @@ package android.app {
|
||||
method public android.graphics.drawable.Drawable getFastDrawable();
|
||||
method public static android.app.WallpaperManager getInstance(android.content.Context);
|
||||
method public android.os.ParcelFileDescriptor getWallpaperFile(int);
|
||||
method public int getWallpaperId(int);
|
||||
method public android.app.WallpaperInfo getWallpaperInfo();
|
||||
method public boolean hasResourceWallpaper(int);
|
||||
method public boolean isWallpaperSettingAllowed();
|
||||
|
||||
@@ -61,6 +61,11 @@ interface IWallpaperManager {
|
||||
ParcelFileDescriptor getWallpaper(IWallpaperManagerCallback cb, int which,
|
||||
out Bundle outParams, int userId);
|
||||
|
||||
/**
|
||||
* Retrieve the given user's current wallpaper ID of the given kind.
|
||||
*/
|
||||
int getWallpaperIdForUser(int which, int userId);
|
||||
|
||||
/**
|
||||
* If the current system wallpaper is a live wallpaper component, return the
|
||||
* information about that wallpaper. Otherwise, if it is a static image,
|
||||
|
||||
@@ -725,6 +725,38 @@ public class WallpaperManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ID of the current wallpaper of the given kind. If there is no
|
||||
* such wallpaper configured, returns a negative number.
|
||||
*
|
||||
* @param which The wallpaper whose ID is to be returned. Must be a single
|
||||
* defined kind of wallpaper, either {@link #FLAG_SET_SYSTEM} or
|
||||
* {@link #FLAG_SET_LOCK}.
|
||||
* @return The positive numeric ID of the current wallpaper of the given kind,
|
||||
* or a negative value if no such wallpaper is configured.
|
||||
*/
|
||||
public int getWallpaperId(int which) {
|
||||
return getWallpaperIdForUser(which, mContext.getUserId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ID of the given user's current wallpaper of the given kind. If there
|
||||
* is no such wallpaper configured, returns a negative number.
|
||||
* @hide
|
||||
*/
|
||||
public int getWallpaperIdForUser(int which, int userId) {
|
||||
try {
|
||||
if (sGlobals.mService == null) {
|
||||
Log.w(TAG, "WallpaperService not running");
|
||||
return -1;
|
||||
} else {
|
||||
return sGlobals.mService.getWallpaperIdForUser(which, userId);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an Intent that will launch an activity that crops the given
|
||||
* image and sets the device's wallpaper. If there is a default HOME activity
|
||||
|
||||
@@ -20,6 +20,7 @@ import static android.app.WallpaperManager.FLAG_SET_SYSTEM;
|
||||
import static android.app.WallpaperManager.FLAG_SET_LOCK;
|
||||
import static android.os.ParcelFileDescriptor.*;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.ActivityManagerNative;
|
||||
import android.app.AppGlobals;
|
||||
import android.app.AppOpsManager;
|
||||
@@ -875,12 +876,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub {
|
||||
if (!isWallpaperSupported(callingPackage) || !isWallpaperSettingAllowed(callingPackage)) {
|
||||
return;
|
||||
}
|
||||
if (userId != UserHandle.getCallingUserId()) {
|
||||
// cross-user call
|
||||
mContext.enforceCallingOrSelfPermission(
|
||||
android.Manifest.permission.INTERACT_ACROSS_USERS_FULL,
|
||||
"WallpaperManagerService");
|
||||
}
|
||||
userId = ActivityManager.handleIncomingUser(Binder.getCallingPid(),
|
||||
Binder.getCallingUid(), userId, false, true, "clearWallpaper", null);
|
||||
|
||||
synchronized (mLock) {
|
||||
clearWallpaperLocked(false, which, userId, null);
|
||||
@@ -1103,12 +1100,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub {
|
||||
@Override
|
||||
public ParcelFileDescriptor getWallpaper(IWallpaperManagerCallback cb, final int which,
|
||||
Bundle outParams, int wallpaperUserId) {
|
||||
if (wallpaperUserId != UserHandle.getCallingUserId()) {
|
||||
// cross-user call
|
||||
mContext.enforceCallingOrSelfPermission(
|
||||
android.Manifest.permission.INTERACT_ACROSS_USERS_FULL,
|
||||
"WallpaperManagerService");
|
||||
}
|
||||
wallpaperUserId = ActivityManager.handleIncomingUser(Binder.getCallingPid(),
|
||||
Binder.getCallingUid(), wallpaperUserId, false, true, "getWallpaper", null);
|
||||
|
||||
if (which != FLAG_SET_SYSTEM && which != FLAG_SET_LOCK) {
|
||||
throw new IllegalArgumentException("Must specify exactly one kind of wallpaper to read");
|
||||
@@ -1147,6 +1140,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public WallpaperInfo getWallpaperInfo() {
|
||||
int userId = UserHandle.getCallingUserId();
|
||||
synchronized (mLock) {
|
||||
@@ -1158,6 +1152,26 @@ public class WallpaperManagerService extends IWallpaperManager.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWallpaperIdForUser(int which, int userId) {
|
||||
userId = ActivityManager.handleIncomingUser(Binder.getCallingPid(),
|
||||
Binder.getCallingUid(), userId, false, true, "getWallpaperIdForUser", null);
|
||||
|
||||
if (which != FLAG_SET_SYSTEM && which != FLAG_SET_LOCK) {
|
||||
throw new IllegalArgumentException("Must specify exactly one kind of wallpaper");
|
||||
}
|
||||
|
||||
final SparseArray<WallpaperData> map =
|
||||
(which == FLAG_SET_LOCK) ? mLockWallpaperMap : mWallpaperMap;
|
||||
synchronized (mLock) {
|
||||
WallpaperData wallpaper = map.get(userId);
|
||||
if (wallpaper != null) {
|
||||
return wallpaper.wallpaperId;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setLockWallpaperCallback(IWallpaperManagerCallback cb) {
|
||||
checkPermission(android.Manifest.permission.INTERNAL_SYSTEM_WINDOW);
|
||||
|
||||
Reference in New Issue
Block a user