Add new WallpaperInfo attr settingsSliceUri.
Add settingsSliceUri attribute for supporting live wallpaper inline- control, public for AOSP live wallpaper to use. Bug: 117200693 Test: atest tests/Internal/src/android/app/WallpaperInfoTest.java Change-Id: Iffe9fbd9f49daf8a63d5745f91532de13b7288e3
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -16,4 +16,5 @@
|
||||
-->
|
||||
<wallpaper
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:supportsAmbientMode="true"/>
|
||||
android:settingsSliceUri="content://com.android.internal.tests/slice"
|
||||
android:supportsAmbientMode="true"/>
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user