From 10b13e85058e06f6390da298fd06daa0135de7e9 Mon Sep 17 00:00:00 2001 From: Nick Chameyev Date: Thu, 23 Sep 2021 17:13:40 +0000 Subject: [PATCH] Rename shouldUseDefaultUnfoldTransition attribute and update docs Renames the shouldUseDefaultUnfoldTransition attribute name to use more generic shouldUseDefaultDeviceStateChangeTransition name as the transition could be used on different form factors depending on the OEMs. Test: manual Fixes: 200730817 Fixes: 200698833 Change-Id: I1c5d755f76f455475471fc893d4748c6adf51b8c --- core/api/current.txt | 4 +-- core/java/android/app/WallpaperInfo.java | 34 ++++++++++--------- core/res/res/values/attrs.xml | 16 +++++---- core/res/res/values/public.xml | 2 +- .../systemui/util/WallpaperController.kt | 6 ++-- .../systemui/util/WallpaperControllerTest.kt | 7 ++-- 6 files changed, 37 insertions(+), 32 deletions(-) diff --git a/core/api/current.txt b/core/api/current.txt index 8ba8c1a7ab4c0..90c1e032ee4ee 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -1298,7 +1298,7 @@ package android { field public static final int shortcutLongLabel = 16844074; // 0x101052a field public static final int shortcutShortLabel = 16844073; // 0x1010529 field public static final int shouldDisableView = 16843246; // 0x10101ee - field public static final int shouldUseDefaultUnfoldTransition; + field public static final int shouldUseDefaultDeviceStateChangeTransition; field public static final int showAsAction = 16843481; // 0x10102d9 field public static final int showDefault = 16843258; // 0x10101fa field public static final int showDividers = 16843561; // 0x1010329 @@ -6927,7 +6927,7 @@ package android.app { method public android.graphics.drawable.Drawable loadIcon(android.content.pm.PackageManager); method public CharSequence loadLabel(android.content.pm.PackageManager); method public android.graphics.drawable.Drawable loadThumbnail(android.content.pm.PackageManager); - method public boolean shouldUseDefaultUnfoldTransition(); + method public boolean shouldUseDefaultDeviceStateChangeTransition(); method public boolean supportsMultipleDisplays(); method public void writeToParcel(android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator CREATOR; diff --git a/core/java/android/app/WallpaperInfo.java b/core/java/android/app/WallpaperInfo.java index 4dff4e0e84d62..c552cb62749b2 100644 --- a/core/java/android/app/WallpaperInfo.java +++ b/core/java/android/app/WallpaperInfo.java @@ -81,7 +81,7 @@ public final class WallpaperInfo implements Parcelable { final int mContextDescriptionResource; final boolean mShowMetadataInPreview; final boolean mSupportsAmbientMode; - final boolean mShouldUseDefaultUnfoldTransition; + final boolean mShouldUseDefaultDeviceStateChangeTransition; final String mSettingsSliceUri; final boolean mSupportMultipleDisplays; @@ -146,9 +146,9 @@ public final class WallpaperInfo implements Parcelable { mSupportsAmbientMode = sa.getBoolean( com.android.internal.R.styleable.Wallpaper_supportsAmbientMode, false); - mShouldUseDefaultUnfoldTransition = sa.getBoolean( - com.android.internal.R.styleable.Wallpaper_shouldUseDefaultUnfoldTransition, - true); + mShouldUseDefaultDeviceStateChangeTransition = sa.getBoolean( + com.android.internal.R.styleable + .Wallpaper_shouldUseDefaultDeviceStateChangeTransition, true); mSettingsSliceUri = sa.getString( com.android.internal.R.styleable.Wallpaper_settingsSliceUri); mSupportMultipleDisplays = sa.getBoolean( @@ -175,7 +175,7 @@ public final class WallpaperInfo implements Parcelable { mSupportsAmbientMode = source.readInt() != 0; mSettingsSliceUri = source.readString(); mSupportMultipleDisplays = source.readInt() != 0; - mShouldUseDefaultUnfoldTransition = source.readInt() != 0; + mShouldUseDefaultDeviceStateChangeTransition = source.readInt() != 0; mService = ResolveInfo.CREATOR.createFromParcel(source); } @@ -399,23 +399,25 @@ public final class WallpaperInfo implements Parcelable { } /** - * Returns whether this wallpaper should receive default zooming updates when unfolding. - * If set to false the wallpaper will not receive zoom events when folding or unfolding - * a foldable device, so it can implement its own unfold transition. + * Returns whether this wallpaper should receive default zooming updates when the device + * changes its state (e.g. when folding or unfolding a foldable device). + * If set to false the wallpaper will not receive zoom events when changing the device state, + * so it can implement its own transition instead. *

* This corresponds to the value {@link - * android.R.styleable#Wallpaper_shouldUseDefaultUnfoldTransition} in the XML description - * of the wallpaper. + * android.R.styleable#Wallpaper_shouldUseDefaultDeviceStateChangeTransition} in the + * XML description of the wallpaper. *

* The default value is {@code true}. * - * @see android.R.styleable#Wallpaper_shouldUseDefaultUnfoldTransition - * @return {@code true} if wallpaper should receive default fold/unfold transition updates + * @see android.R.styleable#Wallpaper_shouldUseDefaultDeviceStateChangeTransition + * @return {@code true} if wallpaper should receive default device state change + * transition updates * - * @attr ref android.R.styleable#Wallpaper_shouldUseDefaultUnfoldTransition + * @attr ref android.R.styleable#Wallpaper_shouldUseDefaultDeviceStateChangeTransition */ - public boolean shouldUseDefaultUnfoldTransition() { - return mShouldUseDefaultUnfoldTransition; + public boolean shouldUseDefaultDeviceStateChangeTransition() { + return mShouldUseDefaultDeviceStateChangeTransition; } public void dump(Printer pw, String prefix) { @@ -448,7 +450,7 @@ public final class WallpaperInfo implements Parcelable { dest.writeInt(mSupportsAmbientMode ? 1 : 0); dest.writeString(mSettingsSliceUri); dest.writeInt(mSupportMultipleDisplays ? 1 : 0); - dest.writeInt(mShouldUseDefaultUnfoldTransition ? 1 : 0); + dest.writeInt(mShouldUseDefaultDeviceStateChangeTransition ? 1 : 0); mService.writeToParcel(dest, flags); } diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index 0a6b02d499e52..53396407904a3 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -8371,16 +8371,18 @@ @hide @SystemApi --> - - + zoom rendering should be handled manually. Zoom updates are delivered only when + {@link android.service.wallpaper.WallpaperService.Engine} is created and not destroyed. + Default value is true. + Corresponds to + {@link android.app.WallpaperInfo#shouldUseDefaultDeviceStateChangeTransition()} --> + diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index 7d489049d112f..e17daf09e4da6 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -3221,7 +3221,7 @@ - + diff --git a/packages/SystemUI/src/com/android/systemui/util/WallpaperController.kt b/packages/SystemUI/src/com/android/systemui/util/WallpaperController.kt index db2aca873d0c2..a9810458fe90d 100644 --- a/packages/SystemUI/src/com/android/systemui/util/WallpaperController.kt +++ b/packages/SystemUI/src/com/android/systemui/util/WallpaperController.kt @@ -40,8 +40,8 @@ class WallpaperController @Inject constructor(private val wallpaperManager: Wall this.wallpaperInfo = wallpaperInfo } - private val shouldUseDefaultUnfoldTransition: Boolean - get() = wallpaperInfo?.shouldUseDefaultUnfoldTransition() + private val shouldUseDefaultDeviceStateChangeTransition: Boolean + get() = wallpaperInfo?.shouldUseDefaultDeviceStateChangeTransition() ?: true fun setNotificationShadeZoom(zoomOut: Float) { @@ -50,7 +50,7 @@ class WallpaperController @Inject constructor(private val wallpaperManager: Wall } fun setUnfoldTransitionZoom(zoomOut: Float) { - if (shouldUseDefaultUnfoldTransition) { + if (shouldUseDefaultDeviceStateChangeTransition) { unfoldTransitionZoomOut = zoomOut updateZoom() } diff --git a/packages/SystemUI/tests/src/com/android/systemui/util/WallpaperControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/util/WallpaperControllerTest.kt index 3cb19e3460dd1..de86821c05356 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/util/WallpaperControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/util/WallpaperControllerTest.kt @@ -91,7 +91,7 @@ class WallpaperControllerTest : SysuiTestCase() { @Test fun setUnfoldTransitionZoom_defaultUnfoldTransitionIsDisabled_doesNotUpdateWallpaperZoom() { wallaperController.onWallpaperInfoUpdated(createWallpaperInfo( - useDefaultUnfoldTransition = false + useDefaultTransition = false )) wallaperController.setUnfoldTransitionZoom(0.5f) @@ -136,9 +136,10 @@ class WallpaperControllerTest : SysuiTestCase() { verify(wallpaperManager).setWallpaperZoomOut(any(), anyFloat()) } - private fun createWallpaperInfo(useDefaultUnfoldTransition: Boolean = true): WallpaperInfo { + private fun createWallpaperInfo(useDefaultTransition: Boolean = true): WallpaperInfo { val info = mock(WallpaperInfo::class.java) - whenever(info.shouldUseDefaultUnfoldTransition()).thenReturn(useDefaultUnfoldTransition) + whenever(info.shouldUseDefaultDeviceStateChangeTransition()) + .thenReturn(useDefaultTransition) return info } }