summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xapi/current.txt2
-rw-r--r--core/java/android/app/WallpaperInfo.java24
-rw-r--r--core/res/res/values/attrs.xml3
-rw-r--r--core/res/res/values/public.xml1
-rw-r--r--tests/Internal/res/xml/livewallpaper.xml3
-rw-r--r--tests/Internal/src/android/app/WallpaperInfoTest.java27
6 files changed, 57 insertions, 3 deletions
diff --git a/api/current.txt b/api/current.txt
index 1983fb483ecd..2f0dfc0cce86 100755
--- a/api/current.txt
+++ b/api/current.txt
@@ -1199,6 +1199,7 @@ package android {
field public static final deprecated int selectedWeekBackgroundColor = 16843586; // 0x1010342
field public static final int sessionService = 16843837; // 0x101043d
field public static final int settingsActivity = 16843301; // 0x1010225
+ field public static final int settingsSliceUri = 16844179; // 0x1010593
field public static final int setupActivity = 16843766; // 0x10103f6
field public static final int shadowColor = 16843105; // 0x1010161
field public static final int shadowDx = 16843106; // 0x1010162
@@ -6320,6 +6321,7 @@ package android.app {
method public android.content.pm.ServiceInfo getServiceInfo();
method public java.lang.String getServiceName();
method public java.lang.String getSettingsActivity();
+ method public android.net.Uri getSettingsSliceUri();
method public boolean getShowMetadataInPreview();
method public java.lang.CharSequence loadAuthor(android.content.pm.PackageManager) throws android.content.res.Resources.NotFoundException;
method public java.lang.CharSequence loadContextDescription(android.content.pm.PackageManager) throws android.content.res.Resources.NotFoundException;
diff --git a/core/java/android/app/WallpaperInfo.java b/core/java/android/app/WallpaperInfo.java
index 9873a8152b3f..e33d1fed4b4c 100644
--- a/core/java/android/app/WallpaperInfo.java
+++ b/core/java/android/app/WallpaperInfo.java
@@ -16,6 +16,7 @@
package android.app;
+import android.app.slice.Slice;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.ApplicationInfo;
@@ -77,6 +78,7 @@ public final class WallpaperInfo implements Parcelable {
final int mContextDescriptionResource;
final boolean mShowMetadataInPreview;
final boolean mSupportsAmbientMode;
+ final String mSettingsSliceUri;
/**
* Constructor.
@@ -118,7 +120,6 @@ public final class WallpaperInfo implements Parcelable {
com.android.internal.R.styleable.Wallpaper);
mSettingsActivityName = sa.getString(
com.android.internal.R.styleable.Wallpaper_settingsActivity);
-
mThumbnailResource = sa.getResourceId(
com.android.internal.R.styleable.Wallpaper_thumbnail,
-1);
@@ -140,6 +141,8 @@ public final class WallpaperInfo implements Parcelable {
mSupportsAmbientMode = sa.getBoolean(
com.android.internal.R.styleable.Wallpaper_supportsAmbientMode,
false);
+ mSettingsSliceUri = sa.getString(
+ com.android.internal.R.styleable.Wallpaper_settingsSliceUri);
sa.recycle();
} catch (NameNotFoundException e) {
@@ -159,6 +162,7 @@ public final class WallpaperInfo implements Parcelable {
mContextDescriptionResource = source.readInt();
mShowMetadataInPreview = source.readInt() != 0;
mSupportsAmbientMode = source.readInt() != 0;
+ mSettingsSliceUri = source.readString();
mService = ResolveInfo.CREATOR.createFromParcel(source);
}
@@ -332,13 +336,28 @@ public final class WallpaperInfo implements Parcelable {
* explicit {@link android.content.ComponentName}
* composed of {@link #getPackageName} and the class name returned here.
*
- * <p>A null will be returned if there is no settings activity associated
+ * <p>{@code null} will be returned if there is no settings activity associated
* with the wallpaper.
*/
public String getSettingsActivity() {
return mSettingsActivityName;
}
+ /**
+ * Returns an URI that provides a settings {@link Slice} for this wallpaper.
+ *
+ * <p>{@code null} will be returned if there is no settings Slice URI associated
+ * with the wallpaper.
+ *
+ * @return The URI.
+ */
+ public Uri getSettingsSliceUri() {
+ if (mSettingsSliceUri == null) {
+ return null;
+ }
+ return Uri.parse(mSettingsSliceUri);
+ }
+
public void dump(Printer pw, String prefix) {
pw.println(prefix + "Service:");
mService.dump(pw, prefix + " ");
@@ -367,6 +386,7 @@ public final class WallpaperInfo implements Parcelable {
dest.writeInt(mContextDescriptionResource);
dest.writeInt(mShowMetadataInPreview ? 1 : 0);
dest.writeInt(mSupportsAmbientMode ? 1 : 0);
+ dest.writeString(mSettingsSliceUri);
mService.writeToParcel(dest, flags);
}
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 9bedab53bb2c..32cf2e8bac86 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -7894,6 +7894,9 @@
<!-- Wallpapers optimized and capable of drawing in ambient mode will return true. -->
<attr name="supportsAmbientMode" format="boolean" />
+ <!-- Uri that specifies a settings Slice for this wallpaper. -->
+ <attr name="settingsSliceUri" />
+
</declare-styleable>
<!-- Use <code>dream</code> as the root tag of the XML resource that
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 31212a6ab28f..fd688a72b7ea 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -2916,6 +2916,7 @@
<public name="isLightTheme" />
<public name="isSplitRequired" />
<public name="textLocale" />
+ <public name="settingsSliceUri" />
</public-group>
<public-group type="drawable" first-id="0x010800b4">
diff --git a/tests/Internal/res/xml/livewallpaper.xml b/tests/Internal/res/xml/livewallpaper.xml
index 6b5e84e8f9ad..36e7e4182c31 100644
--- a/tests/Internal/res/xml/livewallpaper.xml
+++ b/tests/Internal/res/xml/livewallpaper.xml
@@ -16,4 +16,5 @@
-->
<wallpaper
xmlns:android="http://schemas.android.com/apk/res/android"
- android:supportsAmbientMode="true"/> \ No newline at end of file
+ android:settingsSliceUri="content://com.android.internal.tests/slice"
+ android:supportsAmbientMode="true"/>
diff --git a/tests/Internal/src/android/app/WallpaperInfoTest.java b/tests/Internal/src/android/app/WallpaperInfoTest.java
index 98045ae98541..7f06f2cb7aeb 100644
--- a/tests/Internal/src/android/app/WallpaperInfoTest.java
+++ b/tests/Internal/src/android/app/WallpaperInfoTest.java
@@ -23,6 +23,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
+import android.net.Uri;
import android.os.Parcel;
import android.service.wallpaper.WallpaperService;
import android.support.test.InstrumentationRegistry;
@@ -64,5 +65,31 @@ public class WallpaperInfoTest {
fromParcel.supportsAmbientMode());
parcel.recycle();
}
+
+ @Test
+ public void testGetSettingsSliceUri() throws Exception {
+ Context context = InstrumentationRegistry.getTargetContext();
+
+ Intent intent = new Intent(WallpaperService.SERVICE_INTERFACE);
+ intent.setPackage("com.android.internal.tests");
+ PackageManager pm = context.getPackageManager();
+ List<ResolveInfo> result = pm.queryIntentServices(intent, PackageManager.GET_META_DATA);
+ assertEquals(1, result.size());
+ ResolveInfo info = result.get(0);
+ WallpaperInfo wallpaperInfo = new WallpaperInfo(context, info);
+
+ // This expected Uri must be the same as that in livewallpaper.xml
+ Uri expectedUri = Uri.parse("content://com.android.internal.tests/slice");
+ Uri settingsUri = wallpaperInfo.getSettingsSliceUri();
+ assertEquals("The loaded URI should equal to the string in livewallpaper.xml",
+ 0, expectedUri.compareTo(settingsUri));
+ Parcel parcel = Parcel.obtain();
+ wallpaperInfo.writeToParcel(parcel, 0 /* flags */);
+ parcel.setDataPosition(0);
+ WallpaperInfo fromParcel = WallpaperInfo.CREATOR.createFromParcel(parcel);
+ assertEquals("settingsSliceUri should be restorable from parcelable",
+ 0, expectedUri.compareTo(fromParcel.getSettingsSliceUri()));
+ parcel.recycle();
+ }
}