diff options
author | Weien Wang <weienwang@google.com> | 2018-10-05 19:46:41 +0800 |
---|---|---|
committer | Weien Wang <weienwang@google.com> | 2018-10-22 14:16:55 +0800 |
commit | 4710c04e1fb7ea57716c0229419a4d5bd37124c3 (patch) | |
tree | 966879f204bf81ea0e1bde398a0cfcc9e0845e46 /tests/Internal | |
parent | 60786f886657c44a3ee89bc6307a8239495268c2 (diff) |
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
Diffstat (limited to 'tests/Internal')
-rw-r--r-- | tests/Internal/res/xml/livewallpaper.xml | 3 | ||||
-rw-r--r-- | tests/Internal/src/android/app/WallpaperInfoTest.java | 27 |
2 files changed, 29 insertions, 1 deletions
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(); + } } |