diff options
| -rw-r--r-- | core/java/android/app/WallpaperManager.java | 23 | ||||
| -rw-r--r-- | packages/SettingsProvider/AndroidManifest.xml | 2 | ||||
| -rw-r--r-- | packages/SettingsProvider/res/drawable-hdpi/ic_launcher_settings.png | bin | 7230 -> 0 bytes | |||
| -rw-r--r-- | packages/SettingsProvider/res/drawable-mdpi/ic_launcher_settings.png | bin | 4122 -> 0 bytes | |||
| -rw-r--r-- | packages/SettingsProvider/res/drawable-xhdpi/ic_launcher_settings.png | bin | 11183 -> 0 bytes | |||
| -rw-r--r-- | packages/SettingsProvider/res/mipmap-hdpi/ic_launcher_settings.png | bin | 0 -> 8822 bytes | |||
| -rw-r--r-- | packages/SettingsProvider/res/mipmap-mdpi/ic_launcher_settings.png | bin | 0 -> 5362 bytes | |||
| -rw-r--r-- | packages/SettingsProvider/res/mipmap-xhdpi/ic_launcher_settings.png | bin | 0 -> 12096 bytes | |||
| -rw-r--r-- | packages/SettingsProvider/res/mipmap-xxhdpi/ic_launcher_settings.png | bin | 0 -> 20300 bytes | |||
| -rw-r--r-- | packages/SettingsProvider/res/mipmap-xxxhdpi/ic_launcher_settings.png | bin | 0 -> 27997 bytes |
10 files changed, 23 insertions, 2 deletions
diff --git a/core/java/android/app/WallpaperManager.java b/core/java/android/app/WallpaperManager.java index c39415f3c2d8..eb1f265026e0 100644 --- a/core/java/android/app/WallpaperManager.java +++ b/core/java/android/app/WallpaperManager.java @@ -16,6 +16,7 @@ package android.app; +import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; @@ -72,6 +73,7 @@ public class WallpaperManager { * an intent; instead, use {@link #getCropAndSetWallpaperIntent}. * <p>Input: {@link Intent#getData} is the URI of the image to crop and set as wallpaper. * <p>Output: RESULT_OK if user decided to crop/set the wallpaper, RESULT_CANCEL otherwise + * Activities that support this intent should specify a MIME filter of "image/*" */ public static final String ACTION_CROP_AND_SET_WALLPAPER = "android.service.wallpaper.CROP_AND_SET_WALLPAPER"; @@ -657,8 +659,19 @@ public class WallpaperManager { * that supports cropping wallpapers, it will be preferred as the default. * Use this method instead of directly creating a {@link #ACTION_CROP_AND_SET_WALLPAPER} * intent. + * + * @param imageUri The image URI that will be set in the intent. The must be a content + * URI and its provider must resolve its type to "image/*" + * + * @throws IllegalArgumentException if the URI is not a content URI or its MIME type is + * not "image/*" */ public Intent getCropAndSetWallpaperIntent(Uri imageUri) { + if (!ContentResolver.SCHEME_CONTENT.equals(imageUri.getScheme())) { + throw new IllegalArgumentException("Image URI must be of the " + + ContentResolver.SCHEME_CONTENT + " scheme type"); + } + final PackageManager packageManager = mContext.getPackageManager(); Intent cropAndSetWallpaperIntent = new Intent(ACTION_CROP_AND_SET_WALLPAPER, imageUri); @@ -680,7 +693,15 @@ public class WallpaperManager { // fallback crop activity cropAndSetWallpaperIntent.setPackage("com.android.wallpapercropper"); - return cropAndSetWallpaperIntent; + List<ResolveInfo> cropAppList = packageManager.queryIntentActivities( + cropAndSetWallpaperIntent, 0); + if (cropAppList.size() > 0) { + return cropAndSetWallpaperIntent; + } + // If the URI is not of the right type, or for some reason the system wallpaper + // cropper doesn't exist, return null + throw new IllegalArgumentException("Cannot use passed URI to set wallpaper; " + + "check that the type returned by ContentProvider matches image/*"); } /** diff --git a/packages/SettingsProvider/AndroidManifest.xml b/packages/SettingsProvider/AndroidManifest.xml index ab2feb9b2c3c..783aa0342ae4 100644 --- a/packages/SettingsProvider/AndroidManifest.xml +++ b/packages/SettingsProvider/AndroidManifest.xml @@ -8,7 +8,7 @@ android:process="system" android:backupAgent="SettingsBackupAgent" android:killAfterRestore="false" - android:icon="@drawable/ic_launcher_settings"> + android:icon="@mipmap/ic_launcher_settings"> <!-- todo add: android:neverEncrypt="true" --> diff --git a/packages/SettingsProvider/res/drawable-hdpi/ic_launcher_settings.png b/packages/SettingsProvider/res/drawable-hdpi/ic_launcher_settings.png Binary files differdeleted file mode 100644 index 8a5a2f704bb5..000000000000 --- a/packages/SettingsProvider/res/drawable-hdpi/ic_launcher_settings.png +++ /dev/null diff --git a/packages/SettingsProvider/res/drawable-mdpi/ic_launcher_settings.png b/packages/SettingsProvider/res/drawable-mdpi/ic_launcher_settings.png Binary files differdeleted file mode 100644 index 803439ff4ae0..000000000000 --- a/packages/SettingsProvider/res/drawable-mdpi/ic_launcher_settings.png +++ /dev/null diff --git a/packages/SettingsProvider/res/drawable-xhdpi/ic_launcher_settings.png b/packages/SettingsProvider/res/drawable-xhdpi/ic_launcher_settings.png Binary files differdeleted file mode 100644 index ec3c8ea3e14e..000000000000 --- a/packages/SettingsProvider/res/drawable-xhdpi/ic_launcher_settings.png +++ /dev/null diff --git a/packages/SettingsProvider/res/mipmap-hdpi/ic_launcher_settings.png b/packages/SettingsProvider/res/mipmap-hdpi/ic_launcher_settings.png Binary files differnew file mode 100644 index 000000000000..a8ccc8938124 --- /dev/null +++ b/packages/SettingsProvider/res/mipmap-hdpi/ic_launcher_settings.png diff --git a/packages/SettingsProvider/res/mipmap-mdpi/ic_launcher_settings.png b/packages/SettingsProvider/res/mipmap-mdpi/ic_launcher_settings.png Binary files differnew file mode 100644 index 000000000000..69709a8b4ed5 --- /dev/null +++ b/packages/SettingsProvider/res/mipmap-mdpi/ic_launcher_settings.png diff --git a/packages/SettingsProvider/res/mipmap-xhdpi/ic_launcher_settings.png b/packages/SettingsProvider/res/mipmap-xhdpi/ic_launcher_settings.png Binary files differnew file mode 100644 index 000000000000..c3adce611a15 --- /dev/null +++ b/packages/SettingsProvider/res/mipmap-xhdpi/ic_launcher_settings.png diff --git a/packages/SettingsProvider/res/mipmap-xxhdpi/ic_launcher_settings.png b/packages/SettingsProvider/res/mipmap-xxhdpi/ic_launcher_settings.png Binary files differnew file mode 100644 index 000000000000..52fe9785598a --- /dev/null +++ b/packages/SettingsProvider/res/mipmap-xxhdpi/ic_launcher_settings.png diff --git a/packages/SettingsProvider/res/mipmap-xxxhdpi/ic_launcher_settings.png b/packages/SettingsProvider/res/mipmap-xxxhdpi/ic_launcher_settings.png Binary files differnew file mode 100644 index 000000000000..6b92795d421f --- /dev/null +++ b/packages/SettingsProvider/res/mipmap-xxxhdpi/ic_launcher_settings.png |