Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0a14f331 authored by Nick Chameyev's avatar Nick Chameyev
Browse files

Add should use default unfold transition attribute to wallpaper

Adds new attribute to wallpaper XML declaration to indicate
whether a wallpaper should receive default zooming transition
updates when folding or unfolding. This attribute allows to
opt-out from the default behaviour during this transition and
implement custom behaviour.

Bug: 196933493
Test: atest android.app.cts.WallpaperInfoTest
Change-Id: I7cb104bf7dfbbe92de72e505ec31d866a59bae4a
parent 75497636
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1298,6 +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 showAsAction = 16843481; // 0x10102d9
    field public static final int showDefault = 16843258; // 0x10101fa
    field public static final int showDividers = 16843561; // 0x1010329
@@ -6926,6 +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 supportsMultipleDisplays();
    method public void writeToParcel(android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.app.WallpaperInfo> CREATOR;
+26 −0
Original line number Diff line number Diff line
@@ -81,6 +81,7 @@ public final class WallpaperInfo implements Parcelable {
    final int mContextDescriptionResource;
    final boolean mShowMetadataInPreview;
    final boolean mSupportsAmbientMode;
    final boolean mShouldUseDefaultUnfoldTransition;
    final String mSettingsSliceUri;
    final boolean mSupportMultipleDisplays;

@@ -145,6 +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);
            mSettingsSliceUri = sa.getString(
                    com.android.internal.R.styleable.Wallpaper_settingsSliceUri);
            mSupportMultipleDisplays = sa.getBoolean(
@@ -171,6 +175,7 @@ public final class WallpaperInfo implements Parcelable {
        mSupportsAmbientMode = source.readInt() != 0;
        mSettingsSliceUri = source.readString();
        mSupportMultipleDisplays = source.readInt() != 0;
        mShouldUseDefaultUnfoldTransition = source.readInt() != 0;
        mService = ResolveInfo.CREATOR.createFromParcel(source);
    }
    
@@ -393,6 +398,26 @@ public final class WallpaperInfo implements Parcelable {
        return mSupportMultipleDisplays;
    }

    /**
     * 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.
     * <p>
     * This corresponds to the value {@link
     * android.R.styleable#Wallpaper_shouldUseDefaultUnfoldTransition} in the XML description
     * of the wallpaper.
     * <p>
     * The default value is {@code true}.
     *
     * @see android.R.styleable#Wallpaper_shouldUseDefaultUnfoldTransition
     * @return {@code true} if wallpaper should receive default fold/unfold transition updates
     *
     * @attr ref android.R.styleable#Wallpaper_shouldUseDefaultUnfoldTransition
     */
    public boolean shouldUseDefaultUnfoldTransition() {
        return mShouldUseDefaultUnfoldTransition;
    }

    public void dump(Printer pw, String prefix) {
        pw.println(prefix + "Service:");
        mService.dump(pw, prefix + "  ");
@@ -423,6 +448,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);
        mService.writeToParcel(dest, flags);
    }

+11 −0
Original line number Diff line number Diff line
@@ -8371,6 +8371,17 @@
             @hide @SystemApi -->
        <attr name="supportsAmbientMode" format="boolean" />
        <!-- Indicates that this wallpaper service should receive zoom updates when unfolding.
             When this value is set to true
             {@link android.service.wallpaper.WallpaperService.Engine} could receive zoom updates
             when folding or unfolding a foldable device. Wallpapers receive zoom updates using
             {@link android.service.wallpaper.WallpaperService.Engine#onZoomChanged(float)} and
             zoom rendering should be handled manually. Default value is true.
             When set to false wallpapers can implement custom folding/unfolding behavior
             by listening to {@link android.hardware.Sensor#TYPE_HINGE_ANGLE}.
             Corresponds to {@link android.app.WallpaperInfo#shouldUseDefaultUnfoldTransition()} -->
        <attr name="shouldUseDefaultUnfoldTransition" format="boolean" />
        <!-- Uri that specifies a settings Slice for this wallpaper. -->
        <attr name="settingsSliceUri" format="string"/>
+1 −0
Original line number Diff line number Diff line
@@ -3221,6 +3221,7 @@
  <eat-comment />

  <staging-public-group type="attr" first-id="0x01ff0000">
    <public name="shouldUseDefaultUnfoldTransition" />
  </staging-public-group>

  <staging-public-group type="id" first-id="0x01fe0000">
+3 −11
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ package com.android.systemui.statusbar
import android.animation.Animator
import android.animation.AnimatorListenerAdapter
import android.animation.ValueAnimator
import android.app.WallpaperManager
import android.os.SystemClock
import android.os.Trace
import android.util.IndentingPrintWriter
@@ -42,6 +41,7 @@ import com.android.systemui.statusbar.phone.DozeParameters
import com.android.systemui.statusbar.phone.PanelExpansionListener
import com.android.systemui.statusbar.phone.ScrimController
import com.android.systemui.statusbar.policy.KeyguardStateController
import com.android.systemui.util.WallpaperController
import java.io.FileDescriptor
import java.io.PrintWriter
import javax.inject.Inject
@@ -58,7 +58,7 @@ class NotificationShadeDepthController @Inject constructor(
    private val biometricUnlockController: BiometricUnlockController,
    private val keyguardStateController: KeyguardStateController,
    private val choreographer: Choreographer,
    private val wallpaperManager: WallpaperManager,
    private val wallpaperController: WallpaperController,
    private val notificationShadeWindowController: NotificationShadeWindowController,
    private val dozeParameters: DozeParameters,
    dumpManager: DumpManager
@@ -215,15 +215,7 @@ class NotificationShadeDepthController @Inject constructor(
        Trace.traceCounter(Trace.TRACE_TAG_APP, "shade_blur_radius", blur)
        blurUtils.applyBlur(blurRoot?.viewRootImpl ?: root.viewRootImpl, blur, opaque)
        lastAppliedBlur = blur
        try {
            if (root.isAttachedToWindow && root.windowToken != null) {
                wallpaperManager.setWallpaperZoomOut(root.windowToken, zoomOut)
            } else {
                Log.i(TAG, "Won't set zoom. Window not attached $root")
            }
        } catch (e: IllegalArgumentException) {
            Log.w(TAG, "Can't set zoom. Window is gone: ${root.windowToken}", e)
        }
        wallpaperController.setNotificationShadeZoom(zoomOut)
        listeners.forEach {
            it.onWallpaperZoomOutChanged(zoomOut)
            it.onBlurRadiusChanged(blur)
Loading