Merge "Merge "Remove usage of Telephonymanager from() hidden API" am: 8e999f22b8 am: fc8b731e33 am: 4931429f5a"
diff --git a/core/java/android/app/IWallpaperManager.aidl b/core/java/android/app/IWallpaperManager.aidl
index 7f5350d..4cb8d93 100644
--- a/core/java/android/app/IWallpaperManager.aidl
+++ b/core/java/android/app/IWallpaperManager.aidl
@@ -58,14 +58,22 @@
@UnsupportedAppUsage
void setWallpaperComponent(in ComponentName name);
+
/**
- * Get the wallpaper for a given user.
+ * @deprecated Use {@link #getWallpaperWithFeature(String, IWallpaperManagerCallback, int,
+ * Bundle, int)}
*/
@UnsupportedAppUsage
ParcelFileDescriptor getWallpaper(String callingPkg, IWallpaperManagerCallback cb, int which,
out Bundle outParams, int userId);
/**
+ * Get the wallpaper for a given user.
+ */
+ ParcelFileDescriptor getWallpaperWithFeature(String callingPkg, String callingFeatureId,
+ 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);
diff --git a/core/java/android/app/WallpaperManager.java b/core/java/android/app/WallpaperManager.java
index 59ecf4a..41604ec 100644
--- a/core/java/android/app/WallpaperManager.java
+++ b/core/java/android/app/WallpaperManager.java
@@ -458,8 +458,9 @@
try {
Bundle params = new Bundle();
- ParcelFileDescriptor fd = mService.getWallpaper(context.getOpPackageName(),
- this, FLAG_SYSTEM, params, userId);
+ ParcelFileDescriptor fd = mService.getWallpaperWithFeature(
+ context.getOpPackageName(), context.getFeatureId(), this, FLAG_SYSTEM,
+ params, userId);
if (fd != null) {
try {
BitmapFactory.Options options = new BitmapFactory.Options();
@@ -985,8 +986,8 @@
} else {
try {
Bundle outParams = new Bundle();
- return sGlobals.mService.getWallpaper(mContext.getOpPackageName(), null, which,
- outParams, userId);
+ return sGlobals.mService.getWallpaperWithFeature(mContext.getOpPackageName(),
+ mContext.getFeatureId(), null, which, outParams, userId);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
} catch (SecurityException e) {
diff --git a/core/java/android/os/storage/StorageManager.java b/core/java/android/os/storage/StorageManager.java
index ac7a0a8..deeeddc 100644
--- a/core/java/android/os/storage/StorageManager.java
+++ b/core/java/android/os/storage/StorageManager.java
@@ -1645,10 +1645,10 @@
* Check that given app holds both permission and appop.
* @hide
*/
- public static boolean checkPermissionAndAppOp(Context context, boolean enforce,
- int pid, int uid, String packageName, String permission, int op) {
- return checkPermissionAndAppOp(context, enforce, pid, uid, packageName, permission, op,
- true);
+ public static boolean checkPermissionAndAppOp(Context context, boolean enforce, int pid,
+ int uid, String packageName, @NonNull String featureId, String permission, int op) {
+ return checkPermissionAndAppOp(context, enforce, pid, uid, packageName, featureId,
+ permission, op, true);
}
/**
@@ -1657,16 +1657,17 @@
*/
public static boolean checkPermissionAndCheckOp(Context context, boolean enforce,
int pid, int uid, String packageName, String permission, int op) {
- return checkPermissionAndAppOp(context, enforce, pid, uid, packageName, permission, op,
- false);
+ return checkPermissionAndAppOp(context, enforce, pid, uid, packageName,
+ null /* featureId is not needed when not noting */, permission, op, false);
}
/**
* Check that given app holds both permission and appop.
* @hide
*/
- private static boolean checkPermissionAndAppOp(Context context, boolean enforce,
- int pid, int uid, String packageName, String permission, int op, boolean note) {
+ private static boolean checkPermissionAndAppOp(Context context, boolean enforce, int pid,
+ int uid, String packageName, @Nullable String featureId, String permission, int op,
+ boolean note) {
if (context.checkPermission(permission, pid, uid) != PERMISSION_GRANTED) {
if (enforce) {
throw new SecurityException(
@@ -1679,7 +1680,7 @@
AppOpsManager appOps = context.getSystemService(AppOpsManager.class);
final int mode;
if (note) {
- mode = appOps.noteOpNoThrow(op, uid, packageName);
+ mode = appOps.noteOpNoThrow(op, uid, packageName, featureId, null);
} else {
try {
appOps.checkPackage(uid, packageName);
@@ -1711,14 +1712,15 @@
}
}
- private boolean checkPermissionAndAppOp(boolean enforce,
- int pid, int uid, String packageName, String permission, int op) {
- return checkPermissionAndAppOp(mContext, enforce, pid, uid, packageName, permission, op);
+ private boolean checkPermissionAndAppOp(boolean enforce, int pid, int uid, String packageName,
+ @Nullable String featureId, String permission, int op) {
+ return checkPermissionAndAppOp(mContext, enforce, pid, uid, packageName, featureId,
+ permission, op);
}
private boolean noteAppOpAllowingLegacy(boolean enforce,
- int pid, int uid, String packageName, int op) {
- final int mode = mAppOps.noteOpNoThrow(op, uid, packageName);
+ int pid, int uid, String packageName, @Nullable String featureId, int op) {
+ final int mode = mAppOps.noteOpNoThrow(op, uid, packageName, featureId, null);
switch (mode) {
case AppOpsManager.MODE_ALLOWED:
return true;
@@ -1749,50 +1751,68 @@
/** {@hide} */
public boolean checkPermissionReadAudio(boolean enforce,
- int pid, int uid, String packageName) {
- if (!checkPermissionAndAppOp(enforce, pid, uid, packageName,
- READ_EXTERNAL_STORAGE, OP_READ_EXTERNAL_STORAGE)) return false;
- return noteAppOpAllowingLegacy(enforce, pid, uid, packageName, OP_READ_MEDIA_AUDIO);
+ int pid, int uid, String packageName, @Nullable String featureId) {
+ if (!checkPermissionAndAppOp(enforce, pid, uid, packageName, featureId,
+ READ_EXTERNAL_STORAGE, OP_READ_EXTERNAL_STORAGE)) {
+ return false;
+ }
+ return noteAppOpAllowingLegacy(enforce, pid, uid, packageName, featureId,
+ OP_READ_MEDIA_AUDIO);
}
/** {@hide} */
public boolean checkPermissionWriteAudio(boolean enforce,
- int pid, int uid, String packageName) {
- if (!checkPermissionAndAppOp(enforce, pid, uid, packageName,
- WRITE_EXTERNAL_STORAGE, OP_WRITE_EXTERNAL_STORAGE)) return false;
- return noteAppOpAllowingLegacy(enforce, pid, uid, packageName, OP_WRITE_MEDIA_AUDIO);
+ int pid, int uid, String packageName, @Nullable String featureId) {
+ if (!checkPermissionAndAppOp(enforce, pid, uid, packageName, featureId,
+ WRITE_EXTERNAL_STORAGE, OP_WRITE_EXTERNAL_STORAGE)) {
+ return false;
+ }
+ return noteAppOpAllowingLegacy(enforce, pid, uid, packageName, featureId,
+ OP_WRITE_MEDIA_AUDIO);
}
/** {@hide} */
public boolean checkPermissionReadVideo(boolean enforce,
- int pid, int uid, String packageName) {
- if (!checkPermissionAndAppOp(enforce, pid, uid, packageName,
- READ_EXTERNAL_STORAGE, OP_READ_EXTERNAL_STORAGE)) return false;
- return noteAppOpAllowingLegacy(enforce, pid, uid, packageName, OP_READ_MEDIA_VIDEO);
+ int pid, int uid, String packageName, @Nullable String featureId) {
+ if (!checkPermissionAndAppOp(enforce, pid, uid, packageName, featureId,
+ READ_EXTERNAL_STORAGE, OP_READ_EXTERNAL_STORAGE)) {
+ return false;
+ }
+ return noteAppOpAllowingLegacy(enforce, pid, uid, packageName, featureId,
+ OP_READ_MEDIA_VIDEO);
}
/** {@hide} */
public boolean checkPermissionWriteVideo(boolean enforce,
- int pid, int uid, String packageName) {
- if (!checkPermissionAndAppOp(enforce, pid, uid, packageName,
- WRITE_EXTERNAL_STORAGE, OP_WRITE_EXTERNAL_STORAGE)) return false;
- return noteAppOpAllowingLegacy(enforce, pid, uid, packageName, OP_WRITE_MEDIA_VIDEO);
+ int pid, int uid, String packageName, @Nullable String featureId) {
+ if (!checkPermissionAndAppOp(enforce, pid, uid, packageName, featureId,
+ WRITE_EXTERNAL_STORAGE, OP_WRITE_EXTERNAL_STORAGE)) {
+ return false;
+ }
+ return noteAppOpAllowingLegacy(enforce, pid, uid, packageName, featureId,
+ OP_WRITE_MEDIA_VIDEO);
}
/** {@hide} */
public boolean checkPermissionReadImages(boolean enforce,
- int pid, int uid, String packageName) {
- if (!checkPermissionAndAppOp(enforce, pid, uid, packageName,
- READ_EXTERNAL_STORAGE, OP_READ_EXTERNAL_STORAGE)) return false;
- return noteAppOpAllowingLegacy(enforce, pid, uid, packageName, OP_READ_MEDIA_IMAGES);
+ int pid, int uid, String packageName, @Nullable String featureId) {
+ if (!checkPermissionAndAppOp(enforce, pid, uid, packageName, featureId,
+ READ_EXTERNAL_STORAGE, OP_READ_EXTERNAL_STORAGE)) {
+ return false;
+ }
+ return noteAppOpAllowingLegacy(enforce, pid, uid, packageName, featureId,
+ OP_READ_MEDIA_IMAGES);
}
/** {@hide} */
public boolean checkPermissionWriteImages(boolean enforce,
- int pid, int uid, String packageName) {
- if (!checkPermissionAndAppOp(enforce, pid, uid, packageName,
- WRITE_EXTERNAL_STORAGE, OP_WRITE_EXTERNAL_STORAGE)) return false;
- return noteAppOpAllowingLegacy(enforce, pid, uid, packageName, OP_WRITE_MEDIA_IMAGES);
+ int pid, int uid, String packageName, @Nullable String featureId) {
+ if (!checkPermissionAndAppOp(enforce, pid, uid, packageName, featureId,
+ WRITE_EXTERNAL_STORAGE, OP_WRITE_EXTERNAL_STORAGE)) {
+ return false;
+ }
+ return noteAppOpAllowingLegacy(enforce, pid, uid, packageName, featureId,
+ OP_WRITE_MEDIA_IMAGES);
}
/** {@hide} */
diff --git a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
index dd561e1..d66aa18 100644
--- a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
+++ b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
@@ -2170,14 +2170,21 @@
}
}
+ @Deprecated
@Override
public ParcelFileDescriptor getWallpaper(String callingPkg, IWallpaperManagerCallback cb,
final int which, Bundle outParams, int wallpaperUserId) {
+ return getWallpaperWithFeature(callingPkg, null, cb, which, outParams, wallpaperUserId);
+ }
+
+ @Override
+ public ParcelFileDescriptor getWallpaperWithFeature(String callingPkg, String callingFeatureId,
+ IWallpaperManagerCallback cb, final int which, Bundle outParams, int wallpaperUserId) {
final int hasPrivilege = mContext.checkCallingOrSelfPermission(
android.Manifest.permission.READ_WALLPAPER_INTERNAL);
if (hasPrivilege != PackageManager.PERMISSION_GRANTED) {
mContext.getSystemService(StorageManager.class).checkPermissionReadImages(true,
- Binder.getCallingPid(), Binder.getCallingUid(), callingPkg);
+ Binder.getCallingPid(), Binder.getCallingUid(), callingPkg, callingFeatureId);
}
wallpaperUserId = ActivityManager.handleIncomingUser(Binder.getCallingPid(),