diff options
136 files changed, 1122 insertions, 7352 deletions
diff --git a/core/java/android/hardware/contexthub/HubEndpoint.java b/core/java/android/hardware/contexthub/HubEndpoint.java index de88895ba55c..af92cffc57f4 100644 --- a/core/java/android/hardware/contexthub/HubEndpoint.java +++ b/core/java/android/hardware/contexthub/HubEndpoint.java @@ -499,11 +499,12 @@ public class HubEndpoint { private final String mPackageName; @Nullable private HubEndpointLifecycleCallback mLifecycleCallback; - - @NonNull private Executor mLifecycleCallbackExecutor; + @Nullable private Executor mLifecycleCallbackExecutor; @Nullable private HubEndpointMessageCallback mMessageCallback; - @NonNull private Executor mMessageCallbackExecutor; + @Nullable private Executor mMessageCallbackExecutor; + + @NonNull private final Executor mMainExecutor; private int mVersion; @Nullable private String mTag; @@ -514,8 +515,7 @@ public class HubEndpoint { public Builder(@NonNull Context context) { mPackageName = context.getPackageName(); mVersion = (int) context.getApplicationInfo().longVersionCode; - mLifecycleCallbackExecutor = context.getMainExecutor(); - mMessageCallbackExecutor = context.getMainExecutor(); + mMainExecutor = context.getMainExecutor(); } /** @@ -546,6 +546,7 @@ public class HubEndpoint { @NonNull public Builder setLifecycleCallback( @NonNull HubEndpointLifecycleCallback lifecycleCallback) { + mLifecycleCallbackExecutor = null; mLifecycleCallback = lifecycleCallback; return this; } @@ -569,6 +570,7 @@ public class HubEndpoint { */ @NonNull public Builder setMessageCallback(@NonNull HubEndpointMessageCallback messageCallback) { + mMessageCallbackExecutor = null; mMessageCallback = messageCallback; return this; } @@ -604,9 +606,9 @@ public class HubEndpoint { return new HubEndpoint( new HubEndpointInfo(mPackageName, mVersion, mTag, mServiceInfos), mLifecycleCallback, - mLifecycleCallbackExecutor, + mLifecycleCallbackExecutor != null ? mLifecycleCallbackExecutor : mMainExecutor, mMessageCallback, - mMessageCallbackExecutor); + mMessageCallbackExecutor != null ? mMessageCallbackExecutor : mMainExecutor); } } } diff --git a/core/java/android/hardware/input/InputSettings.java b/core/java/android/hardware/input/InputSettings.java index f8f7f5e0586e..34c88e91a979 100644 --- a/core/java/android/hardware/input/InputSettings.java +++ b/core/java/android/hardware/input/InputSettings.java @@ -25,6 +25,7 @@ import static com.android.hardware.input.Flags.keyboardA11yBounceKeysFlag; import static com.android.hardware.input.Flags.keyboardA11yMouseKeys; import static com.android.hardware.input.Flags.keyboardA11ySlowKeysFlag; import static com.android.hardware.input.Flags.keyboardA11yStickyKeysFlag; +import static com.android.hardware.input.Flags.mouseScrollingAcceleration; import static com.android.hardware.input.Flags.mouseReverseVerticalScrolling; import static com.android.hardware.input.Flags.mouseSwapPrimaryButton; import static com.android.hardware.input.Flags.touchpadSystemGestureDisable; @@ -392,6 +393,15 @@ public class InputSettings { } /** + * Returns true if the feature flag for toggling the mouse scrolling acceleration is enabled. + * + * @hide + */ + public static boolean isMouseScrollingAccelerationFeatureFlagEnabled() { + return mouseScrollingAcceleration(); + } + + /** * Returns true if the feature flag for mouse reverse vertical scrolling is enabled. * @hide */ @@ -593,7 +603,44 @@ public class InputSettings { } /** - * Whether mouse vertical scrolling is enabled, this applies only to connected mice. + * Whether mouse scrolling acceleration is enabled. This applies only to connected mice. + * + * @param context The application context. + * @return Whether the mouse scrolling is accelerated based on the user's scrolling speed. + * + * @hide + */ + public static boolean isMouseScrollingAccelerationEnabled(@NonNull Context context) { + if (!isMouseScrollingAccelerationFeatureFlagEnabled()) { + return true; + } + + return Settings.System.getIntForUser(context.getContentResolver(), + Settings.System.MOUSE_SCROLLING_ACCELERATION, 0, UserHandle.USER_CURRENT) != 0; + } + + /** + * Sets whether the connected mouse scrolling acceleration is enabled. + * + * @param context The application context. + * @param scrollingAcceleration Whether mouse scrolling acceleration is enabled. + * + * @hide + */ + @RequiresPermission(Manifest.permission.WRITE_SETTINGS) + public static void setMouseScrollingAcceleration(@NonNull Context context, + boolean scrollingAcceleration) { + if (!isMouseScrollingAccelerationFeatureFlagEnabled()) { + return; + } + + Settings.System.putIntForUser(context.getContentResolver(), + Settings.System.MOUSE_SCROLLING_ACCELERATION, scrollingAcceleration ? 1 : 0, + UserHandle.USER_CURRENT); + } + + /** + * Whether mouse vertical scrolling is reversed. This applies only to connected mice. * * @param context The application context. * @return Whether the mouse will have its vertical scrolling reversed diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index c1dd36101fc8..c57243d0bc73 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -6352,6 +6352,16 @@ public final class Settings { "mouse_swap_primary_button"; /** + * Whether to enable mouse scrolling acceleration. + * + * When enabled, mouse scrolling is accelerated based on the user's scrolling speed. + * When disabled, mouse scrolling speed becomes directly proportional to the speed at which + * the wheel is turned. + * @hide + */ + public static final String MOUSE_SCROLLING_ACCELERATION = "mouse_scrolling_acceleration"; + + /** * Pointer fill style, specified by * {@link android.view.PointerIcon.PointerIconVectorStyleFill} constants. * @@ -6601,6 +6611,7 @@ public final class Settings { PRIVATE_SETTINGS.add(MOUSE_REVERSE_VERTICAL_SCROLLING); PRIVATE_SETTINGS.add(MOUSE_SWAP_PRIMARY_BUTTON); PRIVATE_SETTINGS.add(PREFERRED_REGION); + PRIVATE_SETTINGS.add(MOUSE_SCROLLING_ACCELERATION); } /** diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java index 2061abac248e..990b099d616e 100644 --- a/core/java/android/service/wallpaper/WallpaperService.java +++ b/core/java/android/service/wallpaper/WallpaperService.java @@ -2409,6 +2409,12 @@ public abstract class WallpaperService extends Service { }; private Surface getOrCreateBLASTSurface(int width, int height, int format) { + if (mBbqSurfaceControl == null || !mBbqSurfaceControl.isValid()) { + Log.w(TAG, "Skipping BlastBufferQueue update/create" + + " - invalid surface control"); + return null; + } + Surface ret = null; if (mBlastBufferQueue == null) { mBlastBufferQueue = new BLASTBufferQueue("Wallpaper", mBbqSurfaceControl, @@ -2418,11 +2424,7 @@ public abstract class WallpaperService extends Service { // it hasn't changed and there is no need to update. ret = mBlastBufferQueue.createSurface(); } else { - if (mBbqSurfaceControl != null && mBbqSurfaceControl.isValid()) { - mBlastBufferQueue.update(mBbqSurfaceControl, width, height, format); - } else { - Log.w(TAG, "Skipping BlastBufferQueue update - invalid surface control"); - } + mBlastBufferQueue.update(mBbqSurfaceControl, width, height, format); } return ret; diff --git a/core/java/android/window/flags/lse_desktop_experience.aconfig b/core/java/android/window/flags/lse_desktop_experience.aconfig index b5582ff9d9be..ccb1e2b4b652 100644 --- a/core/java/android/window/flags/lse_desktop_experience.aconfig +++ b/core/java/android/window/flags/lse_desktop_experience.aconfig @@ -528,4 +528,11 @@ flag { namespace: "lse_desktop_experience" description: "Enables having a DesktopWallpaperActivity at a per-display level." bug: "381935663" +} + +flag { + name: "enable_desktop_wallpaper_activity_on_system_user" + namespace: "lse_desktop_experience" + description: "Enables starting DesktopWallpaperActivity on system user." + bug: "385294350" }
\ No newline at end of file diff --git a/core/proto/android/providers/settings/system.proto b/core/proto/android/providers/settings/system.proto index e424e82b94cd..dd9bfa51c634 100644 --- a/core/proto/android/providers/settings/system.proto +++ b/core/proto/android/providers/settings/system.proto @@ -227,6 +227,7 @@ message SystemSettingsProto { optional SettingProto reverse_vertical_scrolling = 1 [ (android.privacy).dest = DEST_AUTOMATIC ]; optional SettingProto swap_primary_button = 2 [ (android.privacy).dest = DEST_AUTOMATIC ]; + optional SettingProto scrolling_acceleration = 3 [ (android.privacy).dest = DEST_AUTOMATIC ]; } optional Mouse mouse = 38; diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index ed05e6de0fe0..dc954718d623 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -4559,7 +4559,8 @@ @FlaggedApi(android.companion.virtualdevice.flags.Flags.FLAG_ENABLE_LIMITED_VDM_ROLE) --> <permission android:name="android.permission.REQUEST_COMPANION_PROFILE_SENSOR_DEVICE_STREAMING" - android:protectionLevel="signature|privileged" /> + android:protectionLevel="signature|privileged" + android:featureFlag="android.companion.virtualdevice.flags.enable_limited_vdm_role" /> <!-- Allows application to request to be associated with a vehicle head unit capable of automotive projection diff --git a/libs/WindowManager/Shell/AndroidManifest.xml b/libs/WindowManager/Shell/AndroidManifest.xml index 46fe53716c01..b2ac640a468d 100644 --- a/libs/WindowManager/Shell/AndroidManifest.xml +++ b/libs/WindowManager/Shell/AndroidManifest.xml @@ -26,13 +26,13 @@ <uses-permission android:name="android.permission.SUBSCRIBE_TO_KEYGUARD_LOCKED_STATE" /> <uses-permission android:name="android.permission.UPDATE_DOMAIN_VERIFICATION_USER_SELECTION" /> <uses-permission android:name="android.permission.MANAGE_KEY_GESTURES" /> - <uses-permission android:name="android.permission.MANAGE_DISPLAYS" /> <application> <activity android:name=".desktopmode.DesktopWallpaperActivity" android:excludeFromRecents="true" android:launchMode="singleInstance" + android:showForAllUsers="true" android:theme="@style/DesktopWallpaperTheme" /> <activity diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayController.java index 3a8a7f6e46d3..f532be6b8277 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayController.java @@ -21,7 +21,6 @@ import android.content.Context; import android.content.res.Configuration; import android.graphics.Rect; import android.hardware.display.DisplayManager; -import android.hardware.display.DisplayTopology; import android.os.RemoteException; import android.util.ArraySet; import android.util.Size; @@ -55,7 +54,6 @@ public class DisplayController { private final ShellExecutor mMainExecutor; private final Context mContext; private final IWindowManager mWmService; - private final DisplayManager mDisplayManager; private final DisplayChangeController mChangeController; private final IDisplayWindowListener mDisplayContainerListener; @@ -63,11 +61,10 @@ public class DisplayController { private final ArrayList<OnDisplaysChangedListener> mDisplayChangedListeners = new ArrayList<>(); public DisplayController(Context context, IWindowManager wmService, ShellInit shellInit, - ShellExecutor mainExecutor, DisplayManager displayManager) { + ShellExecutor mainExecutor) { mMainExecutor = mainExecutor; mContext = context; mWmService = wmService; - mDisplayManager = displayManager; // TODO: Inject this instead mChangeController = new DisplayChangeController(mWmService, shellInit, mainExecutor); mDisplayContainerListener = new DisplayWindowListenerImpl(); @@ -77,7 +74,7 @@ public class DisplayController { } /** - * Initializes the window listener and the topology listener. + * Initializes the window listener. */ public void onInit() { try { @@ -85,9 +82,6 @@ public class DisplayController { for (int i = 0; i < displayIds.length; i++) { onDisplayAdded(displayIds[i]); } - - mDisplayManager.registerTopologyListener(mMainExecutor, this::onDisplayTopologyChanged); - onDisplayTopologyChanged(mDisplayManager.getDisplayTopology()); } catch (RemoteException e) { throw new RuntimeException("Unable to register display controller"); } @@ -97,7 +91,8 @@ public class DisplayController { * Gets a display by id from DisplayManager. */ public Display getDisplay(int displayId) { - return mDisplayManager.getDisplay(displayId); + final DisplayManager displayManager = mContext.getSystemService(DisplayManager.class); + return displayManager.getDisplay(displayId); } /** @@ -226,14 +221,6 @@ public class DisplayController { } } - private void onDisplayTopologyChanged(DisplayTopology topology) { - // TODO(b/381472611): Call DisplayTopology#getCoordinates and update values in - // DisplayLayout when DM code is ready. - for (int i = 0; i < mDisplayChangedListeners.size(); ++i) { - mDisplayChangedListeners.get(i).onTopologyChanged(); - } - } - private void onDisplayConfigurationChanged(int displayId, Configuration newConfig) { synchronized (mDisplays) { final DisplayRecord dr = mDisplays.get(displayId); @@ -421,10 +408,5 @@ public class DisplayController { */ default void onKeepClearAreasChanged(int displayId, Set<Rect> restricted, Set<Rect> unrestricted) {} - - /** - * Called when the display topology has changed. - */ - default void onTopologyChanged() {} } } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayLayout.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayLayout.java index 4973a6f16409..b6a1686bd087 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayLayout.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayLayout.java @@ -31,9 +31,7 @@ import android.content.ContentResolver; import android.content.Context; import android.content.res.Resources; import android.graphics.Insets; -import android.graphics.PointF; import android.graphics.Rect; -import android.graphics.RectF; import android.os.SystemProperties; import android.provider.Settings; import android.util.DisplayMetrics; @@ -73,12 +71,9 @@ public class DisplayLayout { public static final int NAV_BAR_RIGHT = 1 << 1; public static final int NAV_BAR_BOTTOM = 1 << 2; - private static final String TAG = "DisplayLayout"; - private int mUiMode; private int mWidth; private int mHeight; - private RectF mGlobalBoundsDp; private DisplayCutout mCutout; private int mRotation; private int mDensityDpi; @@ -114,7 +109,6 @@ public class DisplayLayout { return mUiMode == other.mUiMode && mWidth == other.mWidth && mHeight == other.mHeight - && Objects.equals(mGlobalBoundsDp, other.mGlobalBoundsDp) && Objects.equals(mCutout, other.mCutout) && mRotation == other.mRotation && mDensityDpi == other.mDensityDpi @@ -133,8 +127,8 @@ public class DisplayLayout { @Override public int hashCode() { - return Objects.hash(mUiMode, mWidth, mHeight, mGlobalBoundsDp, mCutout, mRotation, - mDensityDpi, mNonDecorInsets, mStableInsets, mHasNavigationBar, mHasStatusBar, + return Objects.hash(mUiMode, mWidth, mHeight, mCutout, mRotation, mDensityDpi, + mNonDecorInsets, mStableInsets, mHasNavigationBar, mHasStatusBar, mNavBarFrameHeight, mTaskbarFrameHeight, mAllowSeamlessRotationDespiteNavBarMoving, mNavigationBarCanMove, mReverseDefaultRotation, mInsetsState); } @@ -176,7 +170,6 @@ public class DisplayLayout { mUiMode = dl.mUiMode; mWidth = dl.mWidth; mHeight = dl.mHeight; - mGlobalBoundsDp = dl.mGlobalBoundsDp; mCutout = dl.mCutout; mRotation = dl.mRotation; mDensityDpi = dl.mDensityDpi; @@ -200,7 +193,6 @@ public class DisplayLayout { mRotation = info.rotation; mCutout = info.displayCutout; mDensityDpi = info.logicalDensityDpi; - mGlobalBoundsDp = new RectF(0, 0, pxToDp(mWidth), pxToDp(mHeight)); mHasNavigationBar = hasNavigationBar; mHasStatusBar = hasStatusBar; mAllowSeamlessRotationDespiteNavBarMoving = res.getBoolean( @@ -263,11 +255,6 @@ public class DisplayLayout { recalcInsets(res); } - /** Update the global bounds of this layout, in DP. */ - public void setGlobalBoundsDp(RectF bounds) { - mGlobalBoundsDp = bounds; - } - /** Get this layout's non-decor insets. */ public Rect nonDecorInsets() { return mNonDecorInsets; @@ -278,21 +265,16 @@ public class DisplayLayout { return mStableInsets; } - /** Get this layout's width in pixels. */ + /** Get this layout's width. */ public int width() { return mWidth; } - /** Get this layout's height in pixels. */ + /** Get this layout's height. */ public int height() { return mHeight; } - /** Get this layout's global bounds in the multi-display coordinate system in DP. */ - public RectF globalBoundsDp() { - return mGlobalBoundsDp; - } - /** Get this layout's display rotation. */ public int rotation() { return mRotation; @@ -504,48 +486,4 @@ public class DisplayLayout { ? R.dimen.navigation_bar_frame_height_landscape : R.dimen.navigation_bar_frame_height); } - - /** - * Converts a pixel value to a density-independent pixel (dp) value. - * - * @param px The pixel value to convert. - * @return The equivalent value in DP units. - */ - public float pxToDp(Number px) { - return px.floatValue() * DisplayMetrics.DENSITY_DEFAULT / mDensityDpi; - } - - /** - * Converts a density-independent pixel (dp) value to a pixel value. - * - * @param dp The DP value to convert. - * @return The equivalent value in pixel units. - */ - public float dpToPx(Number dp) { - return dp.floatValue() * mDensityDpi / DisplayMetrics.DENSITY_DEFAULT; - } - - /** - * Converts local pixel coordinates on this layout to global DP coordinates. - * - * @param xPx The x-coordinate in pixels, relative to the layout's origin. - * @param yPx The y-coordinate in pixels, relative to the layout's origin. - * @return A PointF object representing the coordinates in global DP units. - */ - public PointF localPxToGlobalDp(Number xPx, Number yPx) { - return new PointF(mGlobalBoundsDp.left + pxToDp(xPx), - mGlobalBoundsDp.top + pxToDp(yPx)); - } - - /** - * Converts global DP coordinates to local pixel coordinates on this layout. - * - * @param xDp The x-coordinate in global DP units. - * @param yDp The y-coordinate in global DP units. - * @return A PointF object representing the coordinates in local pixel units on this layout. - */ - public PointF globalDpToLocalPx(Number xDp, Number yDp) { - return new PointF(dpToPx(xDp.floatValue() - mGlobalBoundsDp.left), - dpToPx(yDp.floatValue() - mGlobalBoundsDp.top)); - } } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellBaseModule.java b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellBaseModule.java index de0048a68ef9..eab7f6c055bd 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellBaseModule.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellBaseModule.java @@ -25,7 +25,6 @@ import android.annotation.NonNull; import android.app.ActivityTaskManager; import android.content.Context; import android.content.pm.PackageManager; -import android.hardware.display.DisplayManager; import android.os.Handler; import android.os.SystemProperties; import android.provider.Settings; @@ -173,9 +172,8 @@ public abstract class WMShellBaseModule { static DisplayController provideDisplayController(Context context, IWindowManager wmService, ShellInit shellInit, - @ShellMainThread ShellExecutor mainExecutor, - DisplayManager displayManager) { - return new DisplayController(context, wmService, shellInit, mainExecutor, displayManager); + @ShellMainThread ShellExecutor mainExecutor) { + return new DisplayController(context, wmService, shellInit, mainExecutor); } @WMSingleton diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java index ace7f078bb10..d02c6b05e5b6 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java @@ -100,6 +100,7 @@ import com.android.wm.shell.desktopmode.SpringDragToDesktopTransitionHandler; import com.android.wm.shell.desktopmode.ToggleResizeDesktopTaskTransitionHandler; import com.android.wm.shell.desktopmode.WindowDecorCaptionHandleRepository; import com.android.wm.shell.desktopmode.compatui.SystemModalsTransitionHandler; +import com.android.wm.shell.desktopmode.desktopwallpaperactivity.DesktopWallpaperActivityTokenProvider; import com.android.wm.shell.desktopmode.education.AppHandleEducationController; import com.android.wm.shell.desktopmode.education.AppHandleEducationFilter; import com.android.wm.shell.desktopmode.education.AppToWebEducationController; @@ -733,7 +734,8 @@ public abstract class WMShellModule { FocusTransitionObserver focusTransitionObserver, DesktopModeEventLogger desktopModeEventLogger, DesktopModeUiEventLogger desktopModeUiEventLogger, - DesktopTilingDecorViewModel desktopTilingDecorViewModel) { + DesktopTilingDecorViewModel desktopTilingDecorViewModel, + DesktopWallpaperActivityTokenProvider desktopWallpaperActivityTokenProvider) { return new DesktopTasksController( context, shellInit, @@ -764,7 +766,8 @@ public abstract class WMShellModule { mainHandler, desktopModeEventLogger, desktopModeUiEventLogger, - desktopTilingDecorViewModel); + desktopTilingDecorViewModel, + desktopWallpaperActivityTokenProvider); } @WMSingleton @@ -1092,6 +1095,7 @@ public abstract class WMShellModule { ShellTaskOrganizer shellTaskOrganizer, Optional<DesktopMixedTransitionHandler> desktopMixedTransitionHandler, Optional<BackAnimationController> backAnimationController, + DesktopWallpaperActivityTokenProvider desktopWallpaperActivityTokenProvider, ShellInit shellInit) { return desktopUserRepositories.flatMap( repository -> @@ -1103,6 +1107,7 @@ public abstract class WMShellModule { shellTaskOrganizer, desktopMixedTransitionHandler.get(), backAnimationController.get(), + desktopWallpaperActivityTokenProvider, shellInit))); } @@ -1306,6 +1311,12 @@ public abstract class WMShellModule { return new DesktopModeUiEventLogger(uiEventLogger, packageManager); } + @WMSingleton + @Provides + static DesktopWallpaperActivityTokenProvider provideDesktopWallpaperActivityTokenProvider() { + return new DesktopWallpaperActivityTokenProvider(); + } + // // Drag and drop // diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopMixedTransitionHandler.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopMixedTransitionHandler.kt index d404634b0db0..996d71c043c2 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopMixedTransitionHandler.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopMixedTransitionHandler.kt @@ -426,7 +426,7 @@ class DesktopMixedTransitionHandler( private fun isWallpaperActivityClosing(info: TransitionInfo) = info.changes.any { change -> - change.mode == TRANSIT_CLOSE && + TransitionUtil.isClosingMode(change.mode) && change.taskInfo != null && DesktopWallpaperActivity.isWallpaperTask(change.taskInfo!!) } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopRepository.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopRepository.kt index c5b570dd3d57..d3066645f32e 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopRepository.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopRepository.kt @@ -23,7 +23,6 @@ import android.util.ArraySet import android.util.SparseArray import android.view.Display.INVALID_DISPLAY import android.window.DesktopModeFlags -import android.window.WindowContainerToken import androidx.core.util.forEach import androidx.core.util.keyIterator import androidx.core.util.valueIterator @@ -90,9 +89,6 @@ class DesktopRepository( } } - /* Current wallpaper activity token to remove wallpaper activity when last task is removed. */ - var wallpaperActivityToken: WindowContainerToken? = null - private val activeTasksListeners = ArraySet<ActiveTasksListener>() private val visibleTasksListeners = ArrayMap<VisibleTasksListener, Executor>() @@ -549,7 +545,6 @@ class DesktopRepository( "${innerPrefix}topTransparentFullscreenTaskId=" + "${data.topTransparentFullscreenTaskId}" ) - pw.println("${innerPrefix}wallpaperActivityToken=$wallpaperActivityToken") } } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt index 94955709bf79..4e7cba23116c 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt @@ -95,6 +95,7 @@ import com.android.wm.shell.desktopmode.DragToDesktopTransitionHandler.DragToDes import com.android.wm.shell.desktopmode.EnterDesktopTaskTransitionHandler.FREEFORM_ANIMATION_DURATION import com.android.wm.shell.desktopmode.ExitDesktopTaskTransitionHandler.FULLSCREEN_ANIMATION_DURATION import com.android.wm.shell.desktopmode.common.ToggleTaskSizeInteraction +import com.android.wm.shell.desktopmode.desktopwallpaperactivity.DesktopWallpaperActivityTokenProvider import com.android.wm.shell.desktopmode.minimize.DesktopWindowLimitRemoteHandler import com.android.wm.shell.draganddrop.DragAndDropController import com.android.wm.shell.freeform.FreeformTaskTransitionStarter @@ -170,6 +171,7 @@ class DesktopTasksController( private val desktopModeEventLogger: DesktopModeEventLogger, private val desktopModeUiEventLogger: DesktopModeUiEventLogger, private val desktopTilingDecorViewModel: DesktopTilingDecorViewModel, + private val desktopWallpaperActivityTokenProvider: DesktopWallpaperActivityTokenProvider, ) : RemoteCallable<DesktopTasksController>, Transitions.TransitionHandler, @@ -1340,35 +1342,60 @@ class DesktopTasksController( private fun addWallpaperActivity(displayId: Int, wct: WindowContainerTransaction) { logV("addWallpaperActivity") - val userHandle = UserHandle.of(userId) - val userContext = context.createContextAsUser(userHandle, /* flags= */ 0) - val intent = Intent(userContext, DesktopWallpaperActivity::class.java) - intent.putExtra(Intent.EXTRA_USER_HANDLE, userId) - val options = - ActivityOptions.makeBasic().apply { - launchWindowingMode = WINDOWING_MODE_FULLSCREEN - pendingIntentBackgroundActivityStartMode = - ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOW_ALWAYS - if (Flags.enableBugFixesForSecondaryDisplay()) { - launchDisplayId = displayId + if (Flags.enableDesktopWallpaperActivityOnSystemUser()) { + val intent = Intent(context, DesktopWallpaperActivity::class.java) + val options = + ActivityOptions.makeBasic().apply { + launchWindowingMode = WINDOWING_MODE_FULLSCREEN + pendingIntentBackgroundActivityStartMode = + ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOW_ALWAYS + if (Flags.enableBugFixesForSecondaryDisplay()) { + launchDisplayId = displayId + } } - } - val pendingIntent = - PendingIntent.getActivityAsUser( - userContext, - /* requestCode= */ 0, - intent, - PendingIntent.FLAG_IMMUTABLE, - /* options= */ null, - userHandle, - ) - wct.sendPendingIntent(pendingIntent, intent, options.toBundle()) + val pendingIntent = + PendingIntent.getActivity( + context, + /* requestCode = */ 0, + intent, + PendingIntent.FLAG_IMMUTABLE, + ) + wct.sendPendingIntent(pendingIntent, intent, options.toBundle()) + } else { + val userHandle = UserHandle.of(userId) + val userContext = context.createContextAsUser(userHandle, /* flags= */ 0) + val intent = Intent(userContext, DesktopWallpaperActivity::class.java) + intent.putExtra(Intent.EXTRA_USER_HANDLE, userId) + val options = + ActivityOptions.makeBasic().apply { + launchWindowingMode = WINDOWING_MODE_FULLSCREEN + pendingIntentBackgroundActivityStartMode = + ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOW_ALWAYS + if (Flags.enableBugFixesForSecondaryDisplay()) { + launchDisplayId = displayId + } + } + val pendingIntent = + PendingIntent.getActivityAsUser( + userContext, + /* requestCode= */ 0, + intent, + PendingIntent.FLAG_IMMUTABLE, + /* options= */ null, + userHandle, + ) + wct.sendPendingIntent(pendingIntent, intent, options.toBundle()) + } } private fun removeWallpaperActivity(wct: WindowContainerTransaction) { - taskRepository.wallpaperActivityToken?.let { token -> + desktopWallpaperActivityTokenProvider.getToken()?.let { token -> logV("removeWallpaperActivity") - wct.removeTask(token) + if (Flags.enableDesktopWallpaperActivityOnSystemUser()) { + wct.reorder(token, /* onTop= */ false) + } else { + wct.removeTask(token) + } } } @@ -1396,9 +1423,7 @@ class DesktopTasksController( desktopModeEnterExitTransitionListener?.onExitDesktopModeTransitionStarted( FULLSCREEN_ANIMATION_DURATION ) - if (taskRepository.wallpaperActivityToken != null) { - removeWallpaperActivity(wct) - } + removeWallpaperActivity(wct) } fun releaseVisualIndicator() { @@ -2583,8 +2608,7 @@ class DesktopTasksController( val innerPrefix = "$prefix " pw.println("${prefix}DesktopTasksController") DesktopModeStatus.dump(pw, innerPrefix, context) - pw.println("${prefix}userId=$userId") - taskRepository.dump(pw, innerPrefix) + userRepositories.dump(pw, innerPrefix) } /** The interface for calls from outside the shell, within the host process. */ diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksTransitionObserver.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksTransitionObserver.kt index 5c79658b6809..e7a00776360e 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksTransitionObserver.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksTransitionObserver.kt @@ -29,9 +29,11 @@ import android.window.DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVI import android.window.TransitionInfo import android.window.WindowContainerTransaction import com.android.internal.protolog.ProtoLog +import com.android.window.flags.Flags import com.android.wm.shell.ShellTaskOrganizer import com.android.wm.shell.back.BackAnimationController import com.android.wm.shell.desktopmode.DesktopModeTransitionTypes.isExitDesktopModeTransition +import com.android.wm.shell.desktopmode.desktopwallpaperactivity.DesktopWallpaperActivityTokenProvider import com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_DESKTOP_MODE import com.android.wm.shell.shared.TransitionUtil import com.android.wm.shell.shared.desktopmode.DesktopModeStatus @@ -50,6 +52,7 @@ class DesktopTasksTransitionObserver( private val shellTaskOrganizer: ShellTaskOrganizer, private val desktopMixedTransitionHandler: DesktopMixedTransitionHandler, private val backAnimationController: BackAnimationController, + private val desktopWallpaperActivityTokenProvider: DesktopWallpaperActivityTokenProvider, shellInit: ShellInit, ) : Transitions.TransitionObserver { @@ -212,7 +215,7 @@ class DesktopTasksTransitionObserver( desktopRepository.getVisibleTaskCount(taskInfo.displayId) == 0 && change.mode == TRANSIT_CLOSE && taskInfo.windowingMode == WINDOWING_MODE_FREEFORM && - desktopRepository.wallpaperActivityToken != null + desktopWallpaperActivityTokenProvider.getToken() != null ) { transitionToCloseWallpaper = transition currentProfileId = taskInfo.userId @@ -232,13 +235,21 @@ class DesktopTasksTransitionObserver( // TODO: b/332682201 Update repository state if (transitionToCloseWallpaper == transition) { // TODO: b/362469671 - Handle merging the animation when desktop is also closing. - val desktopRepository = desktopUserRepositories.getProfile(currentProfileId) - desktopRepository.wallpaperActivityToken?.let { wallpaperActivityToken -> - transitions.startTransition( - TRANSIT_CLOSE, - WindowContainerTransaction().removeTask(wallpaperActivityToken), - null, - ) + desktopWallpaperActivityTokenProvider.getToken()?.let { wallpaperActivityToken -> + if (Flags.enableDesktopWallpaperActivityOnSystemUser()) { + transitions.startTransition( + TRANSIT_TO_BACK, + WindowContainerTransaction() + .reorder(wallpaperActivityToken, /* onTop= */ false), + null, + ) + } else { + transitions.startTransition( + TRANSIT_CLOSE, + WindowContainerTransaction().removeTask(wallpaperActivityToken), + null, + ) + } } transitionToCloseWallpaper = null } @@ -251,10 +262,12 @@ class DesktopTasksTransitionObserver( info.changes.forEach { change -> change.taskInfo?.let { taskInfo -> if (DesktopWallpaperActivity.isWallpaperTask(taskInfo)) { - val desktopRepository = desktopUserRepositories.getProfile(taskInfo.userId) when (change.mode) { WindowManager.TRANSIT_OPEN -> { - desktopRepository.wallpaperActivityToken = taskInfo.token + desktopWallpaperActivityTokenProvider.setToken( + taskInfo.token, + taskInfo.displayId, + ) // After the task for the wallpaper is created, set it non-trimmable. // This is important to prevent recents from trimming and removing the // task. @@ -263,7 +276,8 @@ class DesktopTasksTransitionObserver( .setTaskTrimmableFromRecents(taskInfo.token, false) ) } - TRANSIT_CLOSE -> desktopRepository.wallpaperActivityToken = null + TRANSIT_CLOSE -> + desktopWallpaperActivityTokenProvider.removeToken(taskInfo.displayId) else -> {} } } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopUserRepositories.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopUserRepositories.kt index 8b5d1c502bc9..7f3133e141ef 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopUserRepositories.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopUserRepositories.kt @@ -21,6 +21,7 @@ import android.content.Context import android.content.pm.UserInfo import android.os.UserManager import android.util.SparseArray +import androidx.core.util.forEach import com.android.internal.protolog.ProtoLog import com.android.window.flags.Flags import com.android.wm.shell.desktopmode.persistence.DesktopPersistentRepository @@ -31,6 +32,7 @@ import com.android.wm.shell.shared.desktopmode.DesktopModeStatus import com.android.wm.shell.sysui.ShellController import com.android.wm.shell.sysui.ShellInit import com.android.wm.shell.sysui.UserChangeListener +import java.io.PrintWriter import kotlinx.coroutines.CoroutineScope /** Manages per-user DesktopRepository instances. */ @@ -87,6 +89,14 @@ class DesktopUserRepositories( return desktopRepoByUserId.getOrCreate(profileId) } + /** Dumps [DesktopRepository] for each user. */ + fun dump(pw: PrintWriter, prefix: String) { + desktopRepoByUserId.forEach { key, value -> + pw.println("${prefix}userId=$key") + value.dump(pw, prefix) + } + } + override fun onUserChanged(newUserId: Int, userContext: Context) { logD("onUserChanged previousUserId=%d, newUserId=%d", userId, newUserId) userId = newUserId diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/desktopwallpaperactivity/DesktopWallpaperActivityTokenProvider.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/desktopwallpaperactivity/DesktopWallpaperActivityTokenProvider.kt new file mode 100644 index 000000000000..a87004c07d43 --- /dev/null +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/desktopwallpaperactivity/DesktopWallpaperActivityTokenProvider.kt @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.wm.shell.desktopmode.desktopwallpaperactivity + +import android.util.SparseArray +import android.view.Display.DEFAULT_DISPLAY +import android.window.WindowContainerToken + +/** Provides per display window container tokens for [DesktopWallpaperActivity]. */ +class DesktopWallpaperActivityTokenProvider { + + private val wallpaperActivityTokenByDisplayId = SparseArray<WindowContainerToken>() + + fun setToken(token: WindowContainerToken, displayId: Int = DEFAULT_DISPLAY) { + wallpaperActivityTokenByDisplayId[displayId] = token + } + + fun getToken(displayId: Int = DEFAULT_DISPLAY): WindowContainerToken? { + return wallpaperActivityTokenByDisplayId[displayId] + } + + fun removeToken(displayId: Int = DEFAULT_DISPLAY) { + wallpaperActivityTokenByDisplayId.delete(displayId) + } +} diff --git a/libs/WindowManager/Shell/tests/e2e/desktopmode/flicker-service/src/com/android/wm/shell/flicker/MaximizeAppWithKeyboard.kt b/libs/WindowManager/Shell/tests/e2e/desktopmode/flicker-service/src/com/android/wm/shell/flicker/MaximizeAppWithKeyboard.kt new file mode 100644 index 000000000000..b399e9b52696 --- /dev/null +++ b/libs/WindowManager/Shell/tests/e2e/desktopmode/flicker-service/src/com/android/wm/shell/flicker/MaximizeAppWithKeyboard.kt @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.wm.shell.flicker + +import android.tools.Rotation.ROTATION_90 +import android.tools.flicker.FlickerConfig +import android.tools.flicker.annotation.ExpectedScenarios +import android.tools.flicker.annotation.FlickerConfigProvider +import android.tools.flicker.config.FlickerConfig +import android.tools.flicker.config.FlickerServiceConfig +import android.tools.flicker.junit.FlickerServiceJUnit4ClassRunner +import com.android.wm.shell.flicker.DesktopModeFlickerScenarios.Companion.MAXIMIZE_APP +import com.android.wm.shell.scenarios.MaximizeAppWindow +import org.junit.Test +import org.junit.runner.RunWith + +/** + * Maximize app window by pressing META + = on the keyboard. + * + * Assert that the app window keeps the same increases in size, filling the vertical and horizontal + * stable display bounds. + */ +@RunWith(FlickerServiceJUnit4ClassRunner::class) +class MaximizeAppWithKeyboard : MaximizeAppWindow(rotation = ROTATION_90, usingKeyboard = true) { + @ExpectedScenarios(["MAXIMIZE_APP"]) + @Test + override fun maximizeAppWindow() = super.maximizeAppWindow() + + + companion object { + @JvmStatic + @FlickerConfigProvider + fun flickerConfigProvider(): FlickerConfig = + FlickerConfig().use(FlickerServiceConfig.DEFAULT).use(MAXIMIZE_APP) + } +}
\ No newline at end of file diff --git a/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardStatusViewScope.java b/libs/WindowManager/Shell/tests/e2e/desktopmode/scenarios/src/com/android/wm/shell/functional/EnterDesktopViaMenuOfLiveOverviewTaskTest.kt index 6c2c9f2d8e2f..e28f0c0e12d2 100644 --- a/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardStatusViewScope.java +++ b/libs/WindowManager/Shell/tests/e2e/desktopmode/scenarios/src/com/android/wm/shell/functional/EnterDesktopViaMenuOfLiveOverviewTaskTest.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 The Android Open Source Project + * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,19 +14,14 @@ * limitations under the License. */ -package com.android.keyguard.dagger; +package com.android.wm.shell.functional -import static java.lang.annotation.RetentionPolicy.RUNTIME; +import android.platform.test.annotations.Postsubmit +import com.android.wm.shell.scenarios.EnterDesktopViaMenuOfLiveOverviewTask +import org.junit.runner.RunWith +import org.junit.runners.BlockJUnit4ClassRunner -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; - -import javax.inject.Scope; - -/** - * Scope annotation for singleton items within the {@link KeyguardStatusViewComponent}. - */ -@Documented -@Retention(RUNTIME) -@Scope -public @interface KeyguardStatusViewScope {} +/* Functional test for [EnterDesktopViaMenuOfLiveOverviewTask]. */ +@RunWith(BlockJUnit4ClassRunner::class) +@Postsubmit +class EnterDesktopViaMenuOfLiveOverviewTaskTest : EnterDesktopViaMenuOfLiveOverviewTask() diff --git a/libs/WindowManager/Shell/tests/e2e/desktopmode/scenarios/src/com/android/wm/shell/scenarios/EnterDesktopViaMenuOfLiveOverviewTask.kt b/libs/WindowManager/Shell/tests/e2e/desktopmode/scenarios/src/com/android/wm/shell/scenarios/EnterDesktopViaMenuOfLiveOverviewTask.kt new file mode 100644 index 000000000000..43a2ae3f1c91 --- /dev/null +++ b/libs/WindowManager/Shell/tests/e2e/desktopmode/scenarios/src/com/android/wm/shell/scenarios/EnterDesktopViaMenuOfLiveOverviewTask.kt @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.wm.shell.scenarios + +import android.app.Instrumentation +import android.tools.NavBar +import android.tools.Rotation +import android.tools.traces.parsers.WindowManagerStateHelper +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.uiautomator.UiDevice +import com.android.launcher3.tapl.LauncherInstrumentation +import com.android.server.wm.flicker.helpers.MailAppHelper +import com.android.window.flags.Flags +import com.android.wm.shell.Utils +import org.junit.After +import org.junit.Assume +import org.junit.Before +import org.junit.Ignore +import org.junit.Rule +import org.junit.Test + +@Ignore("Base Test Class") +abstract class EnterDesktopViaMenuOfLiveOverviewTask +constructor() { + + private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() + private val tapl = LauncherInstrumentation() + private val wmHelper = WindowManagerStateHelper(instrumentation) + private val device = UiDevice.getInstance(instrumentation) + private val mailApp = MailAppHelper(instrumentation) + + @Rule @JvmField val testSetupRule = Utils.testSetupRule(NavBar.MODE_GESTURAL, Rotation.ROTATION_0) + + @Before + fun setup() { + Assume.assumeTrue(Flags.enableDesktopWindowingMode() && tapl.isTablet) + // Clear all tasks + val overview = tapl.goHome().switchToOverview() + if (overview.hasTasks()) { + overview.dismissAllTasks() + } + mailApp.open() + } + + @Test + open fun desktopViaMenuOfLiveOverviewTask() { + tapl.getLaunchedAppState().switchToOverview() + .getCurrentTask().tapMenu().tapDesktopMenuItem() + } + + @After + fun teardown() { + mailApp.exit(wmHelper) + } +} diff --git a/libs/WindowManager/Shell/tests/e2e/desktopmode/scenarios/src/com/android/wm/shell/scenarios/MaximizeAppWindow.kt b/libs/WindowManager/Shell/tests/e2e/desktopmode/scenarios/src/com/android/wm/shell/scenarios/MaximizeAppWindow.kt index d2be4944d365..966aea3088c4 100644 --- a/libs/WindowManager/Shell/tests/e2e/desktopmode/scenarios/src/com/android/wm/shell/scenarios/MaximizeAppWindow.kt +++ b/libs/WindowManager/Shell/tests/e2e/desktopmode/scenarios/src/com/android/wm/shell/scenarios/MaximizeAppWindow.kt @@ -38,8 +38,11 @@ import org.junit.Test @Ignore("Test Base Class") abstract class MaximizeAppWindow -constructor(private val rotation: Rotation = Rotation.ROTATION_0, isResizable: Boolean = true) { - +constructor( + private val rotation: Rotation = Rotation.ROTATION_0, + isResizable: Boolean = true, + private val usingKeyboard: Boolean = false +) { private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() private val tapl = LauncherInstrumentation() private val wmHelper = WindowManagerStateHelper(instrumentation) @@ -55,6 +58,9 @@ constructor(private val rotation: Rotation = Rotation.ROTATION_0, isResizable: B @Before fun setup() { Assume.assumeTrue(Flags.enableDesktopWindowingMode() && tapl.isTablet) + if (usingKeyboard) { + Assume.assumeTrue(Flags.enableTaskResizingKeyboardShortcuts()) + } tapl.setEnableRotation(true) tapl.setExpectedRotation(rotation.value) ChangeDisplayOrientationRule.setRotation(rotation) @@ -63,7 +69,7 @@ constructor(private val rotation: Rotation = Rotation.ROTATION_0, isResizable: B @Test open fun maximizeAppWindow() { - testApp.maximiseDesktopApp(wmHelper, device) + testApp.maximiseDesktopApp(wmHelper, device, usingKeyboard = usingKeyboard) } @After diff --git a/libs/WindowManager/Shell/tests/e2e/desktopmode/scenarios/src/com/android/wm/shell/scenarios/MinimizeAppWindows.kt b/libs/WindowManager/Shell/tests/e2e/desktopmode/scenarios/src/com/android/wm/shell/scenarios/MinimizeAppWindows.kt index 835559cd0936..46c97b0a1397 100644 --- a/libs/WindowManager/Shell/tests/e2e/desktopmode/scenarios/src/com/android/wm/shell/scenarios/MinimizeAppWindows.kt +++ b/libs/WindowManager/Shell/tests/e2e/desktopmode/scenarios/src/com/android/wm/shell/scenarios/MinimizeAppWindows.kt @@ -61,6 +61,9 @@ constructor( fun setup() { Assume.assumeTrue(Flags.enableDesktopWindowingMode() && tapl.isTablet) Assume.assumeTrue(Flags.enableMinimizeButton()) + if (usingKeyboard) { + Assume.assumeTrue(Flags.enableTaskResizingKeyboardShortcuts()) + } tapl.setEnableRotation(true) tapl.setExpectedRotation(rotation.value) ChangeDisplayOrientationRule.setRotation(rotation) diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/DisplayControllerTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/DisplayControllerTests.java index d3de0f7c09b4..1e5e153fdfe1 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/DisplayControllerTests.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/DisplayControllerTests.java @@ -22,7 +22,6 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import android.content.Context; -import android.hardware.display.DisplayManager; import android.view.IWindowManager; import androidx.test.ext.junit.runners.AndroidJUnit4; @@ -51,14 +50,12 @@ public class DisplayControllerTests extends ShellTestCase { private @Mock IWindowManager mWM; private @Mock ShellInit mShellInit; private @Mock ShellExecutor mMainExecutor; - private @Mock DisplayManager mDisplayManager; private DisplayController mController; @Before public void setUp() { MockitoAnnotations.initMocks(this); - mController = new DisplayController( - mContext, mWM, mShellInit, mMainExecutor, mDisplayManager); + mController = new DisplayController(mContext, mWM, mShellInit, mMainExecutor); } @Test diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/DisplayLayoutTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/DisplayLayoutTest.java index b0a455d1bcf8..d467b399ebbb 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/DisplayLayoutTest.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/DisplayLayoutTest.java @@ -33,9 +33,7 @@ import static org.mockito.Mockito.when; import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Insets; -import android.graphics.PointF; import android.graphics.Rect; -import android.graphics.RectF; import android.view.DisplayCutout; import android.view.DisplayInfo; @@ -60,7 +58,6 @@ import org.mockito.quality.Strictness; @SmallTest public class DisplayLayoutTest extends ShellTestCase { private MockitoSession mMockitoSession; - private static final float DELTA = 0.1f; // Constant for assertion delta @Before public void setup() { @@ -133,39 +130,6 @@ public class DisplayLayoutTest extends ShellTestCase { assertEquals(new Rect(40, 0, 60, 0), dl.nonDecorInsets()); } - @Test - public void testDpPxConversion() { - int px = 100; - float dp = 53.33f; - int xPx = 100; - int yPx = 200; - float xDp = 164.33f; - float yDp = 328.66f; - - Resources res = createResources(40, 50, false); - DisplayInfo info = createDisplayInfo(1000, 1500, 0, ROTATION_0); - DisplayLayout dl = new DisplayLayout(info, res, false, false); - dl.setGlobalBoundsDp(new RectF(111f, 222f, 300f, 400f)); - - // Test pxToDp - float resultDp = dl.pxToDp(px); - assertEquals(dp, resultDp, DELTA); - - // Test dpToPx - float resultPx = dl.dpToPx(dp); - assertEquals(px, resultPx, DELTA); - - // Test localPxToGlobalDp - PointF resultGlobalDp = dl.localPxToGlobalDp(xPx, yPx); - assertEquals(xDp, resultGlobalDp.x, DELTA); - assertEquals(yDp, resultGlobalDp.y, DELTA); - - // Test globalDpToLocalPx - PointF resultLocalPx = dl.globalDpToLocalPx(xDp, yDp); - assertEquals(xPx, resultLocalPx.x, DELTA); - assertEquals(yPx, resultLocalPx.y, DELTA); - } - private Resources createResources(int navLand, int navPort, boolean navMoves) { Configuration cfg = new Configuration(); cfg.uiMode = UI_MODE_TYPE_NORMAL; diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt index 61aec739724a..fe0852689ee9 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt @@ -111,6 +111,7 @@ import com.android.wm.shell.desktopmode.DesktopTestHelpers.createSplitScreenTask import com.android.wm.shell.desktopmode.EnterDesktopTaskTransitionHandler.FREEFORM_ANIMATION_DURATION import com.android.wm.shell.desktopmode.ExitDesktopTaskTransitionHandler.FULLSCREEN_ANIMATION_DURATION import com.android.wm.shell.desktopmode.common.ToggleTaskSizeInteraction +import com.android.wm.shell.desktopmode.desktopwallpaperactivity.DesktopWallpaperActivityTokenProvider import com.android.wm.shell.desktopmode.minimize.DesktopWindowLimitRemoteHandler import com.android.wm.shell.desktopmode.persistence.Desktop import com.android.wm.shell.desktopmode.persistence.DesktopPersistentRepository @@ -236,6 +237,10 @@ class DesktopTasksControllerTest : ShellTestCase() { @Mock lateinit var desktopModeEnterExitTransitionListener: DesktopModeEntryExitTransitionListener @Mock private lateinit var userManager: UserManager + @Mock + private lateinit var desktopWallpaperActivityTokenProvider: + DesktopWallpaperActivityTokenProvider + private lateinit var controller: DesktopTasksController private lateinit var shellInit: ShellInit private lateinit var taskRepository: DesktopRepository @@ -257,6 +262,7 @@ class DesktopTasksControllerTest : ShellTestCase() { private val RESIZABLE_PORTRAIT_BOUNDS = Rect(680, 75, 1880, 1275) private val UNRESIZABLE_LANDSCAPE_BOUNDS = Rect(25, 449, 1575, 1611) private val UNRESIZABLE_PORTRAIT_BOUNDS = Rect(830, 75, 1730, 1275) + private val wallpaperToken = MockToken().token() @Before fun setUp() { @@ -324,6 +330,7 @@ class DesktopTasksControllerTest : ShellTestCase() { ) ) .thenReturn(ExitResult.NoExit) + whenever(desktopWallpaperActivityTokenProvider.getToken()).thenReturn(wallpaperToken) controller = createController() controller.setSplitScreenController(splitScreenController) @@ -375,6 +382,7 @@ class DesktopTasksControllerTest : ShellTestCase() { desktopModeEventLogger, desktopModeUiEventLogger, desktopTilingDecorViewModel, + desktopWallpaperActivityTokenProvider, ) } @@ -1486,11 +1494,9 @@ class DesktopTasksControllerTest : ShellTestCase() { } @Test + @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER) fun moveToFullscreen_tdaFullscreen_windowingModeUndefined_removesWallpaperActivity() { val task = setUpFreeformTask() - val wallpaperToken = MockToken().token() - - taskRepository.wallpaperActivityToken = wallpaperToken assertNotNull(rootTaskDisplayAreaOrganizer.getDisplayAreaInfo(DEFAULT_DISPLAY)) .configuration .windowConfiguration @@ -1504,7 +1510,7 @@ class DesktopTasksControllerTest : ShellTestCase() { .onExitDesktopModeTransitionStarted(FULLSCREEN_ANIMATION_DURATION) assertThat(taskChange.windowingMode).isEqualTo(WINDOWING_MODE_UNDEFINED) // Removes wallpaper activity when leaving desktop - wct.assertRemoveAt(index = 0, wallpaperToken) + wct.assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test @@ -1521,11 +1527,10 @@ class DesktopTasksControllerTest : ShellTestCase() { } @Test + @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER) fun moveToFullscreen_tdaFreeform_windowingModeFullscreen_removesWallpaperActivity() { val task = setUpFreeformTask() - val wallpaperToken = MockToken().token() - taskRepository.wallpaperActivityToken = wallpaperToken assertNotNull(rootTaskDisplayAreaOrganizer.getDisplayAreaInfo(DEFAULT_DISPLAY)) .configuration .windowConfiguration @@ -1539,7 +1544,7 @@ class DesktopTasksControllerTest : ShellTestCase() { verify(desktopModeEnterExitTransitionListener) .onExitDesktopModeTransitionStarted(FULLSCREEN_ANIMATION_DURATION) // Removes wallpaper activity when leaving desktop - wct.assertRemoveAt(index = 0, wallpaperToken) + wct.assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test @@ -1547,9 +1552,7 @@ class DesktopTasksControllerTest : ShellTestCase() { val task1 = setUpFreeformTask() // Setup task2 setUpFreeformTask() - val wallpaperToken = MockToken().token() - taskRepository.wallpaperActivityToken = wallpaperToken assertNotNull(rootTaskDisplayAreaOrganizer.getDisplayAreaInfo(DEFAULT_DISPLAY)) .configuration .windowConfiguration @@ -1748,8 +1751,6 @@ class DesktopTasksControllerTest : ShellTestCase() { .thenReturn(secondDisplayArea) // Add a task and a wallpaper val task = setUpFreeformTask(displayId = DEFAULT_DISPLAY) - val wallpaperToken = MockToken().token() - taskRepository.wallpaperActivityToken = wallpaperToken controller.moveToNextDisplay(task.taskId) @@ -1960,28 +1961,29 @@ class DesktopTasksControllerTest : ShellTestCase() { fun onDesktopWindowClose_singleActiveTask_noWallpaperActivityToken() { val task = setUpFreeformTask() val wct = WindowContainerTransaction() + whenever(desktopWallpaperActivityTokenProvider.getToken()).thenReturn(null) + controller.onDesktopWindowClose(wct, displayId = DEFAULT_DISPLAY, task) + // Doesn't modify transaction assertThat(wct.hierarchyOps).isEmpty() } @Test + @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER) fun onDesktopWindowClose_singleActiveTask_hasWallpaperActivityToken() { val task = setUpFreeformTask() - val wallpaperToken = MockToken().token() - taskRepository.wallpaperActivityToken = wallpaperToken val wct = WindowContainerTransaction() controller.onDesktopWindowClose(wct, displayId = DEFAULT_DISPLAY, task) // Adds remove wallpaper operation - wct.assertRemoveAt(index = 0, wallpaperToken) + wct.assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test fun onDesktopWindowClose_singleActiveTask_isClosing() { val task = setUpFreeformTask() - val wallpaperToken = MockToken().token() - taskRepository.wallpaperActivityToken = wallpaperToken + taskRepository.addClosingTask(DEFAULT_DISPLAY, task.taskId) val wct = WindowContainerTransaction() @@ -1993,8 +1995,7 @@ class DesktopTasksControllerTest : ShellTestCase() { @Test fun onDesktopWindowClose_singleActiveTask_isMinimized() { val task = setUpFreeformTask() - val wallpaperToken = MockToken().token() - taskRepository.wallpaperActivityToken = wallpaperToken + taskRepository.minimizeTask(DEFAULT_DISPLAY, task.taskId) val wct = WindowContainerTransaction() @@ -2007,8 +2008,6 @@ class DesktopTasksControllerTest : ShellTestCase() { fun onDesktopWindowClose_multipleActiveTasks() { val task1 = setUpFreeformTask() setUpFreeformTask() - val wallpaperToken = MockToken().token() - taskRepository.wallpaperActivityToken = wallpaperToken val wct = WindowContainerTransaction() controller.onDesktopWindowClose(wct, displayId = DEFAULT_DISPLAY, task1) @@ -2017,31 +2016,31 @@ class DesktopTasksControllerTest : ShellTestCase() { } @Test + @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER) fun onDesktopWindowClose_multipleActiveTasks_isOnlyNonClosingTask() { val task1 = setUpFreeformTask() val task2 = setUpFreeformTask() - val wallpaperToken = MockToken().token() - taskRepository.wallpaperActivityToken = wallpaperToken + taskRepository.addClosingTask(DEFAULT_DISPLAY, task2.taskId) val wct = WindowContainerTransaction() controller.onDesktopWindowClose(wct, displayId = DEFAULT_DISPLAY, task1) // Adds remove wallpaper operation - wct.assertRemoveAt(index = 0, wallpaperToken) + wct.assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test + @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER) fun onDesktopWindowClose_multipleActiveTasks_hasMinimized() { val task1 = setUpFreeformTask() val task2 = setUpFreeformTask() - val wallpaperToken = MockToken().token() - taskRepository.wallpaperActivityToken = wallpaperToken + taskRepository.minimizeTask(DEFAULT_DISPLAY, task2.taskId) val wct = WindowContainerTransaction() controller.onDesktopWindowClose(wct, displayId = DEFAULT_DISPLAY, task1) // Adds remove wallpaper operation - wct.assertRemoveAt(index = 0, wallpaperToken) + wct.assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test @@ -2050,8 +2049,6 @@ class DesktopTasksControllerTest : ShellTestCase() { val transition = Binder() whenever(freeformTaskTransitionStarter.startMinimizedModeTransition(any())) .thenReturn(transition) - val wallpaperToken = MockToken().token() - taskRepository.wallpaperActivityToken = wallpaperToken controller.minimizeTask(task) @@ -2103,13 +2100,12 @@ class DesktopTasksControllerTest : ShellTestCase() { } @Test + @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER) fun onTaskMinimize_singleActiveTask_hasWallpaperActivityToken_removesWallpaper() { val task = setUpFreeformTask() val transition = Binder() whenever(freeformTaskTransitionStarter.startMinimizedModeTransition(any())) .thenReturn(transition) - val wallpaperToken = MockToken().token() - taskRepository.wallpaperActivityToken = wallpaperToken // The only active task is being minimized. controller.minimizeTask(task) @@ -2117,7 +2113,7 @@ class DesktopTasksControllerTest : ShellTestCase() { val captor = ArgumentCaptor.forClass(WindowContainerTransaction::class.java) verify(freeformTaskTransitionStarter).startMinimizedModeTransition(captor.capture()) // Adds remove wallpaper operation - captor.value.assertRemoveAt(index = 0, wallpaperToken) + captor.value.assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test @@ -2126,8 +2122,6 @@ class DesktopTasksControllerTest : ShellTestCase() { val transition = Binder() whenever(freeformTaskTransitionStarter.startMinimizedModeTransition(any())) .thenReturn(transition) - val wallpaperToken = MockToken().token() - taskRepository.wallpaperActivityToken = wallpaperToken taskRepository.minimizeTask(DEFAULT_DISPLAY, task.taskId) // The only active task is already minimized. @@ -2147,8 +2141,6 @@ class DesktopTasksControllerTest : ShellTestCase() { val transition = Binder() whenever(freeformTaskTransitionStarter.startMinimizedModeTransition(any())) .thenReturn(transition) - val wallpaperToken = MockToken().token() - taskRepository.wallpaperActivityToken = wallpaperToken controller.minimizeTask(task1) @@ -2160,14 +2152,13 @@ class DesktopTasksControllerTest : ShellTestCase() { } @Test + @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER) fun onDesktopWindowMinimize_multipleActiveTasks_minimizesTheOnlyVisibleTask_removesWallpaper() { val task1 = setUpFreeformTask(active = true) val task2 = setUpFreeformTask(active = true) val transition = Binder() whenever(freeformTaskTransitionStarter.startMinimizedModeTransition(any())) .thenReturn(transition) - val wallpaperToken = MockToken().token() - taskRepository.wallpaperActivityToken = wallpaperToken taskRepository.minimizeTask(DEFAULT_DISPLAY, task2.taskId) // task1 is the only visible task as task2 is minimized. @@ -2176,7 +2167,7 @@ class DesktopTasksControllerTest : ShellTestCase() { val captor = ArgumentCaptor.forClass(WindowContainerTransaction::class.java) verify(freeformTaskTransitionStarter).startMinimizedModeTransition(captor.capture()) // Adds remove wallpaper operation - captor.value.assertRemoveAt(index = 0, wallpaperToken) + captor.value.assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test @@ -2776,6 +2767,7 @@ class DesktopTasksControllerTest : ShellTestCase() { @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY) fun handleRequest_backTransition_singleTaskNoToken_withWallpaper_removesTask() { val task = setUpFreeformTask() + whenever(desktopWallpaperActivityTokenProvider.getToken()).thenReturn(null) val result = controller.handleRequest(Binder(), createTransition(task, type = TRANSIT_TO_BACK)) @@ -2799,6 +2791,7 @@ class DesktopTasksControllerTest : ShellTestCase() { @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY) fun handleRequest_backTransition_singleTaskNoToken_doesNotHandle() { val task = setUpFreeformTask() + whenever(desktopWallpaperActivityTokenProvider.getToken()).thenReturn(null) val result = controller.handleRequest(Binder(), createTransition(task, type = TRANSIT_TO_BACK)) @@ -2811,7 +2804,6 @@ class DesktopTasksControllerTest : ShellTestCase() { fun handleRequest_backTransition_singleTaskWithToken_noWallpaper_doesNotHandle() { val task = setUpFreeformTask() - taskRepository.wallpaperActivityToken = MockToken().token() val result = controller.handleRequest(Binder(), createTransition(task, type = TRANSIT_TO_BACK)) @@ -2819,17 +2811,19 @@ class DesktopTasksControllerTest : ShellTestCase() { } @Test - @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY) + @EnableFlags( + Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY, + Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER, + ) fun handleRequest_backTransition_singleTaskWithToken_removesWallpaper() { val task = setUpFreeformTask() - val wallpaperToken = MockToken().token() - taskRepository.wallpaperActivityToken = wallpaperToken val result = controller.handleRequest(Binder(), createTransition(task, type = TRANSIT_TO_BACK)) // Should create remove wallpaper transaction - assertNotNull(result, "Should handle request").assertRemoveAt(index = 0, wallpaperToken) + assertNotNull(result, "Should handle request") + .assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test @@ -2838,7 +2832,6 @@ class DesktopTasksControllerTest : ShellTestCase() { val task1 = setUpFreeformTask() setUpFreeformTask() - taskRepository.wallpaperActivityToken = MockToken().token() val result = controller.handleRequest(Binder(), createTransition(task1, type = TRANSIT_TO_BACK)) @@ -2851,7 +2844,6 @@ class DesktopTasksControllerTest : ShellTestCase() { val task1 = setUpFreeformTask() setUpFreeformTask() - taskRepository.wallpaperActivityToken = MockToken().token() val result = controller.handleRequest(Binder(), createTransition(task1, type = TRANSIT_TO_BACK)) @@ -2862,35 +2854,37 @@ class DesktopTasksControllerTest : ShellTestCase() { @EnableFlags( Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY, Flags.FLAG_ENABLE_DESKTOP_WINDOWING_BACK_NAVIGATION, + Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER, ) fun handleRequest_backTransition_multipleTasksSingleNonClosing_removesWallpaperAndTask() { val task1 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) val task2 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) - val wallpaperToken = MockToken().token() - taskRepository.wallpaperActivityToken = wallpaperToken taskRepository.addClosingTask(displayId = DEFAULT_DISPLAY, taskId = task2.taskId) val result = controller.handleRequest(Binder(), createTransition(task1, type = TRANSIT_TO_BACK)) // Should create remove wallpaper transaction - assertNotNull(result, "Should handle request").assertRemoveAt(index = 0, wallpaperToken) + assertNotNull(result, "Should handle request") + .assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test - @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY) + @EnableFlags( + Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY, + Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER, + ) fun handleRequest_backTransition_multipleTasksSingleNonMinimized_removesWallpaperAndTask() { val task1 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) val task2 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) - val wallpaperToken = MockToken().token() - taskRepository.wallpaperActivityToken = wallpaperToken taskRepository.minimizeTask(displayId = DEFAULT_DISPLAY, taskId = task2.taskId) val result = controller.handleRequest(Binder(), createTransition(task1, type = TRANSIT_TO_BACK)) // Should create remove wallpaper transaction - assertNotNull(result, "Should handle request").assertRemoveAt(index = 0, wallpaperToken) + assertNotNull(result, "Should handle request") + .assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test @@ -2898,9 +2892,7 @@ class DesktopTasksControllerTest : ShellTestCase() { fun handleRequest_backTransition_nonMinimizadTask_withWallpaper_removesWallpaper() { val task1 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) val task2 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) - val wallpaperToken = MockToken().token() - taskRepository.wallpaperActivityToken = wallpaperToken taskRepository.minimizeTask(displayId = DEFAULT_DISPLAY, taskId = task2.taskId) // Task is being minimized so mark it as not visible. taskRepository.updateTask(displayId = DEFAULT_DISPLAY, task2.taskId, isVisible = false) @@ -2925,6 +2917,7 @@ class DesktopTasksControllerTest : ShellTestCase() { @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY) fun handleRequest_closeTransition_singleTaskNoToken_doesNotHandle() { val task = setUpFreeformTask() + whenever(desktopWallpaperActivityTokenProvider.getToken()).thenReturn(null) val result = controller.handleRequest(Binder(), createTransition(task, type = TRANSIT_CLOSE)) @@ -2937,7 +2930,6 @@ class DesktopTasksControllerTest : ShellTestCase() { fun handleRequest_closeTransition_singleTaskWithToken_noWallpaper_doesNotHandle() { val task = setUpFreeformTask() - taskRepository.wallpaperActivityToken = MockToken().token() val result = controller.handleRequest(Binder(), createTransition(task, type = TRANSIT_CLOSE)) @@ -2945,17 +2937,19 @@ class DesktopTasksControllerTest : ShellTestCase() { } @Test - @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY) + @EnableFlags( + Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY, + Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER, + ) fun handleRequest_closeTransition_singleTaskWithToken_withWallpaper_removesWallpaper() { val task = setUpFreeformTask() - val wallpaperToken = MockToken().token() - taskRepository.wallpaperActivityToken = wallpaperToken val result = controller.handleRequest(Binder(), createTransition(task, type = TRANSIT_CLOSE)) // Should create remove wallpaper transaction - assertNotNull(result, "Should handle request").assertRemoveAt(index = 0, wallpaperToken) + assertNotNull(result, "Should handle request") + .assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test @@ -2964,7 +2958,6 @@ class DesktopTasksControllerTest : ShellTestCase() { val task1 = setUpFreeformTask() setUpFreeformTask() - taskRepository.wallpaperActivityToken = MockToken().token() val result = controller.handleRequest(Binder(), createTransition(task1, type = TRANSIT_CLOSE)) @@ -2977,7 +2970,6 @@ class DesktopTasksControllerTest : ShellTestCase() { val task1 = setUpFreeformTask() setUpFreeformTask() - taskRepository.wallpaperActivityToken = MockToken().token() val result = controller.handleRequest(Binder(), createTransition(task1, type = TRANSIT_CLOSE)) @@ -2985,35 +2977,39 @@ class DesktopTasksControllerTest : ShellTestCase() { } @Test - @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY) + @EnableFlags( + Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY, + Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER, + ) fun handleRequest_closeTransition_multipleTasksSingleNonClosing_removesWallpaper() { val task1 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) val task2 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) - val wallpaperToken = MockToken().token() - taskRepository.wallpaperActivityToken = wallpaperToken taskRepository.addClosingTask(displayId = DEFAULT_DISPLAY, taskId = task2.taskId) val result = controller.handleRequest(Binder(), createTransition(task1, type = TRANSIT_CLOSE)) // Should create remove wallpaper transaction - assertNotNull(result, "Should handle request").assertRemoveAt(index = 0, wallpaperToken) + assertNotNull(result, "Should handle request") + .assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test - @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY) + @EnableFlags( + Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY, + Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER, + ) fun handleRequest_closeTransition_multipleTasksSingleNonMinimized_removesWallpaper() { val task1 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) val task2 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) - val wallpaperToken = MockToken().token() - taskRepository.wallpaperActivityToken = wallpaperToken taskRepository.minimizeTask(displayId = DEFAULT_DISPLAY, taskId = task2.taskId) val result = controller.handleRequest(Binder(), createTransition(task1, type = TRANSIT_CLOSE)) // Should create remove wallpaper transaction - assertNotNull(result, "Should handle request").assertRemoveAt(index = 0, wallpaperToken) + assertNotNull(result, "Should handle request") + .assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test @@ -3021,9 +3017,7 @@ class DesktopTasksControllerTest : ShellTestCase() { fun handleRequest_closeTransition_minimizadTask_withWallpaper_removesWallpaper() { val task1 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) val task2 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) - val wallpaperToken = MockToken().token() - taskRepository.wallpaperActivityToken = wallpaperToken taskRepository.minimizeTask(displayId = DEFAULT_DISPLAY, taskId = task2.taskId) // Task is being minimized so mark it as not visible. taskRepository.updateTask(displayId = DEFAULT_DISPLAY, task2.taskId, isVisible = false) @@ -3095,16 +3089,15 @@ class DesktopTasksControllerTest : ShellTestCase() { } @Test + @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER) fun moveFocusedTaskToFullscreen_onlyVisibleNonMinimizedTask_removesWallpaperActivity() { val task1 = setUpFreeformTask() val task2 = setUpFreeformTask() val task3 = setUpFreeformTask() - val wallpaperToken = MockToken().token() task1.isFocused = false task2.isFocused = true task3.isFocused = false - taskRepository.wallpaperActivityToken = wallpaperToken taskRepository.minimizeTask(DEFAULT_DISPLAY, task1.taskId) taskRepository.updateTask(DEFAULT_DISPLAY, task3.taskId, isVisible = false) @@ -3114,7 +3107,7 @@ class DesktopTasksControllerTest : ShellTestCase() { val taskChange = assertNotNull(wct.changes[task2.token.asBinder()]) assertThat(taskChange.windowingMode) .isEqualTo(WINDOWING_MODE_UNDEFINED) // inherited FULLSCREEN - wct.assertRemoveAt(index = 0, wallpaperToken) + wct.assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test @@ -3122,12 +3115,10 @@ class DesktopTasksControllerTest : ShellTestCase() { val task1 = setUpFreeformTask() val task2 = setUpFreeformTask() val task3 = setUpFreeformTask() - val wallpaperToken = MockToken().token() task1.isFocused = false task2.isFocused = true task3.isFocused = false - taskRepository.wallpaperActivityToken = wallpaperToken controller.enterFullscreen(DEFAULT_DISPLAY, transitionSource = UNKNOWN) val wct = getLatestExitDesktopWct() @@ -3610,16 +3601,15 @@ class DesktopTasksControllerTest : ShellTestCase() { } @Test + @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER) fun enterSplit_onlyVisibleNonMinimizedTask_removesWallpaperActivity() { val task1 = setUpFreeformTask() val task2 = setUpFreeformTask() val task3 = setUpFreeformTask() - val wallpaperToken = MockToken().token() task1.isFocused = false task2.isFocused = true task3.isFocused = false - taskRepository.wallpaperActivityToken = wallpaperToken taskRepository.minimizeTask(DEFAULT_DISPLAY, task1.taskId) taskRepository.updateTask(DEFAULT_DISPLAY, task3.taskId, isVisible = false) @@ -3634,7 +3624,7 @@ class DesktopTasksControllerTest : ShellTestCase() { eq(task2.configuration.windowConfiguration.bounds), ) // Removes wallpaper activity when leaving desktop - wctArgument.value.assertRemoveAt(index = 0, wallpaperToken) + wctArgument.value.assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test @@ -3642,12 +3632,10 @@ class DesktopTasksControllerTest : ShellTestCase() { val task1 = setUpFreeformTask() val task2 = setUpFreeformTask() val task3 = setUpFreeformTask() - val wallpaperToken = MockToken().token() task1.isFocused = false task2.isFocused = true task3.isFocused = false - taskRepository.wallpaperActivityToken = wallpaperToken controller.enterSplit(DEFAULT_DISPLAY, leftOrTop = false) @@ -5091,6 +5079,18 @@ private fun WindowContainerTransaction.assertReorderAt( toTop?.let { assertThat(op.toTop).isEqualTo(it) } } +private fun WindowContainerTransaction.assertReorderAt( + index: Int, + token: WindowContainerToken, + toTop: Boolean? = null, +) { + assertIndexInBounds(index) + val op = hierarchyOps[index] + assertThat(op.type).isEqualTo(HIERARCHY_OP_TYPE_REORDER) + assertThat(op.container).isEqualTo(token.asBinder()) + toTop?.let { assertThat(op.toTop).isEqualTo(it) } +} + private fun WindowContainerTransaction.assertReorderSequence(vararg tasks: RunningTaskInfo) { for (i in tasks.indices) { assertReorderAt(i, tasks[i]) diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksTransitionObserverTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksTransitionObserverTest.kt index c66d203fd89a..d491d445458d 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksTransitionObserverTest.kt +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksTransitionObserverTest.kt @@ -35,7 +35,7 @@ import android.window.TransitionInfo import android.window.TransitionInfo.Change import android.window.WindowContainerToken import android.window.WindowContainerTransaction -import android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_REMOVE_TASK +import android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_REORDER import com.android.modules.utils.testing.ExtendedMockitoRule import com.android.window.flags.Flags import com.android.wm.shell.MockToken @@ -43,6 +43,7 @@ import com.android.wm.shell.ShellTaskOrganizer import com.android.wm.shell.back.BackAnimationController import com.android.wm.shell.common.ShellExecutor import com.android.wm.shell.desktopmode.DesktopModeTransitionTypes.TRANSIT_EXIT_DESKTOP_MODE_TASK_DRAG +import com.android.wm.shell.desktopmode.desktopwallpaperactivity.DesktopWallpaperActivityTokenProvider import com.android.wm.shell.shared.desktopmode.DesktopModeStatus import com.android.wm.shell.sysui.ShellInit import com.android.wm.shell.transition.Transitions @@ -87,6 +88,9 @@ class DesktopTasksTransitionObserverTest { private val taskRepository = mock<DesktopRepository>() private val mixedHandler = mock<DesktopMixedTransitionHandler>() private val backAnimationController = mock<BackAnimationController>() + private val desktopWallpaperActivityTokenProvider = + mock<DesktopWallpaperActivityTokenProvider>() + private val wallpaperToken = MockToken().token() private lateinit var transitionObserver: DesktopTasksTransitionObserver private lateinit var shellInit: ShellInit @@ -98,6 +102,7 @@ class DesktopTasksTransitionObserverTest { whenever(userRepositories.current).thenReturn(taskRepository) whenever(userRepositories.getProfile(anyInt())).thenReturn(taskRepository) + whenever(desktopWallpaperActivityTokenProvider.getToken()).thenReturn(wallpaperToken) transitionObserver = DesktopTasksTransitionObserver( @@ -107,6 +112,7 @@ class DesktopTasksTransitionObserverTest { shellTaskOrganizer, mixedHandler, backAnimationController, + desktopWallpaperActivityTokenProvider, shellInit, ) } @@ -233,12 +239,11 @@ class DesktopTasksTransitionObserverTest { } @Test + @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER) fun closeLastTask_wallpaperTokenExists_wallpaperIsRemoved() { val mockTransition = Mockito.mock(IBinder::class.java) val task = createTaskInfo(1, WINDOWING_MODE_FREEFORM) - val wallpaperToken = MockToken().token() whenever(taskRepository.getVisibleTaskCount(task.displayId)).thenReturn(0) - whenever(taskRepository.wallpaperActivityToken).thenReturn(wallpaperToken) transitionObserver.onTransitionReady( transition = mockTransition, @@ -248,9 +253,9 @@ class DesktopTasksTransitionObserverTest { ) transitionObserver.onTransitionFinished(mockTransition, false) - val wct = getLatestWct(type = TRANSIT_CLOSE) + val wct = getLatestWct(type = TRANSIT_TO_BACK) assertThat(wct.hierarchyOps).hasSize(1) - wct.assertRemoveAt(index = 0, wallpaperToken) + wct.assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test @@ -377,11 +382,16 @@ class DesktopTasksTransitionObserverTest { return arg.value } - private fun WindowContainerTransaction.assertRemoveAt(index: Int, token: WindowContainerToken) { + private fun WindowContainerTransaction.assertReorderAt( + index: Int, + token: WindowContainerToken, + toTop: Boolean? = null, + ) { assertIndexInBounds(index) val op = hierarchyOps[index] - assertThat(op.type).isEqualTo(HIERARCHY_OP_TYPE_REMOVE_TASK) + assertThat(op.type).isEqualTo(HIERARCHY_OP_TYPE_REORDER) assertThat(op.container).isEqualTo(token.asBinder()) + toTop?.let { assertThat(op.toTop).isEqualTo(it) } } private fun WindowContainerTransaction.assertIndexInBounds(index: Int) { diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorationTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorationTests.java index 855b3ddd99b5..e99e5cce8b27 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorationTests.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorationTests.java @@ -164,6 +164,13 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { private static final Uri TEST_URI3 = Uri.parse("https://slides.google.com/"); private static final Uri TEST_URI4 = Uri.parse("https://calendar.google.com/"); + private static final boolean DEFAULT_APPLY_START_TRANSACTION_ON_DRAW = true; + private static final boolean DEFAULT_SHOULD_SET_TASK_POSITIONING_AND_CROP = false; + private static final boolean DEFAULT_IS_STATUSBAR_VISIBLE = true; + private static final boolean DEFAULT_IS_KEYGUARD_VISIBLE_AND_OCCLUDED = false; + private static final boolean DEFAULT_IS_IN_FULL_IMMERSIVE_MODE = false; + private static final boolean DEFAULT_HAS_GLOBAL_FOCUS = true; + @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(DEVICE_DEFAULT); @Mock @@ -325,16 +332,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FREEFORM); RelayoutParams relayoutParams = new RelayoutParams(); - DesktopModeWindowDecoration.updateRelayoutParams( - relayoutParams, mContext, taskInfo, mMockSplitScreenController, - /* applyStartTransactionOnDraw= */ true, - /* shouldSetTaskPositionAndCrop */ false, - /* isStatusBarVisible */ true, - /* isKeyguardVisibleAndOccluded */ false, - /* inFullImmersiveMode */ false, - new InsetsState(), - /* hasGlobalFocus= */ true, - mExclusionRegion); + updateRelayoutParams(relayoutParams, taskInfo); assertThat(relayoutParams.mShadowRadius) .isNotEqualTo(WindowDecoration.INVALID_SHADOW_RADIUS); @@ -346,16 +344,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FULLSCREEN); RelayoutParams relayoutParams = new RelayoutParams(); - DesktopModeWindowDecoration.updateRelayoutParams( - relayoutParams, mContext, taskInfo, mMockSplitScreenController, - /* applyStartTransactionOnDraw= */ true, - /* shouldSetTaskPositionAndCrop */ false, - /* isStatusBarVisible */ true, - /* isKeyguardVisibleAndOccluded */ false, - /* inFullImmersiveMode */ false, - new InsetsState(), - /* hasGlobalFocus= */ true, - mExclusionRegion); + updateRelayoutParams(relayoutParams, taskInfo); assertThat(relayoutParams.mShadowRadius).isEqualTo(WindowDecoration.INVALID_SHADOW_RADIUS); } @@ -366,16 +355,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_MULTI_WINDOW); RelayoutParams relayoutParams = new RelayoutParams(); - DesktopModeWindowDecoration.updateRelayoutParams( - relayoutParams, mContext, taskInfo, mMockSplitScreenController, - /* applyStartTransactionOnDraw= */ true, - /* shouldSetTaskPositionAndCrop */ false, - /* isStatusBarVisible */ true, - /* isKeyguardVisibleAndOccluded */ false, - /* inFullImmersiveMode */ false, - new InsetsState(), - /* hasGlobalFocus= */ true, - mExclusionRegion); + updateRelayoutParams(relayoutParams, taskInfo); assertThat(relayoutParams.mShadowRadius).isEqualTo(WindowDecoration.INVALID_SHADOW_RADIUS); } @@ -387,19 +367,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { fillRoundedCornersResources(/* fillValue= */ 30); RelayoutParams relayoutParams = new RelayoutParams(); - DesktopModeWindowDecoration.updateRelayoutParams( - relayoutParams, - mTestableContext, - taskInfo, - mMockSplitScreenController, - /* applyStartTransactionOnDraw= */ true, - /* shouldSetTaskPositionAndCrop */ false, - /* isStatusBarVisible */ true, - /* isKeyguardVisibleAndOccluded */ false, - /* inFullImmersiveMode */ false, - new InsetsState(), - /* hasGlobalFocus= */ true, - mExclusionRegion); + updateRelayoutParams(relayoutParams, taskInfo); assertThat(relayoutParams.mCornerRadius).isGreaterThan(0); } @@ -411,19 +379,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { fillRoundedCornersResources(/* fillValue= */ 30); RelayoutParams relayoutParams = new RelayoutParams(); - DesktopModeWindowDecoration.updateRelayoutParams( - relayoutParams, - mTestableContext, - taskInfo, - mMockSplitScreenController, - /* applyStartTransactionOnDraw= */ true, - /* shouldSetTaskPositionAndCrop */ false, - /* isStatusBarVisible */ true, - /* isKeyguardVisibleAndOccluded */ false, - /* inFullImmersiveMode */ false, - new InsetsState(), - /* hasGlobalFocus= */ true, - mExclusionRegion); + updateRelayoutParams(relayoutParams, taskInfo); assertThat(relayoutParams.mCornerRadius).isEqualTo(INVALID_CORNER_RADIUS); } @@ -435,19 +391,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { fillRoundedCornersResources(/* fillValue= */ 30); RelayoutParams relayoutParams = new RelayoutParams(); - DesktopModeWindowDecoration.updateRelayoutParams( - relayoutParams, - mTestableContext, - taskInfo, - mMockSplitScreenController, - /* applyStartTransactionOnDraw= */ true, - /* shouldSetTaskPositionAndCrop */ false, - /* isStatusBarVisible */ true, - /* isKeyguardVisibleAndOccluded */ false, - /* inFullImmersiveMode */ false, - new InsetsState(), - /* hasGlobalFocus= */ true, - mExclusionRegion); + updateRelayoutParams(relayoutParams, taskInfo); assertThat(relayoutParams.mCornerRadius).isEqualTo(INVALID_CORNER_RADIUS); } @@ -463,19 +407,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { taskInfo.configuration.densityDpi = customTaskDensity; final RelayoutParams relayoutParams = new RelayoutParams(); - DesktopModeWindowDecoration.updateRelayoutParams( - relayoutParams, - mTestableContext, - taskInfo, - mMockSplitScreenController, - /* applyStartTransactionOnDraw= */ true, - /* shouldSetTaskPositionAndCrop */ false, - /* isStatusBarVisible */ true, - /* isKeyguardVisibleAndOccluded */ false, - /* inFullImmersiveMode */ false, - new InsetsState(), - /* hasGlobalFocus= */ true, - mExclusionRegion); + updateRelayoutParams(relayoutParams, taskInfo); assertThat(relayoutParams.mWindowDecorConfig.densityDpi).isEqualTo(customTaskDensity); } @@ -492,19 +424,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { taskInfo.configuration.densityDpi = customTaskDensity; final RelayoutParams relayoutParams = new RelayoutParams(); - DesktopModeWindowDecoration.updateRelayoutParams( - relayoutParams, - mTestableContext, - taskInfo, - mMockSplitScreenController, - /* applyStartTransactionOnDraw= */ true, - /* shouldSetTaskPositionAndCrop */ false, - /* isStatusBarVisible */ true, - /* isKeyguardVisibleAndOccluded */ false, - /* inFullImmersiveMode */ false, - new InsetsState(), - /* hasGlobalFocus= */ true, - mExclusionRegion); + updateRelayoutParams(relayoutParams, taskInfo); assertThat(relayoutParams.mWindowDecorConfig.densityDpi).isEqualTo(systemDensity); } @@ -518,19 +438,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { APPEARANCE_TRANSPARENT_CAPTION_BAR_BACKGROUND); final RelayoutParams relayoutParams = new RelayoutParams(); - DesktopModeWindowDecoration.updateRelayoutParams( - relayoutParams, - mTestableContext, - taskInfo, - mMockSplitScreenController, - /* applyStartTransactionOnDraw= */ true, - /* shouldSetTaskPositionAndCrop */ false, - /* isStatusBarVisible */ true, - /* isKeyguardVisibleAndOccluded */ false, - /* inFullImmersiveMode */ false, - new InsetsState(), - /* hasGlobalFocus= */ true, - mExclusionRegion); + updateRelayoutParams(relayoutParams, taskInfo); assertThat(relayoutParams.hasInputFeatureSpy()).isTrue(); } @@ -544,19 +452,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { APPEARANCE_TRANSPARENT_CAPTION_BAR_BACKGROUND); final RelayoutParams relayoutParams = new RelayoutParams(); - DesktopModeWindowDecoration.updateRelayoutParams( - relayoutParams, - mTestableContext, - taskInfo, - mMockSplitScreenController, - /* applyStartTransactionOnDraw= */ true, - /* shouldSetTaskPositionAndCrop */ false, - /* isStatusBarVisible */ true, - /* isKeyguardVisibleAndOccluded */ false, - /* inFullImmersiveMode */ false, - new InsetsState(), - /* hasGlobalFocus= */ true, - mExclusionRegion); + updateRelayoutParams(relayoutParams, taskInfo); assertThat(relayoutParams.mLimitTouchRegionToSystemAreas).isTrue(); } @@ -569,19 +465,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { taskInfo.taskDescription.setTopOpaqueSystemBarsAppearance(0); final RelayoutParams relayoutParams = new RelayoutParams(); - DesktopModeWindowDecoration.updateRelayoutParams( - relayoutParams, - mTestableContext, - taskInfo, - mMockSplitScreenController, - /* applyStartTransactionOnDraw= */ true, - /* shouldSetTaskPositionAndCrop */ false, - /* isStatusBarVisible */ true, - /* isKeyguardVisibleAndOccluded */ false, - /* inFullImmersiveMode */ false, - new InsetsState(), - /* hasGlobalFocus= */ true, - mExclusionRegion); + updateRelayoutParams(relayoutParams, taskInfo); assertThat(relayoutParams.hasInputFeatureSpy()).isFalse(); } @@ -594,19 +478,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { taskInfo.taskDescription.setTopOpaqueSystemBarsAppearance(0); final RelayoutParams relayoutParams = new RelayoutParams(); - DesktopModeWindowDecoration.updateRelayoutParams( - relayoutParams, - mTestableContext, - taskInfo, - mMockSplitScreenController, - /* applyStartTransactionOnDraw= */ true, - /* shouldSetTaskPositionAndCrop */ false, - /* isStatusBarVisible */ true, - /* isKeyguardVisibleAndOccluded */ false, - /* inFullImmersiveMode */ false, - new InsetsState(), - /* hasGlobalFocus= */ true, - mExclusionRegion); + updateRelayoutParams(relayoutParams, taskInfo); assertThat(relayoutParams.mLimitTouchRegionToSystemAreas).isFalse(); } @@ -618,19 +490,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FULLSCREEN); final RelayoutParams relayoutParams = new RelayoutParams(); - DesktopModeWindowDecoration.updateRelayoutParams( - relayoutParams, - mTestableContext, - taskInfo, - mMockSplitScreenController, - /* applyStartTransactionOnDraw= */ true, - /* shouldSetTaskPositionAndCrop */ false, - /* isStatusBarVisible */ true, - /* isKeyguardVisibleAndOccluded */ false, - /* inFullImmersiveMode */ false, - new InsetsState(), - /* hasGlobalFocus= */ true, - mExclusionRegion); + updateRelayoutParams(relayoutParams, taskInfo); assertThat(relayoutParams.hasInputFeatureSpy()).isFalse(); } @@ -642,19 +502,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FULLSCREEN); final RelayoutParams relayoutParams = new RelayoutParams(); - DesktopModeWindowDecoration.updateRelayoutParams( - relayoutParams, - mTestableContext, - taskInfo, - mMockSplitScreenController, - /* applyStartTransactionOnDraw= */ true, - /* shouldSetTaskPositionAndCrop */ false, - /* isStatusBarVisible */ true, - /* isKeyguardVisibleAndOccluded */ false, - /* inFullImmersiveMode */ false, - new InsetsState(), - /* hasGlobalFocus= */ true, - mExclusionRegion); + updateRelayoutParams(relayoutParams, taskInfo); assertThat(relayoutParams.mLimitTouchRegionToSystemAreas).isFalse(); } @@ -665,19 +513,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FREEFORM); final RelayoutParams relayoutParams = new RelayoutParams(); - DesktopModeWindowDecoration.updateRelayoutParams( - relayoutParams, - mTestableContext, - taskInfo, - mMockSplitScreenController, - /* applyStartTransactionOnDraw= */ true, - /* shouldSetTaskPositionAndCrop */ false, - /* isStatusBarVisible */ true, - /* isKeyguardVisibleAndOccluded */ false, - /* inFullImmersiveMode */ false, - new InsetsState(), - /* hasGlobalFocus= */ true, - mExclusionRegion); + updateRelayoutParams(relayoutParams, taskInfo); assertThat(hasNoInputChannelFeature(relayoutParams)).isFalse(); } @@ -689,19 +525,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FULLSCREEN); final RelayoutParams relayoutParams = new RelayoutParams(); - DesktopModeWindowDecoration.updateRelayoutParams( - relayoutParams, - mTestableContext, - taskInfo, - mMockSplitScreenController, - /* applyStartTransactionOnDraw= */ true, - /* shouldSetTaskPositionAndCrop */ false, - /* isStatusBarVisible */ true, - /* isKeyguardVisibleAndOccluded */ false, - /* inFullImmersiveMode */ false, - new InsetsState(), - /* hasGlobalFocus= */ true, - mExclusionRegion); + updateRelayoutParams(relayoutParams, taskInfo); assertThat(hasNoInputChannelFeature(relayoutParams)).isTrue(); } @@ -713,19 +537,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_MULTI_WINDOW); final RelayoutParams relayoutParams = new RelayoutParams(); - DesktopModeWindowDecoration.updateRelayoutParams( - relayoutParams, - mTestableContext, - taskInfo, - mMockSplitScreenController, - /* applyStartTransactionOnDraw= */ true, - /* shouldSetTaskPositionAndCrop */ false, - /* isStatusBarVisible */ true, - /* isKeyguardVisibleAndOccluded */ false, - /* inFullImmersiveMode */ false, - new InsetsState(), - /* hasGlobalFocus= */ true, - mExclusionRegion); + updateRelayoutParams(relayoutParams, taskInfo); assertThat(hasNoInputChannelFeature(relayoutParams)).isTrue(); } @@ -738,19 +550,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { taskInfo.taskDescription.setTopOpaqueSystemBarsAppearance(0); final RelayoutParams relayoutParams = new RelayoutParams(); - DesktopModeWindowDecoration.updateRelayoutParams( - relayoutParams, - mTestableContext, - taskInfo, - mMockSplitScreenController, - /* applyStartTransactionOnDraw= */ true, - /* shouldSetTaskPositionAndCrop */ false, - /* isStatusBarVisible */ true, - /* isKeyguardVisibleAndOccluded */ false, - /* inFullImmersiveMode */ false, - new InsetsState(), - /* hasGlobalFocus= */ true, - mExclusionRegion); + updateRelayoutParams(relayoutParams, taskInfo); assertThat((relayoutParams.mInsetSourceFlags & FLAG_FORCE_CONSUMING) != 0).isTrue(); } @@ -764,19 +564,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { APPEARANCE_TRANSPARENT_CAPTION_BAR_BACKGROUND); final RelayoutParams relayoutParams = new RelayoutParams(); - DesktopModeWindowDecoration.updateRelayoutParams( - relayoutParams, - mTestableContext, - taskInfo, - mMockSplitScreenController, - /* applyStartTransactionOnDraw= */ true, - /* shouldSetTaskPositionAndCrop */ false, - /* isStatusBarVisible */ true, - /* isKeyguardVisibleAndOccluded */ false, - /* inFullImmersiveMode */ false, - new InsetsState(), - /* hasGlobalFocus= */ true, - mExclusionRegion); + updateRelayoutParams(relayoutParams, taskInfo); assertThat((relayoutParams.mInsetSourceFlags & FLAG_FORCE_CONSUMING) == 0).isTrue(); } @@ -788,19 +576,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FREEFORM); final RelayoutParams relayoutParams = new RelayoutParams(); - DesktopModeWindowDecoration.updateRelayoutParams( - relayoutParams, - mTestableContext, - taskInfo, - mMockSplitScreenController, - /* applyStartTransactionOnDraw= */ true, - /* shouldSetTaskPositionAndCrop */ false, - /* isStatusBarVisible */ true, - /* isKeyguardVisibleAndOccluded */ false, - /* inFullImmersiveMode */ false, - new InsetsState(), - /* hasGlobalFocus= */ true, - mExclusionRegion); + updateRelayoutParams(relayoutParams, taskInfo); assertThat( (relayoutParams.mInsetSourceFlags & FLAG_FORCE_CONSUMING_OPAQUE_CAPTION_BAR) != 0) @@ -814,19 +590,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FULLSCREEN); final RelayoutParams relayoutParams = new RelayoutParams(); - DesktopModeWindowDecoration.updateRelayoutParams( - relayoutParams, - mTestableContext, - taskInfo, - mMockSplitScreenController, - /* applyStartTransactionOnDraw= */ true, - /* shouldSetTaskPositionAndCrop */ false, - /* isStatusBarVisible */ true, - /* isKeyguardVisibleAndOccluded */ false, - /* inFullImmersiveMode */ false, - new InsetsState(), - /* hasGlobalFocus= */ true, - mExclusionRegion); + updateRelayoutParams(relayoutParams, taskInfo); assertThat( (relayoutParams.mInsetSourceFlags & FLAG_FORCE_CONSUMING_OPAQUE_CAPTION_BAR) == 0) @@ -841,19 +605,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { when(mMockSplitScreenController.getSplitPosition(taskInfo.taskId)) .thenReturn(SPLIT_POSITION_BOTTOM_OR_RIGHT); - DesktopModeWindowDecoration.updateRelayoutParams( - relayoutParams, - mTestableContext, - taskInfo, - mMockSplitScreenController, - /* applyStartTransactionOnDraw= */ true, - /* shouldSetTaskPositionAndCrop */ false, - /* isStatusBarVisible */ true, - /* isKeyguardVisibleAndOccluded */ false, - /* inFullImmersiveMode */ true, - new InsetsState(), - /* hasGlobalFocus= */ true, - mExclusionRegion); + updateRelayoutParams(relayoutParams, taskInfo); assertThat(relayoutParams.mIsInsetSource).isTrue(); } @@ -876,13 +628,13 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { mTestableContext, taskInfo, mMockSplitScreenController, - /* applyStartTransactionOnDraw= */ true, - /* shouldSetTaskPositionAndCrop */ false, - /* isStatusBarVisible */ true, - /* isKeyguardVisibleAndOccluded */ false, + DEFAULT_APPLY_START_TRANSACTION_ON_DRAW, + DEFAULT_SHOULD_SET_TASK_POSITIONING_AND_CROP, + DEFAULT_IS_STATUSBAR_VISIBLE, + DEFAULT_IS_KEYGUARD_VISIBLE_AND_OCCLUDED, /* inFullImmersiveMode */ true, insetsState, - /* hasGlobalFocus= */ true, + DEFAULT_HAS_GLOBAL_FOCUS, mExclusionRegion); // Takes status bar inset as padding, ignores caption bar inset. @@ -901,13 +653,13 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { mTestableContext, taskInfo, mMockSplitScreenController, - /* applyStartTransactionOnDraw= */ true, - /* shouldSetTaskPositionAndCrop */ false, - /* isStatusBarVisible */ true, - /* isKeyguardVisibleAndOccluded */ false, + DEFAULT_APPLY_START_TRANSACTION_ON_DRAW, + DEFAULT_SHOULD_SET_TASK_POSITIONING_AND_CROP, + DEFAULT_IS_STATUSBAR_VISIBLE, + DEFAULT_IS_KEYGUARD_VISIBLE_AND_OCCLUDED, /* inFullImmersiveMode */ true, new InsetsState(), - /* hasGlobalFocus= */ true, + DEFAULT_HAS_GLOBAL_FOCUS, mExclusionRegion); assertThat(relayoutParams.mIsInsetSource).isFalse(); @@ -925,13 +677,13 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { mTestableContext, taskInfo, mMockSplitScreenController, - /* applyStartTransactionOnDraw= */ true, - /* shouldSetTaskPositionAndCrop */ false, + DEFAULT_APPLY_START_TRANSACTION_ON_DRAW, + DEFAULT_SHOULD_SET_TASK_POSITIONING_AND_CROP, /* isStatusBarVisible */ false, - /* isKeyguardVisibleAndOccluded */ false, - /* inFullImmersiveMode */ false, + DEFAULT_IS_KEYGUARD_VISIBLE_AND_OCCLUDED, + DEFAULT_IS_IN_FULL_IMMERSIVE_MODE, new InsetsState(), - /* hasGlobalFocus= */ true, + DEFAULT_HAS_GLOBAL_FOCUS, mExclusionRegion); // Header is always shown because it's assumed the status bar is always visible. @@ -949,13 +701,13 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { mTestableContext, taskInfo, mMockSplitScreenController, - /* applyStartTransactionOnDraw= */ true, - /* shouldSetTaskPositionAndCrop */ false, + DEFAULT_APPLY_START_TRANSACTION_ON_DRAW, + DEFAULT_SHOULD_SET_TASK_POSITIONING_AND_CROP, /* isStatusBarVisible */ true, /* isKeyguardVisibleAndOccluded */ false, - /* inFullImmersiveMode */ false, + DEFAULT_IS_IN_FULL_IMMERSIVE_MODE, new InsetsState(), - /* hasGlobalFocus= */ true, + DEFAULT_HAS_GLOBAL_FOCUS, mExclusionRegion); assertThat(relayoutParams.mIsCaptionVisible).isTrue(); @@ -972,13 +724,13 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { mTestableContext, taskInfo, mMockSplitScreenController, - /* applyStartTransactionOnDraw= */ true, - /* shouldSetTaskPositionAndCrop */ false, + DEFAULT_APPLY_START_TRANSACTION_ON_DRAW, + DEFAULT_SHOULD_SET_TASK_POSITIONING_AND_CROP, /* isStatusBarVisible */ false, - /* isKeyguardVisibleAndOccluded */ false, - /* inFullImmersiveMode */ false, + DEFAULT_IS_KEYGUARD_VISIBLE_AND_OCCLUDED, + DEFAULT_IS_IN_FULL_IMMERSIVE_MODE, new InsetsState(), - /* hasGlobalFocus= */ true, + DEFAULT_HAS_GLOBAL_FOCUS, mExclusionRegion); assertThat(relayoutParams.mIsCaptionVisible).isFalse(); @@ -995,13 +747,13 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { mTestableContext, taskInfo, mMockSplitScreenController, - /* applyStartTransactionOnDraw= */ true, - /* shouldSetTaskPositionAndCrop */ false, - /* isStatusBarVisible */ true, + DEFAULT_APPLY_START_TRANSACTION_ON_DRAW, + DEFAULT_SHOULD_SET_TASK_POSITIONING_AND_CROP, + DEFAULT_IS_STATUSBAR_VISIBLE, /* isKeyguardVisibleAndOccluded */ true, - /* inFullImmersiveMode */ false, + DEFAULT_IS_IN_FULL_IMMERSIVE_MODE, new InsetsState(), - /* hasGlobalFocus= */ true, + DEFAULT_HAS_GLOBAL_FOCUS, mExclusionRegion); assertThat(relayoutParams.mIsCaptionVisible).isFalse(); @@ -1019,13 +771,13 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { mTestableContext, taskInfo, mMockSplitScreenController, - /* applyStartTransactionOnDraw= */ true, - /* shouldSetTaskPositionAndCrop */ false, + DEFAULT_APPLY_START_TRANSACTION_ON_DRAW, + DEFAULT_SHOULD_SET_TASK_POSITIONING_AND_CROP, /* isStatusBarVisible */ true, - /* isKeyguardVisibleAndOccluded */ false, + DEFAULT_IS_KEYGUARD_VISIBLE_AND_OCCLUDED, /* inFullImmersiveMode */ true, new InsetsState(), - /* hasGlobalFocus= */ true, + DEFAULT_HAS_GLOBAL_FOCUS, mExclusionRegion); assertThat(relayoutParams.mIsCaptionVisible).isTrue(); @@ -1035,13 +787,13 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { mTestableContext, taskInfo, mMockSplitScreenController, - /* applyStartTransactionOnDraw= */ true, - /* shouldSetTaskPositionAndCrop */ false, + DEFAULT_APPLY_START_TRANSACTION_ON_DRAW, + DEFAULT_SHOULD_SET_TASK_POSITIONING_AND_CROP, /* isStatusBarVisible */ false, - /* isKeyguardVisibleAndOccluded */ false, + DEFAULT_IS_KEYGUARD_VISIBLE_AND_OCCLUDED, /* inFullImmersiveMode */ true, new InsetsState(), - /* hasGlobalFocus= */ true, + DEFAULT_HAS_GLOBAL_FOCUS, mExclusionRegion); assertThat(relayoutParams.mIsCaptionVisible).isFalse(); @@ -1059,13 +811,13 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { mTestableContext, taskInfo, mMockSplitScreenController, - /* applyStartTransactionOnDraw= */ true, - /* shouldSetTaskPositionAndCrop */ false, - /* isStatusBarVisible */ true, + DEFAULT_APPLY_START_TRANSACTION_ON_DRAW, + DEFAULT_SHOULD_SET_TASK_POSITIONING_AND_CROP, + DEFAULT_IS_STATUSBAR_VISIBLE, /* isKeyguardVisibleAndOccluded */ true, /* inFullImmersiveMode */ true, new InsetsState(), - /* hasGlobalFocus= */ true, + DEFAULT_HAS_GLOBAL_FOCUS, mExclusionRegion); assertThat(relayoutParams.mIsCaptionVisible).isFalse(); @@ -1078,19 +830,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FULLSCREEN); final RelayoutParams relayoutParams = new RelayoutParams(); - DesktopModeWindowDecoration.updateRelayoutParams( - relayoutParams, - mTestableContext, - taskInfo, - mMockSplitScreenController, - /* applyStartTransactionOnDraw= */ true, - /* shouldSetTaskPositionAndCrop= */ false, - /* isStatusBarVisible= */ true, - /* isKeyguardVisibleAndOccluded= */ false, - /* inFullImmersiveMode= */ false, - new InsetsState(), - /* hasGlobalFocus= */ true, - mExclusionRegion); + updateRelayoutParams(relayoutParams, taskInfo); // App Handles don't need to be rendered in sync with the task animation, per UX. assertThat(relayoutParams.mAsyncViewHost).isTrue(); @@ -1103,19 +843,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FREEFORM); final RelayoutParams relayoutParams = new RelayoutParams(); - DesktopModeWindowDecoration.updateRelayoutParams( - relayoutParams, - mTestableContext, - taskInfo, - mMockSplitScreenController, - /* applyStartTransactionOnDraw= */ true, - /* shouldSetTaskPositionAndCrop= */ false, - /* isStatusBarVisible= */ true, - /* isKeyguardVisibleAndOccluded= */ false, - /* inFullImmersiveMode= */ false, - new InsetsState(), - /* hasGlobalFocus= */ true, - mExclusionRegion); + updateRelayoutParams(relayoutParams, taskInfo); // App Headers must be rendered in sync with the task animation, so it cannot be delayed. assertThat(relayoutParams.mAsyncViewHost).isFalse(); @@ -1734,6 +1462,23 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { R.dimen.rounded_corner_radius_bottom, fillValue); } + private void updateRelayoutParams( + RelayoutParams relayoutParams, ActivityManager.RunningTaskInfo taskInfo) { + DesktopModeWindowDecoration.updateRelayoutParams( + relayoutParams, + mTestableContext, + taskInfo, + mMockSplitScreenController, + DEFAULT_APPLY_START_TRANSACTION_ON_DRAW, + DEFAULT_SHOULD_SET_TASK_POSITIONING_AND_CROP, + DEFAULT_IS_STATUSBAR_VISIBLE, + DEFAULT_IS_KEYGUARD_VISIBLE_AND_OCCLUDED, + DEFAULT_IS_IN_FULL_IMMERSIVE_MODE, + new InsetsState(), + DEFAULT_HAS_GLOBAL_FOCUS, + mExclusionRegion); + } + private DesktopModeWindowDecoration createWindowDecoration( ActivityManager.RunningTaskInfo taskInfo, @Nullable Uri capturedLink, @Nullable Uri webUri, @Nullable Uri sessionTransferUri, @Nullable Uri genericLink) { diff --git a/libs/dream/lowlight/res/values/config.xml b/libs/dream/lowlight/res/values/config.xml index 78fefbf41141..2b8fe029d842 100644 --- a/libs/dream/lowlight/res/values/config.xml +++ b/libs/dream/lowlight/res/values/config.xml @@ -15,8 +15,6 @@ ~ limitations under the License. --> <resources> - <!-- The dream component used when the device is low light environment. --> - <string translatable="false" name="config_lowLightDreamComponent"/> <!-- The max number of milliseconds to wait for the low light transition before setting the system dream component --> <integer name="config_lowLightTransitionTimeoutMs">2000</integer> diff --git a/libs/dream/lowlight/src/com/android/dream/lowlight/dagger/LowLightDreamComponent.kt b/libs/dream/lowlight/src/com/android/dream/lowlight/dagger/LowLightDreamComponent.kt new file mode 100644 index 000000000000..2314f9490829 --- /dev/null +++ b/libs/dream/lowlight/src/com/android/dream/lowlight/dagger/LowLightDreamComponent.kt @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.dream.lowlight.dagger + +import android.app.DreamManager +import android.content.ComponentName +import dagger.BindsInstance +import dagger.Subcomponent +import javax.inject.Named + +@Subcomponent(modules = [LowLightDreamModule::class]) +interface LowLightDreamComponent { + @Subcomponent.Factory + interface Factory { + fun create(@BindsInstance dreamManager: DreamManager, + @Named(LowLightDreamModule.LOW_LIGHT_DREAM_COMPONENT) + @BindsInstance lowLightDreamComponent: ComponentName? + ): LowLightDreamComponent + } +}
\ No newline at end of file diff --git a/libs/dream/lowlight/src/com/android/dream/lowlight/dagger/LowLightDreamModule.kt b/libs/dream/lowlight/src/com/android/dream/lowlight/dagger/LowLightDreamModule.kt index dd274bd9d509..0161eef1260f 100644 --- a/libs/dream/lowlight/src/com/android/dream/lowlight/dagger/LowLightDreamModule.kt +++ b/libs/dream/lowlight/src/com/android/dream/lowlight/dagger/LowLightDreamModule.kt @@ -15,8 +15,6 @@ */ package com.android.dream.lowlight.dagger -import android.app.DreamManager -import android.content.ComponentName import android.content.Context import com.android.dream.lowlight.R import com.android.dream.lowlight.dagger.qualifiers.Application @@ -35,30 +33,6 @@ import javax.inject.Named */ @Module object LowLightDreamModule { - /** - * Provides dream manager. - */ - @Provides - fun providesDreamManager(context: Context): DreamManager { - return requireNotNull(context.getSystemService(DreamManager::class.java)) - } - - /** - * Provides the component name of the low light dream, or null if not configured. - */ - @Provides - @Named(LOW_LIGHT_DREAM_COMPONENT) - fun providesLowLightDreamComponent(context: Context): ComponentName? { - val lowLightDreamComponent = context.resources.getString( - R.string.config_lowLightDreamComponent - ) - return if (lowLightDreamComponent.isEmpty()) { - null - } else { - ComponentName.unflattenFromString(lowLightDreamComponent) - } - } - @Provides @Named(LOW_LIGHT_TRANSITION_TIMEOUT_MS) fun providesLowLightTransitionTimeout(context: Context): Long { diff --git a/nfc/api/system-current.txt b/nfc/api/system-current.txt index 6bd6072a2f43..6e69da1c6daa 100644 --- a/nfc/api/system-current.txt +++ b/nfc/api/system-current.txt @@ -118,7 +118,7 @@ package android.nfc { method public void onNdefRead(@NonNull java.util.function.Consumer<java.lang.Boolean>); method public void onReaderOptionChanged(boolean); method public void onRfDiscoveryStarted(boolean); - method public void onRfFieldActivated(boolean); + method public void onRfFieldDetected(boolean); method public void onRoutingChanged(@NonNull java.util.function.Consumer<java.lang.Boolean>); method public void onRoutingTableFull(); method public void onStateUpdated(int); diff --git a/nfc/java/android/nfc/INfcOemExtensionCallback.aidl b/nfc/java/android/nfc/INfcOemExtensionCallback.aidl index e5eac0b4d6fd..357d3229306c 100644 --- a/nfc/java/android/nfc/INfcOemExtensionCallback.aidl +++ b/nfc/java/android/nfc/INfcOemExtensionCallback.aidl @@ -45,7 +45,7 @@ interface INfcOemExtensionCallback { void onHceEventReceived(int action); void onReaderOptionChanged(boolean enabled); void onCardEmulationActivated(boolean isActivated); - void onRfFieldActivated(boolean isActivated); + void onRfFieldDetected(boolean isActive); void onRfDiscoveryStarted(boolean isDiscoveryStarted); void onEeListenActivated(boolean isActivated); void onEeUpdated(); diff --git a/nfc/java/android/nfc/NfcOemExtension.java b/nfc/java/android/nfc/NfcOemExtension.java index b46e34368e77..1fc0786d3582 100644 --- a/nfc/java/android/nfc/NfcOemExtension.java +++ b/nfc/java/android/nfc/NfcOemExtension.java @@ -408,12 +408,12 @@ public final class NfcOemExtension { void onCardEmulationActivated(boolean isActivated); /** - * Notifies the Remote NFC Endpoint RF Field is activated. + * Notifies the Remote NFC Endpoint RF Field is detected. * NFC Forum NCI-2.3 ch.5.3 specification * - * @param isActivated true, if RF Field is ON, else RF Field is OFF. + * @param isActive true, if RF Field is ON, else RF Field is OFF. */ - void onRfFieldActivated(boolean isActivated); + void onRfFieldDetected(boolean isActive); /** * Notifies the NFC RF discovery is started or in the IDLE state. @@ -596,7 +596,7 @@ public final class NfcOemExtension { Log.i(TAG, "updateNfCState"); executor.execute(() -> { callback.onCardEmulationActivated(mCardEmulationActivated); - callback.onRfFieldActivated(mRfFieldActivated); + callback.onRfFieldDetected(mRfFieldActivated); callback.onRfDiscoveryStarted(mRfDiscoveryStarted); callback.onEeListenActivated(mEeListenActivated); }); @@ -936,10 +936,10 @@ public final class NfcOemExtension { } @Override - public void onRfFieldActivated(boolean isActivated) throws RemoteException { - mRfFieldActivated = isActivated; + public void onRfFieldDetected(boolean isActive) throws RemoteException { + mRfFieldActivated = isActive; mCallbackMap.forEach((cb, ex) -> - handleVoidCallback(isActivated, cb::onRfFieldActivated, ex)); + handleVoidCallback(isActive, cb::onRfFieldDetected, ex)); } @Override diff --git a/nfc/tests/src/android/nfc/cardemulation/CardemulationTest.java b/nfc/tests/src/android/nfc/cardemulation/CardemulationTest.java index a21583542a66..48632064621c 100644 --- a/nfc/tests/src/android/nfc/cardemulation/CardemulationTest.java +++ b/nfc/tests/src/android/nfc/cardemulation/CardemulationTest.java @@ -51,6 +51,9 @@ import org.mockito.MockitoAnnotations; import org.mockito.MockitoSession; import org.mockito.quality.Strictness; +import java.util.ArrayList; +import java.util.List; + @RunWith(AndroidJUnit4.class) public class CardemulationTest { @@ -171,7 +174,7 @@ public class CardemulationTest { } @Test - public void testRemovePollingLoopFilterForService()throws RemoteException { + public void testRemovePollingLoopFilterForService() throws RemoteException { UserHandle userHandle = mock(UserHandle.class); when(userHandle.getIdentifier()).thenReturn(1); when(mContext.getUser()).thenReturn(userHandle); @@ -183,4 +186,99 @@ public class CardemulationTest { assertThat(result).isTrue(); verify(mINfcCardEmulation).removePollingLoopFilterForService(anyInt(), any(), anyString()); } + + @Test + public void testRegisterPollingLoopPatternFilterForService() throws RemoteException { + UserHandle userHandle = mock(UserHandle.class); + when(userHandle.getIdentifier()).thenReturn(1); + when(mContext.getUser()).thenReturn(userHandle); + ComponentName componentName = mock(ComponentName.class); + when(mINfcCardEmulation.registerPollingLoopPatternFilterForService(anyInt(), any(), + anyString(), anyBoolean())).thenReturn(true); + boolean result = mCardEmulation.registerPollingLoopPatternFilterForService(componentName, + "A0000000041010", true); + assertThat(result).isTrue(); + verify(mINfcCardEmulation).registerPollingLoopPatternFilterForService(anyInt(), any(), + anyString(), anyBoolean()); + } + + @Test + public void testRemovePollingLoopPatternFilterForService() throws RemoteException { + UserHandle userHandle = mock(UserHandle.class); + when(userHandle.getIdentifier()).thenReturn(1); + when(mContext.getUser()).thenReturn(userHandle); + ComponentName componentName = mock(ComponentName.class); + when(mINfcCardEmulation.removePollingLoopPatternFilterForService(anyInt(), any(), + anyString())).thenReturn(true); + boolean result = mCardEmulation.removePollingLoopPatternFilterForService(componentName, + "A0000000041010"); + assertThat(result).isTrue(); + verify(mINfcCardEmulation).removePollingLoopPatternFilterForService(anyInt(), any(), + anyString()); + } + + @Test + public void testRegisterAidsForService() throws RemoteException { + UserHandle userHandle = mock(UserHandle.class); + when(userHandle.getIdentifier()).thenReturn(1); + when(mContext.getUser()).thenReturn(userHandle); + ComponentName componentName = mock(ComponentName.class); + when(mINfcCardEmulation.registerAidGroupForService(anyInt(), any(), + any())).thenReturn(true); + List<String> aids = new ArrayList<>(); + aids.add("A0000000041010"); + boolean result = mCardEmulation.registerAidsForService(componentName, "payment", + aids); + assertThat(result).isTrue(); + verify(mINfcCardEmulation).registerAidGroupForService(anyInt(), any(), + any()); + } + + @Test + public void testUnsetOffHostForService() throws RemoteException { + UserHandle userHandle = mock(UserHandle.class); + when(userHandle.getIdentifier()).thenReturn(1); + when(mContext.getUser()).thenReturn(userHandle); + ComponentName componentName = mock(ComponentName.class); + when(mINfcCardEmulation.unsetOffHostForService(1, componentName)).thenReturn(true); + boolean result = mCardEmulation.unsetOffHostForService(componentName); + assertThat(result).isTrue(); + verify(mINfcCardEmulation).unsetOffHostForService(1, componentName); + } + + @Test + public void testSetOffHostForService() throws RemoteException { + UserHandle userHandle = mock(UserHandle.class); + when(userHandle.getIdentifier()).thenReturn(1); + when(mContext.getUser()).thenReturn(userHandle); + when(NfcAdapter.getDefaultAdapter(any())).thenReturn(mNfcAdapter); + List<String> elements = new ArrayList<>(); + elements.add("eSE"); + when(mNfcAdapter.getSupportedOffHostSecureElements()).thenReturn(elements); + ComponentName componentName = mock(ComponentName.class); + when(mINfcCardEmulation.setOffHostForService(anyInt(), any(), anyString())) + .thenReturn(true); + boolean result = mCardEmulation.setOffHostForService(componentName, + "eSE"); + assertThat(result).isTrue(); + verify(mINfcCardEmulation).setOffHostForService(anyInt(), any(), anyString()); + } + + @Test + public void testGetAidsForService() throws RemoteException { + UserHandle userHandle = mock(UserHandle.class); + when(userHandle.getIdentifier()).thenReturn(1); + when(mContext.getUser()).thenReturn(userHandle); + ComponentName componentName = mock(ComponentName.class); + List<String> elements = new ArrayList<>(); + elements.add("eSE"); + AidGroup aidGroup = mock(AidGroup.class); + when(aidGroup.getAids()).thenReturn(elements); + when(mINfcCardEmulation.getAidGroupForService(1, componentName, "payment")) + .thenReturn(aidGroup); + List<String> result = mCardEmulation.getAidsForService(componentName, "payment"); + assertThat(result).isNotNull(); + assertThat(result.size()).isGreaterThan(0); + verify(mINfcCardEmulation).getAidGroupForService(1, componentName, "payment"); + } } diff --git a/packages/SettingsProvider/src/android/provider/settings/backup/SystemSettings.java b/packages/SettingsProvider/src/android/provider/settings/backup/SystemSettings.java index 935ea2549d49..f1bbfc62681a 100644 --- a/packages/SettingsProvider/src/android/provider/settings/backup/SystemSettings.java +++ b/packages/SettingsProvider/src/android/provider/settings/backup/SystemSettings.java @@ -108,6 +108,7 @@ public class SystemSettings { Settings.System.AUTO_LAUNCH_MEDIA_CONTROLS, Settings.System.LOCALE_PREFERENCES, Settings.System.MOUSE_REVERSE_VERTICAL_SCROLLING, + Settings.System.MOUSE_SCROLLING_ACCELERATION, Settings.System.MOUSE_SWAP_PRIMARY_BUTTON, Settings.System.TOUCHPAD_POINTER_SPEED, Settings.System.TOUCHPAD_NATURAL_SCROLLING, diff --git a/packages/SettingsProvider/src/android/provider/settings/validators/SystemSettingsValidators.java b/packages/SettingsProvider/src/android/provider/settings/validators/SystemSettingsValidators.java index 63f401c63b93..6abd9b73e26d 100644 --- a/packages/SettingsProvider/src/android/provider/settings/validators/SystemSettingsValidators.java +++ b/packages/SettingsProvider/src/android/provider/settings/validators/SystemSettingsValidators.java @@ -225,6 +225,7 @@ public class SystemSettingsValidators { new InclusiveFloatRangeValidator(DEFAULT_POINTER_SCALE, LARGE_POINTER_SCALE)); VALIDATORS.put(System.MOUSE_REVERSE_VERTICAL_SCROLLING, BOOLEAN_VALIDATOR); VALIDATORS.put(System.MOUSE_SWAP_PRIMARY_BUTTON, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.MOUSE_SCROLLING_ACCELERATION, BOOLEAN_VALIDATOR); VALIDATORS.put(System.TOUCHPAD_POINTER_SPEED, new InclusiveIntegerRangeValidator(-7, 7)); VALIDATORS.put(System.TOUCHPAD_NATURAL_SCROLLING, BOOLEAN_VALIDATOR); VALIDATORS.put(System.TOUCHPAD_TAP_TO_CLICK, BOOLEAN_VALIDATOR); diff --git a/packages/SystemUI/aconfig/systemui.aconfig b/packages/SystemUI/aconfig/systemui.aconfig index c4ef837f9280..87fb58ee359e 100644 --- a/packages/SystemUI/aconfig/systemui.aconfig +++ b/packages/SystemUI/aconfig/systemui.aconfig @@ -547,14 +547,6 @@ flag { } flag { - name: "migrate_clocks_to_blueprint" - namespace: "systemui" - description: "Move clock related views from KeyguardStatusView to KeyguardRootView, " - "and use modern architecture for lockscreen clocks" - bug: "301502635" -} - -flag { name: "clock_reactive_variants" namespace: "systemui" description: "Add reactive variant fonts to some clocks" @@ -1222,6 +1214,13 @@ flag { } flag { + name: "low_light_clock_dream" + namespace: "systemui" + description: "Enables low light clock dream experience on mobile phones" + bug: "378174125" +} + +flag { name: "communal_standalone_support" namespace: "systemui" description: "Support communal features without a dock" @@ -1809,6 +1808,9 @@ flag { namespace: "systemui" description: "Disables expansion of the shade via two finger swipe on a trackpad" bug: "356804470" + metadata { + purpose: PURPOSE_BUGFIX + } } flag { diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/qs/ui/composable/QuickSettingsShadeOverlay.kt b/packages/SystemUI/compose/features/src/com/android/systemui/qs/ui/composable/QuickSettingsShadeOverlay.kt index 4a28d2862988..3327fc020da3 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/qs/ui/composable/QuickSettingsShadeOverlay.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/qs/ui/composable/QuickSettingsShadeOverlay.kt @@ -27,17 +27,17 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.requiredHeightIn +import androidx.compose.foundation.layout.requiredHeight import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.android.compose.animation.scene.ContentScope -import com.android.compose.animation.scene.SceneScope import com.android.compose.animation.scene.UserAction import com.android.compose.animation.scene.UserActionResult import com.android.systemui.battery.BatteryMeterViewController @@ -46,20 +46,18 @@ import com.android.systemui.compose.modifiers.sysuiResTag import com.android.systemui.dagger.SysUISingleton import com.android.systemui.lifecycle.rememberViewModel import com.android.systemui.notifications.ui.composable.SnoozeableHeadsUpNotificationSpace -import com.android.systemui.plugins.qs.TileDetailsViewModel import com.android.systemui.qs.composefragment.ui.GridAnchor import com.android.systemui.qs.flags.QsDetailedView import com.android.systemui.qs.panels.ui.compose.EditMode import com.android.systemui.qs.panels.ui.compose.TileDetails import com.android.systemui.qs.panels.ui.compose.TileGrid import com.android.systemui.qs.panels.ui.compose.toolbar.Toolbar -import com.android.systemui.qs.ui.composable.QuickSettingsShade.Dimensions.GridMaxHeight import com.android.systemui.qs.ui.viewmodel.QuickSettingsContainerViewModel import com.android.systemui.qs.ui.viewmodel.QuickSettingsShadeOverlayActionsViewModel import com.android.systemui.qs.ui.viewmodel.QuickSettingsShadeOverlayContentViewModel import com.android.systemui.scene.shared.model.Overlays import com.android.systemui.scene.ui.composable.Overlay -import com.android.systemui.shade.ui.composable.ExpandedShadeHeader +import com.android.systemui.shade.ui.composable.CollapsedShadeHeader import com.android.systemui.shade.ui.composable.OverlayShade import com.android.systemui.statusbar.notification.stack.ui.view.NotificationScrollView import com.android.systemui.statusbar.notification.stack.ui.viewmodel.NotificationsPlaceholderViewModel @@ -105,12 +103,11 @@ constructor( onScrimClicked = viewModel::onScrimClicked, ) { Column { - ExpandedShadeHeader( + CollapsedShadeHeader( viewModelFactory = viewModel.shadeHeaderViewModelFactory, createTintedIconManager = tintedIconManagerFactory::create, createBatteryMeterViewController = batteryMeterViewControllerFactory::create, statusBarIconController = statusBarIconController, - modifier = Modifier.padding(QuickSettingsShade.Dimensions.Padding), ) ShadeBody(viewModel = viewModel.quickSettingsContainerViewModel) @@ -127,7 +124,7 @@ constructor( } } -// A sealed interface to represent the possible states of the `ShadeBody` +// The possible states of the `ShadeBody`. sealed interface ShadeBodyState { data object Editing : ShadeBodyState @@ -136,23 +133,19 @@ sealed interface ShadeBodyState { data object Default : ShadeBodyState } -// Function to map the current state of the `ShadeBody` -fun checkQsState(isEditing: Boolean, tileDetails: TileDetailsViewModel?): ShadeBodyState { - if (isEditing) { - return ShadeBodyState.Editing - } else if (tileDetails != null && QsDetailedView.isEnabled) { - return ShadeBodyState.TileDetails - } - return ShadeBodyState.Default -} - @Composable -fun SceneScope.ShadeBody(viewModel: QuickSettingsContainerViewModel) { +fun ContentScope.ShadeBody(viewModel: QuickSettingsContainerViewModel) { val isEditing by viewModel.editModeViewModel.isEditing.collectAsStateWithLifecycle() - val tileDetails = viewModel.detailsViewModel.activeTileDetails + val tileDetails = + if (QsDetailedView.isEnabled) viewModel.detailsViewModel.activeTileDetails else null AnimatedContent( - targetState = checkQsState(isEditing, tileDetails), + targetState = + when { + isEditing -> ShadeBodyState.Editing + tileDetails != null -> ShadeBodyState.TileDetails + else -> ShadeBodyState.Default + }, transitionSpec = { fadeIn(tween(500)) togetherWith fadeOut(tween(500)) }, ) { state -> when (state) { @@ -178,34 +171,43 @@ fun SceneScope.ShadeBody(viewModel: QuickSettingsContainerViewModel) { /** Column containing Brightness and QS tiles. */ @Composable -fun SceneScope.QuickSettingsLayout( +fun ContentScope.QuickSettingsLayout( viewModel: QuickSettingsContainerViewModel, modifier: Modifier = Modifier, ) { Column( verticalArrangement = Arrangement.spacedBy(QuickSettingsShade.Dimensions.Padding), horizontalAlignment = Alignment.CenterHorizontally, - modifier = - modifier - .fillMaxWidth() - .padding( - start = QuickSettingsShade.Dimensions.Padding, - end = QuickSettingsShade.Dimensions.Padding, - bottom = QuickSettingsShade.Dimensions.Padding / 2, - ), + modifier = modifier + .padding( + start = QuickSettingsShade.Dimensions.Padding, + end = QuickSettingsShade.Dimensions.Padding, + bottom = QuickSettingsShade.Dimensions.Padding, + ), ) { - Toolbar(viewModel.toolbarViewModelFactory) - BrightnessSliderContainer( - viewModel = viewModel.brightnessSliderViewModel, + Toolbar( modifier = - Modifier.fillMaxWidth().height(QuickSettingsShade.Dimensions.BrightnessSliderHeight), + Modifier.fillMaxWidth().requiredHeight(QuickSettingsShade.Dimensions.ToolbarHeight), + toolbarViewModelFactory = viewModel.toolbarViewModelFactory, ) - Box( - modifier = - Modifier.requiredHeightIn(max = GridMaxHeight).verticalScroll(rememberScrollState()) + Column( + verticalArrangement = Arrangement.spacedBy(QuickSettingsShade.Dimensions.Padding), + modifier = Modifier.fillMaxWidth().verticalScroll(rememberScrollState()), ) { - GridAnchor() - TileGrid(viewModel = viewModel.tileGridViewModel, modifier = Modifier.fillMaxWidth()) + BrightnessSliderContainer( + viewModel = viewModel.brightnessSliderViewModel, + containerColor = Color.Transparent, + modifier = + Modifier.fillMaxWidth() + .height(QuickSettingsShade.Dimensions.BrightnessSliderHeight), + ) + Box { + GridAnchor() + TileGrid( + viewModel = viewModel.tileGridViewModel, + modifier = Modifier.fillMaxWidth(), + ) + } } } } @@ -214,7 +216,7 @@ object QuickSettingsShade { object Dimensions { val Padding = 16.dp + val ToolbarHeight = 48.dp val BrightnessSliderHeight = 64.dp - val GridMaxHeight = 420.dp } } diff --git a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardClockAccessibilityDelegateTest.java b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardClockAccessibilityDelegateTest.java deleted file mode 100644 index b937db6bd76d..000000000000 --- a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardClockAccessibilityDelegateTest.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (C) 2017 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License - */ - -package com.android.keyguard; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import android.text.TextUtils; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; -import android.widget.TextView; - -import androidx.test.ext.junit.runners.AndroidJUnit4; -import androidx.test.filters.SmallTest; - -import com.android.systemui.SysuiTestCase; -import com.android.systemui.res.R; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -import java.util.List; - -@SmallTest -@RunWith(AndroidJUnit4.class) -public class KeyguardClockAccessibilityDelegateTest extends SysuiTestCase { - - private TextView mView; - private String m12HoursFormat; - private String m24HoursFormat; - - @Before - public void setUp() throws Exception { - m12HoursFormat = mContext.getString(R.string.keyguard_widget_12_hours_format); - m24HoursFormat = mContext.getString(R.string.keyguard_widget_24_hours_format); - - mView = new TextView(mContext); - mView.setText(m12HoursFormat); - mView.setContentDescription(m12HoursFormat); - mView.setAccessibilityDelegate(new KeyguardClockAccessibilityDelegate(mContext)); - } - - @Test - public void onInitializeAccessibilityEvent_producesNonEmptyAsciiContentDesc() throws Exception { - AccessibilityEvent ev = AccessibilityEvent.obtain(); - mView.onInitializeAccessibilityEvent(ev); - - assertFalse(TextUtils.isEmpty(ev.getContentDescription())); - assertTrue(isAscii(ev.getContentDescription())); - } - - @Test - public void onPopulateAccessibilityEvent_producesNonEmptyAsciiText() throws Exception { - AccessibilityEvent ev = AccessibilityEvent.obtain(); - mView.onPopulateAccessibilityEvent(ev); - - assertFalse(isEmpty(ev.getText())); - assertTrue(isAscii(ev.getText())); - } - - @Test - public void onInitializeAccessibilityNodeInfo_producesNonEmptyAsciiText() throws Exception { - AccessibilityNodeInfo info = AccessibilityNodeInfo.obtain(); - // Usually done in View.onInitializeAccessibilityNodeInfoInternal, but only when attached. - info.setContentDescription(mView.getContentDescription()); - mView.onInitializeAccessibilityNodeInfo(info); - - assertFalse(TextUtils.isEmpty(info.getText())); - assertTrue(isAscii(info.getText())); - - assertFalse(TextUtils.isEmpty(info.getContentDescription())); - assertTrue(isAscii(info.getContentDescription())); - } - - @Test - public void isNeeded_returnsTrueIfDateFormatsContainNonAscii() { - if (!isAscii(m12HoursFormat) || !isAscii(m24HoursFormat)) { - assertTrue(KeyguardClockAccessibilityDelegate.isNeeded(mContext)); - } - } - - @Test - public void isNeeded_returnsWhetherFancyColonExists() { - boolean hasFancyColon = !TextUtils.isEmpty(mContext.getString( - R.string.keyguard_fancy_colon)); - - assertEquals(hasFancyColon, KeyguardClockAccessibilityDelegate.isNeeded(mContext)); - } - - private boolean isAscii(CharSequence text) { - return text.chars().allMatch((i) -> i < 128); - } - - private boolean isAscii(List<CharSequence> texts) { - return texts.stream().allMatch(this::isAscii); - } - - private boolean isEmpty(List<CharSequence> texts) { - return texts.stream().allMatch(TextUtils::isEmpty); - } -} diff --git a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSliceViewControllerTest.java b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSliceViewControllerTest.java index 8b5372a1f035..9d10011159c7 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSliceViewControllerTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSliceViewControllerTest.java @@ -17,7 +17,6 @@ package com.android.keyguard; import static org.junit.Assume.assumeFalse; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -36,7 +35,6 @@ import com.android.systemui.keyguard.KeyguardSliceProvider; import com.android.systemui.plugins.ActivityStarter; import com.android.systemui.settings.FakeDisplayTracker; import com.android.systemui.statusbar.policy.ConfigurationController; -import com.android.systemui.tuner.TunerService; import org.junit.After; import org.junit.Before; @@ -53,8 +51,6 @@ public class KeyguardSliceViewControllerTest extends SysuiTestCase { @Mock private KeyguardSliceView mView; @Mock - private TunerService mTunerService; - @Mock private ConfigurationController mConfigurationController; @Mock private ActivityStarter mActivityStarter; @@ -74,7 +70,7 @@ public class KeyguardSliceViewControllerTest extends SysuiTestCase { when(mView.isAttachedToWindow()).thenReturn(true); when(mView.getContext()).thenReturn(mContext); mController = new KeyguardSliceViewController(mHandler, mBgHandler, mView, - mActivityStarter, mConfigurationController, mTunerService, mDumpManager, + mActivityStarter, mConfigurationController, mDumpManager, mDisplayTracker); mController.setupUri(KeyguardSliceProvider.KEYGUARD_SLICE_URI); } @@ -101,7 +97,6 @@ public class KeyguardSliceViewControllerTest extends SysuiTestCase { assumeFalse(isWatch()); mController.init(); - verify(mTunerService).addTunable(any(TunerService.Tunable.class), anyString()); verify(mConfigurationController).addCallback( any(ConfigurationController.ConfigurationListener.class)); } @@ -120,7 +115,6 @@ public class KeyguardSliceViewControllerTest extends SysuiTestCase { attachListenerArgumentCaptor.getValue().onViewDetachedFromWindow(mView); - verify(mTunerService).removeTunable(any(TunerService.Tunable.class)); verify(mConfigurationController).removeCallback( any(ConfigurationController.ConfigurationListener.class)); } diff --git a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardStatusAreaViewTest.kt b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardStatusAreaViewTest.kt deleted file mode 100644 index 64e499674d9f..000000000000 --- a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardStatusAreaViewTest.kt +++ /dev/null @@ -1,44 +0,0 @@ -package com.android.keyguard - -import android.testing.TestableLooper.RunWithLooper -import androidx.test.ext.junit.runners.AndroidJUnit4 -import androidx.test.filters.SmallTest -import com.android.systemui.SysuiTestCase -import org.junit.Assert.assertEquals -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith - -@SmallTest -@RunWith(AndroidJUnit4::class) -@RunWithLooper(setAsMainLooper = true) -class KeyguardStatusAreaViewTest : SysuiTestCase() { - - private lateinit var view: KeyguardStatusAreaView - - @Before - fun setUp() { - view = KeyguardStatusAreaView(context) - } - - @Test - fun checkTranslationX_AddedTotals() { - view.translateXFromClockDesign = 10f - assertEquals(10f, view.translationX) - - view.translateXFromAod = 20f - assertEquals(30f, view.translationX) - - view.translateXFromUnfold = 30f - assertEquals(60f, view.translationX) - } - - @Test - fun checkTranslationY_AddedTotals() { - view.translateYFromClockSize = 10f - assertEquals(10f, view.translationY) - - view.translateYFromClockDesign = 20f - assertEquals(30f, view.translationY) - } -} diff --git a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardStatusViewControllerBaseTest.java b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardStatusViewControllerBaseTest.java deleted file mode 100644 index 2b4fc5bd5cc5..000000000000 --- a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardStatusViewControllerBaseTest.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (C) 2020 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.keyguard; - -import static org.mockito.Mockito.atLeast; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import android.view.View; -import android.view.ViewTreeObserver; -import android.widget.FrameLayout; - -import com.android.keyguard.logging.KeyguardLogger; -import com.android.systemui.SysuiTestCase; -import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository; -import com.android.systemui.keyguard.domain.interactor.KeyguardInteractorFactory; -import com.android.systemui.kosmos.KosmosJavaAdapter; -import com.android.systemui.power.data.repository.FakePowerRepository; -import com.android.systemui.power.domain.interactor.PowerInteractorFactory; -import com.android.systemui.res.R; -import com.android.systemui.statusbar.notification.AnimatableProperty; -import com.android.systemui.statusbar.phone.DozeParameters; -import com.android.systemui.statusbar.phone.ScreenOffAnimationController; -import com.android.systemui.statusbar.policy.ConfigurationController; -import com.android.systemui.statusbar.policy.KeyguardStateController; - -import org.junit.Before; -import org.mockito.ArgumentCaptor; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -public class KeyguardStatusViewControllerBaseTest extends SysuiTestCase { - - private KosmosJavaAdapter mKosmos; - @Mock protected KeyguardStatusView mKeyguardStatusView; - - @Mock protected KeyguardSliceViewController mKeyguardSliceViewController; - @Mock protected KeyguardClockSwitchController mKeyguardClockSwitchController; - @Mock protected KeyguardStateController mKeyguardStateController; - @Mock protected KeyguardUpdateMonitor mKeyguardUpdateMonitor; - @Mock protected ConfigurationController mConfigurationController; - @Mock protected DozeParameters mDozeParameters; - @Mock protected ScreenOffAnimationController mScreenOffAnimationController; - @Mock protected KeyguardLogger mKeyguardLogger; - @Mock protected KeyguardStatusViewController mControllerMock; - @Mock protected ViewTreeObserver mViewTreeObserver; - protected FakeKeyguardRepository mFakeKeyguardRepository; - protected FakePowerRepository mFakePowerRepository; - - protected KeyguardStatusViewController mController; - - @Mock protected KeyguardClockSwitch mKeyguardClockSwitch; - @Mock protected FrameLayout mMediaHostContainer; - @Mock protected KeyguardStatusAreaView mKeyguardStatusAreaView; - - @Before - public void setup() { - mKosmos = new KosmosJavaAdapter(this); - MockitoAnnotations.initMocks(this); - - KeyguardInteractorFactory.WithDependencies deps = KeyguardInteractorFactory.create(); - mFakeKeyguardRepository = deps.getRepository(); - mFakePowerRepository = new FakePowerRepository(); - - mController = new KeyguardStatusViewController( - mKeyguardStatusView, - mKeyguardSliceViewController, - mKeyguardClockSwitchController, - mKeyguardStateController, - mKeyguardUpdateMonitor, - mConfigurationController, - mDozeParameters, - mScreenOffAnimationController, - mKeyguardLogger, - mKosmos.getInteractionJankMonitor(), - deps.getKeyguardInteractor(), - PowerInteractorFactory.create( - mFakePowerRepository - ).getPowerInteractor()) { - @Override - void setProperty( - AnimatableProperty property, - float value, - boolean animate) { - // Route into the mock version for verification - mControllerMock.setProperty(property, value, animate); - } - }; - - when(mKeyguardStatusView.getViewTreeObserver()).thenReturn(mViewTreeObserver); - when(mKeyguardClockSwitchController.getView()).thenReturn(mKeyguardClockSwitch); - when(mKeyguardStatusView.findViewById(R.id.keyguard_status_area)) - .thenReturn(mKeyguardStatusAreaView); - } - - protected void givenViewAttached() { - ArgumentCaptor<View.OnAttachStateChangeListener> captor = - ArgumentCaptor.forClass(View.OnAttachStateChangeListener.class); - verify(mKeyguardStatusView, atLeast(1)).addOnAttachStateChangeListener(captor.capture()); - - for (View.OnAttachStateChangeListener listener : captor.getAllValues()) { - listener.onViewAttachedToWindow(mKeyguardStatusView); - } - } -} diff --git a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardStatusViewControllerWithCoroutinesTest.kt b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardStatusViewControllerWithCoroutinesTest.kt deleted file mode 100644 index c29439d89753..000000000000 --- a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardStatusViewControllerWithCoroutinesTest.kt +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2023 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.keyguard - -import android.testing.TestableLooper -import androidx.test.ext.junit.runners.AndroidJUnit4 -import androidx.test.filters.SmallTest -import com.android.systemui.power.shared.model.ScreenPowerState -import kotlinx.coroutines.cancelChildren -import kotlinx.coroutines.test.runCurrent -import kotlinx.coroutines.test.runTest -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.Mockito.clearInvocations -import org.mockito.Mockito.never -import org.mockito.Mockito.verify - -@RunWith(AndroidJUnit4::class) -@TestableLooper.RunWithLooper(setAsMainLooper = true) -@SmallTest -class KeyguardStatusViewControllerWithCoroutinesTest : KeyguardStatusViewControllerBaseTest() { - - @Test - fun dozeTimeTickUpdatesSlices() = runTest { - mController.startCoroutines(coroutineContext) - givenViewAttached() - runCurrent() - clearInvocations(mKeyguardSliceViewController) - - mFakeKeyguardRepository.dozeTimeTick() - runCurrent() - verify(mKeyguardSliceViewController).refresh() - - coroutineContext.cancelChildren() - } - - @Test - fun onScreenTurningOnUpdatesSlices() = runTest { - mController.startCoroutines(coroutineContext) - givenViewAttached() - runCurrent() - clearInvocations(mKeyguardSliceViewController) - - mFakePowerRepository.setScreenPowerState(ScreenPowerState.SCREEN_ON) - runCurrent() - verify(mKeyguardSliceViewController, never()).refresh() - - // Should only be called during a 'turning on' event - mFakePowerRepository.setScreenPowerState(ScreenPowerState.SCREEN_TURNING_ON) - runCurrent() - verify(mKeyguardSliceViewController).refresh() - - coroutineContext.cancelChildren() - } -} diff --git a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardStatusViewTest.kt b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardStatusViewTest.kt deleted file mode 100644 index 16d2f0205c84..000000000000 --- a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardStatusViewTest.kt +++ /dev/null @@ -1,56 +0,0 @@ -package com.android.keyguard - -import androidx.test.ext.junit.runners.AndroidJUnit4 -import androidx.test.filters.SmallTest -import android.testing.TestableLooper.RunWithLooper -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import com.android.systemui.res.R -import com.android.systemui.SysuiTestCase -import com.android.systemui.util.children -import com.google.common.truth.Truth.assertThat -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith - -@SmallTest -@RunWith(AndroidJUnit4::class) -@RunWithLooper(setAsMainLooper = true) -class KeyguardStatusViewTest : SysuiTestCase() { - - private lateinit var keyguardStatusView: KeyguardStatusView - private val mediaView: View - get() = keyguardStatusView.requireViewById(R.id.status_view_media_container) - private val statusViewContainer: ViewGroup - get() = keyguardStatusView.requireViewById(R.id.status_view_container) - private val childrenExcludingMedia - get() = statusViewContainer.children.filter { it != mediaView } - - @Before - fun setUp() { - keyguardStatusView = - LayoutInflater.from(context).inflate(R.layout.keyguard_status_view, /* root= */ null) - as KeyguardStatusView - } - - @Test - fun setChildrenTranslationYExcludingMediaView_mediaViewIsNotTranslated() { - val translationY = 1234f - - keyguardStatusView.setChildrenTranslationY(translationY, /* excludeMedia= */ true) - - assertThat(mediaView.translationY).isEqualTo(0) - - childrenExcludingMedia.forEach { assertThat(it.translationY).isEqualTo(translationY) } - } - - @Test - fun setChildrenTranslationYIncludeMediaView() { - val translationY = 1234f - - keyguardStatusView.setChildrenTranslationY(translationY, /* excludeMedia= */ false) - - statusViewContainer.children.forEach { assertThat(it.translationY).isEqualTo(translationY) } - } -} diff --git a/packages/SystemUI/multivalentTests/src/com/android/keyguard/SplitShadeTransitionAdapterTest.kt b/packages/SystemUI/multivalentTests/src/com/android/keyguard/SplitShadeTransitionAdapterTest.kt deleted file mode 100644 index c7d11ef16100..000000000000 --- a/packages/SystemUI/multivalentTests/src/com/android/keyguard/SplitShadeTransitionAdapterTest.kt +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (C) 2023 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.android.keyguard - -import android.animation.Animator -import android.transition.TransitionValues -import android.view.View -import android.view.ViewGroup -import androidx.test.ext.junit.runners.AndroidJUnit4 -import androidx.test.filters.SmallTest -import com.android.keyguard.KeyguardStatusViewController.SplitShadeTransitionAdapter -import com.android.systemui.SysuiTestCase -import com.android.systemui.util.mockito.mock -import com.google.common.truth.Truth.assertThat -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.Mock -import org.mockito.MockitoAnnotations - -@SmallTest -@RunWith(AndroidJUnit4::class) -class SplitShadeTransitionAdapterTest : SysuiTestCase() { - - @Mock private lateinit var KeyguardClockSwitchController: KeyguardClockSwitchController - - private lateinit var adapter: SplitShadeTransitionAdapter - - @Before - fun setUp() { - MockitoAnnotations.initMocks(this) - adapter = SplitShadeTransitionAdapter(KeyguardClockSwitchController) - } - - @Test - fun createAnimator_nullStartValues_returnsNull() { - val endValues = createEndValues() - - val animator = adapter.createAnimator(startValues = null, endValues = endValues) - - assertThat(animator).isNull() - } - - @Test - fun createAnimator_nullEndValues_returnsNull() { - val animator = adapter.createAnimator(startValues = createStartValues(), endValues = null) - - assertThat(animator).isNull() - } - - @Test - fun createAnimator_nonNullStartAndEndValues_returnsAnimator() { - val animator = - adapter.createAnimator(startValues = createStartValues(), endValues = createEndValues()) - - assertThat(animator).isNotNull() - } - - private fun createStartValues() = - TransitionValues().also { values -> - values.view = View(context) - adapter.captureStartValues(values) - } - - private fun createEndValues() = - TransitionValues().also { values -> - values.view = View(context) - adapter.captureEndValues(values) - } -} - -private fun SplitShadeTransitionAdapter.createAnimator( - startValues: TransitionValues?, - endValues: TransitionValues? -): Animator? { - return createAnimator(/* sceneRoot= */ mock(), startValues, endValues) -} diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinderTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinderTest.kt index 040d3b8f09cb..4e3d18c80a4f 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinderTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinderTest.kt @@ -21,8 +21,6 @@ import androidx.constraintlayout.helper.widget.Layer import androidx.constraintlayout.widget.ConstraintLayout import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest -import com.android.keyguard.KeyguardClockSwitch.LARGE -import com.android.keyguard.KeyguardClockSwitch.SMALL import com.android.systemui.SysuiTestCase import com.android.systemui.keyguard.shared.model.ClockSize import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel @@ -80,6 +78,7 @@ class KeyguardClockViewBinderTest : SysuiTestCase() { verify(rootView).addView(smallClockView) verify(rootView).addView(largeClockView) } + @Test fun addClockViewsToBurnInLayer_LargeWeatherClock() { setupWeatherClock() @@ -110,7 +109,7 @@ class KeyguardClockViewBinderTest : SysuiTestCase() { name = "", description = "", useAlternateSmartspaceAODTransition = true, - useCustomClockScene = true + useCustomClockScene = true, ) whenever(clock.config).thenReturn(clockConfig) } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/view/layout/blueprints/DefaultKeyguardBlueprintTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/view/layout/blueprints/DefaultKeyguardBlueprintTest.kt index 9fab0d9065b6..67a43327efc2 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/view/layout/blueprints/DefaultKeyguardBlueprintTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/view/layout/blueprints/DefaultKeyguardBlueprintTest.kt @@ -37,7 +37,6 @@ import com.android.systemui.keyguard.ui.view.layout.sections.DefaultNotification import com.android.systemui.keyguard.ui.view.layout.sections.DefaultSettingsPopupMenuSection import com.android.systemui.keyguard.ui.view.layout.sections.DefaultShortcutsSection import com.android.systemui.keyguard.ui.view.layout.sections.DefaultStatusBarSection -import com.android.systemui.keyguard.ui.view.layout.sections.DefaultStatusViewSection import com.android.systemui.keyguard.ui.view.layout.sections.DefaultUdfpsAccessibilityOverlaySection import com.android.systemui.keyguard.ui.view.layout.sections.KeyguardSliceViewSection import com.android.systemui.keyguard.ui.view.layout.sections.SmartspaceSection @@ -67,7 +66,6 @@ class DefaultKeyguardBlueprintTest : SysuiTestCase() { @Mock private lateinit var defaultShortcutsSection: DefaultShortcutsSection @Mock private lateinit var defaultAmbientIndicationAreaSection: Optional<KeyguardSection> @Mock private lateinit var defaultSettingsPopupMenuSection: DefaultSettingsPopupMenuSection - @Mock private lateinit var defaultStatusViewSection: DefaultStatusViewSection @Mock private lateinit var defaultStatusBarViewSection: DefaultStatusBarSection @Mock private lateinit var defaultNSSLSection: DefaultNotificationStackScrollLayoutSection @Mock private lateinit var splitShadeGuidelines: SplitShadeGuidelines @@ -79,6 +77,7 @@ class DefaultKeyguardBlueprintTest : SysuiTestCase() { @Mock private lateinit var keyguardSliceViewSection: KeyguardSliceViewSection @Mock private lateinit var udfpsAccessibilityOverlaySection: DefaultUdfpsAccessibilityOverlaySection + @Before fun setup() { MockitoAnnotations.initMocks(this) @@ -91,7 +90,6 @@ class DefaultKeyguardBlueprintTest : SysuiTestCase() { defaultShortcutsSection, defaultAmbientIndicationAreaSection, defaultSettingsPopupMenuSection, - defaultStatusViewSection, defaultStatusBarViewSection, defaultNSSLSection, aodNotificationIconsSection, diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSectionTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSectionTest.kt index c0db95f9e5d2..7706c500c52b 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSectionTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSectionTest.kt @@ -17,7 +17,6 @@ package com.android.systemui.keyguard.ui.view.layout.sections -import android.platform.test.annotations.EnableFlags import android.view.View import android.widget.LinearLayout import androidx.constraintlayout.widget.ConstraintLayout @@ -26,7 +25,6 @@ import androidx.constraintlayout.widget.ConstraintSet.GONE import androidx.constraintlayout.widget.ConstraintSet.VISIBLE import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest -import com.android.systemui.Flags import com.android.systemui.SysuiTestCase import com.android.systemui.customization.R as customR import com.android.systemui.keyguard.KeyguardUnlockAnimationController @@ -50,7 +48,6 @@ import org.mockito.MockitoAnnotations @RunWith(AndroidJUnit4::class) @SmallTest -@EnableFlags(Flags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT) class SmartspaceSectionTest : SysuiTestCase() { private lateinit var underTest: SmartspaceSection @Mock private lateinit var keyguardClockViewModel: KeyguardClockViewModel diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/AodAlphaViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/AodAlphaViewModelTest.kt deleted file mode 100644 index 9e696011e285..000000000000 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/AodAlphaViewModelTest.kt +++ /dev/null @@ -1,269 +0,0 @@ -/* - * Copyright (C) 2023 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@file:OptIn(ExperimentalCoroutinesApi::class) - -package com.android.systemui.keyguard.ui.viewmodel - -import android.platform.test.annotations.DisableFlags -import android.platform.test.annotations.EnableFlags -import androidx.test.ext.junit.runners.AndroidJUnit4 -import androidx.test.filters.SmallTest -import com.android.systemui.Flags -import com.android.systemui.Flags as AConfigFlags -import com.android.systemui.SysuiTestCase -import com.android.systemui.coroutines.collectLastValue -import com.android.systemui.flags.DisableSceneContainer -import com.android.systemui.flags.EnableSceneContainer -import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository -import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository -import com.android.systemui.keyguard.shared.model.KeyguardState -import com.android.systemui.keyguard.shared.model.TransitionState -import com.android.systemui.keyguard.shared.model.TransitionStep -import com.android.systemui.kosmos.testScope -import com.android.systemui.scene.data.repository.Idle -import com.android.systemui.scene.data.repository.Transition -import com.android.systemui.scene.data.repository.setSceneTransition -import com.android.systemui.scene.shared.model.Scenes -import com.android.systemui.testKosmos -import com.android.systemui.util.mockito.whenever -import com.google.common.truth.Truth.assertThat -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.test.runTest -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.Mock -import org.mockito.MockitoAnnotations - -@SmallTest -@RunWith(AndroidJUnit4::class) -class AodAlphaViewModelTest : SysuiTestCase() { - - @Mock private lateinit var goneToAodTransitionViewModel: GoneToAodTransitionViewModel - - private val kosmos = testKosmos() - private val testScope = kosmos.testScope - private val keyguardRepository = kosmos.fakeKeyguardRepository - private val keyguardTransitionRepository = kosmos.fakeKeyguardTransitionRepository - - private lateinit var underTest: AodAlphaViewModel - - private val enterFromTopAnimationAlpha = MutableStateFlow(0f) - - @Before - fun setUp() { - MockitoAnnotations.initMocks(this) - whenever(goneToAodTransitionViewModel.enterFromTopAnimationAlpha) - .thenReturn(enterFromTopAnimationAlpha) - kosmos.goneToAodTransitionViewModel = goneToAodTransitionViewModel - - underTest = kosmos.aodAlphaViewModel - } - - @Test - @DisableSceneContainer - @DisableFlags(Flags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT) - fun alpha_WhenNotGone_clockMigrationFlagIsOff_emitsKeyguardAlpha() = - testScope.runTest { - val alpha by collectLastValue(underTest.alpha) - - keyguardTransitionRepository.sendTransitionSteps( - from = KeyguardState.AOD, - to = KeyguardState.LOCKSCREEN, - testScope = testScope, - ) - - keyguardRepository.setKeyguardAlpha(0.5f) - assertThat(alpha).isEqualTo(0.5f) - - keyguardRepository.setKeyguardAlpha(0.8f) - assertThat(alpha).isEqualTo(0.8f) - } - - @Test - @DisableSceneContainer - fun alpha_WhenGoneToAod() = - testScope.runTest { - val alpha by collectLastValue(underTest.alpha) - - keyguardTransitionRepository.sendTransitionSteps( - from = KeyguardState.AOD, - to = KeyguardState.GONE, - testScope = testScope, - ) - assertThat(alpha).isEqualTo(0f) - - keyguardTransitionRepository.sendTransitionSteps( - from = KeyguardState.GONE, - to = KeyguardState.AOD, - testScope = testScope, - ) - enterFromTopAnimationAlpha.value = 0.5f - assertThat(alpha).isEqualTo(0.5f) - - enterFromTopAnimationAlpha.value = 1f - assertThat(alpha).isEqualTo(1f) - } - - @Test - @EnableSceneContainer - fun alpha_WhenGoneToAod_scene_container() = - testScope.runTest { - val alpha by collectLastValue(underTest.alpha) - - kosmos.setSceneTransition(Transition(from = Scenes.Lockscreen, to = Scenes.Gone)) - keyguardTransitionRepository.sendTransitionSteps( - from = KeyguardState.AOD, - to = KeyguardState.UNDEFINED, - testScope = testScope, - ) - kosmos.setSceneTransition(Idle(Scenes.Gone)) - assertThat(alpha).isEqualTo(0f) - - kosmos.setSceneTransition(Transition(from = Scenes.Gone, to = Scenes.Lockscreen)) - keyguardTransitionRepository.sendTransitionSteps( - from = KeyguardState.UNDEFINED, - to = KeyguardState.AOD, - testScope = testScope, - ) - enterFromTopAnimationAlpha.value = 0.5f - assertThat(alpha).isEqualTo(0.5f) - - enterFromTopAnimationAlpha.value = 1f - assertThat(alpha).isEqualTo(1f) - } - - @Test - @DisableSceneContainer - fun alpha_WhenGoneToDozing() = - testScope.runTest { - val alpha by collectLastValue(underTest.alpha) - - keyguardTransitionRepository.sendTransitionSteps( - from = KeyguardState.AOD, - to = KeyguardState.GONE, - testScope = testScope, - ) - assertThat(alpha).isEqualTo(0f) - - keyguardTransitionRepository.sendTransitionSteps( - from = KeyguardState.GONE, - to = KeyguardState.DOZING, - testScope = testScope, - ) - assertThat(alpha).isEqualTo(1f) - } - - @Test - @EnableSceneContainer - fun alpha_WhenGoneToDozing_scene_container() = - testScope.runTest { - val alpha by collectLastValue(underTest.alpha) - - kosmos.setSceneTransition(Idle(Scenes.Gone)) - assertThat(alpha).isEqualTo(0f) - - kosmos.setSceneTransition(Transition(from = Scenes.Gone, to = Scenes.Lockscreen)) - keyguardTransitionRepository.sendTransitionSteps( - from = KeyguardState.UNDEFINED, - to = KeyguardState.DOZING, - testScope = testScope, - ) - assertThat(alpha).isEqualTo(1f) - } - - @Test - @DisableSceneContainer - @EnableFlags(Flags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT) - fun alpha_whenGone_equalsZero() = - testScope.runTest { - val alpha by collectLastValue(underTest.alpha) - - keyguardTransitionRepository.sendTransitionStep( - TransitionStep( - from = KeyguardState.LOCKSCREEN, - to = KeyguardState.GONE, - transitionState = TransitionState.STARTED, - ) - ) - assertThat(alpha).isNull() - - keyguardTransitionRepository.sendTransitionStep( - TransitionStep( - from = KeyguardState.LOCKSCREEN, - to = KeyguardState.GONE, - transitionState = TransitionState.RUNNING, - value = 0.5f, - ) - ) - assertThat(alpha).isNull() - - keyguardTransitionRepository.sendTransitionStep( - TransitionStep( - from = KeyguardState.LOCKSCREEN, - to = KeyguardState.GONE, - transitionState = TransitionState.RUNNING, - value = 1f, - ) - ) - assertThat(alpha).isEqualTo(0f) - } - - @Test - @DisableSceneContainer - fun enterFromTopAlpha() = - testScope.runTest { - val alpha by collectLastValue(underTest.alpha) - - keyguardTransitionRepository.sendTransitionStep( - TransitionStep( - from = KeyguardState.GONE, - to = KeyguardState.AOD, - transitionState = TransitionState.STARTED, - ) - ) - - enterFromTopAnimationAlpha.value = 0.2f - assertThat(alpha).isEqualTo(0.2f) - - enterFromTopAnimationAlpha.value = 1f - assertThat(alpha).isEqualTo(1f) - } - - @Test - @EnableSceneContainer - fun enterFromTopAlpha_scene_container() = - testScope.runTest { - val alpha by collectLastValue(underTest.alpha) - - kosmos.setSceneTransition(Transition(from = Scenes.Gone, to = Scenes.Lockscreen)) - keyguardTransitionRepository.sendTransitionStep( - TransitionStep( - from = KeyguardState.UNDEFINED, - to = KeyguardState.AOD, - transitionState = TransitionState.STARTED, - ) - ) - - enterFromTopAnimationAlpha.value = 0.2f - assertThat(alpha).isEqualTo(0.2f) - - enterFromTopAnimationAlpha.value = 1f - assertThat(alpha).isEqualTo(1f) - } -} diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardIndicationAreaViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardIndicationAreaViewModelTest.kt index 242ee3a783f2..bd892d588d8b 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardIndicationAreaViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardIndicationAreaViewModelTest.kt @@ -16,11 +16,8 @@ package com.android.systemui.keyguard.ui.viewmodel -import android.platform.test.annotations.DisableFlags -import android.platform.test.flag.junit.FlagsParameterization import androidx.test.filters.SmallTest import com.android.compose.animation.scene.ObservableTransitionState -import com.android.systemui.Flags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT import com.android.systemui.SysuiTestCase import com.android.systemui.common.ui.domain.interactor.configurationInteractor import com.android.systemui.communal.data.repository.fakeCommunalSceneRepository @@ -45,18 +42,14 @@ import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Test -import org.junit.runner.RunWith import org.mockito.ArgumentMatchers.anyInt import org.mockito.kotlin.any import org.mockito.kotlin.doReturn import org.mockito.kotlin.mock -import platform.test.runner.parameterized.ParameterizedAndroidJunit4 -import platform.test.runner.parameterized.Parameters @OptIn(ExperimentalCoroutinesApi::class) @SmallTest -@RunWith(ParameterizedAndroidJunit4::class) -class KeyguardIndicationAreaViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { +class KeyguardIndicationAreaViewModelTest() : SysuiTestCase() { private val kosmos = testKosmos() private val testScope = kosmos.testScope private lateinit var underTest: KeyguardIndicationAreaViewModel @@ -75,11 +68,6 @@ class KeyguardIndicationAreaViewModelTest(flags: FlagsParameterization) : SysuiT slotId = KeyguardQuickAffordancePosition.BOTTOM_END.toSlotId() ) ) - private val alphaFlow = MutableStateFlow(1f) - - init { - mSetFlagsRule.setFlagsParameterization(flags) - } @Before fun setUp() { @@ -106,47 +94,11 @@ class KeyguardIndicationAreaViewModelTest(flags: FlagsParameterization) : SysuiT keyguardTransitionInteractor = kosmos.keyguardTransitionInteractor, backgroundDispatcher = kosmos.testDispatcher, communalSceneInteractor = kosmos.communalSceneInteractor, - mainDispatcher = kosmos.testDispatcher + mainDispatcher = kosmos.testDispatcher, ) } @Test - fun isIndicationAreaPadded() = - testScope.runTest { - keyguardRepository.setKeyguardShowing(true) - val isIndicationAreaPadded by collectLastValue(underTest.isIndicationAreaPadded) - - assertThat(isIndicationAreaPadded).isFalse() - startButtonFlow.value = startButtonFlow.value.copy(isVisible = true) - assertThat(isIndicationAreaPadded).isTrue() - endButtonFlow.value = endButtonFlow.value.copy(isVisible = true) - assertThat(isIndicationAreaPadded).isTrue() - startButtonFlow.value = startButtonFlow.value.copy(isVisible = false) - assertThat(isIndicationAreaPadded).isTrue() - endButtonFlow.value = endButtonFlow.value.copy(isVisible = false) - assertThat(isIndicationAreaPadded).isFalse() - } - - @Test - @DisableFlags(FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT) - fun indicationAreaTranslationY() = - testScope.runTest { - val translationY by - collectLastValue(underTest.indicationAreaTranslationY(DEFAULT_BURN_IN_OFFSET)) - - // Negative 0 - apparently there's a difference in floating point arithmetic - FML - assertThat(translationY).isEqualTo(-0f) - val expected1 = setDozeAmountAndCalculateExpectedTranslationY(0.1f) - assertThat(translationY).isEqualTo(expected1) - val expected2 = setDozeAmountAndCalculateExpectedTranslationY(0.2f) - assertThat(translationY).isEqualTo(expected2) - val expected3 = setDozeAmountAndCalculateExpectedTranslationY(0.5f) - assertThat(translationY).isEqualTo(expected3) - val expected4 = setDozeAmountAndCalculateExpectedTranslationY(1f) - assertThat(translationY).isEqualTo(expected4) - } - - @Test fun visibilityWhenCommunalNotShowing() = testScope.runTest { keyguardRepository.setStatusBarState(StatusBarState.KEYGUARD) @@ -185,13 +137,5 @@ class KeyguardIndicationAreaViewModelTest(flags: FlagsParameterization) : SysuiT companion object { private const val DEFAULT_BURN_IN_OFFSET = 5 private const val RETURNED_BURN_IN_OFFSET = 3 - - @JvmStatic - @Parameters(name = "{0}") - fun getParams(): List<FlagsParameterization> { - return FlagsParameterization.allCombinationsOf( - FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT, - ) - } } } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java index 07a408b9a4d7..0e931679ec74 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java @@ -28,15 +28,12 @@ import static kotlinx.coroutines.flow.StateFlowKt.MutableStateFlow; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyFloat; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -55,7 +52,6 @@ import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.view.ViewParent; -import android.view.ViewPropertyAnimator; import android.view.ViewTreeObserver; import android.view.accessibility.AccessibilityManager; @@ -66,17 +62,11 @@ import com.android.internal.logging.UiEventLogger; import com.android.internal.logging.testing.UiEventLoggerFake; import com.android.internal.statusbar.IStatusBarService; import com.android.internal.util.LatencyTracker; -import com.android.keyguard.KeyguardClockSwitch; -import com.android.keyguard.KeyguardClockSwitchController; import com.android.keyguard.KeyguardSliceViewController; -import com.android.keyguard.KeyguardStatusView; -import com.android.keyguard.KeyguardStatusViewController; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.dagger.KeyguardStatusBarViewComponent; -import com.android.keyguard.dagger.KeyguardStatusViewComponent; import com.android.keyguard.logging.KeyguardLogger; import com.android.systemui.SysuiTestCase; -import com.android.systemui.biometrics.AuthController; import com.android.systemui.bouncer.domain.interactor.AlternateBouncerInteractor; import com.android.systemui.classifier.FalsingCollectorFake; import com.android.systemui.classifier.FalsingManagerFake; @@ -91,7 +81,6 @@ import com.android.systemui.fragments.FragmentHostManager; import com.android.systemui.fragments.FragmentService; import com.android.systemui.haptics.msdl.FakeMSDLPlayer; import com.android.systemui.keyguard.KeyguardUnlockAnimationController; -import com.android.systemui.keyguard.KeyguardViewConfigurator; import com.android.systemui.keyguard.data.repository.FakeKeyguardClockRepository; import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository; import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor; @@ -99,14 +88,8 @@ import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor; import com.android.systemui.keyguard.domain.interactor.KeyguardInteractorFactory; import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor; import com.android.systemui.keyguard.domain.interactor.NaturalScrollingSettingObserver; -import com.android.systemui.keyguard.ui.view.KeyguardRootView; import com.android.systemui.keyguard.ui.viewmodel.DreamingToLockscreenTransitionViewModel; -import com.android.systemui.keyguard.ui.viewmodel.GoneToDreamingTransitionViewModel; import com.android.systemui.keyguard.ui.viewmodel.KeyguardTouchHandlingViewModel; -import com.android.systemui.keyguard.ui.viewmodel.LockscreenToDreamingTransitionViewModel; -import com.android.systemui.keyguard.ui.viewmodel.LockscreenToOccludedTransitionViewModel; -import com.android.systemui.keyguard.ui.viewmodel.OccludedToLockscreenTransitionViewModel; -import com.android.systemui.keyguard.ui.viewmodel.PrimaryBouncerToGoneTransitionViewModel; import com.android.systemui.kosmos.KosmosJavaAdapter; import com.android.systemui.media.controls.domain.pipeline.MediaDataManager; import com.android.systemui.media.controls.ui.controller.KeyguardMediaController; @@ -216,7 +199,6 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { @Mock protected CentralSurfaces mCentralSurfaces; @Mock protected NotificationStackScrollLayout mNotificationStackScrollLayout; - @Mock protected ViewPropertyAnimator mViewPropertyAnimator; @Mock protected HeadsUpManager mHeadsUpManager; @Mock protected NotificationGutsManager mGutsManager; @Mock protected KeyguardStatusBarView mKeyguardStatusBar; @@ -240,30 +222,22 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { @Mock protected MetricsLogger mMetricsLogger; @Mock protected Resources mResources; @Mock protected Configuration mConfiguration; - @Mock protected KeyguardClockSwitch mKeyguardClockSwitch; @Mock protected MediaHierarchyManager mMediaHierarchyManager; @Mock protected ConversationNotificationManager mConversationNotificationManager; @Mock protected StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; - @Mock protected KeyguardStatusViewComponent.Factory mKeyguardStatusViewComponentFactory; - @Mock protected KeyguardStatusViewComponent mKeyguardStatusViewComponent; @Mock protected KeyguardStatusBarViewComponent.Factory mKeyguardStatusBarViewComponentFactory; @Mock protected KeyguardStatusBarViewComponent mKeyguardStatusBarViewComponent; - @Mock protected KeyguardClockSwitchController mKeyguardClockSwitchController; @Mock protected KeyguardStatusBarViewController mKeyguardStatusBarViewController; @Mock protected LightBarController mLightBarController; @Mock protected NotificationStackScrollLayoutController mNotificationStackScrollLayoutController; @Mock protected NotificationShadeDepthController mNotificationShadeDepthController; @Mock protected LockscreenShadeTransitionController mLockscreenShadeTransitionController; - @Mock protected AuthController mAuthController; @Mock protected ScrimController mScrimController; @Mock protected MediaDataManager mMediaDataManager; @Mock protected AmbientState mAmbientState; @Mock protected UserManager mUserManager; @Mock protected UiEventLogger mUiEventLogger; - @Mock protected KeyguardViewConfigurator mKeyguardViewConfigurator; - @Mock protected KeyguardRootView mKeyguardRootView; - @Mock protected View mKeyguardRootViewChild; @Mock protected KeyguardMediaController mKeyguardMediaController; @Mock protected NavigationModeController mNavigationModeController; @Mock protected NavigationBarController mNavigationBarController; @@ -295,15 +269,6 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { @Mock protected ViewTreeObserver mViewTreeObserver; @Mock protected DreamingToLockscreenTransitionViewModel mDreamingToLockscreenTransitionViewModel; - @Mock protected OccludedToLockscreenTransitionViewModel - mOccludedToLockscreenTransitionViewModel; - @Mock protected LockscreenToDreamingTransitionViewModel - mLockscreenToDreamingTransitionViewModel; - @Mock protected LockscreenToOccludedTransitionViewModel - mLockscreenToOccludedTransitionViewModel; - @Mock protected GoneToDreamingTransitionViewModel mGoneToDreamingTransitionViewModel; - @Mock protected PrimaryBouncerToGoneTransitionViewModel - mPrimaryBouncerToGoneTransitionViewModel; @Mock protected KeyguardTransitionInteractor mKeyguardTransitionInteractor; @Mock protected KeyguardTouchHandlingViewModel mKeyuardTouchHandlingViewModel; @Mock protected AlternateBouncerInteractor mAlternateBouncerInteractor; @@ -311,7 +276,6 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { @Mock protected CoroutineDispatcher mMainDispatcher; @Mock protected KeyguardSliceViewController mKeyguardSliceViewController; private final KeyguardLogger mKeyguardLogger = new KeyguardLogger(logcatLogBuffer()); - @Mock protected KeyguardStatusView mKeyguardStatusView; @Captor protected ArgumentCaptor<NotificationStackScrollLayout.OnEmptySpaceClickListener> mEmptySpaceClickListenerCaptor; @@ -345,7 +309,6 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { protected List<View.OnAttachStateChangeListener> mOnAttachStateChangeListeners; protected Handler mMainHandler; protected View.OnLayoutChangeListener mLayoutChangeListener; - protected KeyguardStatusViewController mKeyguardStatusViewController; protected ShadeRepository mShadeRepository; protected FakeMSDLPlayer mMSDLPlayer = mKosmos.getMsdlPlayer(); @@ -427,23 +390,6 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { () -> mKosmos.getSceneBackInteractor(), () -> mKosmos.getAlternateBouncerInteractor()); - KeyguardStatusView keyguardStatusView = new KeyguardStatusView(mContext); - keyguardStatusView.setId(R.id.keyguard_status_view); - mKeyguardStatusViewController = spy(new KeyguardStatusViewController( - mKeyguardStatusView, - mKeyguardSliceViewController, - mKeyguardClockSwitchController, - mKeyguardStateController, - mUpdateMonitor, - mConfigurationController, - mDozeParameters, - mScreenOffAnimationController, - mKeyguardLogger, - mKosmos.getInteractionJankMonitor(), - mKeyguardInteractor, - mPowerInteractor)); - - when(mAuthController.isUdfpsEnrolled(anyInt())).thenReturn(false); when(mHeadsUpCallback.getContext()).thenReturn(mContext); when(mView.getResources()).thenReturn(mResources); when(mView.getWidth()).thenReturn(PANEL_WIDTH); @@ -462,31 +408,15 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { .thenReturn(SPLIT_SHADE_FULL_TRANSITION_DISTANCE); when(mView.getContext()).thenReturn(getContext()); when(mView.findViewById(R.id.keyguard_header)).thenReturn(mKeyguardStatusBar); - when(mView.findViewById(R.id.keyguard_clock_container)).thenReturn(mKeyguardClockSwitch); when(mView.findViewById(R.id.notification_stack_scroller)) .thenReturn(mNotificationStackScrollLayout); when(mNotificationStackScrollLayoutController.getHeight()).thenReturn(1000); when(mNotificationStackScrollLayoutController.getHeadsUpCallback()) .thenReturn(mHeadsUpCallback); - when(mView.animate()).thenReturn(mViewPropertyAnimator); - when(mKeyguardStatusView.animate()).thenReturn(mViewPropertyAnimator); - when(mViewPropertyAnimator.translationX(anyFloat())).thenReturn(mViewPropertyAnimator); - when(mViewPropertyAnimator.alpha(anyFloat())).thenReturn(mViewPropertyAnimator); - when(mViewPropertyAnimator.setDuration(anyLong())).thenReturn(mViewPropertyAnimator); - when(mViewPropertyAnimator.setStartDelay(anyLong())).thenReturn(mViewPropertyAnimator); - when(mViewPropertyAnimator.setInterpolator(any())).thenReturn(mViewPropertyAnimator); - when(mViewPropertyAnimator.setListener(any())).thenReturn(mViewPropertyAnimator); - when(mViewPropertyAnimator.setUpdateListener(any())).thenReturn(mViewPropertyAnimator); - when(mViewPropertyAnimator.withEndAction(any())).thenReturn(mViewPropertyAnimator); - when(mView.findViewById(R.id.keyguard_status_view)) - .thenReturn(mock(KeyguardStatusView.class)); ViewGroup rootView = mock(ViewGroup.class); when(rootView.isVisibleToUser()).thenReturn(true); when(mView.getRootView()).thenReturn(rootView); - when(rootView.findViewById(R.id.keyguard_status_view)) - .thenReturn(mock(KeyguardStatusView.class)); mNotificationContainerParent = new NotificationsQuickSettingsContainer(getContext(), null); - mNotificationContainerParent.addView(keyguardStatusView); mNotificationContainerParent.onFinishInflate(); when(mView.findViewById(R.id.notification_container_parent)) .thenReturn(mNotificationContainerParent); @@ -518,36 +448,6 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { when(mDreamingToLockscreenTransitionViewModel.lockscreenTranslationY(anyInt())) .thenReturn(emptyFlow()); - // Occluded->Lockscreen - when(mOccludedToLockscreenTransitionViewModel.getLockscreenAlpha()) - .thenReturn(emptyFlow()); - when(mOccludedToLockscreenTransitionViewModel.getLockscreenTranslationY()) - .thenReturn(emptyFlow()); - - // Lockscreen->Dreaming - when(mLockscreenToDreamingTransitionViewModel.getLockscreenAlpha()) - .thenReturn(emptyFlow()); - when(mLockscreenToDreamingTransitionViewModel.lockscreenTranslationY(anyInt())) - .thenReturn(emptyFlow()); - - // Gone->Dreaming - when(mGoneToDreamingTransitionViewModel.getLockscreenAlpha()) - .thenReturn(emptyFlow()); - when(mGoneToDreamingTransitionViewModel.lockscreenTranslationY(anyInt())) - .thenReturn(emptyFlow()); - - // Lockscreen->Occluded - when(mLockscreenToOccludedTransitionViewModel.getLockscreenAlpha()) - .thenReturn(emptyFlow()); - when(mLockscreenToOccludedTransitionViewModel.getLockscreenTranslationY()) - .thenReturn(emptyFlow()); - - // Primary Bouncer->Gone - when(mPrimaryBouncerToGoneTransitionViewModel.getLockscreenAlpha()) - .thenReturn(emptyFlow()); - when(mPrimaryBouncerToGoneTransitionViewModel.getNotificationAlpha()) - .thenReturn(emptyFlow()); - NotificationsKeyguardViewStateRepository notifsKeyguardViewStateRepository = new NotificationsKeyguardViewStateRepository(); NotificationsKeyguardInteractor notifsKeyguardInteractor = @@ -589,18 +489,10 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { mShadeInteractor, mLockscreenShadeTransitionController, mDumpManager); - when(mKeyguardStatusViewComponentFactory.build(any(), any())) - .thenReturn(mKeyguardStatusViewComponent); - when(mKeyguardStatusViewComponent.getKeyguardClockSwitchController()) - .thenReturn(mKeyguardClockSwitchController); - when(mKeyguardStatusViewComponent.getKeyguardStatusViewController()) - .thenReturn(mKeyguardStatusViewController); when(mKeyguardStatusBarViewComponentFactory.build(any(), any())) .thenReturn(mKeyguardStatusBarViewComponent); when(mKeyguardStatusBarViewComponent.getKeyguardStatusBarViewController()) .thenReturn(mKeyguardStatusBarViewController); - when(mLayoutInflater.inflate(eq(R.layout.keyguard_status_view), any(), anyBoolean())) - .thenReturn(keyguardStatusView); when(mNotificationRemoteInputManager.isRemoteInputActive()) .thenReturn(false); doAnswer(invocation -> { @@ -637,9 +529,6 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { when(longPressHandlingView.getResources()).thenReturn(longPressHandlingViewRes); when(longPressHandlingViewRes.getString(anyInt())).thenReturn(""); - when(mKeyguardRootView.findViewById(anyInt())).thenReturn(mKeyguardRootViewChild); - when(mKeyguardViewConfigurator.getKeyguardRootView()).thenReturn(mKeyguardRootView); - mNotificationPanelViewController = new NotificationPanelViewController( mView, mMainHandler, @@ -661,10 +550,8 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { mGutsManager, mNotificationsQSContainerController, mNotificationStackScrollLayoutController, - mKeyguardStatusViewComponentFactory, mKeyguardStatusBarViewComponentFactory, mLockscreenShadeTransitionController, - mAuthController, mScrimController, mUserManager, mMediaDataManager, @@ -694,11 +581,6 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { mKeyguardClockInteractor, mAlternateBouncerInteractor, mDreamingToLockscreenTransitionViewModel, - mOccludedToLockscreenTransitionViewModel, - mLockscreenToDreamingTransitionViewModel, - mGoneToDreamingTransitionViewModel, - mLockscreenToOccludedTransitionViewModel, - mPrimaryBouncerToGoneTransitionViewModel, mMainDispatcher, mKeyguardTransitionInteractor, mDumpManager, @@ -708,7 +590,6 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { mSharedNotificationContainerInteractor, mActiveNotificationsInteractor, mShadeAnimationInteractor, - mKeyguardViewConfigurator, mDeviceEntryFaceAuthInteractor, new ResourcesSplitShadeStateController(), mPowerInteractor, @@ -749,7 +630,6 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { .setHeadsUpAppearanceController(mock(HeadsUpAppearanceController.class)); verify(mNotificationStackScrollLayoutController) .setOnEmptySpaceClickListener(mEmptySpaceClickListenerCaptor.capture()); - reset(mKeyguardStatusViewController); when(mNotificationPanelViewControllerLazy.get()) .thenReturn(mNotificationPanelViewController); @@ -797,7 +677,6 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { public void tearDown() { List<Animator> leakedAnimators = null; if (mNotificationPanelViewController != null) { - mNotificationPanelViewController.mBottomAreaShadeAlphaAnimator.cancel(); mNotificationPanelViewController.cancelHeightAnimator(); leakedAnimators = mNotificationPanelViewController.mTestSetOfAnimatorsUsed.stream() .filter(Animator::isRunning).toList(); @@ -811,19 +690,6 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { } } - protected void setBottomPadding(int stackBottom, int lockIconPadding, int indicationPadding, - int ambientPadding) { - - when(mNotificationStackScrollLayoutController.getTop()).thenReturn(0); - when(mNotificationStackScrollLayoutController.getHeight()).thenReturn(stackBottom); - when(mNotificationStackScrollLayoutController.getBottom()).thenReturn(stackBottom); - when(mKeyguardRootViewChild.getTop()).thenReturn((int) (stackBottom - lockIconPadding)); - - when(mResources.getDimensionPixelSize(R.dimen.keyguard_indication_bottom_padding)) - .thenReturn(indicationPadding); - mNotificationPanelViewController.loadDimens(); - } - protected void triggerPositionClockAndNotifications() { mNotificationPanelViewController.onQsSetExpansionHeightCalled(false); } @@ -871,18 +737,6 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { ); } - protected void assertKeyguardStatusViewCentered() { - mNotificationPanelViewController.updateResources(); - assertThat(getConstraintSetLayout(R.id.keyguard_status_view).endToEnd).isAnyOf( - ConstraintSet.PARENT_ID, ConstraintSet.UNSET); - } - - protected void assertKeyguardStatusViewNotCentered() { - mNotificationPanelViewController.updateResources(); - assertThat(getConstraintSetLayout(R.id.keyguard_status_view).endToEnd).isEqualTo( - R.id.qs_edge_guideline); - } - protected void setIsFullWidth(boolean fullWidth) { float nsslWidth = fullWidth ? PANEL_WIDTH : PANEL_WIDTH / 2f; when(mNotificationStackScrollLayoutController.getWidth()).thenReturn(nsslWidth); diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java index 51f00a09ff43..ba989dbd0e73 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java @@ -57,42 +57,6 @@ public class NotificationPanelViewControllerTest extends NotificationPanelViewCo } @Test - @Ignore("b/261472011 - Test appears inconsistent across environments") - public void getVerticalSpaceForLockscreenNotifications_useLockIconBottomPadding_returnsSpaceAvailable() { - setBottomPadding(/* stackScrollLayoutBottom= */ 180, - /* lockIconPadding= */ 20, - /* indicationPadding= */ 0, - /* ambientPadding= */ 0); - - assertThat(mNotificationPanelViewController.getVerticalSpaceForLockscreenNotifications()) - .isEqualTo(80); - } - - @Test - @Ignore("b/261472011 - Test appears inconsistent across environments") - public void getVerticalSpaceForLockscreenNotifications_useIndicationBottomPadding_returnsSpaceAvailable() { - setBottomPadding(/* stackScrollLayoutBottom= */ 180, - /* lockIconPadding= */ 0, - /* indicationPadding= */ 30, - /* ambientPadding= */ 0); - - assertThat(mNotificationPanelViewController.getVerticalSpaceForLockscreenNotifications()) - .isEqualTo(70); - } - - @Test - @Ignore("b/261472011 - Test appears inconsistent across environments") - public void getVerticalSpaceForLockscreenNotifications_useAmbientBottomPadding_returnsSpaceAvailable() { - setBottomPadding(/* stackScrollLayoutBottom= */ 180, - /* lockIconPadding= */ 0, - /* indicationPadding= */ 0, - /* ambientPadding= */ 40); - - assertThat(mNotificationPanelViewController.getVerticalSpaceForLockscreenNotifications()) - .isEqualTo(60); - } - - @Test @EnableFlags(com.android.systemui.Flags.FLAG_SHADE_EXPANDS_ON_STATUS_BAR_LONG_PRESS) public void onStatusBarLongPress_shadeExpands() { long downTime = 42L; diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationShadeWindowViewTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationShadeWindowViewTest.kt index 0361ffe475a2..3d3d666825ad 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationShadeWindowViewTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationShadeWindowViewTest.kt @@ -16,11 +16,9 @@ package com.android.systemui.shade import android.content.res.Configuration -import android.os.SystemClock import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import android.testing.TestableLooper.RunWithLooper -import android.view.MotionEvent import android.widget.FrameLayout import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/QuickSettingsControllerImplBaseTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/QuickSettingsControllerImplBaseTest.java index b58c13c34505..7433267ab3b0 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/QuickSettingsControllerImplBaseTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/QuickSettingsControllerImplBaseTest.java @@ -32,7 +32,6 @@ import android.view.accessibility.AccessibilityManager; import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.UiEventLogger; -import com.android.keyguard.KeyguardStatusView; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.systemui.SysuiTestCase; import com.android.systemui.deviceentry.domain.interactor.DeviceEntryFaceAuthInteractor; @@ -200,9 +199,6 @@ public class QuickSettingsControllerImplBaseTest extends SysuiTestCase { ), mKosmos.getShadeModeInteractor()); - KeyguardStatusView keyguardStatusView = new KeyguardStatusView(mContext); - keyguardStatusView.setId(R.id.keyguard_status_view); - when(mResources.getDimensionPixelSize( R.dimen.lockscreen_shade_qs_transition_distance)).thenReturn(DEFAULT_HEIGHT); when(mPanelView.getResources()).thenReturn(mResources); @@ -218,8 +214,6 @@ public class QuickSettingsControllerImplBaseTest extends SysuiTestCase { when(mQs.getHeaderBottom()).thenReturn(QS_FRAME_BOTTOM); when(mPanelView.getY()).thenReturn((float) QS_FRAME_TOP); when(mPanelView.getHeight()).thenReturn(QS_FRAME_BOTTOM); - when(mPanelView.findViewById(R.id.keyguard_status_view)) - .thenReturn(mock(KeyguardStatusView.class)); when(mQs.getView()).thenReturn(mPanelView); when(mQSFragment.getView()).thenReturn(mPanelView); diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt index 6bdd86efa8c0..459778868ccd 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt @@ -24,7 +24,6 @@ import android.platform.test.annotations.EnableFlags import android.platform.test.flag.junit.FlagsParameterization import androidx.test.filters.SmallTest import com.android.compose.animation.scene.ObservableTransitionState -import com.android.systemui.Flags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT import com.android.systemui.SysuiTestCase import com.android.systemui.bouncer.data.repository.keyguardBouncerRepository import com.android.systemui.common.shared.model.NotificationContainerBounds @@ -91,8 +90,6 @@ import platform.test.runner.parameterized.Parameters @SmallTest @RunWith(ParameterizedAndroidJunit4::class) -// SharedNotificationContainerViewModel is only bound when FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT is on -@EnableFlags(FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT) class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { companion object { diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/KeyguardQsUserSwitchControllerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/KeyguardQsUserSwitchControllerTest.kt index b7a35158fdf6..abfd64adab22 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/KeyguardQsUserSwitchControllerTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/KeyguardQsUserSwitchControllerTest.kt @@ -24,11 +24,10 @@ import android.widget.FrameLayout import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.internal.logging.UiEventLogger -import com.android.systemui.res.R import com.android.systemui.SysuiTestCase import com.android.systemui.plugins.FalsingManager import com.android.systemui.qs.user.UserSwitchDialogController -import com.android.systemui.statusbar.SysuiStatusBarStateController +import com.android.systemui.res.R import com.android.systemui.statusbar.phone.DozeParameters import com.android.systemui.statusbar.phone.LockscreenGestureLogger import com.android.systemui.statusbar.phone.ScreenOffAnimationController @@ -47,32 +46,21 @@ import org.mockito.MockitoAnnotations @TestableLooper.RunWithLooper @RunWith(AndroidJUnit4::class) class KeyguardQsUserSwitchControllerTest : SysuiTestCase() { - @Mock - private lateinit var userSwitcherController: UserSwitcherController - - @Mock - private lateinit var keyguardStateController: KeyguardStateController + @Mock private lateinit var userSwitcherController: UserSwitcherController - @Mock - private lateinit var falsingManager: FalsingManager + @Mock private lateinit var keyguardStateController: KeyguardStateController - @Mock - private lateinit var configurationController: ConfigurationController + @Mock private lateinit var falsingManager: FalsingManager - @Mock - private lateinit var statusBarStateController: SysuiStatusBarStateController + @Mock private lateinit var configurationController: ConfigurationController - @Mock - private lateinit var dozeParameters: DozeParameters + @Mock private lateinit var dozeParameters: DozeParameters - @Mock - private lateinit var screenOffAnimationController: ScreenOffAnimationController + @Mock private lateinit var screenOffAnimationController: ScreenOffAnimationController - @Mock - private lateinit var userSwitchDialogController: UserSwitchDialogController + @Mock private lateinit var userSwitchDialogController: UserSwitchDialogController - @Mock - private lateinit var uiEventLogger: UiEventLogger + @Mock private lateinit var uiEventLogger: UiEventLogger private lateinit var view: FrameLayout private lateinit var testableLooper: TestableLooper @@ -83,10 +71,12 @@ class KeyguardQsUserSwitchControllerTest : SysuiTestCase() { MockitoAnnotations.initMocks(this) testableLooper = TestableLooper.get(this) - view = LayoutInflater.from(context) - .inflate(R.layout.keyguard_qs_user_switch, null) as FrameLayout + view = + LayoutInflater.from(context).inflate(R.layout.keyguard_qs_user_switch, null) + as FrameLayout - keyguardQsUserSwitchController = KeyguardQsUserSwitchController( + keyguardQsUserSwitchController = + KeyguardQsUserSwitchController( view, context, context.resources, @@ -94,11 +84,11 @@ class KeyguardQsUserSwitchControllerTest : SysuiTestCase() { keyguardStateController, falsingManager, configurationController, - statusBarStateController, dozeParameters, screenOffAnimationController, userSwitchDialogController, - uiEventLogger) + uiEventLogger, + ) ViewUtils.attachView(view) testableLooper.processAllMessages() @@ -117,7 +107,7 @@ class KeyguardQsUserSwitchControllerTest : SysuiTestCase() { fun testUiEventLogged() { view.findViewById<View>(R.id.kg_multi_user_avatar)?.performClick() verify(uiEventLogger, times(1)) - .log(LockscreenGestureLogger.LockscreenUiEvent.LOCKSCREEN_SWITCH_USER_TAP) + .log(LockscreenGestureLogger.LockscreenUiEvent.LOCKSCREEN_SWITCH_USER_TAP) } @Test diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/unfold/FoldAodAnimationControllerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/unfold/FoldAodAnimationControllerTest.kt index c29b86c1fa37..1135a5f86952 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/unfold/FoldAodAnimationControllerTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/unfold/FoldAodAnimationControllerTest.kt @@ -19,8 +19,6 @@ package com.android.systemui.unfold import android.hardware.devicestate.DeviceStateManager import android.hardware.devicestate.DeviceStateManager.FoldStateListener import android.os.PowerManager -import android.view.ViewGroup -import android.view.ViewTreeObserver import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.internal.util.LatencyTracker @@ -74,10 +72,6 @@ class FoldAodAnimationControllerTest : SysuiTestCase() { @Mock lateinit var shadeViewController: ShadeViewController - @Mock lateinit var viewGroup: ViewGroup - - @Mock lateinit var viewTreeObserver: ViewTreeObserver - @Mock lateinit var shadeFoldAnimator: ShadeFoldAnimator @Mock lateinit var foldTransitionInteractor: ToAodFoldTransitionInteractor @@ -97,11 +91,8 @@ class FoldAodAnimationControllerTest : SysuiTestCase() { deviceStates = FoldableTestUtils.findDeviceStates(context) - // TODO(b/254878364): remove this call to NPVC.getView() whenever(shadeViewController.shadeFoldAnimator).thenReturn(shadeFoldAnimator) whenever(foldTransitionInteractor.foldAnimator).thenReturn(shadeFoldAnimator) - whenever(shadeFoldAnimator.view).thenReturn(viewGroup) - whenever(viewGroup.viewTreeObserver).thenReturn(viewTreeObserver) whenever(wakefulnessLifecycle.lastSleepReason) .thenReturn(PowerManager.GO_TO_SLEEP_REASON_DEVICE_FOLD) whenever(shadeFoldAnimator.startFoldToAodAnimation(any(), any(), any())).then { diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_clock_presentation.xml b/packages/SystemUI/res-keyguard/layout/keyguard_clock_presentation.xml deleted file mode 100644 index f68ab8110b6d..000000000000 --- a/packages/SystemUI/res-keyguard/layout/keyguard_clock_presentation.xml +++ /dev/null @@ -1,45 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?><!-- -** -** Copyright 2023, The Android Open Source Project -** -** Licensed under the Apache License, Version 2.0 (the "License") -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -*/ ---> - -<androidx.constraintlayout.widget.ConstraintLayout - xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - android:id="@+id/presentation" - android:layout_width="match_parent" - android:layout_height="match_parent"> - <com.android.keyguard.KeyguardStatusView - android:id="@+id/clock" - android:layout_width="0dp" - android:layout_height="0dp" - android:layout_gravity="center" - android:orientation="vertical" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintDimensionRatio="1:1" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent"> - - - <include - android:id="@+id/keyguard_clock_container" - layout="@layout/keyguard_clock_switch" - android:layout_width="match_parent" - android:layout_height="wrap_content"/> - </com.android.keyguard.KeyguardStatusView> - -</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml b/packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml deleted file mode 100644 index 8bef4759c55d..000000000000 --- a/packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml +++ /dev/null @@ -1,67 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -** -** Copyright 2018, The Android Open Source Project -** -** Licensed under the Apache License, Version 2.0 (the "License") -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -*/ ---> - -<!-- This is a view that shows clock information in Keyguard. --> -<com.android.keyguard.KeyguardClockSwitch - xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/keyguard_clock_container" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:clipChildren="false" - android:layout_gravity="center_horizontal|top"> - <com.android.keyguard.KeyguardClockFrame - android:id="@id/lockscreen_clock_view" - android:layout_width="wrap_content" - android:layout_height="@dimen/small_clock_height" - android:layout_alignParentStart="true" - android:layout_alignParentTop="true" - android:clipChildren="false" - android:paddingStart="@dimen/clock_padding_start" - android:visibility="invisible" /> - <com.android.keyguard.KeyguardClockFrame - android:id="@id/lockscreen_clock_view_large" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:clipChildren="false" - android:visibility="gone" /> - - <!-- Not quite optimal but needed to translate these items as a group. The - NotificationIconContainer has its own logic for translation. --> - <com.android.keyguard.KeyguardStatusAreaView - android:id="@+id/keyguard_status_area" - android:orientation="vertical" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_alignParentStart="true" - android:layout_below="@id/lockscreen_clock_view"> - - <include layout="@layout/keyguard_slice_view" - android:id="@+id/keyguard_slice_view" - android:layout_width="match_parent" - android:layout_height="wrap_content" /> - - <com.android.systemui.statusbar.phone.NotificationIconContainer - android:id="@+id/left_aligned_notification_icon_container" - android:layout_width="match_parent" - android:layout_height="@dimen/notification_shelf_height" - android:paddingStart="@dimen/below_clock_padding_start_icons" - android:visibility="invisible" - /> - </com.android.keyguard.KeyguardStatusAreaView> -</com.android.keyguard.KeyguardClockSwitch> diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_presentation.xml b/packages/SystemUI/res-keyguard/layout/keyguard_presentation.xml deleted file mode 100644 index 8a0dd125d88b..000000000000 --- a/packages/SystemUI/res-keyguard/layout/keyguard_presentation.xml +++ /dev/null @@ -1,50 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -** -** Copyright 2013, The Android Open Source Project -** -** Licensed under the Apache License, Version 2.0 (the "License") -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -*/ ---> - -<!-- This is a view that shows general status information in Keyguard. --> -<FrameLayout - xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/presentation" - android:layout_width="match_parent" - android:layout_height="match_parent"> - <!-- This is mostly keyguard_status_view.xml with minor modifications --> - <com.android.keyguard.KeyguardStatusView - android:id="@+id/clock" - android:orientation="vertical" - android:layout_width="@dimen/keyguard_presentation_width" - android:layout_height="wrap_content"> - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="vertical"> - <include - layout="@layout/keyguard_clock_switch" - android:id="@+id/keyguard_clock_container" - android:layout_width="match_parent" - android:layout_height="wrap_content" /> - <ImageView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginTop="24dp" - android:layout_gravity="center_horizontal" - android:src="@drawable/kg_security_lock_normal" /> - </LinearLayout> - </com.android.keyguard.KeyguardStatusView> - -</FrameLayout> diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_slice_view.xml b/packages/SystemUI/res-keyguard/layout/keyguard_slice_view.xml index 7c5dbc247428..99b98dd2cdb7 100644 --- a/packages/SystemUI/res-keyguard/layout/keyguard_slice_view.xml +++ b/packages/SystemUI/res-keyguard/layout/keyguard_slice_view.xml @@ -20,6 +20,7 @@ <!-- This is a view that shows general status information in Keyguard. --> <com.android.keyguard.KeyguardSliceView xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/keyguard_slice_view" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="start" diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_status_view.xml b/packages/SystemUI/res-keyguard/layout/keyguard_status_view.xml deleted file mode 100644 index e6122a094707..000000000000 --- a/packages/SystemUI/res-keyguard/layout/keyguard_status_view.xml +++ /dev/null @@ -1,52 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -** -** Copyright 2009, The Android Open Source Project -** -** Licensed under the Apache License, Version 2.0 (the "License") -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -*/ ---> - -<!-- This is a view that shows general status information in Keyguard. --> -<com.android.keyguard.KeyguardStatusView - xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:systemui="http://schemas.android.com/apk/res-auto" - android:id="@+id/keyguard_status_view" - android:orientation="vertical" - systemui:layout_constraintStart_toStartOf="parent" - systemui:layout_constraintEnd_toEndOf="parent" - systemui:layout_constraintTop_toTopOf="parent" - android:layout_marginHorizontal="@dimen/status_view_margin_horizontal" - android:clipChildren="false" - android:layout_width="0dp" - android:layout_height="wrap_content"> - <com.android.keyguard.KeyguardStatusContainer - android:id="@+id/status_view_container" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:clipChildren="false" - android:clipToPadding="false" - android:orientation="vertical"> - <include - layout="@layout/keyguard_clock_switch" - android:id="@+id/keyguard_clock_container" - android:layout_width="match_parent" - android:layout_height="wrap_content" /> - <FrameLayout - android:id="@id/status_view_media_container" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:padding="@dimen/qs_media_padding" - /> - </com.android.keyguard.KeyguardStatusContainer> -</com.android.keyguard.KeyguardStatusView> diff --git a/packages/SystemUI/res/layout/media_output_dialog.xml b/packages/SystemUI/res/layout/media_output_dialog.xml index 9c1dc6448b4b..6f8b4cd3e4a9 100644 --- a/packages/SystemUI/res/layout/media_output_dialog.xml +++ b/packages/SystemUI/res/layout/media_output_dialog.xml @@ -120,36 +120,6 @@ </LinearLayout> <LinearLayout - android:id="@+id/cast_app_section" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginTop="20dp" - android:layout_marginStart="@dimen/dialog_side_padding" - android:layout_marginEnd="@dimen/dialog_side_padding" - android:layout_marginBottom="@dimen/dialog_bottom_padding" - android:orientation="vertical" - android:visibility="gone"> - <TextView - android:id="@+id/launch_app_title" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="center_vertical|start" - android:ellipsize="end" - android:textColor="?android:attr/textColorPrimary" - android:text="@string/media_output_dialog_launch_app_text" - android:maxLines="1" - android:fontFamily="@*android:string/config_headlineFontFamilyMedium" - android:textSize="16sp"/> - - <Button - android:id="@+id/launch_app_button" - style="@style/Widget.Dialog.Button.BorderButton" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:drawablePadding="5dp"/> - </LinearLayout> - - <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="4dp" diff --git a/packages/SystemUI/res/layout/status_bar_expanded.xml b/packages/SystemUI/res/layout/status_bar_expanded.xml index 46a9d475cbb6..b106ad55fb3c 100644 --- a/packages/SystemUI/res/layout/status_bar_expanded.xml +++ b/packages/SystemUI/res/layout/status_bar_expanded.xml @@ -41,10 +41,6 @@ android:clipToPadding="false" android:clipChildren="false"> - <include - layout="@layout/keyguard_status_view" - android:visibility="gone"/> - <include layout="@layout/dock_info_overlay"/> <FrameLayout diff --git a/packages/SystemUI/res/values-sw600dp-long/config.xml b/packages/SystemUI/res/values-sw600dp-long/config.xml new file mode 100644 index 000000000000..92e346982749 --- /dev/null +++ b/packages/SystemUI/res/values-sw600dp-long/config.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** Copyright 2012, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<!-- These resources are around just to allow their values to be customized + for different hardware and product builds. --> +<resources xmlns:android="http://schemas.android.com/apk/res/android"> + <!-- The number of columns in the Split Shade QuickSettings --> + <integer name="quick_settings_split_shade_num_columns">6</integer> +</resources> diff --git a/packages/SystemUI/res/values-sw600dp/config.xml b/packages/SystemUI/res/values-sw600dp/config.xml index ec24c3df36a8..ab0f788dbb13 100644 --- a/packages/SystemUI/res/values-sw600dp/config.xml +++ b/packages/SystemUI/res/values-sw600dp/config.xml @@ -23,9 +23,6 @@ <!-- The maximum number of rows in the QuickSettings --> <integer name="quick_settings_max_rows">4</integer> - <!-- The number of columns in the Split Shade QuickSettings --> - <integer name="quick_settings_split_shade_num_columns">6</integer> - <!-- Use collapsed layout for media player in landscape QQS --> <bool name="config_quickSettingsMediaLandscapeCollapsed">false</bool> diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml index 113f3d2bc35e..940e87d3d163 100644 --- a/packages/SystemUI/res/values/config.xml +++ b/packages/SystemUI/res/values/config.xml @@ -1103,4 +1103,8 @@ Whether the user switching can only happen by logging out and going through the system user (login screen). --> <bool name="config_userSwitchingMustGoThroughLoginScreen">false</bool> + + + <!-- The dream component used when the device is low light environment. --> + <string translatable="false" name="config_lowLightDreamComponent"/> </resources> diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index bfaa3369d94e..70a94f9f9a59 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -1514,7 +1514,6 @@ <dimen name="media_output_dialog_header_icon_padding">16dp</dimen> <dimen name="media_output_dialog_icon_corner_radius">16dp</dimen> <dimen name="media_output_dialog_title_anim_y_delta">12.5dp</dimen> - <dimen name="media_output_dialog_app_tier_icon_size">20dp</dimen> <dimen name="media_output_dialog_background_radius">16dp</dimen> <dimen name="media_output_dialog_active_background_radius">30dp</dimen> <dimen name="media_output_dialog_default_margin_end">16dp</dimen> diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index f14ee14889c4..399c2d60094d 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -3207,8 +3207,6 @@ <string name="media_output_dialog_connect_failed">Can\'t switch. Tap to try again.</string> <!-- Title for connecting item [CHAR LIMIT=60] --> <string name="media_output_dialog_pairing_new">Connect a device</string> - <!-- Title for launch app [CHAR LIMIT=60] --> - <string name="media_output_dialog_launch_app_text">To cast this session, please open the app.</string> <!-- App name when can't get app name [CHAR LIMIT=60] --> <string name="media_output_dialog_unknown_launch_app_name">Unknown app</string> <!-- Button text for stopping casting [CHAR LIMIT=60] --> diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockAccessibilityDelegate.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockAccessibilityDelegate.java deleted file mode 100644 index f7db48aefdaf..000000000000 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockAccessibilityDelegate.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2017 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License - */ - -package com.android.keyguard; - -import android.content.Context; -import android.text.TextUtils; -import android.view.View; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; -import android.widget.TextView; - -import com.android.systemui.res.R; - -/** - * Replaces fancy colons with regular colons. Only works on TextViews. - */ -class KeyguardClockAccessibilityDelegate extends View.AccessibilityDelegate { - private final String mFancyColon; - - public KeyguardClockAccessibilityDelegate(Context context) { - mFancyColon = context.getString(R.string.keyguard_fancy_colon); - } - - @Override - public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) { - super.onInitializeAccessibilityEvent(host, event); - if (TextUtils.isEmpty(mFancyColon)) { - return; - } - CharSequence text = event.getContentDescription(); - if (!TextUtils.isEmpty(text)) { - event.setContentDescription(replaceFancyColon(text)); - } - } - - @Override - public void onPopulateAccessibilityEvent(View host, AccessibilityEvent event) { - if (TextUtils.isEmpty(mFancyColon)) { - super.onPopulateAccessibilityEvent(host, event); - } else { - CharSequence text = ((TextView) host).getText(); - if (!TextUtils.isEmpty(text)) { - event.getText().add(replaceFancyColon(text)); - } - } - } - - @Override - public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfo(host, info); - if (TextUtils.isEmpty(mFancyColon)) { - return; - } - if (!TextUtils.isEmpty(info.getText())) { - info.setText(replaceFancyColon(info.getText())); - } - if (!TextUtils.isEmpty(info.getContentDescription())) { - info.setContentDescription(replaceFancyColon(info.getContentDescription())); - } - } - - private CharSequence replaceFancyColon(CharSequence text) { - if (TextUtils.isEmpty(mFancyColon)) { - return text; - } - return text.toString().replace(mFancyColon, ":"); - } - - public static boolean isNeeded(Context context) { - return !TextUtils.isEmpty(context.getString(R.string.keyguard_fancy_colon)); - } -} diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockFrame.kt b/packages/SystemUI/src/com/android/keyguard/KeyguardClockFrame.kt deleted file mode 100644 index 1cb8e43cf2c8..000000000000 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockFrame.kt +++ /dev/null @@ -1,53 +0,0 @@ -package com.android.keyguard - -import android.content.Context -import android.graphics.Canvas -import android.util.AttributeSet -import android.view.View -import android.widget.FrameLayout - -class KeyguardClockFrame( - context: Context, - attrs: AttributeSet, -) : FrameLayout(context, attrs) { - private var drawAlpha: Int = 255 - - protected override fun onSetAlpha(alpha: Int): Boolean { - // Ignore alpha passed from View, prefer to compute it from set values - drawAlpha = (255 * this.alpha * transitionAlpha).toInt() - return true - } - - protected override fun dispatchDraw(canvas: Canvas) { - saveCanvasAlpha(this, canvas, drawAlpha) { super.dispatchDraw(it) } - } - - companion object { - @JvmStatic - fun saveCanvasAlpha(view: View, canvas: Canvas, alpha: Int, drawFunc: (Canvas) -> Unit) { - if (alpha <= 0) { - // Zero Alpha -> skip drawing phase - return - } - - if (alpha >= 255) { - // Max alpha -> no need for layer - drawFunc(canvas) - return - } - - // Find x & y of view on screen - var (x, y) = - run { - val locationOnScreen = IntArray(2) - view.getLocationOnScreen(locationOnScreen) - Pair(locationOnScreen[0].toFloat(), locationOnScreen[1].toFloat()) - } - - val restoreTo = - canvas.saveLayerAlpha(-1f * x, -1f * y, x + view.width, y + view.height, alpha) - drawFunc(canvas) - canvas.restoreToCount(restoreTo) - } - } -} diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java deleted file mode 100644 index 71d4e9af6f55..000000000000 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java +++ /dev/null @@ -1,501 +0,0 @@ -package com.android.keyguard; - -import static com.android.keyguard.KeyguardStatusAreaView.TRANSLATE_X_CLOCK_DESIGN; -import static com.android.keyguard.KeyguardStatusAreaView.TRANSLATE_Y_CLOCK_DESIGN; -import static com.android.keyguard.KeyguardStatusAreaView.TRANSLATE_Y_CLOCK_SIZE; - -import android.animation.Animator; -import android.animation.AnimatorListenerAdapter; -import android.animation.AnimatorSet; -import android.animation.ObjectAnimator; -import android.content.Context; -import android.graphics.Canvas; -import android.graphics.Rect; -import android.util.AttributeSet; -import android.view.View; -import android.view.ViewGroup; -import android.widget.RelativeLayout; - -import androidx.annotation.IntDef; -import androidx.annotation.VisibleForTesting; -import androidx.core.content.res.ResourcesCompat; - -import com.android.app.animation.Interpolators; -import com.android.keyguard.dagger.KeyguardStatusViewScope; -import com.android.systemui.keyguard.MigrateClocksToBlueprint; -import com.android.systemui.log.LogBuffer; -import com.android.systemui.log.core.LogLevel; -import com.android.systemui.plugins.clocks.ClockController; -import com.android.systemui.res.R; -import com.android.systemui.shared.clocks.DefaultClockController; - -import java.io.PrintWriter; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * Switch to show plugin clock when plugin is connected, otherwise it will show default clock. - */ -@KeyguardStatusViewScope -public class KeyguardClockSwitch extends RelativeLayout { - - private static final String TAG = "KeyguardClockSwitch"; - public static final String MISSING_CLOCK_ID = "CLOCK_MISSING"; - - private static final long CLOCK_OUT_MILLIS = 133; - private static final long CLOCK_IN_MILLIS = 167; - public static final long CLOCK_IN_START_DELAY_MILLIS = 133; - private static final long STATUS_AREA_START_DELAY_MILLIS = 0; - private static final long STATUS_AREA_MOVE_UP_MILLIS = 967; - private static final long STATUS_AREA_MOVE_DOWN_MILLIS = 467; - private static final float SMARTSPACE_TRANSLATION_CENTER_MULTIPLIER = 1.4f; - private static final float SMARTSPACE_TOP_PADDING_MULTIPLIER = 2.625f; - - @IntDef({LARGE, SMALL}) - @Retention(RetentionPolicy.SOURCE) - public @interface ClockSize { } - - public static final int LARGE = 0; - public static final int SMALL = 1; - // compensate for translation of parents subject to device screen - // In this case, the translation comes from KeyguardStatusView - public int screenOffsetYPadding = 0; - - /** Returns a region for the large clock to position itself, based on the given parent. */ - public static Rect getLargeClockRegion(ViewGroup parent) { - int largeClockTopMargin = parent.getResources() - .getDimensionPixelSize( - com.android.systemui.customization.R.dimen.keyguard_large_clock_top_margin); - int targetHeight = parent.getResources() - .getDimensionPixelSize( - com.android.systemui.customization.R.dimen.large_clock_text_size) - * 2; - int top = parent.getHeight() / 2 - targetHeight / 2 - + largeClockTopMargin / 2; - return new Rect( - parent.getLeft(), - top, - parent.getRight(), - top + targetHeight); - } - - /** Returns a region for the small clock to position itself, based on the given parent. */ - public static Rect getSmallClockRegion(ViewGroup parent) { - int targetHeight = parent.getResources() - .getDimensionPixelSize( - com.android.systemui.customization.R.dimen.small_clock_text_size); - return new Rect( - parent.getLeft(), - parent.getTop(), - parent.getRight(), - parent.getTop() + targetHeight); - } - - /** - * Frame for small/large clocks - */ - private KeyguardClockFrame mSmallClockFrame; - private KeyguardClockFrame mLargeClockFrame; - private ClockController mClock; - - // It's bc_smartspace_view, assigned by KeyguardClockSwitchController - // to get the top padding for translating smartspace for weather clock - private View mSmartspace; - - // Smartspace in weather clock is translated by this value - // to compensate for the position invisible dateWeatherView - private int mSmartspaceTop = -1; - - private KeyguardStatusAreaView mStatusArea; - private int mSmartspaceTopOffset; - private float mWeatherClockSmartspaceScaling = 1f; - private int mWeatherClockSmartspaceTranslateX = 0; - private int mWeatherClockSmartspaceTranslateY = 0; - private int mDrawAlpha = 255; - - private int mStatusBarHeight = 0; - - /** - * Maintain state so that a newly connected plugin can be initialized. - */ - private float mDarkAmount; - private boolean mSplitShadeCentered = false; - - /** - * Indicates which clock is currently displayed - should be one of {@link ClockSize}. - * Use null to signify it is uninitialized. - */ - @ClockSize private Integer mDisplayedClockSize = null; - - @VisibleForTesting AnimatorSet mClockInAnim = null; - @VisibleForTesting AnimatorSet mClockOutAnim = null; - @VisibleForTesting AnimatorSet mStatusAreaAnim = null; - - private int mClockSwitchYAmount; - @VisibleForTesting boolean mChildrenAreLaidOut = false; - @VisibleForTesting boolean mAnimateOnLayout = true; - private LogBuffer mLogBuffer = null; - - public KeyguardClockSwitch(Context context, AttributeSet attrs) { - super(context, attrs); - } - - /** - * Apply dp changes on configuration change - */ - public void onConfigChanged() { - mClockSwitchYAmount = mContext.getResources().getDimensionPixelSize( - R.dimen.keyguard_clock_switch_y_shift); - mSmartspaceTopOffset = (int) (mContext.getResources().getDimensionPixelSize( - com.android.systemui.customization.R.dimen.keyguard_smartspace_top_offset) - * mContext.getResources().getConfiguration().fontScale - / mContext.getResources().getDisplayMetrics().density - * SMARTSPACE_TOP_PADDING_MULTIPLIER); - mWeatherClockSmartspaceScaling = ResourcesCompat.getFloat( - mContext.getResources(), R.dimen.weather_clock_smartspace_scale); - mWeatherClockSmartspaceTranslateX = mContext.getResources().getDimensionPixelSize( - R.dimen.weather_clock_smartspace_translateX); - mWeatherClockSmartspaceTranslateY = mContext.getResources().getDimensionPixelSize( - R.dimen.weather_clock_smartspace_translateY); - mStatusBarHeight = mContext.getResources().getDimensionPixelSize( - R.dimen.status_bar_height); - updateStatusArea(/* animate= */false); - } - - /** Get bc_smartspace_view from KeyguardClockSwitchController - * Use its top to decide the translation value */ - public void setSmartspace(View smartspace) { - mSmartspace = smartspace; - } - - /** Sets whether the large clock is being shown on a connected display. */ - public void setLargeClockOnSecondaryDisplay(boolean onSecondaryDisplay) { - if (mClock != null) { - mClock.getLargeClock().getEvents().onSecondaryDisplayChanged(onSecondaryDisplay); - } - } - - /** - * Enable or disable split shade specific positioning - */ - public void setSplitShadeCentered(boolean splitShadeCentered) { - if (mSplitShadeCentered != splitShadeCentered) { - mSplitShadeCentered = splitShadeCentered; - updateStatusArea(/* animate= */true); - } - } - - public boolean getSplitShadeCentered() { - return mSplitShadeCentered; - } - - @Override - protected void onFinishInflate() { - super.onFinishInflate(); - if (!MigrateClocksToBlueprint.isEnabled()) { - mSmallClockFrame = findViewById( - com.android.systemui.customization.R.id.lockscreen_clock_view); - mLargeClockFrame = findViewById( - com.android.systemui.customization.R.id.lockscreen_clock_view_large); - mStatusArea = findViewById(R.id.keyguard_status_area); - } else { - removeView(findViewById( - com.android.systemui.customization.R.id.lockscreen_clock_view)); - removeView(findViewById( - com.android.systemui.customization.R.id.lockscreen_clock_view_large)); - } - onConfigChanged(); - } - - @Override - protected boolean onSetAlpha(int alpha) { - mDrawAlpha = alpha; - return true; - } - - @Override - protected void dispatchDraw(Canvas canvas) { - KeyguardClockFrame.saveCanvasAlpha( - this, canvas, mDrawAlpha, - c -> { - super.dispatchDraw(c); - return kotlin.Unit.INSTANCE; - }); - } - - public void setLogBuffer(LogBuffer logBuffer) { - mLogBuffer = logBuffer; - } - - public LogBuffer getLogBuffer() { - return mLogBuffer; - } - - /** Returns the id of the currently rendering clock */ - public String getClockId() { - if (mClock == null) { - return MISSING_CLOCK_ID; - } - return mClock.getConfig().getId(); - } - - void setClock(ClockController clock, int statusBarState) { - mClock = clock; - - // Disconnect from existing plugin. - mSmallClockFrame.removeAllViews(); - mLargeClockFrame.removeAllViews(); - - if (clock == null) { - if (mLogBuffer != null) { - mLogBuffer.log(TAG, LogLevel.ERROR, "No clock being shown"); - } - return; - } - - // Attach small and big clock views to hierarchy. - if (mLogBuffer != null) { - mLogBuffer.log(TAG, LogLevel.INFO, "Attached new clock views to switch"); - } - mSmallClockFrame.addView(clock.getSmallClock().getView()); - mLargeClockFrame.addView(clock.getLargeClock().getView()); - updateClockTargetRegions(); - updateStatusArea(/* animate= */false); - } - - private void updateStatusArea(boolean animate) { - if (mDisplayedClockSize != null && mChildrenAreLaidOut) { - updateClockViews(mDisplayedClockSize == LARGE, animate); - } - } - - void updateClockTargetRegions() { - if (MigrateClocksToBlueprint.isEnabled()) { - return; - } - if (mClock != null) { - if (mSmallClockFrame.isLaidOut()) { - Rect targetRegion = getSmallClockRegion(mSmallClockFrame); - mClock.getSmallClock().getEvents().onTargetRegionChanged(targetRegion); - } - - if (mLargeClockFrame.isLaidOut()) { - Rect targetRegion = getLargeClockRegion(mLargeClockFrame); - if (mClock instanceof DefaultClockController) { - mClock.getLargeClock().getEvents().onTargetRegionChanged( - targetRegion); - } else { - mClock.getLargeClock().getEvents().onTargetRegionChanged( - new Rect( - targetRegion.left, - targetRegion.top - screenOffsetYPadding, - targetRegion.right, - targetRegion.bottom - screenOffsetYPadding)); - } - } - } - } - - private void updateClockViews(boolean useLargeClock, boolean animate) { - if (mLogBuffer != null) { - mLogBuffer.log(TAG, LogLevel.DEBUG, (msg) -> { - msg.setBool1(useLargeClock); - msg.setBool2(animate); - msg.setBool3(mChildrenAreLaidOut); - return kotlin.Unit.INSTANCE; - }, (msg) -> "updateClockViews" - + "; useLargeClock=" + msg.getBool1() - + "; animate=" + msg.getBool2() - + "; mChildrenAreLaidOut=" + msg.getBool3()); - } - - if (mClockInAnim != null) mClockInAnim.cancel(); - if (mClockOutAnim != null) mClockOutAnim.cancel(); - if (mStatusAreaAnim != null) mStatusAreaAnim.cancel(); - - mClockInAnim = null; - mClockOutAnim = null; - mStatusAreaAnim = null; - - View in, out; - // statusAreaYTranslation uses for the translation for both mStatusArea and mSmallClockFrame - // statusAreaClockTranslateY only uses for mStatusArea - float statusAreaYTranslation, statusAreaClockScale = 1f; - float statusAreaClockTranslateX = 0f, statusAreaClockTranslateY = 0f; - float clockInYTranslation, clockOutYTranslation; - if (useLargeClock) { - out = mSmallClockFrame; - in = mLargeClockFrame; - if (indexOfChild(in) == -1) addView(in, 0); - statusAreaYTranslation = mSmallClockFrame.getTop() - mStatusArea.getTop() - + mSmartspaceTopOffset; - // TODO: Load from clock config when less risky - if (mClock != null - && mClock.getLargeClock().getConfig().getHasCustomWeatherDataDisplay()) { - statusAreaClockScale = mWeatherClockSmartspaceScaling; - statusAreaClockTranslateX = mWeatherClockSmartspaceTranslateX; - if (mSplitShadeCentered) { - statusAreaClockTranslateX *= SMARTSPACE_TRANSLATION_CENTER_MULTIPLIER; - } - - // On large weather clock, - // top padding for time is status bar height from top of the screen. - // On small one, - // it's screenOffsetYPadding (translationY for KeyguardStatusView), - // Cause smartspace is positioned according to the smallClockFrame - // we need to translate the difference between bottom of large clock and small clock - // Also, we need to counter offset the empty date weather view, mSmartspaceTop - // mWeatherClockSmartspaceTranslateY is only for Felix - statusAreaClockTranslateY = mStatusBarHeight - 0.6F * mSmallClockFrame.getHeight() - - mSmartspaceTop - screenOffsetYPadding - - statusAreaYTranslation + mWeatherClockSmartspaceTranslateY; - } - clockInYTranslation = 0; - clockOutYTranslation = 0; // Small clock translation is handled with statusArea - } else { - in = mSmallClockFrame; - out = mLargeClockFrame; - statusAreaYTranslation = 0f; - clockInYTranslation = 0f; - clockOutYTranslation = mClockSwitchYAmount * -1f; - - // Must remove in order for notifications to appear in the proper place, ideally this - // would happen after the out animation runs, but we can't guarantee that the - // nofications won't enter only after the out animation runs. - removeView(out); - } - - if (!animate) { - out.setAlpha(0f); - out.setTranslationY(clockOutYTranslation); - out.setVisibility(INVISIBLE); - in.setAlpha(1f); - in.setTranslationY(clockInYTranslation); - in.setVisibility(VISIBLE); - mStatusArea.setScaleX(statusAreaClockScale); - mStatusArea.setScaleY(statusAreaClockScale); - mStatusArea.setTranslateXFromClockDesign(statusAreaClockTranslateX); - mStatusArea.setTranslateYFromClockDesign(statusAreaClockTranslateY); - mStatusArea.setTranslateYFromClockSize(statusAreaYTranslation); - mSmallClockFrame.setTranslationY(statusAreaYTranslation); - return; - } - - mClockOutAnim = new AnimatorSet(); - mClockOutAnim.setDuration(CLOCK_OUT_MILLIS); - mClockOutAnim.setInterpolator(Interpolators.LINEAR); - mClockOutAnim.playTogether( - ObjectAnimator.ofFloat(out, ALPHA, 0f), - ObjectAnimator.ofFloat(out, TRANSLATION_Y, clockOutYTranslation)); - mClockOutAnim.addListener(new AnimatorListenerAdapter() { - public void onAnimationEnd(Animator animation) { - if (mClockOutAnim == animation) { - out.setVisibility(INVISIBLE); - mClockOutAnim = null; - } - } - }); - - in.setVisibility(View.VISIBLE); - mClockInAnim = new AnimatorSet(); - mClockInAnim.setDuration(CLOCK_IN_MILLIS); - mClockInAnim.setInterpolator(Interpolators.LINEAR_OUT_SLOW_IN); - mClockInAnim.playTogether( - ObjectAnimator.ofFloat(in, ALPHA, 1f), - ObjectAnimator.ofFloat(in, TRANSLATION_Y, clockInYTranslation)); - mClockInAnim.setStartDelay(CLOCK_IN_START_DELAY_MILLIS); - mClockInAnim.addListener(new AnimatorListenerAdapter() { - public void onAnimationEnd(Animator animation) { - if (mClockInAnim == animation) { - mClockInAnim = null; - } - } - }); - - mStatusAreaAnim = new AnimatorSet(); - mStatusAreaAnim.setStartDelay(STATUS_AREA_START_DELAY_MILLIS); - mStatusAreaAnim.setDuration( - useLargeClock ? STATUS_AREA_MOVE_UP_MILLIS : STATUS_AREA_MOVE_DOWN_MILLIS); - mStatusAreaAnim.setInterpolator(Interpolators.EMPHASIZED); - mStatusAreaAnim.playTogether( - ObjectAnimator.ofFloat(mStatusArea, TRANSLATE_Y_CLOCK_SIZE.getProperty(), - statusAreaYTranslation), - ObjectAnimator.ofFloat(mSmallClockFrame, TRANSLATION_Y, statusAreaYTranslation), - ObjectAnimator.ofFloat(mStatusArea, SCALE_X, statusAreaClockScale), - ObjectAnimator.ofFloat(mStatusArea, SCALE_Y, statusAreaClockScale), - ObjectAnimator.ofFloat(mStatusArea, TRANSLATE_X_CLOCK_DESIGN.getProperty(), - statusAreaClockTranslateX), - ObjectAnimator.ofFloat(mStatusArea, TRANSLATE_Y_CLOCK_DESIGN.getProperty(), - statusAreaClockTranslateY)); - mStatusAreaAnim.addListener(new AnimatorListenerAdapter() { - public void onAnimationEnd(Animator animation) { - if (mStatusAreaAnim == animation) { - mStatusAreaAnim = null; - } - } - }); - - mClockInAnim.start(); - mClockOutAnim.start(); - mStatusAreaAnim.start(); - } - - /** - * Display the desired clock and hide the other one - * - * @return true if desired clock appeared and false if it was already visible - */ - boolean switchToClock(@ClockSize int clockSize, boolean animate) { - if (mDisplayedClockSize != null && clockSize == mDisplayedClockSize) { - return false; - } - - // let's make sure clock is changed only after all views were laid out so we can - // translate them properly - if (mChildrenAreLaidOut) { - updateClockViews(clockSize == LARGE, animate); - } - - mDisplayedClockSize = clockSize; - return true; - } - - @Override - protected void onLayout(boolean changed, int l, int t, int r, int b) { - super.onLayout(changed, l, t, r, b); - // TODO: b/305022530 - if (mClock != null && mClock.getConfig().getId().equals("DIGITAL_CLOCK_METRO")) { - mClock.getSmallClock().getEvents().onThemeChanged(mClock.getSmallClock().getTheme()); - mClock.getLargeClock().getEvents().onThemeChanged(mClock.getLargeClock().getTheme()); - } - - if (changed) { - post(() -> updateClockTargetRegions()); - } - - if (mSmartspace != null && mSmartspaceTop != mSmartspace.getTop() - && mDisplayedClockSize != null) { - mSmartspaceTop = mSmartspace.getTop(); - post(() -> updateClockViews(mDisplayedClockSize == LARGE, mAnimateOnLayout)); - } - - if (mDisplayedClockSize != null && !mChildrenAreLaidOut) { - post(() -> updateClockViews(mDisplayedClockSize == LARGE, mAnimateOnLayout)); - } - mChildrenAreLaidOut = true; - } - - public void dump(PrintWriter pw, String[] args) { - pw.println("KeyguardClockSwitch:"); - pw.println(" mSmallClockFrame = " + mSmallClockFrame); - if (mSmallClockFrame != null) { - pw.println(" mSmallClockFrame.alpha = " + mSmallClockFrame.getAlpha()); - } - pw.println(" mLargeClockFrame = " + mLargeClockFrame); - if (mLargeClockFrame != null) { - pw.println(" mLargeClockFrame.alpha = " + mLargeClockFrame.getAlpha()); - } - pw.println(" mStatusArea = " + mStatusArea); - pw.println(" mDisplayedClockSize = " + mDisplayedClockSize); - } -} diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java deleted file mode 100644 index 0e1eccc8231c..000000000000 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java +++ /dev/null @@ -1,676 +0,0 @@ -/* - * Copyright (C) 2020 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.keyguard; - -import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; -import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; - -import static com.android.keyguard.KeyguardClockSwitch.LARGE; -import static com.android.keyguard.KeyguardClockSwitch.SMALL; -import static com.android.systemui.Flags.smartspaceRelocateToBottom; - -import android.annotation.Nullable; -import android.database.ContentObserver; -import android.os.UserHandle; -import android.provider.Settings; -import android.text.TextUtils; -import android.view.View; -import android.view.ViewGroup; -import android.widget.FrameLayout; -import android.widget.LinearLayout; - -import androidx.annotation.NonNull; - -import com.android.systemui.Dumpable; -import com.android.systemui.dagger.qualifiers.Background; -import com.android.systemui.dagger.qualifiers.Main; -import com.android.systemui.dump.DumpManager; -import com.android.systemui.keyguard.KeyguardUnlockAnimationController; -import com.android.systemui.keyguard.MigrateClocksToBlueprint; -import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor; -import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor; -import com.android.systemui.keyguard.ui.view.InWindowLauncherUnlockAnimationManager; -import com.android.systemui.log.LogBuffer; -import com.android.systemui.log.core.LogLevel; -import com.android.systemui.log.dagger.KeyguardClockLog; -import com.android.systemui.plugins.clocks.ClockController; -import com.android.systemui.plugins.statusbar.StatusBarStateController; -import com.android.systemui.res.R; -import com.android.systemui.shared.clocks.ClockRegistry; -import com.android.systemui.shared.regionsampling.RegionSampler; -import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController; -import com.android.systemui.statusbar.notification.AnimatableProperty; -import com.android.systemui.statusbar.notification.PropertyAnimator; -import com.android.systemui.statusbar.notification.stack.AnimationProperties; -import com.android.systemui.statusbar.phone.NotificationIconContainer; -import com.android.systemui.util.ViewController; -import com.android.systemui.util.concurrency.DelayableExecutor; -import com.android.systemui.util.settings.SecureSettings; - -import kotlinx.coroutines.DisposableHandle; - -import java.io.PrintWriter; -import java.util.Locale; -import java.util.concurrent.Executor; - -import javax.inject.Inject; - -/** - * Injectable controller for {@link KeyguardClockSwitch}. - */ -public class KeyguardClockSwitchController extends ViewController<KeyguardClockSwitch> - implements Dumpable { - private static final String TAG = "KeyguardClockSwitchController"; - - private final StatusBarStateController mStatusBarStateController; - private final ClockRegistry mClockRegistry; - private final KeyguardSliceViewController mKeyguardSliceViewController; - private final LockscreenSmartspaceController mSmartspaceController; - private final SecureSettings mSecureSettings; - private final DumpManager mDumpManager; - private final ClockEventController mClockEventController; - private final LogBuffer mLogBuffer; - private FrameLayout mSmallClockFrame; // top aligned clock - private FrameLayout mLargeClockFrame; // centered clock - - @KeyguardClockSwitch.ClockSize - private int mCurrentClockSize = SMALL; - - private int mKeyguardSmallClockTopMargin = 0; - private int mKeyguardLargeClockTopMargin = 0; - private int mKeyguardDateWeatherViewInvisibility = View.INVISIBLE; - private final ClockRegistry.ClockChangeListener mClockChangedListener; - - private ViewGroup mStatusArea; - - // If the SMARTSPACE flag is set, keyguard_slice_view is replaced by the following views. - private ViewGroup mDateWeatherView; - private View mWeatherView; - private View mSmartspaceView; - - private final KeyguardUnlockAnimationController mKeyguardUnlockAnimationController; - private final InWindowLauncherUnlockAnimationManager mInWindowLauncherUnlockAnimationManager; - - private boolean mShownOnSecondaryDisplay = false; - private boolean mOnlyClock = false; - private KeyguardInteractor mKeyguardInteractor; - private KeyguardClockInteractor mKeyguardClockInteractor; - private final DelayableExecutor mUiExecutor; - private final Executor mBgExecutor; - private boolean mCanShowDoubleLineClock = true; - private DisposableHandle mAodIconsBindHandle; - @Nullable private NotificationIconContainer mAodIconContainer; - - private final ContentObserver mDoubleLineClockObserver = new ContentObserver(null) { - @Override - public void onChange(boolean change) { - updateDoubleLineClock(); - } - }; - private final ContentObserver mShowWeatherObserver = new ContentObserver(null) { - @Override - public void onChange(boolean change) { - setWeatherVisibility(); - } - }; - - private final KeyguardUnlockAnimationController.KeyguardUnlockAnimationListener - mKeyguardUnlockAnimationListener = - new KeyguardUnlockAnimationController.KeyguardUnlockAnimationListener() { - @Override - public void onUnlockAnimationFinished() { - // For performance reasons, reset this once the unlock animation ends. - setClipChildrenForUnlock(true); - } - }; - - @Inject - public KeyguardClockSwitchController( - KeyguardClockSwitch keyguardClockSwitch, - StatusBarStateController statusBarStateController, - ClockRegistry clockRegistry, - KeyguardSliceViewController keyguardSliceViewController, - LockscreenSmartspaceController smartspaceController, - KeyguardUnlockAnimationController keyguardUnlockAnimationController, - SecureSettings secureSettings, - @Main DelayableExecutor uiExecutor, - @Background Executor bgExecutor, - DumpManager dumpManager, - ClockEventController clockEventController, - @KeyguardClockLog LogBuffer logBuffer, - KeyguardInteractor keyguardInteractor, - KeyguardClockInteractor keyguardClockInteractor, - InWindowLauncherUnlockAnimationManager inWindowLauncherUnlockAnimationManager) { - super(keyguardClockSwitch); - mStatusBarStateController = statusBarStateController; - mClockRegistry = clockRegistry; - mKeyguardSliceViewController = keyguardSliceViewController; - mSmartspaceController = smartspaceController; - mSecureSettings = secureSettings; - mUiExecutor = uiExecutor; - mBgExecutor = bgExecutor; - mKeyguardUnlockAnimationController = keyguardUnlockAnimationController; - mDumpManager = dumpManager; - mClockEventController = clockEventController; - mLogBuffer = logBuffer; - mView.setLogBuffer(mLogBuffer); - mKeyguardInteractor = keyguardInteractor; - mKeyguardClockInteractor = keyguardClockInteractor; - mInWindowLauncherUnlockAnimationManager = inWindowLauncherUnlockAnimationManager; - - mClockChangedListener = new ClockRegistry.ClockChangeListener() { - @Override - public void onCurrentClockChanged() { - if (!MigrateClocksToBlueprint.isEnabled()) { - setClock(mClockRegistry.createCurrentClock()); - } - } - @Override - public void onAvailableClocksChanged() { } - }; - } - - /** - * When set, limits the information shown in an external display. - */ - public void setShownOnSecondaryDisplay(boolean shownOnSecondaryDisplay) { - mShownOnSecondaryDisplay = shownOnSecondaryDisplay; - } - - /** - * Mostly used for alternate displays, limit the information shown - * - * @deprecated use {@link KeyguardClockSwitchController#setShownOnSecondaryDisplay} - */ - @Deprecated - public void setOnlyClock(boolean onlyClock) { - mOnlyClock = onlyClock; - } - - /** - * Used for status view to pass the screen offset from parent view - */ - public void setLockscreenClockY(int clockY) { - if (mView.screenOffsetYPadding != clockY) { - mView.screenOffsetYPadding = clockY; - mView.post(() -> mView.updateClockTargetRegions()); - } - } - - /** - * Attach the controller to the view it relates to. - */ - @Override - protected void onInit() { - mKeyguardSliceViewController.init(); - - if (!MigrateClocksToBlueprint.isEnabled()) { - mSmallClockFrame = mView - .findViewById(com.android.systemui.customization.R.id.lockscreen_clock_view); - mLargeClockFrame = mView - .findViewById(com.android.systemui.customization.R.id.lockscreen_clock_view_large); - } - - if (!mOnlyClock) { - mDumpManager.unregisterDumpable(getClass().getSimpleName()); // unregister previous - mDumpManager.registerDumpable(getClass().getSimpleName(), this); - } - } - - public KeyguardClockSwitch getView() { - return mView; - } - - private void hideSliceViewAndNotificationIconContainer() { - View ksv = mView.findViewById(R.id.keyguard_slice_view); - ksv.setVisibility(View.GONE); - - View nic = mView.findViewById( - R.id.left_aligned_notification_icon_container); - if (nic != null) { - nic.setVisibility(View.GONE); - } - } - - @Override - protected void onViewAttached() { - mClockRegistry.registerClockChangeListener(mClockChangedListener); - setClock(mClockRegistry.createCurrentClock()); - if (!MigrateClocksToBlueprint.isEnabled()) { - mClockEventController.registerListeners(mView); - } - mKeyguardSmallClockTopMargin = - mView.getResources().getDimensionPixelSize(R.dimen.keyguard_clock_top_margin); - mKeyguardLargeClockTopMargin = - mView.getResources().getDimensionPixelSize( - com.android.systemui.customization.R.dimen.keyguard_large_clock_top_margin); - mKeyguardDateWeatherViewInvisibility = - mView.getResources().getInteger(R.integer.keyguard_date_weather_view_invisibility); - - if (mShownOnSecondaryDisplay) { - mView.setLargeClockOnSecondaryDisplay(true); - mClockEventController.setLargeClockOnSecondaryDisplay(true); - displayClock(LARGE, /* animate= */ false); - hideSliceViewAndNotificationIconContainer(); - return; - } - - if (mOnlyClock) { - hideSliceViewAndNotificationIconContainer(); - return; - } - mStatusArea = mView.findViewById(R.id.keyguard_status_area); - - mBgExecutor.execute(() -> { - mSecureSettings.registerContentObserverForUserSync( - Settings.Secure.LOCKSCREEN_USE_DOUBLE_LINE_CLOCK, - false, /* notifyForDescendants */ - mDoubleLineClockObserver, - UserHandle.USER_ALL - ); - - mSecureSettings.registerContentObserverForUserSync( - Settings.Secure.LOCK_SCREEN_WEATHER_ENABLED, - false, /* notifyForDescendants */ - mShowWeatherObserver, - UserHandle.USER_ALL - ); - }); - - updateDoubleLineClock(); - - mKeyguardUnlockAnimationController.addKeyguardUnlockAnimationListener( - mKeyguardUnlockAnimationListener); - - if (mSmartspaceController.isEnabled()) { - View ksv = mView.findViewById(R.id.keyguard_slice_view); - int viewIndex = mStatusArea.indexOfChild(ksv); - ksv.setVisibility(View.GONE); - - removeViewsFromStatusArea(); - addSmartspaceView(); - // TODO(b/261757708): add content observer for the Settings toggle and add/remove - // weather according to the Settings. - if (mSmartspaceController.isDateWeatherDecoupled()) { - addDateWeatherView(); - } - } - if (!MigrateClocksToBlueprint.isEnabled()) { - setDateWeatherVisibility(); - setWeatherVisibility(); - } - - } - - int getNotificationIconAreaHeight() { - if (MigrateClocksToBlueprint.isEnabled()) { - return 0; - } else { - return mAodIconContainer != null ? mAodIconContainer.getHeight() : 0; - } - } - - @Nullable - View getAodNotifIconContainer() { - return mAodIconContainer; - } - - @Override - protected void onViewDetached() { - mClockRegistry.unregisterClockChangeListener(mClockChangedListener); - if (!MigrateClocksToBlueprint.isEnabled()) { - mClockEventController.unregisterListeners(); - } - setClock(null); - - mBgExecutor.execute(() -> { - mSecureSettings.unregisterContentObserverSync(mDoubleLineClockObserver); - mSecureSettings.unregisterContentObserverSync(mShowWeatherObserver); - }); - - mKeyguardUnlockAnimationController.removeKeyguardUnlockAnimationListener( - mKeyguardUnlockAnimationListener); - } - - void onLocaleListChanged() { - if (mSmartspaceController.isEnabled()) { - removeViewsFromStatusArea(); - addSmartspaceView(); - if (mSmartspaceController.isDateWeatherDecoupled()) { - mDateWeatherView.removeView(mWeatherView); - addDateWeatherView(); - setDateWeatherVisibility(); - setWeatherVisibility(); - } - } - } - - private void addDateWeatherView() { - if (MigrateClocksToBlueprint.isEnabled()) { - return; - } - mDateWeatherView = (ViewGroup) mSmartspaceController.buildAndConnectDateView(mView); - LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( - MATCH_PARENT, WRAP_CONTENT); - mStatusArea.addView(mDateWeatherView, 0, lp); - int startPadding = getContext().getResources().getDimensionPixelSize( - R.dimen.below_clock_padding_start); - int endPadding = getContext().getResources().getDimensionPixelSize( - R.dimen.below_clock_padding_end); - mDateWeatherView.setPaddingRelative(startPadding, 0, endPadding, 0); - addWeatherView(); - } - - private void addWeatherView() { - if (MigrateClocksToBlueprint.isEnabled()) { - return; - } - LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( - WRAP_CONTENT, WRAP_CONTENT); - mWeatherView = mSmartspaceController.buildAndConnectWeatherView(mView); - // Place weather right after the date, before the extras - final int index = mDateWeatherView.getChildCount() == 0 ? 0 : 1; - mDateWeatherView.addView(mWeatherView, index, lp); - mWeatherView.setPaddingRelative(0, 0, 4, 0); - } - - private void addSmartspaceView() { - if (MigrateClocksToBlueprint.isEnabled()) { - return; - } - - if (smartspaceRelocateToBottom()) { - return; - } - - mSmartspaceView = mSmartspaceController.buildAndConnectView(mView); - LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( - MATCH_PARENT, WRAP_CONTENT); - mStatusArea.addView(mSmartspaceView, 0, lp); - int startPadding = getContext().getResources().getDimensionPixelSize( - R.dimen.below_clock_padding_start); - int endPadding = getContext().getResources().getDimensionPixelSize( - R.dimen.below_clock_padding_end); - mSmartspaceView.setPaddingRelative(startPadding, 0, endPadding, 0); - - mKeyguardUnlockAnimationController.setLockscreenSmartspace(mSmartspaceView); - mInWindowLauncherUnlockAnimationManager.setLockscreenSmartspace(mSmartspaceView); - - mView.setSmartspace(mSmartspaceView); - } - - /** - * Apply dp changes on configuration change - */ - public void onConfigChanged() { - mView.onConfigChanged(); - mKeyguardSmallClockTopMargin = - mView.getResources().getDimensionPixelSize(R.dimen.keyguard_clock_top_margin); - mKeyguardLargeClockTopMargin = - mView.getResources().getDimensionPixelSize( - com.android.systemui.customization.R.dimen.keyguard_large_clock_top_margin); - mKeyguardDateWeatherViewInvisibility = - mView.getResources().getInteger(R.integer.keyguard_date_weather_view_invisibility); - mView.updateClockTargetRegions(); - setDateWeatherVisibility(); - } - - /** - * Enable or disable split shade center specific positioning - */ - public void setSplitShadeCentered(boolean splitShadeCentered) { - mView.setSplitShadeCentered(splitShadeCentered); - } - - /** - * Set if the split shade is enabled - */ - public void setSplitShadeEnabled(boolean splitShadeEnabled) { - mSmartspaceController.setSplitShadeEnabled(splitShadeEnabled); - } - - /** - * Set which clock should be displayed on the keyguard. The other one will be automatically - * hidden. - */ - public void displayClock(@KeyguardClockSwitch.ClockSize int clockSize, boolean animate) { - if (!mCanShowDoubleLineClock && clockSize == KeyguardClockSwitch.LARGE) { - return; - } - - mCurrentClockSize = clockSize; - setDateWeatherVisibility(); - - ClockController clock = getClock(); - boolean appeared = mView.switchToClock(clockSize, animate); - if (clock != null && animate && appeared && clockSize == LARGE) { - mUiExecutor.executeDelayed(() -> clock.getLargeClock().getAnimations().enter(), - KeyguardClockSwitch.CLOCK_IN_START_DELAY_MILLIS); - } - } - - /** - * Animates the clock view between folded and unfolded states - */ - public void animateFoldToAod(float foldFraction) { - ClockController clock = getClock(); - if (clock != null) { - clock.getSmallClock().getAnimations().fold(foldFraction); - clock.getLargeClock().getAnimations().fold(foldFraction); - } - } - - /** - * Refresh clock. Called in response to TIME_TICK broadcasts. - */ - void refresh() { - mLogBuffer.log(TAG, LogLevel.INFO, "refresh"); - if (mSmartspaceController != null) { - mSmartspaceController.requestSmartspaceUpdate(); - } - ClockController clock = getClock(); - if (clock != null) { - clock.getSmallClock().getEvents().onTimeTick(); - clock.getLargeClock().getEvents().onTimeTick(); - } - } - - /** - * Update position of the view, with optional animation. Move the slice view and the clock - * slightly towards the center in order to prevent burn-in. Y positioning occurs at the - * view parent level. The large clock view will scale instead of using x position offsets, to - * keep the clock centered. - */ - void updatePosition(int x, float scale, AnimationProperties props, boolean animate) { - x = getCurrentLayoutDirection() == View.LAYOUT_DIRECTION_RTL ? -x : x; - if (!MigrateClocksToBlueprint.isEnabled()) { - PropertyAnimator.setProperty(mSmallClockFrame, AnimatableProperty.TRANSLATION_X, - x, props, animate); - PropertyAnimator.setProperty(mLargeClockFrame, AnimatableProperty.SCALE_X, - scale, props, animate); - PropertyAnimator.setProperty(mLargeClockFrame, AnimatableProperty.SCALE_Y, - scale, props, animate); - - } - - if (mStatusArea != null) { - PropertyAnimator.setProperty(mStatusArea, KeyguardStatusAreaView.TRANSLATE_X_AOD, - x, props, animate); - } - } - - /** - * Get y-bottom position of the currently visible clock on the keyguard. - * We can't directly getBottom() because clock changes positions in AOD for burn-in - */ - int getClockBottom(int statusBarHeaderHeight) { - ClockController clock = getClock(); - if (clock == null) { - return 0; - } - - if (MigrateClocksToBlueprint.isEnabled()) { - return 0; - } - - if (mLargeClockFrame.getVisibility() == View.VISIBLE) { - // This gets the expected clock bottom if mLargeClockFrame had a top margin, but it's - // top margin only contributed to height and didn't move the top of the view (as this - // was the computation previously). As we no longer have a margin, we add this back - // into the computation manually. - int frameHeight = mLargeClockFrame.getHeight(); - int clockHeight = clock.getLargeClock().getView().getHeight(); - return frameHeight / 2 + clockHeight / 2 + mKeyguardLargeClockTopMargin / -2; - } else { - int clockHeight = clock.getSmallClock().getView().getHeight(); - return clockHeight + statusBarHeaderHeight + mKeyguardSmallClockTopMargin; - } - } - - /** - * Get the height of the currently visible clock on the keyguard. - */ - int getClockHeight() { - ClockController clock = getClock(); - if (clock == null) { - return 0; - } - - if (mLargeClockFrame.getVisibility() == View.VISIBLE) { - return clock.getLargeClock().getView().getHeight(); - } else { - return clock.getSmallClock().getView().getHeight(); - } - } - - boolean isClockTopAligned() { - if (MigrateClocksToBlueprint.isEnabled()) { - return mKeyguardClockInteractor.getClockSize().getValue().getLegacyValue() == LARGE; - } - return mLargeClockFrame.getVisibility() != View.VISIBLE; - } - - private void setClock(ClockController clock) { - if (MigrateClocksToBlueprint.isEnabled()) { - return; - } - if (clock != null && mLogBuffer != null) { - mLogBuffer.log(TAG, LogLevel.INFO, "New Clock"); - } - - mClockEventController.setClock(clock); - mView.setClock(clock, mStatusBarStateController.getState()); - setDateWeatherVisibility(); - } - - @Nullable - public ClockController getClock() { - if (MigrateClocksToBlueprint.isEnabled()) { - return mKeyguardClockInteractor.getCurrentClock().getValue(); - } else { - return mClockEventController.getClock(); - } - } - - private int getCurrentLayoutDirection() { - return TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()); - } - - private void updateDoubleLineClock() { - if (MigrateClocksToBlueprint.isEnabled()) { - return; - } - mCanShowDoubleLineClock = mSecureSettings.getIntForUser( - Settings.Secure.LOCKSCREEN_USE_DOUBLE_LINE_CLOCK, mView.getResources() - .getInteger(com.android.internal.R.integer.config_doublelineClockDefault), - UserHandle.USER_CURRENT) != 0; - - if (!mCanShowDoubleLineClock) { - mUiExecutor.execute(() -> displayClock(KeyguardClockSwitch.SMALL, - /* animate */ true)); - } - } - - private void setDateWeatherVisibility() { - if (mDateWeatherView != null) { - mUiExecutor.execute(() -> { - mDateWeatherView.setVisibility(clockHasCustomWeatherDataDisplay() - ? mKeyguardDateWeatherViewInvisibility - : View.VISIBLE); - }); - } - } - - private void setWeatherVisibility() { - if (mWeatherView != null) { - mUiExecutor.execute(() -> { - mWeatherView.setVisibility( - mSmartspaceController.isWeatherEnabled() ? View.VISIBLE : View.GONE); - }); - } - } - - /** - * Sets the clipChildren property on relevant views, to allow the smartspace to draw out of - * bounds during the unlock transition. - */ - private void setClipChildrenForUnlock(boolean clip) { - if (mStatusArea != null) { - mStatusArea.setClipChildren(clip); - } - } - - @Override - public void dump(@NonNull PrintWriter pw, @NonNull String[] args) { - pw.println("currentClockSizeLarge: " + (mCurrentClockSize == LARGE)); - pw.println("mCanShowDoubleLineClock: " + mCanShowDoubleLineClock); - mView.dump(pw, args); - mClockRegistry.dump(pw, args); - ClockController clock = getClock(); - if (clock != null) { - clock.dump(pw); - } - final RegionSampler smallRegionSampler = mClockEventController.getSmallRegionSampler(); - if (smallRegionSampler != null) { - smallRegionSampler.dump(pw); - } - final RegionSampler largeRegionSampler = mClockEventController.getLargeRegionSampler(); - if (largeRegionSampler != null) { - largeRegionSampler.dump(pw); - } - } - - /** Returns true if the clock handles the display of weather information */ - private boolean clockHasCustomWeatherDataDisplay() { - ClockController clock = getClock(); - if (clock == null) { - return false; - } - - return ((mCurrentClockSize == LARGE) ? clock.getLargeClock() : clock.getSmallClock()) - .getConfig().getHasCustomWeatherDataDisplay(); - } - - private void removeViewsFromStatusArea() { - for (int i = mStatusArea.getChildCount() - 1; i >= 0; i--) { - final View childView = mStatusArea.getChildAt(i); - if (childView.getTag(R.id.tag_smartspace_view) != null) { - mStatusArea.removeViewAt(i); - } - } - } -} diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSliceViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSliceViewController.java index 63088aaf7ff4..42460617d476 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSliceViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSliceViewController.java @@ -22,7 +22,6 @@ import android.app.PendingIntent; import android.net.Uri; import android.os.Handler; import android.os.Trace; -import android.provider.Settings; import android.util.Log; import android.view.Display; import android.view.View; @@ -38,7 +37,6 @@ import androidx.slice.widget.RowContent; import androidx.slice.widget.SliceContent; import androidx.slice.widget.SliceLiveData; -import com.android.keyguard.dagger.KeyguardStatusViewScope; import com.android.systemui.Dumpable; import com.android.systemui.Flags; import com.android.systemui.dagger.qualifiers.Background; @@ -48,7 +46,6 @@ import com.android.systemui.keyguard.KeyguardSliceProvider; import com.android.systemui.plugins.ActivityStarter; import com.android.systemui.settings.DisplayTracker; import com.android.systemui.statusbar.policy.ConfigurationController; -import com.android.systemui.tuner.TunerService; import com.android.systemui.util.ViewController; import java.io.PrintWriter; @@ -59,7 +56,6 @@ import java.util.stream.Collectors; import javax.inject.Inject; /** Controller for a {@link KeyguardSliceView}. */ -@KeyguardStatusViewScope public class KeyguardSliceViewController extends ViewController<KeyguardSliceView> implements Dumpable { private static final String TAG = "KeyguardSliceViewCtrl"; @@ -68,7 +64,6 @@ public class KeyguardSliceViewController extends ViewController<KeyguardSliceVie private final Handler mBgHandler; private final ActivityStarter mActivityStarter; private final ConfigurationController mConfigurationController; - private final TunerService mTunerService; private final DumpManager mDumpManager; private final DisplayTracker mDisplayTracker; private int mDisplayId; @@ -77,8 +72,6 @@ public class KeyguardSliceViewController extends ViewController<KeyguardSliceVie private Slice mSlice; private Map<View, PendingIntent> mClickActions; - TunerService.Tunable mTunable = (key, newValue) -> setupUri(newValue); - ConfigurationController.ConfigurationListener mConfigurationListener = new ConfigurationController.ConfigurationListener() { @Override @@ -116,7 +109,6 @@ public class KeyguardSliceViewController extends ViewController<KeyguardSliceVie KeyguardSliceView keyguardSliceView, ActivityStarter activityStarter, ConfigurationController configurationController, - TunerService tunerService, DumpManager dumpManager, DisplayTracker displayTracker) { super(keyguardSliceView); @@ -124,7 +116,6 @@ public class KeyguardSliceViewController extends ViewController<KeyguardSliceVie mBgHandler = bgHandler; mActivityStarter = activityStarter; mConfigurationController = configurationController; - mTunerService = tunerService; mDumpManager = dumpManager; mDisplayTracker = displayTracker; } @@ -135,7 +126,6 @@ public class KeyguardSliceViewController extends ViewController<KeyguardSliceVie if (display != null) { mDisplayId = display.getDisplayId(); } - mTunerService.addTunable(mTunable, Settings.Secure.KEYGUARD_SLICE_URI); // Make sure we always have the most current slice if (mDisplayId == mDisplayTracker.getDefaultDisplayId() && mLiveData != null) { mLiveData.observeForever(mObserver); @@ -153,7 +143,6 @@ public class KeyguardSliceViewController extends ViewController<KeyguardSliceVie if (mDisplayId == mDisplayTracker.getDefaultDisplayId()) { mLiveData.removeObserver(mObserver); } - mTunerService.removeTunable(mTunable); mConfigurationController.removeCallback(mConfigurationListener); mDumpManager.unregisterDumpable( TAG + "@" + Integer.toHexString( diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusAreaView.kt b/packages/SystemUI/src/com/android/keyguard/KeyguardStatusAreaView.kt deleted file mode 100644 index 11b1a7d00056..000000000000 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusAreaView.kt +++ /dev/null @@ -1,118 +0,0 @@ -package com.android.keyguard - -import android.content.Context -import android.util.AttributeSet -import android.util.FloatProperty -import android.widget.LinearLayout -import com.android.systemui.res.R -import com.android.systemui.statusbar.notification.AnimatableProperty - -class KeyguardStatusAreaView( - context: Context, - attrs: AttributeSet? = null, -) : LinearLayout(context, attrs) { - var translateXFromClockDesign = 0f - get() = field - set(value) { - field = value - translationX = translateXFromAod + translateXFromClockDesign + translateXFromUnfold - } - - var translateXFromAod = 0f - get() = field - set(value) { - field = value - translationX = translateXFromAod + translateXFromClockDesign + translateXFromUnfold - } - - var translateXFromUnfold = 0F - get() = field - set(value) { - field = value - translationX = translateXFromAod + translateXFromClockDesign + translateXFromUnfold - } - - var translateYFromClockSize = 0f - get() = field - set(value) { - field = value - translationY = value + translateYFromClockDesign - } - - var translateYFromClockDesign = 0f - get() = field - set(value) { - field = value - translationY = value + translateYFromClockSize - } - - companion object { - @JvmField - val TRANSLATE_X_CLOCK_DESIGN = - AnimatableProperty.from( - object : FloatProperty<KeyguardStatusAreaView>("TranslateXClockDesign") { - override fun setValue(view: KeyguardStatusAreaView, value: Float) { - view.translateXFromClockDesign = value - } - - override fun get(view: KeyguardStatusAreaView): Float { - return view.translateXFromClockDesign - } - }, - R.id.translate_x_clock_design_animator_tag, - R.id.translate_x_clock_design_animator_start_tag, - R.id.translate_x_clock_design_animator_end_tag - ) - - @JvmField - val TRANSLATE_X_AOD = - AnimatableProperty.from( - object : FloatProperty<KeyguardStatusAreaView>("TranslateXAod") { - override fun setValue(view: KeyguardStatusAreaView, value: Float) { - view.translateXFromAod = value - } - - override fun get(view: KeyguardStatusAreaView): Float { - return view.translateXFromAod - } - }, - R.id.translate_x_aod_animator_tag, - R.id.translate_x_aod_animator_start_tag, - R.id.translate_x_aod_animator_end_tag - ) - - @JvmField - val TRANSLATE_Y_CLOCK_SIZE = - AnimatableProperty.from( - object : FloatProperty<KeyguardStatusAreaView>("TranslateYClockSize") { - override fun setValue(view: KeyguardStatusAreaView, value: Float) { - view.translateYFromClockSize = value - } - - override fun get(view: KeyguardStatusAreaView): Float { - return view.translateYFromClockSize - } - }, - R.id.translate_y_clock_size_animator_tag, - R.id.translate_y_clock_size_animator_start_tag, - R.id.translate_y_clock_size_animator_end_tag - ) - - @JvmField - val TRANSLATE_Y_CLOCK_DESIGN = - AnimatableProperty.from( - object : FloatProperty<KeyguardStatusAreaView>("TranslateYClockDesign") { - override fun setValue(view: KeyguardStatusAreaView, value: Float) { - view.translateYFromClockDesign = value - } - - override fun get(view: KeyguardStatusAreaView): Float { - return view.translateYFromClockDesign - } - }, - R.id.translate_y_clock_design_animator_tag, - R.id.translate_y_clock_design_animator_start_tag, - R.id.translate_y_clock_design_animator_end_tag - ) - } -} diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusContainer.kt b/packages/SystemUI/src/com/android/keyguard/KeyguardStatusContainer.kt deleted file mode 100644 index 298eff27060b..000000000000 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusContainer.kt +++ /dev/null @@ -1,22 +0,0 @@ -package com.android.keyguard - -import android.content.Context -import android.graphics.Canvas -import android.util.AttributeSet -import android.widget.LinearLayout - -class KeyguardStatusContainer( - context: Context, - attrs: AttributeSet, -) : LinearLayout(context, attrs) { - private var drawAlpha: Int = 255 - - protected override fun onSetAlpha(alpha: Int): Boolean { - drawAlpha = alpha - return true - } - - protected override fun dispatchDraw(canvas: Canvas) { - KeyguardClockFrame.saveCanvasAlpha(this, canvas, drawAlpha) { super.dispatchDraw(canvas) } - } -} diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardStatusView.java deleted file mode 100644 index 073f33fe5245..000000000000 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusView.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.keyguard; - -import static java.util.Collections.emptySet; - -import android.content.Context; -import android.graphics.Canvas; -import android.os.Build; -import android.os.Trace; -import android.util.AttributeSet; -import android.view.MotionEvent; -import android.view.View; -import android.view.ViewGroup; -import android.view.ViewPropertyAnimator; -import android.widget.GridLayout; - -import com.android.systemui.res.R; -import com.android.systemui.shade.TouchLogger; -import com.android.systemui.statusbar.CrossFadeHelper; - -import java.util.Set; - -/** - * View consisting of: - * - keyguard clock - * - media player (split shade mode only) - */ -public class KeyguardStatusView extends GridLayout { - private static final boolean DEBUG = KeyguardConstants.DEBUG; - private static final String TAG = "KeyguardStatusView"; - - private ViewGroup mStatusViewContainer; - private KeyguardClockSwitch mClockView; - private KeyguardSliceView mKeyguardSlice; - private View mMediaHostContainer; - - private int mDrawAlpha = 255; - private float mDarkAmount = 0; - - public KeyguardStatusView(Context context) { - this(context, null, 0); - } - - public KeyguardStatusView(Context context, AttributeSet attrs) { - this(context, attrs, 0); - } - - public KeyguardStatusView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - @Override - protected void onFinishInflate() { - super.onFinishInflate(); - mStatusViewContainer = findViewById(R.id.status_view_container); - - mClockView = findViewById(R.id.keyguard_clock_container); - if (KeyguardClockAccessibilityDelegate.isNeeded(mContext)) { - mClockView.setAccessibilityDelegate(new KeyguardClockAccessibilityDelegate(mContext)); - } - - mKeyguardSlice = findViewById(R.id.keyguard_slice_view); - - mMediaHostContainer = findViewById(R.id.status_view_media_container); - - updateDark(); - } - - void setDarkAmount(float darkAmount) { - if (mDarkAmount == darkAmount) { - return; - } - mDarkAmount = darkAmount; - CrossFadeHelper.fadeOut(mMediaHostContainer, darkAmount); - updateDark(); - } - - void updateDark() { - mKeyguardSlice.setDarkAmount(mDarkAmount); - } - - /** Sets a translationY value on every child view except for the media view. */ - public void setChildrenTranslationY(float translationY, boolean excludeMedia) { - setChildrenTranslationYExcluding(translationY, - excludeMedia ? Set.of(mMediaHostContainer) : emptySet()); - } - - /** Sets a translationY value on every view except for the views in the provided set. */ - private void setChildrenTranslationYExcluding(float translationY, Set<View> excludedViews) { - for (int i = 0; i < mStatusViewContainer.getChildCount(); i++) { - final View child = mStatusViewContainer.getChildAt(i); - - if (!excludedViews.contains(child)) { - child.setTranslationY(translationY); - } - } - } - - @Override - public boolean dispatchTouchEvent(MotionEvent ev) { - return TouchLogger.logDispatchTouch(TAG, ev, super.dispatchTouchEvent(ev)); - } - - @Override - public ViewPropertyAnimator animate() { - if (Build.IS_DEBUGGABLE) { - throw new IllegalArgumentException( - "KeyguardStatusView does not support ViewPropertyAnimator. " - + "Use PropertyAnimator instead."); - } - return super.animate(); - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - Trace.beginSection("KeyguardStatusView#onMeasure"); - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - Trace.endSection(); - } - - @Override - protected boolean onSetAlpha(int alpha) { - mDrawAlpha = alpha; - return true; - } - - @Override - protected void dispatchDraw(Canvas canvas) { - KeyguardClockFrame.saveCanvasAlpha( - this, canvas, mDrawAlpha, - c -> { - super.dispatchDraw(c); - return kotlin.Unit.INSTANCE; - }); - } -} diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java deleted file mode 100644 index 0684824ea0b8..000000000000 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java +++ /dev/null @@ -1,664 +0,0 @@ -/* - * Copyright (C) 2020 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.keyguard; - -import static androidx.constraintlayout.widget.ConstraintSet.END; -import static androidx.constraintlayout.widget.ConstraintSet.PARENT_ID; - -import static com.android.internal.jank.InteractionJankMonitor.CUJ_LOCKSCREEN_CLOCK_MOVE_ANIMATION; -import static com.android.systemui.util.kotlin.JavaAdapterKt.collectFlow; - -import android.animation.Animator; -import android.animation.ValueAnimator; -import android.annotation.Nullable; -import android.content.res.Configuration; -import android.graphics.Rect; -import android.transition.ChangeBounds; -import android.transition.Transition; -import android.transition.TransitionListenerAdapter; -import android.transition.TransitionManager; -import android.transition.TransitionSet; -import android.transition.TransitionValues; -import android.util.Slog; -import android.view.View; -import android.view.ViewGroup; -import android.widget.FrameLayout; - -import androidx.annotation.NonNull; -import androidx.annotation.VisibleForTesting; -import androidx.constraintlayout.widget.ConstraintLayout; -import androidx.constraintlayout.widget.ConstraintSet; -import androidx.viewpager.widget.ViewPager; - -import com.android.app.animation.Interpolators; -import com.android.internal.jank.InteractionJankMonitor; -import com.android.keyguard.KeyguardClockSwitch.ClockSize; -import com.android.keyguard.logging.KeyguardLogger; -import com.android.systemui.animation.ViewHierarchyAnimator; -import com.android.systemui.keyguard.MigrateClocksToBlueprint; -import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor; -import com.android.systemui.plugins.clocks.ClockController; -import com.android.systemui.power.domain.interactor.PowerInteractor; -import com.android.systemui.power.shared.model.ScreenPowerState; -import com.android.systemui.res.R; -import com.android.systemui.statusbar.notification.AnimatableProperty; -import com.android.systemui.statusbar.notification.PropertyAnimator; -import com.android.systemui.statusbar.notification.stack.AnimationProperties; -import com.android.systemui.statusbar.notification.stack.StackStateAnimator; -import com.android.systemui.statusbar.phone.DozeParameters; -import com.android.systemui.statusbar.phone.ScreenOffAnimationController; -import com.android.systemui.statusbar.policy.ConfigurationController; -import com.android.systemui.statusbar.policy.KeyguardStateController; -import com.android.systemui.util.ViewController; - -import kotlin.coroutines.CoroutineContext; -import kotlin.coroutines.EmptyCoroutineContext; - -import javax.inject.Inject; - -/** - * Injectable controller for {@link KeyguardStatusView}. - */ -public class KeyguardStatusViewController extends ViewController<KeyguardStatusView> { - private static final boolean DEBUG = KeyguardConstants.DEBUG; - @VisibleForTesting static final String TAG = "KeyguardStatusViewController"; - private static final long STATUS_AREA_HEIGHT_ANIMATION_MILLIS = 133; - - /** - * Duration to use for the animator when the keyguard status view alignment changes, and a - * custom clock animation is in use. - */ - private static final int KEYGUARD_STATUS_VIEW_CUSTOM_CLOCK_MOVE_DURATION = 1000; - - public static final AnimationProperties CLOCK_ANIMATION_PROPERTIES = - new AnimationProperties().setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD); - - private final KeyguardSliceViewController mKeyguardSliceViewController; - private final KeyguardClockSwitchController mKeyguardClockSwitchController; - private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; - private final ConfigurationController mConfigurationController; - private final KeyguardVisibilityHelper mKeyguardVisibilityHelper; - private final InteractionJankMonitor mInteractionJankMonitor; - private final Rect mClipBounds = new Rect(); - private final KeyguardInteractor mKeyguardInteractor; - private final PowerInteractor mPowerInteractor; - private final DozeParameters mDozeParameters; - - private View mStatusArea = null; - private ValueAnimator mStatusAreaHeightAnimator = null; - - private Boolean mSplitShadeEnabled = false; - private Boolean mStatusViewCentered = true; - - private final TransitionListenerAdapter mKeyguardStatusAlignmentTransitionListener = - new TransitionListenerAdapter() { - @Override - public void onTransitionCancel(Transition transition) { - mInteractionJankMonitor.cancel(CUJ_LOCKSCREEN_CLOCK_MOVE_ANIMATION); - } - - @Override - public void onTransitionEnd(Transition transition) { - mInteractionJankMonitor.end(CUJ_LOCKSCREEN_CLOCK_MOVE_ANIMATION); - } - }; - - private final View.OnLayoutChangeListener mStatusAreaLayoutChangeListener = - new View.OnLayoutChangeListener() { - @Override - public void onLayoutChange(View v, - int left, int top, int right, int bottom, - int oldLeft, int oldTop, int oldRight, int oldBottom - ) { - if (!mDozeParameters.getAlwaysOn()) { - return; - } - - int oldHeight = oldBottom - oldTop; - int diff = v.getHeight() - oldHeight; - if (diff == 0) { - return; - } - - int startValue = -1 * diff; - long duration = STATUS_AREA_HEIGHT_ANIMATION_MILLIS; - if (mStatusAreaHeightAnimator != null - && mStatusAreaHeightAnimator.isRunning()) { - duration += mStatusAreaHeightAnimator.getDuration() - - mStatusAreaHeightAnimator.getCurrentPlayTime(); - startValue += (int) mStatusAreaHeightAnimator.getAnimatedValue(); - mStatusAreaHeightAnimator.cancel(); - mStatusAreaHeightAnimator = null; - } - - mStatusAreaHeightAnimator = ValueAnimator.ofInt(startValue, 0); - mStatusAreaHeightAnimator.setDuration(duration); - final View nic = mKeyguardClockSwitchController.getAodNotifIconContainer(); - if (nic != null) { - mStatusAreaHeightAnimator.addUpdateListener(anim -> { - nic.setTranslationY((int) anim.getAnimatedValue()); - }); - } - mStatusAreaHeightAnimator.start(); - } - }; - - @Inject - public KeyguardStatusViewController( - KeyguardStatusView keyguardStatusView, - KeyguardSliceViewController keyguardSliceViewController, - KeyguardClockSwitchController keyguardClockSwitchController, - KeyguardStateController keyguardStateController, - KeyguardUpdateMonitor keyguardUpdateMonitor, - ConfigurationController configurationController, - DozeParameters dozeParameters, - ScreenOffAnimationController screenOffAnimationController, - KeyguardLogger logger, - InteractionJankMonitor interactionJankMonitor, - KeyguardInteractor keyguardInteractor, - PowerInteractor powerInteractor) { - super(keyguardStatusView); - mKeyguardSliceViewController = keyguardSliceViewController; - mKeyguardClockSwitchController = keyguardClockSwitchController; - mKeyguardUpdateMonitor = keyguardUpdateMonitor; - mConfigurationController = configurationController; - mDozeParameters = dozeParameters; - mKeyguardVisibilityHelper = new KeyguardVisibilityHelper(mView, keyguardStateController, - dozeParameters, screenOffAnimationController, /* animateYPos= */ true, - logger.getBuffer()); - mInteractionJankMonitor = interactionJankMonitor; - mKeyguardInteractor = keyguardInteractor; - mPowerInteractor = powerInteractor; - } - - @Override - public void onInit() { - mKeyguardClockSwitchController.init(); - final View mediaHostContainer = mView.findViewById(R.id.status_view_media_container); - if (mediaHostContainer != null) { - mKeyguardClockSwitchController.getView().addOnLayoutChangeListener( - (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> { - if (!mSplitShadeEnabled - || mKeyguardClockSwitchController.getView().getSplitShadeCentered() - // Note: isKeyguardVisible() returns false after Launcher -> AOD. - || !mKeyguardUpdateMonitor.isKeyguardVisible()) { - return; - } - - int oldHeight = oldBottom - oldTop; - if (v.getHeight() == oldHeight) return; - - if (mediaHostContainer.getVisibility() != View.VISIBLE - // If the media is appearing, also don't do the transition. - || mediaHostContainer.getHeight() == 0) { - return; - } - - ViewHierarchyAnimator.Companion.animateNextUpdate(mediaHostContainer, - Interpolators.STANDARD, /* duration= */ 500L, - /* animateChildren= */ false); - }); - } - - if (MigrateClocksToBlueprint.isEnabled()) { - startCoroutines(EmptyCoroutineContext.INSTANCE); - mView.setVisibility(View.GONE); - } - } - - void startCoroutines(CoroutineContext context) { - collectFlow(mView, mKeyguardInteractor.getDozeTimeTick(), - (Long millis) -> { - dozeTimeTick(); - }, context); - - collectFlow(mView, mPowerInteractor.getScreenPowerState(), - (ScreenPowerState powerState) -> { - if (powerState == ScreenPowerState.SCREEN_TURNING_ON) { - dozeTimeTick(); - } - }, context); - } - - public KeyguardStatusView getView() { - return mView; - } - - @Override - protected void onViewAttached() { - mStatusArea = mView.findViewById(R.id.keyguard_status_area); - if (MigrateClocksToBlueprint.isEnabled()) { - return; - } - - mStatusArea.addOnLayoutChangeListener(mStatusAreaLayoutChangeListener); - mKeyguardUpdateMonitor.registerCallback(mInfoCallback); - mConfigurationController.addCallback(mConfigurationListener); - } - - @Override - protected void onViewDetached() { - if (MigrateClocksToBlueprint.isEnabled()) { - return; - } - - mStatusArea.removeOnLayoutChangeListener(mStatusAreaLayoutChangeListener); - mKeyguardUpdateMonitor.removeCallback(mInfoCallback); - mConfigurationController.removeCallback(mConfigurationListener); - } - - /** Sets the StatusView as shown on an external display. */ - public void setDisplayedOnSecondaryDisplay() { - mKeyguardClockSwitchController.setShownOnSecondaryDisplay(true); - } - - /** - * Updates views on doze time tick. - */ - public void dozeTimeTick() { - refreshTime(); - mKeyguardSliceViewController.refresh(); - } - - /** - * Set which clock should be displayed on the keyguard. The other one will be automatically - * hidden. - */ - public void displayClock(@ClockSize int clockSize, boolean animate) { - mKeyguardClockSwitchController.displayClock(clockSize, animate); - } - - /** - * Performs fold to aod animation of the clocks (changes font weight from bold to thin). - * This animation is played when AOD is enabled and foldable device is fully folded, it is - * displayed on the outer screen - * @param foldFraction current fraction of fold animation complete - */ - public void animateFoldToAod(float foldFraction) { - mKeyguardClockSwitchController.animateFoldToAod(foldFraction); - } - - /** - * Sets a translationY on the views on the keyguard, except on the media view. - */ - public void setTranslationY(float translationY, boolean excludeMedia) { - mView.setChildrenTranslationY(translationY, excludeMedia); - } - - /** - * Set keyguard status view alpha. - */ - public void setAlpha(float alpha) { - if (!mKeyguardVisibilityHelper.isVisibilityAnimating()) { - mView.setAlpha(alpha); - } - } - - /** - * Update the pivot position based on the parent view - */ - public void updatePivot(float parentWidth, float parentHeight) { - mView.setPivotX(parentWidth / 2f); - mView.setPivotY(mKeyguardClockSwitchController.getClockHeight() / 2f); - } - - /** - * Get the height of the keyguard status view without the notification icon area, as that's - * only visible on AOD. - * - * We internally animate height changes to the status area to prevent discontinuities in the - * doze animation introduced by the height suddenly changing due to smartpace. - */ - public int getLockscreenHeight() { - int heightAnimValue = mStatusAreaHeightAnimator == null ? 0 : - (int) mStatusAreaHeightAnimator.getAnimatedValue(); - return mView.getHeight() + heightAnimValue - - mKeyguardClockSwitchController.getNotificationIconAreaHeight(); - } - - /** - * Get y-bottom position of the currently visible clock. - */ - public int getClockBottom(int statusBarHeaderHeight) { - return mKeyguardClockSwitchController.getClockBottom(statusBarHeaderHeight); - } - - /** - * @return true if the currently displayed clock is top aligned (as opposed to center aligned) - */ - public boolean isClockTopAligned() { - return mKeyguardClockSwitchController.isClockTopAligned(); - } - - /** - * Pass top margin from ClockPositionAlgorithm in NotificationPanelViewController - * Use for clock view in LS to compensate for top margin to align to the screen - * Regardless of translation from AOD and unlock gestures - */ - public void setLockscreenClockY(int clockY) { - mKeyguardClockSwitchController.setLockscreenClockY(clockY); - } - - /** - * Set whether the view accessibility importance mode. - */ - public void setStatusAccessibilityImportance(int mode) { - mView.setImportantForAccessibility(mode); - } - - @VisibleForTesting - void setProperty(AnimatableProperty property, float value, boolean animate) { - PropertyAnimator.setProperty(mView, property, value, CLOCK_ANIMATION_PROPERTIES, animate); - } - - /** - * Update position of the view with an optional animation - */ - public void updatePosition(int x, int y, float scale, boolean animate) { - setProperty(AnimatableProperty.Y, y, animate); - - ClockController clock = mKeyguardClockSwitchController.getClock(); - if (clock != null && clock.getConfig().getUseAlternateSmartspaceAODTransition()) { - // If requested, scale the entire view instead of just the clock view - mKeyguardClockSwitchController.updatePosition(x, 1f /* scale */, - CLOCK_ANIMATION_PROPERTIES, animate); - setProperty(AnimatableProperty.SCALE_X, scale, animate); - setProperty(AnimatableProperty.SCALE_Y, scale, animate); - } else { - mKeyguardClockSwitchController.updatePosition(x, scale, - CLOCK_ANIMATION_PROPERTIES, animate); - setProperty(AnimatableProperty.SCALE_X, 1f, animate); - setProperty(AnimatableProperty.SCALE_Y, 1f, animate); - } - } - - /** - * Set the visibility of the keyguard status view based on some new state. - */ - public void setKeyguardStatusViewVisibility( - int statusBarState, - boolean keyguardFadingAway, - boolean goingToFullShade, - int oldStatusBarState) { - mKeyguardVisibilityHelper.setViewVisibility( - statusBarState, keyguardFadingAway, goingToFullShade, oldStatusBarState); - } - - private void refreshTime() { - mKeyguardClockSwitchController.refresh(); - } - - private final ConfigurationController.ConfigurationListener mConfigurationListener = - new ConfigurationController.ConfigurationListener() { - @Override - public void onLocaleListChanged() { - refreshTime(); - mKeyguardClockSwitchController.onLocaleListChanged(); - } - - @Override - public void onConfigChanged(Configuration newConfig) { - mKeyguardClockSwitchController.onConfigChanged(); - } - }; - - private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() { - @Override - public void onTimeChanged() { - Slog.v(TAG, "onTimeChanged"); - refreshTime(); - } - - @Override - public void onKeyguardVisibilityChanged(boolean visible) { - if (visible) { - if (DEBUG) Slog.v(TAG, "refresh statusview visible:true"); - refreshTime(); - } - } - }; - - /** - * Rect that specifies how KSV should be clipped, on its parent's coordinates. - */ - public void setClipBounds(Rect clipBounds) { - if (clipBounds != null) { - mClipBounds.set(clipBounds.left, (int) (clipBounds.top - mView.getY()), - clipBounds.right, (int) (clipBounds.bottom - mView.getY())); - mView.setClipBounds(mClipBounds); - } else { - mView.setClipBounds(null); - } - } - - /** - * Returns true if the large clock will block the notification shelf in AOD - */ - public boolean isLargeClockBlockingNotificationShelf() { - ClockController clock = mKeyguardClockSwitchController.getClock(); - return clock != null && clock.getLargeClock().getConfig().getHasCustomWeatherDataDisplay(); - } - - /** - * Set if the split shade is enabled - */ - public void setSplitShadeEnabled(boolean enabled) { - mKeyguardClockSwitchController.setSplitShadeEnabled(enabled); - mSplitShadeEnabled = enabled; - } - - /** - * Updates the alignment of the KeyguardStatusView and animates the transition if requested. - */ - public void updateAlignment( - ConstraintLayout layout, - boolean splitShadeEnabled, - boolean shouldBeCentered, - boolean animate) { - if (MigrateClocksToBlueprint.isEnabled()) { - mKeyguardInteractor.setClockShouldBeCentered(shouldBeCentered); - } else { - mKeyguardClockSwitchController.setSplitShadeCentered( - splitShadeEnabled && shouldBeCentered); - } - if (mStatusViewCentered == shouldBeCentered) { - return; - } - - mStatusViewCentered = shouldBeCentered; - if (layout == null) { - return; - } - - ConstraintSet constraintSet = new ConstraintSet(); - constraintSet.clone(layout); - int guideline; - if (MigrateClocksToBlueprint.isEnabled()) { - guideline = R.id.split_shade_guideline; - } else { - guideline = R.id.qs_edge_guideline; - } - - int statusConstraint = shouldBeCentered ? PARENT_ID : guideline; - constraintSet.connect(R.id.keyguard_status_view, END, statusConstraint, END); - if (!animate) { - constraintSet.applyTo(layout); - return; - } - - mInteractionJankMonitor.begin(mView, CUJ_LOCKSCREEN_CLOCK_MOVE_ANIMATION); - /* This transition blocks any layout changes while running. For that reason - * special logic with setting visibility was added to {@link BcSmartspaceView#setDozing} - * for split shade to avoid jump of the media object. */ - ChangeBounds transition = new ChangeBounds(); - if (splitShadeEnabled) { - // Excluding media from the transition on split-shade, as it doesn't transition - // horizontally properly. - transition.excludeTarget(R.id.status_view_media_container, true); - - // Exclude smartspace viewpager and its children from the transition. - // - Each step of the transition causes the ViewPager to invoke resize, - // which invokes scrolling to the recalculated position. The scrolling - // actions are congested, resulting in kinky translation, and - // delay in settling to the final position. (http://b/281620564#comment1) - // - Also, the scrolling is unnecessary in the transition. We just want - // the viewpager to stay on the same page. - // - Exclude by Class type instead of resource id, since the resource id - // isn't available for all devices, and probably better to exclude all - // ViewPagers any way. - transition.excludeTarget(ViewPager.class, true); - transition.excludeChildren(ViewPager.class, true); - } - - transition.setInterpolator(Interpolators.FAST_OUT_SLOW_IN); - transition.setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD); - - ClockController clock = mKeyguardClockSwitchController.getClock(); - boolean customClockAnimation = clock != null - && clock.getLargeClock().getConfig().getHasCustomPositionUpdatedAnimation(); - // When migrateClocksToBlueprint is on, customized clock animation is conducted in - // KeyguardClockViewBinder - if (customClockAnimation && !MigrateClocksToBlueprint.isEnabled()) { - // Find the clock, so we can exclude it from this transition. - FrameLayout clockContainerView = mView.findViewById( - com.android.systemui.customization.R.id.lockscreen_clock_view_large); - - // The clock container can sometimes be null. If it is, just fall back to the - // old animation rather than setting up the custom animations. - if (clockContainerView == null || clockContainerView.getChildCount() == 0) { - transition.addListener(mKeyguardStatusAlignmentTransitionListener); - TransitionManager.beginDelayedTransition(layout, transition); - } else { - View clockView = clockContainerView.getChildAt(0); - - TransitionSet set = new TransitionSet(); - set.addTransition(transition); - - SplitShadeTransitionAdapter adapter = - new SplitShadeTransitionAdapter(mKeyguardClockSwitchController); - - // Use linear here, so the actual clock can pick its own interpolator. - adapter.setInterpolator(Interpolators.LINEAR); - adapter.setDuration(KEYGUARD_STATUS_VIEW_CUSTOM_CLOCK_MOVE_DURATION); - adapter.addTarget(clockView); - set.addTransition(adapter); - - if (splitShadeEnabled) { - // Exclude smartspace viewpager and its children from the transition set. - // - This is necessary in addition to excluding them from the - // ChangeBounds child transition. - // - Without this, the viewpager is scrolled to the new position - // (corresponding to its end size) before the size change is realized. - // Note that the size change is realized at the end of the ChangeBounds - // transition. With the "prescrolling", the viewpager ends up in a weird - // position, then recovers smoothly during the transition, and ends at - // the position for the current page. - // - Exclude by Class type instead of resource id, since the resource id - // isn't available for all devices, and probably better to exclude all - // ViewPagers any way. - set.excludeTarget(ViewPager.class, true); - set.excludeChildren(ViewPager.class, true); - } - - set.addListener(mKeyguardStatusAlignmentTransitionListener); - TransitionManager.beginDelayedTransition(layout, set); - } - } else { - transition.addListener(mKeyguardStatusAlignmentTransitionListener); - TransitionManager.beginDelayedTransition(layout, transition); - } - - constraintSet.applyTo(layout); - } - - public ClockController getClockController() { - return mKeyguardClockSwitchController.getClock(); - } - - String getInstanceName() { - return TAG + "#" + hashCode(); - } - - @VisibleForTesting - static class SplitShadeTransitionAdapter extends Transition { - private static final String PROP_BOUNDS_LEFT = "splitShadeTransitionAdapter:boundsLeft"; - private static final String PROP_BOUNDS_RIGHT = "splitShadeTransitionAdapter:boundsRight"; - private static final String PROP_X_IN_WINDOW = "splitShadeTransitionAdapter:xInWindow"; - private static final String[] TRANSITION_PROPERTIES = { - PROP_BOUNDS_LEFT, PROP_BOUNDS_RIGHT, PROP_X_IN_WINDOW}; - - private final KeyguardClockSwitchController mController; - - @VisibleForTesting - SplitShadeTransitionAdapter(KeyguardClockSwitchController controller) { - mController = controller; - } - - private void captureValues(TransitionValues transitionValues) { - transitionValues.values.put(PROP_BOUNDS_LEFT, transitionValues.view.getLeft()); - transitionValues.values.put(PROP_BOUNDS_RIGHT, transitionValues.view.getRight()); - int[] locationInWindowTmp = new int[2]; - transitionValues.view.getLocationInWindow(locationInWindowTmp); - transitionValues.values.put(PROP_X_IN_WINDOW, locationInWindowTmp[0]); - } - - @Override - public void captureEndValues(TransitionValues transitionValues) { - captureValues(transitionValues); - } - - @Override - public void captureStartValues(TransitionValues transitionValues) { - captureValues(transitionValues); - } - - @Nullable - @Override - public Animator createAnimator(@NonNull ViewGroup sceneRoot, - @Nullable TransitionValues startValues, - @Nullable TransitionValues endValues) { - if (startValues == null || endValues == null) { - return null; - } - ValueAnimator anim = ValueAnimator.ofFloat(0, 1); - - int fromLeft = (int) startValues.values.get(PROP_BOUNDS_LEFT); - int fromWindowX = (int) startValues.values.get(PROP_X_IN_WINDOW); - int toWindowX = (int) endValues.values.get(PROP_X_IN_WINDOW); - // Using windowX, to determine direction, instead of left, as in RTL the difference of - // toLeft - fromLeft is always positive, even when moving left. - int direction = toWindowX - fromWindowX > 0 ? 1 : -1; - - anim.addUpdateListener(animation -> { - ClockController clock = mController.getClock(); - if (clock == null) { - return; - } - - clock.getLargeClock().getAnimations() - .onPositionUpdated(fromLeft, direction, animation.getAnimatedFraction()); - }); - - return anim; - } - - @Override - public String[] getTransitionProperties() { - return TRANSITION_PROPERTIES; - } - } -} diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardVisibilityHelper.java b/packages/SystemUI/src/com/android/keyguard/KeyguardVisibilityHelper.java deleted file mode 100644 index fd8b6d5f05e1..000000000000 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardVisibilityHelper.java +++ /dev/null @@ -1,225 +0,0 @@ -/* - * Copyright (C) 2021 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.keyguard; - -import static com.android.systemui.statusbar.StatusBarState.KEYGUARD; -import static com.android.systemui.statusbar.StatusBarState.SHADE; - -import android.util.Property; -import android.view.View; - -import com.android.app.animation.Interpolators; -import com.android.systemui.keyguard.MigrateClocksToBlueprint; -import com.android.systemui.log.LogBuffer; -import com.android.systemui.log.core.LogLevel; -import com.android.systemui.statusbar.StatusBarState; -import com.android.systemui.statusbar.notification.AnimatableProperty; -import com.android.systemui.statusbar.notification.PropertyAnimator; -import com.android.systemui.statusbar.notification.stack.AnimationProperties; -import com.android.systemui.statusbar.phone.DozeParameters; -import com.android.systemui.statusbar.phone.ScreenOffAnimationController; -import com.android.systemui.statusbar.policy.KeyguardStateController; -import com.android.systemui.util.Assert; - -import com.google.errorprone.annotations.CompileTimeConstant; - -import java.util.function.Consumer; - -/** - * Helper class for updating visibility of keyguard views based on keyguard and status bar state. - * This logic is shared by both the keyguard status view and the keyguard user switcher. - */ -public class KeyguardVisibilityHelper { - private static final String TAG = "KeyguardVisibilityHelper"; - - private View mView; - private final KeyguardStateController mKeyguardStateController; - private final DozeParameters mDozeParameters; - private final ScreenOffAnimationController mScreenOffAnimationController; - private boolean mAnimateYPos; - private boolean mKeyguardViewVisibilityAnimating; - private boolean mLastOccludedState = false; - private final AnimationProperties mAnimationProperties = new AnimationProperties(); - private final LogBuffer mLogBuffer; - - public KeyguardVisibilityHelper(View view, - KeyguardStateController keyguardStateController, - DozeParameters dozeParameters, - ScreenOffAnimationController screenOffAnimationController, - boolean animateYPos, - LogBuffer logBuffer) { - mView = view; - mKeyguardStateController = keyguardStateController; - mDozeParameters = dozeParameters; - mScreenOffAnimationController = screenOffAnimationController; - mAnimateYPos = animateYPos; - mLogBuffer = logBuffer; - } - - private void log(@CompileTimeConstant String message) { - if (mLogBuffer != null) { - mLogBuffer.log(TAG, LogLevel.DEBUG, message); - } - } - - public boolean isVisibilityAnimating() { - return mKeyguardViewVisibilityAnimating; - } - - /** - * Set the visibility of a keyguard view based on some new state. - */ - public void setViewVisibility( - int statusBarState, - boolean keyguardFadingAway, - boolean goingToFullShade, - int oldStatusBarState) { - if (MigrateClocksToBlueprint.isEnabled()) { - log("Ignoring KeyguardVisibilityelper, migrateClocksToBlueprint flag on"); - return; - } - Assert.isMainThread(); - PropertyAnimator.cancelAnimation(mView, AnimatableProperty.ALPHA); - boolean isOccluded = mKeyguardStateController.isOccluded(); - mKeyguardViewVisibilityAnimating = false; - - if ((!keyguardFadingAway && oldStatusBarState == KEYGUARD - && statusBarState != KEYGUARD) || goingToFullShade) { - mKeyguardViewVisibilityAnimating = true; - - AnimationProperties animProps = new AnimationProperties() - .setCustomInterpolator(View.ALPHA, Interpolators.ALPHA_OUT) - .setAnimationEndAction(mSetGoneEndAction); - if (keyguardFadingAway) { - animProps - .setDelay(mKeyguardStateController.getKeyguardFadingAwayDelay()) - .setDuration(mKeyguardStateController.getShortenedFadingAwayDuration()); - log("goingToFullShade && keyguardFadingAway"); - } else { - animProps.setDelay(0).setDuration(160); - log("goingToFullShade && !keyguardFadingAway"); - } - if (MigrateClocksToBlueprint.isEnabled()) { - log("Using LockscreenToGoneTransition 1"); - } else { - PropertyAnimator.setProperty( - mView, AnimatableProperty.ALPHA, 0f, animProps, true /* animate */); - } - } else if (oldStatusBarState == StatusBarState.SHADE_LOCKED && statusBarState == KEYGUARD) { - mView.setVisibility(View.VISIBLE); - mKeyguardViewVisibilityAnimating = true; - mView.setAlpha(0f); - PropertyAnimator.setProperty( - mView, AnimatableProperty.ALPHA, 1f, - new AnimationProperties() - .setDelay(0) - .setDuration(320) - .setCustomInterpolator(View.ALPHA, Interpolators.ALPHA_IN) - .setAnimationEndAction( - property -> mSetVisibleEndRunnable.run()), - true /* animate */); - log("keyguardFadingAway transition w/ Y Aniamtion"); - } else if (statusBarState == KEYGUARD) { - // Sometimes, device will be unlocked and then locked very quickly. - // keyguardFadingAway hasn't been set to false cause unlock animation hasn't finished - // So we should not animate keyguard fading away in this case (when oldState is SHADE) - if (oldStatusBarState != SHADE) { - log("statusBarState == KEYGUARD && oldStatusBarState != SHADE"); - } else { - log("statusBarState == KEYGUARD && oldStatusBarState == SHADE"); - } - - if (keyguardFadingAway && oldStatusBarState != SHADE) { - mKeyguardViewVisibilityAnimating = true; - AnimationProperties animProps = new AnimationProperties() - .setDelay(0) - .setCustomInterpolator(View.ALPHA, Interpolators.FAST_OUT_LINEAR_IN) - .setAnimationEndAction(mSetInvisibleEndAction); - if (mAnimateYPos) { - float target = mView.getY() - mView.getHeight() * 0.05f; - int delay = 0; - int duration = 125; - // We animate the Y property separately using the PropertyAnimator, as the panel - // view also needs to update the end position. - mAnimationProperties.setDuration(duration).setDelay(delay); - PropertyAnimator.cancelAnimation(mView, AnimatableProperty.Y); - PropertyAnimator.setProperty(mView, AnimatableProperty.Y, target, - mAnimationProperties, - true /* animate */); - animProps.setDuration(duration) - .setDelay(delay); - log("keyguardFadingAway transition w/ Y Aniamtion"); - } else { - log("keyguardFadingAway transition w/o Y Animation"); - } - PropertyAnimator.setProperty( - mView, AnimatableProperty.ALPHA, 0f, - animProps, - true /* animate */); - } else if (mScreenOffAnimationController.shouldAnimateInKeyguard()) { - if (MigrateClocksToBlueprint.isEnabled()) { - log("Using GoneToAodTransition"); - mKeyguardViewVisibilityAnimating = false; - } else { - log("ScreenOff transition"); - mKeyguardViewVisibilityAnimating = true; - - // Ask the screen off animation controller to animate the keyguard visibility - // for us since it may need to be cancelled due to keyguard lifecycle events. - mScreenOffAnimationController.animateInKeyguard(mView, mSetVisibleEndRunnable); - } - } else { - log("Direct set Visibility to VISIBLE"); - mView.setVisibility(View.VISIBLE); - } - } else { - if (MigrateClocksToBlueprint.isEnabled()) { - log("Using LockscreenToGoneTransition 2"); - } else { - log("Direct set Visibility to GONE"); - mView.setVisibility(View.GONE); - mView.setAlpha(1f); - } - } - - mLastOccludedState = isOccluded; - } - - private final Consumer<Property> mSetInvisibleEndAction = new Consumer<>() { - @Override - public void accept(Property property) { - mKeyguardViewVisibilityAnimating = false; - mView.setVisibility(View.INVISIBLE); - log("Callback Set Visibility to INVISIBLE"); - } - }; - - private final Consumer<Property> mSetGoneEndAction = new Consumer<>() { - @Override - public void accept(Property property) { - mKeyguardViewVisibilityAnimating = false; - mView.setVisibility(View.GONE); - log("CallbackSet Visibility to GONE"); - } - }; - - private final Runnable mSetVisibleEndRunnable = () -> { - mKeyguardViewVisibilityAnimating = false; - mView.setVisibility(View.VISIBLE); - log("Callback Set Visibility to VISIBLE"); - }; -} diff --git a/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardStatusBarViewComponent.java b/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardStatusBarViewComponent.java index 91dd1d643c96..9a4717064c56 100644 --- a/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardStatusBarViewComponent.java +++ b/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardStatusBarViewComponent.java @@ -16,7 +16,6 @@ package com.android.keyguard.dagger; -import com.android.keyguard.KeyguardStatusViewController; import com.android.systemui.shade.ShadeViewStateProvider; import com.android.systemui.statusbar.phone.KeyguardStatusBarView; import com.android.systemui.statusbar.phone.KeyguardStatusBarViewController; @@ -25,9 +24,7 @@ import dagger.BindsInstance; import dagger.Subcomponent; /** - * Subcomponent for helping work with KeyguardStatusView and its children. - * - * TODO: unify this with {@link KeyguardStatusViewComponent} + * Subcomponent for helping work with KeyguardStatusBarView and its children. */ @Subcomponent(modules = {KeyguardStatusBarViewModule.class}) @KeyguardStatusBarViewScope @@ -41,6 +38,5 @@ public interface KeyguardStatusBarViewComponent { shadeViewStateProvider); } - /** Builds a {@link KeyguardStatusViewController}. */ KeyguardStatusBarViewController getKeyguardStatusBarViewController(); } diff --git a/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardStatusViewComponent.java b/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardStatusViewComponent.java deleted file mode 100644 index f3014f1ecc58..000000000000 --- a/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardStatusViewComponent.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2020 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.keyguard.dagger; - -import android.view.Display; - -import com.android.keyguard.KeyguardClockSwitchController; -import com.android.keyguard.KeyguardStatusView; -import com.android.keyguard.KeyguardStatusViewController; - -import dagger.BindsInstance; -import dagger.Subcomponent; - -/** - * Subcomponent for helping work with KeyguardStatusView and its children. - * - * TODO: unify this with {@link KeyguardStatusBarViewComponent} - */ -@Subcomponent(modules = {KeyguardStatusViewModule.class, KeyguardDisplayModule.class}) -@KeyguardStatusViewScope -public interface KeyguardStatusViewComponent { - /** Simple factory for {@link KeyguardStatusViewComponent}. */ - @Subcomponent.Factory - interface Factory { - /** Creates {@link KeyguardStatusViewComponent} for a given display. */ - KeyguardStatusViewComponent build( - @BindsInstance KeyguardStatusView presentation, - @BindsInstance Display display - ); - } - - /** Builds a {@link com.android.keyguard.KeyguardClockSwitchController}. */ - KeyguardClockSwitchController getKeyguardClockSwitchController(); - - /** Builds a {@link com.android.keyguard.KeyguardStatusViewController}. */ - KeyguardStatusViewController getKeyguardStatusViewController(); -} diff --git a/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardStatusViewModule.java b/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardStatusViewModule.java deleted file mode 100644 index 7575f0e80d1c..000000000000 --- a/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardStatusViewModule.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2020 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.keyguard.dagger; - -import com.android.keyguard.KeyguardClockSwitch; -import com.android.keyguard.KeyguardSliceView; -import com.android.keyguard.KeyguardStatusView; -import com.android.systemui.res.R; - -import dagger.Module; -import dagger.Provides; - -/** Dagger module for {@link KeyguardStatusViewComponent}. */ -@Module -public abstract class KeyguardStatusViewModule { - @Provides - static KeyguardClockSwitch getKeyguardClockSwitch(KeyguardStatusView keyguardPresentation) { - return keyguardPresentation.findViewById(R.id.keyguard_clock_container); - } - - @Provides - static KeyguardSliceView getKeyguardSliceView(KeyguardClockSwitch keyguardClockSwitch) { - return keyguardClockSwitch.findViewById(R.id.keyguard_slice_view); - } -} diff --git a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java index b272d65a8a11..0b2b3687c121 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java @@ -48,7 +48,6 @@ import androidx.lifecycle.ViewModelStore; import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.compose.animation.scene.SceneKey; -import com.android.dream.lowlight.dagger.LowLightDreamModule; import com.android.internal.logging.UiEvent; import com.android.internal.logging.UiEventLogger; import com.android.internal.policy.PhoneWindow; @@ -67,6 +66,7 @@ import com.android.systemui.communal.shared.model.CommunalTransitionKeys; import com.android.systemui.complication.dagger.ComplicationComponent; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dreams.complication.dagger.DreamComplicationComponent; +import com.android.systemui.dreams.dagger.DreamModule; import com.android.systemui.dreams.dagger.DreamOverlayComponent; import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor; import com.android.systemui.navigationbar.gestural.domain.GestureInteractor; @@ -391,7 +391,7 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ SystemDialogsCloser systemDialogsCloser, UiEventLogger uiEventLogger, @Named(DREAM_TOUCH_INSET_MANAGER) TouchInsetManager touchInsetManager, - @Nullable @Named(LowLightDreamModule.LOW_LIGHT_DREAM_COMPONENT) + @Nullable @Named(DreamModule.LOW_LIGHT_DREAM_SERVICE) ComponentName lowLightDreamComponent, @Nullable @Named(HOME_CONTROL_PANEL_DREAM_COMPONENT) ComponentName homeControlPanelDreamComponent, diff --git a/packages/SystemUI/src/com/android/systemui/dreams/dagger/DreamModule.java b/packages/SystemUI/src/com/android/systemui/dreams/dagger/DreamModule.java index 216cb86f8865..faab31eff4f7 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/dagger/DreamModule.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/dagger/DreamModule.java @@ -17,14 +17,16 @@ package com.android.systemui.dreams.dagger; import android.annotation.Nullable; +import android.app.DreamManager; import android.app.Service; import android.content.ComponentName; import android.content.Context; import android.content.pm.PackageManager; import android.content.res.Resources; -import com.android.dream.lowlight.dagger.LowLightDreamModule; +import com.android.dream.lowlight.dagger.LowLightDreamComponent; import com.android.settingslib.dream.DreamBackend; +import com.android.systemui.Flags; import com.android.systemui.ambient.touch.scrim.dagger.ScrimModule; import com.android.systemui.complication.dagger.RegisteredComplicationsModule; import com.android.systemui.dagger.SysUISingleton; @@ -47,12 +49,14 @@ import com.android.systemui.res.R; import com.android.systemui.touch.TouchInsetManager; import dagger.Binds; +import dagger.BindsOptionalOf; import dagger.Module; import dagger.Provides; import dagger.multibindings.ClassKey; import dagger.multibindings.IntoMap; import dagger.multibindings.StringKey; +import java.util.Objects; import java.util.Optional; import java.util.concurrent.Executor; @@ -63,7 +67,6 @@ import javax.inject.Named; */ @Module(includes = { RegisteredComplicationsModule.class, - LowLightDreamModule.class, ScrimModule.class, HomeControlsDataSourceModule.class, }, @@ -71,6 +74,7 @@ import javax.inject.Named; DreamComplicationComponent.class, DreamOverlayComponent.class, HomeControlsRemoteServiceComponent.class, + LowLightDreamComponent.class, }) public interface DreamModule { String DREAM_ONLY_ENABLED_FOR_DOCK_USER = "dream_only_enabled_for_dock_user"; @@ -81,6 +85,9 @@ public interface DreamModule { String DREAM_OVERLAY_WINDOW_TITLE = "dream_overlay_window_title"; String HOME_CONTROL_PANEL_DREAM_COMPONENT = "home_control_panel_dream_component"; String DREAM_TILE_SPEC = "dream"; + String LOW_LIGHT_DREAM_SERVICE = "low_light_dream_component"; + + String LOW_LIGHT_CLOCK_DREAM = "low_light_clock_dream"; /** * Provides the dream component @@ -214,4 +221,49 @@ public interface DreamModule { QSTilePolicy.NoRestrictions.INSTANCE ); } + + /** + * Provides dream manager. + */ + @Provides + static DreamManager providesDreamManager(Context context) { + return Objects.requireNonNull(context.getSystemService(DreamManager.class)); + } + + /** + * Binds a default (unset) clock dream. + */ + @BindsOptionalOf + @Named(LOW_LIGHT_CLOCK_DREAM) + ComponentName bindsLowLightClockDream(); + + /** + * Provides the component name of the low light dream, or null if not configured. + */ + @Provides + @Nullable + @Named(LOW_LIGHT_DREAM_SERVICE) + static ComponentName providesLowLightDreamService(Context context, + @Named(LOW_LIGHT_CLOCK_DREAM) Optional<ComponentName> clockDream) { + if (Flags.lowLightClockDream() && clockDream.isPresent()) { + return clockDream.get(); + } + + String lowLightDreamComponent = context.getResources().getString( + R.string.config_lowLightDreamComponent + ); + return lowLightDreamComponent.isEmpty() + ? null : ComponentName.unflattenFromString(lowLightDreamComponent); + } + + /** + * Provides Dagger component for low light dependencies. + */ + @Provides + @SysUISingleton + static LowLightDreamComponent providesLowLightDreamComponent( + LowLightDreamComponent.Factory factory, DreamManager dreamManager, + @Named(LOW_LIGHT_DREAM_SERVICE) ComponentName lowLightDreamService) { + return factory.create(dreamManager, lowLightDreamService); + } } diff --git a/packages/SystemUI/src/com/android/systemui/flags/FlagDependencies.kt b/packages/SystemUI/src/com/android/systemui/flags/FlagDependencies.kt index 3cc184d7ddf4..63ac783ad42b 100644 --- a/packages/SystemUI/src/com/android/systemui/flags/FlagDependencies.kt +++ b/packages/SystemUI/src/com/android/systemui/flags/FlagDependencies.kt @@ -31,7 +31,6 @@ import com.android.systemui.Flags.statusBarCallChipNotificationIcon import com.android.systemui.Flags.statusBarScreenSharingChips import com.android.systemui.Flags.statusBarUseReposForCallChip import com.android.systemui.dagger.SysUISingleton -import com.android.systemui.keyguard.MigrateClocksToBlueprint import com.android.systemui.scene.shared.flag.SceneContainerFlag import com.android.systemui.shade.shared.flag.DualShade import com.android.systemui.statusbar.notification.collection.SortBySectionTimeFlag @@ -64,9 +63,6 @@ class FlagDependencies @Inject constructor(featureFlags: FeatureFlagsClassic, ha // SceneContainer dependencies SceneContainerFlag.getFlagDependencies().forEach { (alpha, beta) -> alpha dependsOn beta } - // CommunalHub dependencies - communalHub dependsOn MigrateClocksToBlueprint.token - // DualShade dependencies DualShade.token dependsOn SceneContainerFlag.getMainAconfigFlag() diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardUnlockAnimationController.kt b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardUnlockAnimationController.kt index d0065c8b06c6..644deb0d358c 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardUnlockAnimationController.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardUnlockAnimationController.kt @@ -170,7 +170,7 @@ constructor( private val notificationShadeWindowController: NotificationShadeWindowController, private val powerManager: PowerManager, private val wallpaperManager: WallpaperManager, - private val deviceStateManager: DeviceStateManager + private val deviceStateManager: DeviceStateManager, ) : KeyguardStateController.Callback, ISysuiUnlockAnimationController.Stub() { interface KeyguardUnlockAnimationListener { @@ -194,7 +194,7 @@ constructor( playingCannedAnimation: Boolean, isWakeAndUnlockNotFromDream: Boolean, unlockAnimationStartDelay: Long, - unlockAnimationDuration: Long + unlockAnimationDuration: Long, ) {} /** @@ -250,7 +250,7 @@ constructor( */ override fun setLauncherUnlockController( activityClass: String, - callback: ILauncherUnlockAnimationController? + callback: ILauncherUnlockAnimationController?, ) { launcherActivityClass = activityClass launcherUnlockController = callback @@ -370,7 +370,7 @@ constructor( Log.d( TAG, "skip finishSurfaceBehindRemoteAnimation" + - " surfaceBehindAlpha=$surfaceBehindAlpha" + " surfaceBehindAlpha=$surfaceBehindAlpha", ) } } @@ -387,7 +387,7 @@ constructor( addUpdateListener { valueAnimator: ValueAnimator -> setWallpaperAppearAmount( valueAnimator.animatedValue as Float, - openingWallpaperTargets + openingWallpaperTargets, ) } addListener( @@ -418,7 +418,7 @@ constructor( addUpdateListener { valueAnimator: ValueAnimator -> setWallpaperAppearAmount( valueAnimator.animatedValue as Float, - closingWallpaperTargets + closingWallpaperTargets, ) } } @@ -488,7 +488,7 @@ constructor( Log.wtf( TAG, " !notificationShadeWindowController.isLaunchingActivity: " + - "${!notificationShadeWindowController.isLaunchingActivity}" + "${!notificationShadeWindowController.isLaunchingActivity}", ) Log.wtf(TAG, " launcherUnlockController != null: ${launcherUnlockController != null}") Log.wtf(TAG, " !isFoldable(context): ${!isDeviceFoldable(resources, deviceStateManager)}") @@ -516,7 +516,7 @@ constructor( try { launcherUnlockController?.setUnlockAmount( 1f, - biometricUnlockControllerLazy.get().isWakeAndUnlock /* forceIfAnimating */ + biometricUnlockControllerLazy.get().isWakeAndUnlock, /* forceIfAnimating */ ) } catch (e: DeadObjectException) { Log.e( @@ -524,7 +524,7 @@ constructor( "launcherUnlockAnimationController was dead, but non-null in " + "onKeyguardGoingAwayChanged(). Catching exception as this should mean " + "Launcher is in the process of being destroyed, but the IPC to System UI " + - "telling us hasn't arrived yet." + "telling us hasn't arrived yet.", ) } } @@ -569,7 +569,7 @@ constructor( offset( 0, (lockscreenSmartspace as? BcSmartspaceDataPlugin.SmartspaceView) - ?.currentCardTopPadding ?: 0 + ?.currentCardTopPadding ?: 0, ) } } @@ -583,7 +583,7 @@ constructor( launcherUnlockController?.prepareForUnlock( willUnlockWithSmartspaceTransition, /* willAnimateSmartspace */ lockscreenSmartspaceBounds, /* lockscreenSmartspaceBounds */ - selectedPage /* selectedPage */ + selectedPage, /* selectedPage */ ) launcherPreparedForUnlock = true @@ -611,7 +611,7 @@ constructor( openingWallpapers: Array<RemoteAnimationTarget>, closingWallpapers: Array<RemoteAnimationTarget>, startTime: Long, - requestedShowSurfaceBehindKeyguard: Boolean + requestedShowSurfaceBehindKeyguard: Boolean, ) { if (surfaceTransactionApplier == null) { surfaceTransactionApplier = @@ -650,7 +650,7 @@ constructor( launcherUnlockController?.playUnlockAnimation( true, unlockAnimationDurationMs() + cannedUnlockStartDelayMs(), - 0 /* startDelay */ + 0, /* startDelay */ ) } catch (e: DeadObjectException) { // Hello! If you are here investigating a bug where Launcher is blank (no icons) @@ -663,7 +663,7 @@ constructor( "launcherUnlockAnimationController was dead, but non-null. " + "Catching exception as this should mean Launcher is in the process " + "of being destroyed, but the IPC to System UI telling us hasn't " + - "arrived yet." + "arrived yet.", ) } @@ -689,7 +689,7 @@ constructor( playingCannedUnlockAnimation /* playingCannedAnimation */, isWakeAndUnlockNotFromDream /* isWakeAndUnlockNotFromDream */, cannedUnlockStartDelayMs() /* unlockStartDelay */, - LAUNCHER_ICONS_ANIMATION_DURATION_MS /* unlockAnimationDuration */ + LAUNCHER_ICONS_ANIMATION_DURATION_MS, /* unlockAnimationDuration */ ) } @@ -742,7 +742,7 @@ constructor( Log.wtf( TAG, "Launcher is prepared for unlock, so we should have started the " + - "in-window animation, however we apparently did not." + "in-window animation, however we apparently did not.", ) logInWindowAnimationConditions() } @@ -762,7 +762,7 @@ constructor( launcherUnlockController?.playUnlockAnimation( true /* unlocked */, LAUNCHER_ICONS_ANIMATION_DURATION_MS /* duration */, - cannedUnlockStartDelayMs() /* startDelay */ + cannedUnlockStartDelayMs(), /* startDelay */ ) } catch (e: DeadObjectException) { // Hello! If you are here investigating a bug where Launcher is blank (no icons) @@ -775,7 +775,7 @@ constructor( "launcherUnlockAnimationController was dead, but non-null. " + "Catching exception as this should mean Launcher is in the process " + "of being destroyed, but the IPC to System UI telling us hasn't " + - "arrived yet." + "arrived yet.", ) } @@ -805,7 +805,7 @@ constructor( Log.e( TAG, "Finish keyguard exit animation delayed Runnable ran, but we are " + - "showing and not going away." + "showing and not going away.", ) return@postDelayed } @@ -819,7 +819,7 @@ constructor( .exitKeyguardAndFinishSurfaceBehindRemoteAnimation(false /* cancelled */) } }, - cannedUnlockStartDelayMs() + cannedUnlockStartDelayMs(), ) } @@ -998,7 +998,7 @@ constructor( surfaceBehindMatrix.setTranslate( surfaceBehindRemoteAnimationTarget.screenSpaceBounds.left.toFloat(), surfaceBehindRemoteAnimationTarget.screenSpaceBounds.top.toFloat() + - surfaceHeight * SURFACE_BEHIND_START_TRANSLATION_Y * (1f - amount) + surfaceHeight * SURFACE_BEHIND_START_TRANSLATION_Y * (1f - amount), ) // Scale up from a point at the center-bottom of the surface. @@ -1006,7 +1006,7 @@ constructor( scaleFactor, scaleFactor, keyguardViewController.viewRootImpl.width / 2f, - surfaceHeight * SURFACE_BEHIND_SCALE_PIVOT_Y + surfaceHeight * SURFACE_BEHIND_SCALE_PIVOT_Y, ) // SyncRtSurfaceTransactionApplier cannot apply transaction when the target view is @@ -1141,14 +1141,14 @@ constructor( if (!KeyguardWmStateRefactor.isEnabled) { keyguardViewController.hide( surfaceBehindRemoteAnimationStartTime, - 0 /* fadeOutDuration */ + 0, /* fadeOutDuration */ ) } } else { Log.i( TAG, "#hideKeyguardViewAfterRemoteAnimation called when keyguard view is not " + - "showing. Ignoring..." + "showing. Ignoring...", ) } } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt index e8eb4976194a..5e0768a2fd24 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt @@ -18,19 +18,7 @@ package com.android.systemui.keyguard import android.content.Context -import android.view.LayoutInflater -import android.view.View -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.runtime.remember -import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.ComposeView -import com.android.compose.animation.scene.MutableSceneTransitionLayoutState -import com.android.compose.animation.scene.SceneKey -import com.android.compose.animation.scene.SceneTransitionLayout import com.android.internal.jank.InteractionJankMonitor -import com.android.keyguard.KeyguardStatusView -import com.android.keyguard.KeyguardStatusViewController -import com.android.keyguard.dagger.KeyguardStatusViewComponent import com.android.systemui.CoreStartable import com.android.systemui.Flags.lightRevealMigration import com.android.systemui.biometrics.ui.binder.DeviceEntryUnlockTrackerViewBinder @@ -39,12 +27,9 @@ import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.deviceentry.domain.interactor.DeviceEntryHapticsInteractor import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor -import com.android.systemui.keyguard.shared.model.LockscreenSceneBlueprint import com.android.systemui.keyguard.ui.binder.KeyguardBlueprintViewBinder import com.android.systemui.keyguard.ui.binder.KeyguardRootViewBinder import com.android.systemui.keyguard.ui.binder.LightRevealScrimViewBinder -import com.android.systemui.keyguard.ui.composable.LockscreenContent -import com.android.systemui.keyguard.ui.composable.blueprint.ComposableLockscreenSceneBlueprint import com.android.systemui.keyguard.ui.view.KeyguardIndicationArea import com.android.systemui.keyguard.ui.view.KeyguardRootView import com.android.systemui.keyguard.ui.viewmodel.KeyguardBlueprintViewModel @@ -52,23 +37,19 @@ import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel import com.android.systemui.keyguard.ui.viewmodel.KeyguardRootViewModel import com.android.systemui.keyguard.ui.viewmodel.KeyguardSmartspaceViewModel import com.android.systemui.keyguard.ui.viewmodel.LightRevealScrimViewModel -import com.android.systemui.keyguard.ui.viewmodel.LockscreenContentViewModel import com.android.systemui.keyguard.ui.viewmodel.OccludingAppDeviceEntryMessageViewModel import com.android.systemui.plugins.FalsingManager -import com.android.systemui.res.R import com.android.systemui.scene.shared.flag.SceneContainerFlag import com.android.systemui.shade.ShadeDisplayAware import com.android.systemui.shade.domain.interactor.ShadeInteractor import com.android.systemui.statusbar.KeyguardIndicationController import com.android.systemui.statusbar.LightRevealScrim import com.android.systemui.statusbar.VibratorHelper -import com.android.systemui.statusbar.notification.stack.ui.viewmodel.NotificationLockscreenScrimViewModel import com.android.systemui.statusbar.phone.ScreenOffAnimationController import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager import com.android.systemui.temporarydisplay.chipbar.ChipbarCoordinator import com.android.systemui.wallpapers.ui.viewmodel.WallpaperViewModel import com.google.android.msdl.domain.MSDLPlayer -import dagger.Lazy import java.util.Optional import javax.inject.Inject import kotlinx.coroutines.CoroutineDispatcher @@ -87,7 +68,6 @@ constructor( private val occludingAppDeviceEntryMessageViewModel: OccludingAppDeviceEntryMessageViewModel, private val chipbarCoordinator: ChipbarCoordinator, private val keyguardBlueprintViewModel: KeyguardBlueprintViewModel, - private val keyguardStatusViewComponentFactory: KeyguardStatusViewComponent.Factory, @ShadeDisplayAware private val configuration: ConfigurationState, @ShadeDisplayAware private val context: Context, private val keyguardIndicationController: KeyguardIndicationController, @@ -98,9 +78,6 @@ constructor( private val falsingManager: FalsingManager, private val keyguardClockViewModel: KeyguardClockViewModel, private val smartspaceViewModel: KeyguardSmartspaceViewModel, - private val lockscreenContentViewModelFactory: LockscreenContentViewModel.Factory, - private val notificationScrimViewModelFactory: NotificationLockscreenScrimViewModel.Factory, - private val lockscreenSceneBlueprintsLazy: Lazy<Set<LockscreenSceneBlueprint>>, private val clockInteractor: KeyguardClockInteractor, private val keyguardViewMediator: KeyguardViewMediator, private val deviceEntryUnlockTrackerViewBinder: Optional<DeviceEntryUnlockTrackerViewBinder>, @@ -113,24 +90,6 @@ constructor( ) : CoreStartable { private var rootViewHandle: DisposableHandle? = null - private var indicationAreaHandle: DisposableHandle? = null - - var keyguardStatusViewController: KeyguardStatusViewController? = null - get() { - if (field == null) { - val statusViewComponent = - keyguardStatusViewComponentFactory.build( - LayoutInflater.from(context).inflate(R.layout.keyguard_status_view, null) - as KeyguardStatusView, - context.display, - ) - val controller = statusViewComponent.keyguardStatusViewController - controller.init() - field = controller - } - - return field - } override fun start() { bindKeyguardRootView() @@ -192,42 +151,5 @@ constructor( ) } - private fun createLockscreen( - context: Context, - viewModelFactory: LockscreenContentViewModel.Factory, - notificationScrimViewModelFactory: NotificationLockscreenScrimViewModel.Factory, - blueprints: Set<@JvmSuppressWildcards LockscreenSceneBlueprint>, - ): View { - val sceneBlueprints = - blueprints.mapNotNull { it as? ComposableLockscreenSceneBlueprint }.toSet() - return ComposeView(context).apply { - setContent { - // STL is used solely to provide a SceneScope to enable us to invoke SceneScope - // composables. - val currentScene = remember { SceneKey("root-view-scene-key") } - val state = remember { MutableSceneTransitionLayoutState(currentScene) } - SceneTransitionLayout(state) { - scene(currentScene) { - with( - LockscreenContent( - viewModelFactory = viewModelFactory, - notificationScrimViewModelFactory = - notificationScrimViewModelFactory, - blueprints = sceneBlueprints, - clockInteractor = clockInteractor, - ) - ) { - Content(modifier = Modifier.fillMaxSize()) - } - } - } - } - } - } - - /** - * Temporary, to allow NotificationPanelViewController to use the same instance while code is - * migrated: b/288242803 - */ fun getKeyguardRootView() = keyguardRootView } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/MigrateClocksToBlueprint.kt b/packages/SystemUI/src/com/android/systemui/keyguard/MigrateClocksToBlueprint.kt deleted file mode 100644 index 5a2943bd00b3..000000000000 --- a/packages/SystemUI/src/com/android/systemui/keyguard/MigrateClocksToBlueprint.kt +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2024 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.systemui.keyguard - -import com.android.systemui.Flags -import com.android.systemui.flags.FlagToken -import com.android.systemui.flags.RefactorFlagUtils - -/** Helper for reading or using the migrate clocks to blueprint flag. */ -@Suppress("NOTHING_TO_INLINE") -object MigrateClocksToBlueprint { - /** The aconfig flag name */ - const val FLAG_NAME = Flags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT - - /** A token used for dependency declaration */ - val token: FlagToken - get() = FlagToken(FLAG_NAME, isEnabled) - - /** Is the refactor enabled */ - @JvmStatic - inline val isEnabled - get() = Flags.migrateClocksToBlueprint() - - /** - * Called to ensure code is only run when the flag is enabled. This protects users from the - * unintended behaviors caused by accidentally running new logic, while also crashing on an eng - * build to ensure that the refactor author catches issues in testing. - */ - @JvmStatic - inline fun isUnexpectedlyInLegacyMode() = - RefactorFlagUtils.isUnexpectedlyInLegacyMode(isEnabled, FLAG_NAME) - - /** - * Called to ensure code is only run when the flag is disabled. This will throw an exception if - * the flag is enabled to ensure that the refactor author catches issues in testing. - */ - @JvmStatic - inline fun assertInLegacyMode() = RefactorFlagUtils.assertInLegacyMode(isEnabled, FLAG_NAME) -} diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/dagger/KeyguardModule.java b/packages/SystemUI/src/com/android/systemui/keyguard/dagger/KeyguardModule.java index 496c6fb96b39..d95a126fe4bd 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/dagger/KeyguardModule.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/dagger/KeyguardModule.java @@ -32,7 +32,6 @@ import com.android.keyguard.ViewMediatorCallback; import com.android.keyguard.dagger.KeyguardDisplayModule; import com.android.keyguard.dagger.KeyguardQsUserSwitchComponent; import com.android.keyguard.dagger.KeyguardStatusBarViewComponent; -import com.android.keyguard.dagger.KeyguardStatusViewComponent; import com.android.keyguard.mediator.ScreenOnCoordinator; import com.android.systemui.CoreStartable; import com.android.systemui.animation.ActivityTransitionAnimator; @@ -106,8 +105,7 @@ import java.util.concurrent.Executor; @ExperimentalCoroutinesApi @Module(subcomponents = { KeyguardQsUserSwitchComponent.class, - KeyguardStatusBarViewComponent.class, - KeyguardStatusViewComponent.class}, + KeyguardStatusBarViewComponent.class}, includes = { DeviceEntryIconTransitionModule.class, FalsingModule.class, diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardClockInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardClockInteractor.kt index d18d6dce2e94..f792935e67f3 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardClockInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardClockInteractor.kt @@ -19,7 +19,6 @@ package com.android.systemui.keyguard.domain.interactor import android.util.Log import com.android.keyguard.ClockEventController -import com.android.keyguard.KeyguardClockSwitch import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.keyguard.data.repository.KeyguardClockRepository @@ -121,9 +120,6 @@ constructor( keyguardInteractor.clockShouldBeCentered } - fun setClockSize(@KeyguardClockSwitch.ClockSize size: Int) = - setClockSize(ClockSize.fromLegacy(size)) - fun setClockSize(size: ClockSize) { SceneContainerFlag.assertInLegacyMode() keyguardClockRepository.setClockSize(size) @@ -134,7 +130,7 @@ constructor( return clock?.let { clock -> clock.config.id } ?: run { Log.e(TAG, "No clock is available") - KeyguardClockSwitch.MISSING_CLOCK_ID + "MISSING_CLOCK_ID" } } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt index 85306e67994c..0193d7cba616 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt @@ -27,7 +27,6 @@ import com.android.systemui.common.shared.model.NotificationContainerBounds import com.android.systemui.common.ui.domain.interactor.ConfigurationInteractor import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application -import com.android.systemui.keyguard.MigrateClocksToBlueprint import com.android.systemui.keyguard.data.repository.KeyguardRepository import com.android.systemui.keyguard.shared.model.BiometricUnlockModel import com.android.systemui.keyguard.shared.model.CameraLaunchSourceModel @@ -122,13 +121,11 @@ constructor( // We offset the placeholder bounds by the configured top margin to account for // legacy placement behavior within notifications for splitshade. emit( - if (MigrateClocksToBlueprint.isEnabled) { - if (useSplitShade) { - bounds.copy(bottom = bounds.bottom - keyguardSplitShadeTopMargin) - } else { - bounds - } - } else bounds + if (useSplitShade) { + bounds.copy(bottom = bounds.bottom - keyguardSplitShadeTopMargin) + } else { + bounds + } ) } .stateIn( @@ -340,9 +337,6 @@ constructor( /** The approximate location on the screen of the face unlock sensor, if one is available. */ val faceSensorLocation: Flow<Point?> = repository.faceSensorLocation - @Deprecated("Use the relevant TransitionViewModel") - val keyguardAlpha: Flow<Float> = repository.keyguardAlpha - /** Temporary shim for fading out content when the brightness slider is used */ @Deprecated("SceneContainer uses NotificationStackAppearanceInteractor") val panelAlpha: StateFlow<Float> = repository.panelAlpha.asStateFlow() @@ -483,10 +477,6 @@ constructor( repository.setQuickSettingsVisible(isVisible) } - fun setAlpha(alpha: Float) { - repository.setKeyguardAlpha(alpha) - } - fun setPanelAlpha(alpha: Float) { repository.setPanelAlpha(alpha) } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/ToAodFoldTransitionInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/ToAodFoldTransitionInteractor.kt index 21b9e537cc18..24929b60952a 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/ToAodFoldTransitionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/ToAodFoldTransitionInteractor.kt @@ -16,7 +16,6 @@ package com.android.systemui.keyguard.domain.interactor -import android.view.ViewGroup import com.android.systemui.dagger.SysUISingleton import com.android.systemui.shade.NotificationPanelViewController import com.android.systemui.shade.ShadeFoldAnimator @@ -25,16 +24,12 @@ import javax.inject.Inject @SysUISingleton class ToAodFoldTransitionInteractor @Inject -constructor( - private val keyguardClockInteractor: KeyguardClockInteractor, -) { +constructor(private val keyguardClockInteractor: KeyguardClockInteractor) { private var parentAnimator: NotificationPanelViewController.ShadeFoldAnimatorImpl? = null // TODO(b/331770313): Migrate to PowerInteractor; Deprecate ShadeFoldAnimator again val foldAnimator = object : ShadeFoldAnimator { - override val view: ViewGroup? - get() = throw NotImplementedError("Deprecated. Do not call.") override fun prepareFoldToAodAnimation() { parentAnimator?.prepareFoldToAodAnimation() @@ -43,7 +38,7 @@ constructor( override fun startFoldToAodAnimation( startAction: Runnable, endAction: Runnable, - cancelAction: Runnable + cancelAction: Runnable, ) { parentAnimator?.let { it.buildViewAnimator(startAction, endAction, cancelAction) diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/shared/model/ClockSize.kt b/packages/SystemUI/src/com/android/systemui/keyguard/shared/model/ClockSize.kt index b66129794477..5003a19614a6 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/shared/model/ClockSize.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/shared/model/ClockSize.kt @@ -18,37 +18,19 @@ package com.android.systemui.keyguard.shared.model import android.util.Log -import com.android.keyguard.KeyguardClockSwitch -enum class ClockSize( - @KeyguardClockSwitch.ClockSize val legacyValue: Int, -) { - SMALL(KeyguardClockSwitch.SMALL), - LARGE(KeyguardClockSwitch.LARGE); - - companion object { - private val TAG = ClockSize::class.simpleName!! - fun fromLegacy(@KeyguardClockSwitch.ClockSize value: Int): ClockSize { - for (enumVal in enumValues<ClockSize>()) { - if (enumVal.legacyValue == value) { - return enumVal - } - } - - Log.e(TAG, "Unrecognized legacy clock size value: $value") - return LARGE - } - } +enum class ClockSize { + SMALL, + LARGE, } -enum class ClockSizeSetting( - val settingValue: Int, -) { +enum class ClockSizeSetting(val settingValue: Int) { DYNAMIC(1), SMALL(0); companion object { private val TAG = ClockSizeSetting::class.simpleName!! + fun fromSettingValue(value: Int): ClockSizeSetting { for (enumVal in enumValues<ClockSizeSetting>()) { if (enumVal.settingValue == value) { diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/DefaultKeyguardBlueprint.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/DefaultKeyguardBlueprint.kt index d5a965569553..6973fecc37b4 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/DefaultKeyguardBlueprint.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/DefaultKeyguardBlueprint.kt @@ -31,7 +31,6 @@ import com.android.systemui.keyguard.ui.view.layout.sections.DefaultNotification import com.android.systemui.keyguard.ui.view.layout.sections.DefaultSettingsPopupMenuSection import com.android.systemui.keyguard.ui.view.layout.sections.DefaultShortcutsSection import com.android.systemui.keyguard.ui.view.layout.sections.DefaultStatusBarSection -import com.android.systemui.keyguard.ui.view.layout.sections.DefaultStatusViewSection import com.android.systemui.keyguard.ui.view.layout.sections.DefaultUdfpsAccessibilityOverlaySection import com.android.systemui.keyguard.ui.view.layout.sections.KeyguardSectionsModule.Companion.KEYGUARD_AMBIENT_INDICATION_AREA_SECTION import com.android.systemui.keyguard.ui.view.layout.sections.KeyguardSliceViewSection @@ -60,7 +59,6 @@ constructor( @Named(KEYGUARD_AMBIENT_INDICATION_AREA_SECTION) defaultAmbientIndicationAreaSection: Optional<KeyguardSection>, defaultSettingsPopupMenuSection: DefaultSettingsPopupMenuSection, - defaultStatusViewSection: DefaultStatusViewSection, defaultStatusBarSection: DefaultStatusBarSection, defaultNotificationStackScrollLayoutSection: DefaultNotificationStackScrollLayoutSection, aodNotificationIconsSection: AodNotificationIconsSection, @@ -80,7 +78,6 @@ constructor( defaultShortcutsSection, defaultAmbientIndicationAreaSection.getOrNull(), defaultSettingsPopupMenuSection, - defaultStatusViewSection, defaultStatusBarSection, defaultNotificationStackScrollLayoutSection, aodNotificationIconsSection, diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/SplitShadeKeyguardBlueprint.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/SplitShadeKeyguardBlueprint.kt index 34471771c79b..1eed224be3b5 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/SplitShadeKeyguardBlueprint.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/SplitShadeKeyguardBlueprint.kt @@ -30,7 +30,6 @@ import com.android.systemui.keyguard.ui.view.layout.sections.DefaultIndicationAr import com.android.systemui.keyguard.ui.view.layout.sections.DefaultSettingsPopupMenuSection import com.android.systemui.keyguard.ui.view.layout.sections.DefaultShortcutsSection import com.android.systemui.keyguard.ui.view.layout.sections.DefaultStatusBarSection -import com.android.systemui.keyguard.ui.view.layout.sections.DefaultStatusViewSection import com.android.systemui.keyguard.ui.view.layout.sections.KeyguardSectionsModule import com.android.systemui.keyguard.ui.view.layout.sections.SmartspaceSection import com.android.systemui.keyguard.ui.view.layout.sections.SplitShadeGuidelines @@ -57,7 +56,6 @@ constructor( @Named(KeyguardSectionsModule.KEYGUARD_AMBIENT_INDICATION_AREA_SECTION) defaultAmbientIndicationAreaSection: Optional<KeyguardSection>, defaultSettingsPopupMenuSection: DefaultSettingsPopupMenuSection, - defaultStatusViewSection: DefaultStatusViewSection, defaultStatusBarSection: DefaultStatusBarSection, splitShadeNotificationStackScrollLayoutSection: SplitShadeNotificationStackScrollLayoutSection, splitShadeGuidelines: SplitShadeGuidelines, @@ -77,7 +75,6 @@ constructor( defaultShortcutsSection, defaultAmbientIndicationAreaSection.getOrNull(), defaultSettingsPopupMenuSection, - defaultStatusViewSection, defaultStatusBarSection, splitShadeNotificationStackScrollLayoutSection, splitShadeGuidelines, diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultStatusViewSection.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultStatusViewSection.kt deleted file mode 100644 index 57ea1ad5575d..000000000000 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultStatusViewSection.kt +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (C) 2023 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.android.systemui.keyguard.ui.view.layout.sections - -import android.content.Context -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.view.ViewGroup.LayoutParams.WRAP_CONTENT -import androidx.constraintlayout.widget.ConstraintLayout -import androidx.constraintlayout.widget.ConstraintSet -import androidx.constraintlayout.widget.ConstraintSet.END -import androidx.constraintlayout.widget.ConstraintSet.MATCH_CONSTRAINT -import androidx.constraintlayout.widget.ConstraintSet.PARENT_ID -import androidx.constraintlayout.widget.ConstraintSet.START -import androidx.constraintlayout.widget.ConstraintSet.TOP -import com.android.keyguard.KeyguardStatusView -import com.android.keyguard.dagger.KeyguardStatusViewComponent -import com.android.systemui.keyguard.KeyguardViewConfigurator -import com.android.systemui.keyguard.MigrateClocksToBlueprint -import com.android.systemui.keyguard.shared.model.KeyguardSection -import com.android.systemui.media.controls.ui.controller.KeyguardMediaController -import com.android.systemui.res.R -import com.android.systemui.shade.NotificationPanelView -import com.android.systemui.shade.NotificationPanelViewController -import com.android.systemui.shade.ShadeDisplayAware -import com.android.systemui.statusbar.policy.SplitShadeStateController -import com.android.systemui.util.Utils -import dagger.Lazy -import javax.inject.Inject -import kotlinx.coroutines.ExperimentalCoroutinesApi - -class DefaultStatusViewSection -@Inject -constructor( - @ShadeDisplayAware private val context: Context, - private val notificationPanelView: NotificationPanelView, - private val keyguardStatusViewComponentFactory: KeyguardStatusViewComponent.Factory, - private val keyguardViewConfigurator: Lazy<KeyguardViewConfigurator>, - private val notificationPanelViewController: Lazy<NotificationPanelViewController>, - private val keyguardMediaController: KeyguardMediaController, - private val splitShadeStateController: SplitShadeStateController, -) : KeyguardSection() { - private val statusViewId = R.id.keyguard_status_view - - override fun addViews(constraintLayout: ConstraintLayout) { - if (!MigrateClocksToBlueprint.isEnabled) { - return - } - // At startup, 2 views with the ID `R.id.keyguard_status_view` will be available. - // Disable one of them - notificationPanelView.findViewById<View>(statusViewId)?.let { - notificationPanelView.removeView(it) - } - val keyguardStatusView = - (LayoutInflater.from(context) - .inflate(R.layout.keyguard_status_view, constraintLayout, false) - as KeyguardStatusView) - .apply { clipChildren = false } - - // This is diassembled and moved to [AodNotificationIconsSection] - keyguardStatusView.findViewById<View>(R.id.left_aligned_notification_icon_container)?.let { - it.setVisibility(View.GONE) - } - // Should keep this even if flag, migrating clocks to blueprint, is on - // cause some events in clockEventController rely on keyguardStatusViewController - // TODO(b/313499340): clean up - constraintLayout.addView(keyguardStatusView) - } - - override fun bindData(constraintLayout: ConstraintLayout) { - if (MigrateClocksToBlueprint.isEnabled) { - constraintLayout.findViewById<KeyguardStatusView?>(R.id.keyguard_status_view)?.let { - val statusViewComponent = - keyguardStatusViewComponentFactory.build(it, context.display) - val controller = statusViewComponent.keyguardStatusViewController - controller.init() - keyguardMediaController.attachSplitShadeContainer( - it.requireViewById<ViewGroup>(R.id.status_view_media_container) - ) - keyguardViewConfigurator.get().keyguardStatusViewController = controller - notificationPanelViewController.get().updateStatusViewController() - } - } - } - - override fun applyConstraints(constraintSet: ConstraintSet) { - constraintSet.apply { - constrainWidth(statusViewId, MATCH_CONSTRAINT) - constrainHeight(statusViewId, WRAP_CONTENT) - // TODO(b/296122465): Constrain to the top of [DefaultStatusBarSection] and remove the - // extra margin below. - connect(statusViewId, TOP, PARENT_ID, TOP) - connect(statusViewId, START, PARENT_ID, START) - connect(statusViewId, END, PARENT_ID, END) - - val margin = - if (splitShadeStateController.shouldUseSplitNotificationShade(context.resources)) { - context.resources.getDimensionPixelSize(R.dimen.keyguard_split_shade_top_margin) - } else { - context.resources.getDimensionPixelSize(R.dimen.keyguard_clock_top_margin) + - Utils.getStatusBarHeaderHeightKeyguard(context) - } - setMargin(statusViewId, TOP, margin) - } - } - - @OptIn(ExperimentalCoroutinesApi::class) - override fun removeViews(constraintLayout: ConstraintLayout) { - constraintLayout.removeView(statusViewId) - keyguardViewConfigurator.get().keyguardStatusViewController = null - } -} diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/KeyguardSliceViewSection.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/KeyguardSliceViewSection.kt index 604318a2751c..962e6089dce9 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/KeyguardSliceViewSection.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/KeyguardSliceViewSection.kt @@ -17,37 +17,64 @@ package com.android.systemui.keyguard.ui.view.layout.sections -import android.view.View -import android.view.ViewGroup +import android.os.Handler +import android.view.LayoutInflater import androidx.constraintlayout.widget.Barrier import androidx.constraintlayout.widget.ConstraintLayout import androidx.constraintlayout.widget.ConstraintSet +import com.android.keyguard.KeyguardSliceView +import com.android.keyguard.KeyguardSliceViewController import com.android.systemui.customization.R as customR -import com.android.systemui.keyguard.MigrateClocksToBlueprint +import com.android.systemui.dagger.qualifiers.Background +import com.android.systemui.dagger.qualifiers.Main +import com.android.systemui.dump.DumpManager import com.android.systemui.keyguard.shared.model.KeyguardSection +import com.android.systemui.plugins.ActivityStarter import com.android.systemui.res.R +import com.android.systemui.settings.DisplayTracker import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController +import com.android.systemui.statusbar.policy.ConfigurationController import javax.inject.Inject class KeyguardSliceViewSection @Inject constructor( val smartspaceController: LockscreenSmartspaceController, + val layoutInflater: LayoutInflater, + @Main val handler: Handler, + @Background val bgHandler: Handler, + val activityStarter: ActivityStarter, + val configurationController: ConfigurationController, + val dumpManager: DumpManager, + val displayTracker: DisplayTracker, ) : KeyguardSection() { + private lateinit var sliceView: KeyguardSliceView + override fun addViews(constraintLayout: ConstraintLayout) { - if (!MigrateClocksToBlueprint.isEnabled) return if (smartspaceController.isEnabled) return - constraintLayout.findViewById<View?>(R.id.keyguard_slice_view)?.let { - (it.parent as ViewGroup).removeView(it) - constraintLayout.addView(it) - } + sliceView = + layoutInflater.inflate(R.layout.keyguard_slice_view, null, false) as KeyguardSliceView + constraintLayout.addView(sliceView) } - override fun bindData(constraintLayout: ConstraintLayout) {} + override fun bindData(constraintLayout: ConstraintLayout) { + if (smartspaceController.isEnabled) return + + val controller = + KeyguardSliceViewController( + handler, + bgHandler, + sliceView, + activityStarter, + configurationController, + dumpManager, + displayTracker, + ) + controller.init() + } override fun applyConstraints(constraintSet: ConstraintSet) { - if (!MigrateClocksToBlueprint.isEnabled) return if (smartspaceController.isEnabled) return constraintSet.apply { @@ -55,13 +82,13 @@ constructor( R.id.keyguard_slice_view, ConstraintSet.START, ConstraintSet.PARENT_ID, - ConstraintSet.START + ConstraintSet.START, ) connect( R.id.keyguard_slice_view, ConstraintSet.END, ConstraintSet.PARENT_ID, - ConstraintSet.END + ConstraintSet.END, ) constrainHeight(R.id.keyguard_slice_view, ConstraintSet.WRAP_CONTENT) @@ -69,20 +96,19 @@ constructor( R.id.keyguard_slice_view, ConstraintSet.TOP, customR.id.lockscreen_clock_view, - ConstraintSet.BOTTOM + ConstraintSet.BOTTOM, ) createBarrier( R.id.smart_space_barrier_bottom, Barrier.BOTTOM, 0, - *intArrayOf(R.id.keyguard_slice_view) + *intArrayOf(R.id.keyguard_slice_view), ) } } override fun removeViews(constraintLayout: ConstraintLayout) { - if (!MigrateClocksToBlueprint.isEnabled) return if (smartspaceController.isEnabled) return constraintLayout.removeView(R.id.keyguard_slice_view) diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SplitShadeMediaSection.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SplitShadeMediaSection.kt index f0d21f22c5ee..c91a0072a502 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SplitShadeMediaSection.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SplitShadeMediaSection.kt @@ -17,7 +17,6 @@ package com.android.systemui.keyguard.ui.view.layout.sections import android.content.Context -import android.view.View import android.view.ViewGroup.LayoutParams.WRAP_CONTENT import android.widget.FrameLayout import androidx.constraintlayout.widget.ConstraintLayout @@ -29,11 +28,9 @@ import androidx.constraintlayout.widget.ConstraintSet.PARENT_ID import androidx.constraintlayout.widget.ConstraintSet.START import androidx.constraintlayout.widget.ConstraintSet.TOP import com.android.systemui.customization.R as customR -import com.android.systemui.keyguard.MigrateClocksToBlueprint import com.android.systemui.keyguard.shared.model.KeyguardSection import com.android.systemui.media.controls.ui.controller.KeyguardMediaController import com.android.systemui.res.R -import com.android.systemui.shade.NotificationPanelView import com.android.systemui.shade.ShadeDisplayAware import javax.inject.Inject @@ -42,20 +39,11 @@ class SplitShadeMediaSection @Inject constructor( @ShadeDisplayAware private val context: Context, - private val notificationPanelView: NotificationPanelView, private val keyguardMediaController: KeyguardMediaController, ) : KeyguardSection() { private val mediaContainerId = R.id.status_view_media_container override fun addViews(constraintLayout: ConstraintLayout) { - if (!MigrateClocksToBlueprint.isEnabled) { - return - } - - notificationPanelView.findViewById<View>(mediaContainerId)?.let { - notificationPanelView.removeView(it) - } - val mediaFrame = FrameLayout(context, null).apply { id = mediaContainerId @@ -75,10 +63,6 @@ constructor( override fun bindData(constraintLayout: ConstraintLayout) {} override fun applyConstraints(constraintSet: ConstraintSet) { - if (!MigrateClocksToBlueprint.isEnabled) { - return - } - constraintSet.apply { constrainWidth(mediaContainerId, MATCH_CONSTRAINT) constrainHeight(mediaContainerId, WRAP_CONTENT) @@ -89,10 +73,6 @@ constructor( } override fun removeViews(constraintLayout: ConstraintLayout) { - if (!MigrateClocksToBlueprint.isEnabled) { - return - } - constraintLayout.removeView(mediaContainerId) } } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/AodAlphaViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/AodAlphaViewModel.kt deleted file mode 100644 index acaa15edde82..000000000000 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/AodAlphaViewModel.kt +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 2023 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@file:OptIn(ExperimentalCoroutinesApi::class) - -package com.android.systemui.keyguard.ui.viewmodel - -import com.android.systemui.dagger.SysUISingleton -import com.android.systemui.keyguard.MigrateClocksToBlueprint -import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor -import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor -import com.android.systemui.keyguard.shared.model.KeyguardState.AOD -import com.android.systemui.keyguard.shared.model.KeyguardState.DOZING -import com.android.systemui.keyguard.shared.model.KeyguardState.GONE -import com.android.systemui.keyguard.shared.model.KeyguardState.UNDEFINED -import com.android.systemui.scene.domain.interactor.SceneInteractor -import com.android.systemui.scene.shared.flag.SceneContainerFlag -import com.android.systemui.scene.shared.model.Scenes -import javax.inject.Inject -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.combineTransform -import kotlinx.coroutines.flow.onStart - -/** Models UI state for the alpha of the AOD (always-on display). */ -@SysUISingleton -class AodAlphaViewModel -@Inject -constructor( - keyguardTransitionInteractor: KeyguardTransitionInteractor, - goneToAodTransitionViewModel: GoneToAodTransitionViewModel, - goneToDozingTransitionViewModel: GoneToDozingTransitionViewModel, - keyguardInteractor: KeyguardInteractor, - sceneInteractor: SceneInteractor, -) { - - /** The alpha level for the entire lockscreen while in AOD. */ - val alpha: Flow<Float> = - if (SceneContainerFlag.isEnabled) { - combineTransform( - keyguardTransitionInteractor.transitions, - sceneInteractor.transitionState, - goneToAodTransitionViewModel.enterFromTopAnimationAlpha.onStart { emit(0f) }, - goneToDozingTransitionViewModel.lockscreenAlpha.onStart { emit(0f) }, - keyguardInteractor.keyguardAlpha.onStart { emit(1f) }, - ) { step, sceneTransitionState, goneToAodAlpha, goneToDozingAlpha, keyguardAlpha -> - if (sceneTransitionState.isIdle(Scenes.Gone)) { - emit(0f) - } else if ( - step.from == UNDEFINED && - step.to == AOD && - sceneTransitionState.isTransitioning(Scenes.Gone, Scenes.Lockscreen) - ) { - emit(goneToAodAlpha) - } else if ( - step.from == UNDEFINED && - step.to == DOZING && - sceneTransitionState.isTransitioning(Scenes.Gone, Scenes.Lockscreen) - ) { - emit(goneToDozingAlpha) - } else if (!MigrateClocksToBlueprint.isEnabled) { - emit(keyguardAlpha) - } - } - } else { - combineTransform( - keyguardTransitionInteractor.transitions, - goneToAodTransitionViewModel.enterFromTopAnimationAlpha.onStart { emit(0f) }, - goneToDozingTransitionViewModel.lockscreenAlpha.onStart { emit(0f) }, - keyguardInteractor.keyguardAlpha.onStart { emit(1f) }, - ) { step, goneToAodAlpha, goneToDozingAlpha, keyguardAlpha -> - if (step.to == GONE) { - // When transitioning to GONE, only emit a value when complete as other - // transitions may be controlling the alpha fade - if (step.value == 1f) { - emit(0f) - } - } else if (step.from == GONE && step.to == AOD) { - emit(goneToAodAlpha) - } else if (step.from == GONE && step.to == DOZING) { - emit(goneToDozingAlpha) - } else if (!MigrateClocksToBlueprint.isEnabled) { - emit(keyguardAlpha) - } - } - } -} diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardIndicationAreaViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardIndicationAreaViewModel.kt index 4663a2b3c20c..3dcc60a98506 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardIndicationAreaViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardIndicationAreaViewModel.kt @@ -21,7 +21,6 @@ import com.android.systemui.communal.domain.interactor.CommunalSceneInteractor import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.doze.util.BurnInHelperWrapper -import com.android.systemui.keyguard.MigrateClocksToBlueprint import com.android.systemui.keyguard.domain.interactor.BurnInInteractor import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor @@ -72,8 +71,8 @@ constructor( combine(shortcutsCombinedViewModel.startButton, shortcutsCombinedViewModel.endButton) { startButtonModel, endButtonModel -> - startButtonModel.isVisible || endButtonModel.isVisible - } + startButtonModel.isVisible || endButtonModel.isVisible + } .distinctUntilChanged() @OptIn(ExperimentalCoroutinesApi::class) @@ -101,18 +100,6 @@ constructor( /** Returns an observable for the y-offset by which the indication area should be translated. */ fun indicationAreaTranslationY(defaultBurnInOffset: Int): Flow<Float> { - return if (MigrateClocksToBlueprint.isEnabled) { - burnIn.map { it.translationY.toFloat() }.flowOn(mainDispatcher) - } else { - keyguardInteractor.dozeAmount - .map { dozeAmount -> - dozeAmount * - (burnInHelperWrapper.burnInOffset( - /* amplitude = */ defaultBurnInOffset * 2, - /* xAxis= */ false, - ) - defaultBurnInOffset) - } - .distinctUntilChanged() - } + return burnIn.map { it.translationY.toFloat() }.flowOn(mainDispatcher) } } diff --git a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputAdapter.java b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputAdapter.java index 742f43533e6f..0ada931aea43 100644 --- a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputAdapter.java +++ b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputAdapter.java @@ -98,7 +98,7 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter { ((MediaGroupDividerViewHolder) viewHolder).onBind(currentMediaItem.getTitle()); break; case MediaItem.MediaItemType.TYPE_PAIR_NEW_DEVICE: - ((MediaDeviceViewHolder) viewHolder).onBind(CUSTOMIZED_ITEM_PAIR_NEW); + ((MediaDeviceViewHolder) viewHolder).onBindPairNewDevice(); break; case MediaItem.MediaItemType.TYPE_DEVICE: ((MediaDeviceViewHolder) viewHolder).onBind( @@ -418,20 +418,18 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter { updateIconAreaClickListener(listener); } - @Override - void onBind(int customizedItem) { - if (customizedItem == CUSTOMIZED_ITEM_PAIR_NEW) { - mTitleText.setTextColor(mController.getColorItemContent()); - mCheckBox.setVisibility(View.GONE); - setSingleLineLayout(mContext.getText(R.string.media_output_dialog_pairing_new)); - final Drawable addDrawable = mContext.getDrawable(R.drawable.ic_add); - mTitleIcon.setImageDrawable(addDrawable); - mTitleIcon.setImageTintList( - ColorStateList.valueOf(mController.getColorItemContent())); - mIconAreaLayout.setBackgroundTintList( - ColorStateList.valueOf(mController.getColorItemBackground())); - mContainerLayout.setOnClickListener(mController::launchBluetoothPairing); - } + /** Binds a ViewHolder for a "Connect a device" item. */ + void onBindPairNewDevice() { + mTitleText.setTextColor(mController.getColorItemContent()); + mCheckBox.setVisibility(View.GONE); + setSingleLineLayout(mContext.getText(R.string.media_output_dialog_pairing_new)); + final Drawable addDrawable = mContext.getDrawable(R.drawable.ic_add); + mTitleIcon.setImageDrawable(addDrawable); + mTitleIcon.setImageTintList( + ColorStateList.valueOf(mController.getColorItemContent())); + mIconAreaLayout.setBackgroundTintList( + ColorStateList.valueOf(mController.getColorItemBackground())); + mContainerLayout.setOnClickListener(mController::launchBluetoothPairing); } private void onGroupActionTriggered(boolean isChecked, MediaDevice device) { diff --git a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseAdapter.java b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseAdapter.java index ab998d10287f..af37eea102ca 100644 --- a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseAdapter.java +++ b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseAdapter.java @@ -20,7 +20,6 @@ import static com.android.systemui.media.dialog.MediaOutputSeekbar.VOLUME_PERCEN import android.animation.Animator; import android.animation.ValueAnimator; -import android.annotation.DrawableRes; import android.app.WallpaperColors; import android.content.Context; import android.content.res.ColorStateList; @@ -60,10 +59,6 @@ import java.util.List; public abstract class MediaOutputBaseAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { - static final int CUSTOMIZED_ITEM_PAIR_NEW = 1; - static final int CUSTOMIZED_ITEM_GROUP = 2; - static final int CUSTOMIZED_ITEM_DYNAMIC_GROUP = 3; - protected final MediaSwitchingController mController; private static final int UNMUTE_DEFAULT_VOLUME = 2; @@ -197,8 +192,6 @@ public abstract class MediaOutputBaseAdapter extends ColorStateList.valueOf(mController.getColorSeekbarProgress())); } - abstract void onBind(int customizedItem); - void setSingleLineLayout(CharSequence title) { setSingleLineLayout(title, false, false, false, false); } @@ -456,32 +449,6 @@ public abstract class MediaOutputBaseAdapter extends ColorStateList.valueOf(mController.getColorConnectedItemBackground())); } - private void animateCornerAndVolume(int fromProgress, int toProgress) { - final GradientDrawable layoutBackgroundDrawable = - (GradientDrawable) mItemLayout.getBackground(); - final ClipDrawable clipDrawable = - (ClipDrawable) ((LayerDrawable) mSeekBar.getProgressDrawable()) - .findDrawableByLayerId(android.R.id.progress); - final GradientDrawable targetBackgroundDrawable = - (GradientDrawable) (mIconAreaLayout.getBackground()); - mCornerAnimator.addUpdateListener(animation -> { - float value = (float) animation.getAnimatedValue(); - layoutBackgroundDrawable.setCornerRadius(value); - if (toProgress == 0) { - targetBackgroundDrawable.setCornerRadius(value); - } else { - targetBackgroundDrawable.setCornerRadii(new float[]{ - value, - value, - 0, 0, 0, 0, value, value - }); - } - }); - mVolumeAnimator.setIntValues(fromProgress, toProgress); - mVolumeAnimator.start(); - mCornerAnimator.start(); - } - private void initAnimator() { mCornerAnimator = ValueAnimator.ofFloat(mController.getInactiveRadius(), mController.getActiveRadius()); diff --git a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseDialog.java b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseDialog.java index 6bc995f3437c..9e50fb86fda0 100644 --- a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseDialog.java +++ b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseDialog.java @@ -26,13 +26,9 @@ import android.bluetooth.BluetoothLeBroadcastMetadata; import android.content.Context; import android.content.SharedPreferences; import android.content.res.Configuration; -import android.graphics.Bitmap; -import android.graphics.Canvas; import android.graphics.ColorFilter; -import android.graphics.PixelFormat; import android.graphics.PorterDuff; import android.graphics.PorterDuffColorFilter; -import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.Icon; import android.os.Bundle; @@ -70,7 +66,6 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements MediaSwitchingController.Callback, Window.Callback { private static final String TAG = "MediaOutputDialog"; - private static final String EMPTY_TITLE = " "; private static final String PREF_NAME = "MediaOutputDialog"; private static final String PREF_IS_LE_BROADCAST_FIRST_LAUNCH = "PrefIsLeBroadcastFirstLaunch"; private static final boolean DEBUG = true; @@ -99,11 +94,9 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog private ImageView mBroadcastIcon; private RecyclerView mDevicesRecyclerView; private LinearLayout mDeviceListLayout; - private LinearLayout mCastAppLayout; private LinearLayout mMediaMetadataSectionLayout; private Button mDoneButton; private Button mStopButton; - private Button mAppButton; private int mListMaxHeight; private int mItemHeight; private int mListPaddingTop; @@ -262,9 +255,7 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog mDeviceListLayout = mDialogView.requireViewById(R.id.device_list); mDoneButton = mDialogView.requireViewById(R.id.done); mStopButton = mDialogView.requireViewById(R.id.stop); - mAppButton = mDialogView.requireViewById(R.id.launch_app_button); mAppResourceIcon = mDialogView.requireViewById(R.id.app_source_icon); - mCastAppLayout = mDialogView.requireViewById(R.id.cast_app_section); mBroadcastIcon = mDialogView.requireViewById(R.id.broadcast_icon); mDeviceListLayout.getViewTreeObserver().addOnGlobalLayoutListener( @@ -277,7 +268,6 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog // Init bottom buttons mDoneButton.setOnClickListener(v -> dismiss()); mStopButton.setOnClickListener(v -> onStopButtonClick()); - mAppButton.setOnClickListener(mMediaSwitchingController::tryToLaunchMediaApplication); mMediaMetadataSectionLayout.setOnClickListener( mMediaSwitchingController::tryToLaunchMediaApplication); @@ -333,8 +323,6 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog final IconCompat headerIcon = getHeaderIcon(); final IconCompat appSourceIcon = getAppSourceIcon(); boolean colorSetUpdated = false; - mCastAppLayout.setVisibility( - mMediaSwitchingController.shouldShowLaunchSection() ? View.VISIBLE : View.GONE); if (iconRes != 0) { mHeaderIcon.setVisibility(View.VISIBLE); mHeaderIcon.setImageResource(iconRes); @@ -384,7 +372,6 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog R.dimen.media_output_dialog_header_icon_padding); mHeaderIcon.setLayoutParams(new LinearLayout.LayoutParams(size + padding, size)); } - mAppButton.setText(mMediaSwitchingController.getAppSourceName()); if (!mIncludePlaybackAndAppMetadata) { mHeaderTitle.setVisibility(View.GONE); @@ -443,22 +430,6 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog mDeviceListLayout.setBackgroundColor(mMediaSwitchingController.getColorDialogBackground()); } - private Drawable resizeDrawable(Drawable drawable, int size) { - if (drawable == null) { - return null; - } - int width = drawable.getIntrinsicWidth(); - int height = drawable.getIntrinsicHeight(); - Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 - : Bitmap.Config.RGB_565; - Bitmap bitmap = Bitmap.createBitmap(width, height, config); - Canvas canvas = new Canvas(bitmap); - drawable.setBounds(0, 0, width, height); - drawable.draw(canvas); - return new BitmapDrawable(mContext.getResources(), - Bitmap.createScaledBitmap(bitmap, size, size, false)); - } - public void handleLeBroadcastStarted() { // Waiting for the onBroadcastMetadataChanged. The UI launchs the broadcast dialog when // the metadata is ready. @@ -602,9 +573,6 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog mBroadcastSender.closeSystemDialogs(); } - void onHeaderIconClick() { - } - View getDialogView() { return mDialogView; } diff --git a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaSwitchingController.java b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaSwitchingController.java index 8fbbb8bc4872..1dbb31708fe1 100644 --- a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaSwitchingController.java +++ b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaSwitchingController.java @@ -305,11 +305,6 @@ public class MediaSwitchingController } } - boolean shouldShowLaunchSection() { - // TODO(b/231398073): Implements this when available. - return false; - } - public boolean isRefreshing() { return mIsRefreshing; } diff --git a/packages/SystemUI/src/com/android/systemui/qs/composefragment/ui/GridAnchor.kt b/packages/SystemUI/src/com/android/systemui/qs/composefragment/ui/GridAnchor.kt index f0f46d33b83d..266e875df85a 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/composefragment/ui/GridAnchor.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/composefragment/ui/GridAnchor.kt @@ -19,7 +19,7 @@ package com.android.systemui.qs.composefragment.ui import androidx.compose.foundation.layout.Spacer import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import com.android.compose.animation.scene.SceneScope +import com.android.compose.animation.scene.ContentScope import com.android.systemui.qs.shared.ui.ElementKeys /** @@ -27,7 +27,7 @@ import com.android.systemui.qs.shared.ui.ElementKeys * able to have relative anchor translation of elements that appear in QS. */ @Composable -fun SceneScope.GridAnchor(modifier: Modifier = Modifier) { +fun ContentScope.GridAnchor(modifier: Modifier = Modifier) { // The size of this anchor does not matter, as the tiles don't change size on expansion. Spacer(modifier.element(ElementKeys.GridAnchor)) } diff --git a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/toolbar/Toolbar.kt b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/toolbar/Toolbar.kt index 37fa9e799521..37b1642be57b 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/toolbar/Toolbar.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/toolbar/Toolbar.kt @@ -18,12 +18,9 @@ package com.android.systemui.qs.panels.ui.compose.toolbar import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.requiredHeight import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.dp import com.android.systemui.compose.modifiers.sysuiResTag import com.android.systemui.lifecycle.rememberViewModel import com.android.systemui.qs.footer.ui.compose.IconButton @@ -33,10 +30,7 @@ import com.android.systemui.qs.panels.ui.viewmodel.toolbar.ToolbarViewModel fun Toolbar(toolbarViewModelFactory: ToolbarViewModel.Factory, modifier: Modifier = Modifier) { val viewModel = rememberViewModel("Toolbar") { toolbarViewModelFactory.create() } - Row( - modifier = modifier.fillMaxWidth().requiredHeight(48.dp), - verticalAlignment = Alignment.CenterVertically, - ) { + Row(modifier = modifier, verticalAlignment = Alignment.CenterVertically) { viewModel.userSwitcherViewModel?.let { IconButton(it, Modifier.sysuiResTag("multi_user_switch")) } diff --git a/packages/SystemUI/src/com/android/systemui/scene/shared/flag/SceneContainerFlag.kt b/packages/SystemUI/src/com/android/systemui/scene/shared/flag/SceneContainerFlag.kt index 33bffc2e35ab..dc0c4dc0b01c 100644 --- a/packages/SystemUI/src/com/android/systemui/scene/shared/flag/SceneContainerFlag.kt +++ b/packages/SystemUI/src/com/android/systemui/scene/shared/flag/SceneContainerFlag.kt @@ -23,7 +23,6 @@ import com.android.systemui.Flags.sceneContainer import com.android.systemui.flags.FlagToken import com.android.systemui.flags.RefactorFlagUtils import com.android.systemui.keyguard.KeyguardWmStateRefactor -import com.android.systemui.keyguard.MigrateClocksToBlueprint import com.android.systemui.statusbar.notification.shared.NotificationThrottleHun import com.android.systemui.statusbar.phone.PredictiveBackSysUiFlag @@ -37,7 +36,6 @@ object SceneContainerFlag { get() = sceneContainer() && // mainAconfigFlag KeyguardWmStateRefactor.isEnabled && - MigrateClocksToBlueprint.isEnabled && NotificationThrottleHun.isEnabled && PredictiveBackSysUiFlag.isEnabled @@ -50,7 +48,6 @@ object SceneContainerFlag { inline fun getSecondaryFlags(): Sequence<FlagToken> = sequenceOf( KeyguardWmStateRefactor.token, - MigrateClocksToBlueprint.token, NotificationThrottleHun.token, PredictiveBackSysUiFlag.token, // NOTE: Changes should also be made in isEnabled and @EnableSceneContainer diff --git a/packages/SystemUI/src/com/android/systemui/shade/DebugDrawable.java b/packages/SystemUI/src/com/android/systemui/shade/DebugDrawable.java index d78f4d8238b1..2ca764728054 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/DebugDrawable.java +++ b/packages/SystemUI/src/com/android/systemui/shade/DebugDrawable.java @@ -85,22 +85,6 @@ public class DebugDrawable extends Drawable { mNotificationPanelViewController.getExpandedFraction()), Color.MAGENTA, "calculateNotificationsTopPadding()"); } - drawDebugInfo(canvas, mNotificationPanelViewController.getClockPositionResult().clockY, - Color.GRAY, "mClockPositionResult.clockY"); - - if (mNotificationPanelViewController.isKeyguardShowing()) { - // Notifications have the space between those two lines. - drawDebugInfo(canvas, - mNotificationStackScrollLayoutController.getTop() - + (int) mNotificationPanelViewController - .getKeyguardNotificationTopPadding(), - Color.RED, "NSSL.getTop() + mKeyguardNotificationTopPadding"); - - drawDebugInfo(canvas, mNotificationStackScrollLayoutController.getBottom() - - (int) mNotificationPanelViewController - .getKeyguardNotificationBottomPadding(), - Color.RED, "NSSL.getBottom() - mKeyguardNotificationBottomPadding"); - } mDebugPaint.setColor(Color.CYAN); canvas.drawLine(0, diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java index e681c98b10f4..197e6fc881c8 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java @@ -19,10 +19,7 @@ package com.android.systemui.shade; import static android.view.View.INVISIBLE; import static android.view.View.VISIBLE; -import static com.android.app.animation.Interpolators.EMPHASIZED_ACCELERATE; import static com.android.app.animation.Interpolators.EMPHASIZED_DECELERATE; -import static com.android.keyguard.KeyguardClockSwitch.LARGE; -import static com.android.keyguard.KeyguardClockSwitch.SMALL; import static com.android.systemui.Flags.msdlFeedback; import static com.android.systemui.Flags.predictiveBackAnimateShade; import static com.android.systemui.classifier.Classifier.BOUNCER_UNLOCK; @@ -30,10 +27,7 @@ import static com.android.systemui.classifier.Classifier.GENERIC; import static com.android.systemui.classifier.Classifier.QUICK_SETTINGS; import static com.android.systemui.classifier.Classifier.UNLOCK; import static com.android.systemui.keyguard.shared.model.KeyguardState.AOD; -import static com.android.systemui.keyguard.shared.model.KeyguardState.DREAMING; -import static com.android.systemui.keyguard.shared.model.KeyguardState.GONE; import static com.android.systemui.keyguard.shared.model.KeyguardState.LOCKSCREEN; -import static com.android.systemui.keyguard.shared.model.KeyguardState.OCCLUDED; import static com.android.systemui.navigationbar.gestural.Utilities.isTrackpadThreeFingerSwipe; import static com.android.systemui.shade.ShadeExpansionStateManagerKt.STATE_CLOSED; import static com.android.systemui.shade.ShadeExpansionStateManagerKt.STATE_OPEN; @@ -78,7 +72,6 @@ import android.view.VelocityTracker; import android.view.View; import android.view.View.AccessibilityDelegate; import android.view.ViewConfiguration; -import android.view.ViewGroup; import android.view.ViewPropertyAnimator; import android.view.ViewStub; import android.view.ViewTreeObserver; @@ -87,9 +80,6 @@ import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityNodeInfo; import android.view.animation.Interpolator; -import android.widget.FrameLayout; - -import androidx.constraintlayout.widget.ConstraintLayout; import com.android.app.animation.Interpolators; import com.android.internal.annotations.VisibleForTesting; @@ -99,19 +89,13 @@ import com.android.internal.policy.SystemBarUtils; import com.android.internal.statusbar.IStatusBarService; import com.android.internal.util.LatencyTracker; import com.android.keyguard.ActiveUnlockConfig; -import com.android.keyguard.KeyguardClockSwitch.ClockSize; -import com.android.keyguard.KeyguardStatusView; -import com.android.keyguard.KeyguardStatusViewController; import com.android.keyguard.KeyguardUnfoldTransition; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.dagger.KeyguardStatusBarViewComponent; -import com.android.keyguard.dagger.KeyguardStatusViewComponent; import com.android.systemui.DejankUtils; import com.android.systemui.Dumpable; import com.android.systemui.Gefingerpoken; -import com.android.systemui.biometrics.AuthController; import com.android.systemui.bouncer.domain.interactor.AlternateBouncerInteractor; -import com.android.systemui.bouncer.shared.constants.KeyguardBouncerConstants; import com.android.systemui.classifier.Classifier; import com.android.systemui.classifier.FalsingCollector; import com.android.systemui.dagger.SysUISingleton; @@ -125,24 +109,18 @@ import com.android.systemui.flags.FeatureFlags; import com.android.systemui.flags.Flags; import com.android.systemui.fragments.FragmentService; import com.android.systemui.keyguard.KeyguardUnlockAnimationController; -import com.android.systemui.keyguard.KeyguardViewConfigurator; -import com.android.systemui.keyguard.MigrateClocksToBlueprint; import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor; import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor; import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor; import com.android.systemui.keyguard.domain.interactor.NaturalScrollingSettingObserver; +import com.android.systemui.keyguard.shared.model.ClockSize; import com.android.systemui.keyguard.shared.model.Edge; import com.android.systemui.keyguard.shared.model.TransitionState; import com.android.systemui.keyguard.shared.model.TransitionStep; import com.android.systemui.keyguard.ui.binder.KeyguardLongPressViewBinder; import com.android.systemui.keyguard.ui.transitions.PrimaryBouncerTransition; import com.android.systemui.keyguard.ui.viewmodel.DreamingToLockscreenTransitionViewModel; -import com.android.systemui.keyguard.ui.viewmodel.GoneToDreamingTransitionViewModel; import com.android.systemui.keyguard.ui.viewmodel.KeyguardTouchHandlingViewModel; -import com.android.systemui.keyguard.ui.viewmodel.LockscreenToDreamingTransitionViewModel; -import com.android.systemui.keyguard.ui.viewmodel.LockscreenToOccludedTransitionViewModel; -import com.android.systemui.keyguard.ui.viewmodel.OccludedToLockscreenTransitionViewModel; -import com.android.systemui.keyguard.ui.viewmodel.PrimaryBouncerToGoneTransitionViewModel; import com.android.systemui.media.controls.domain.pipeline.MediaDataManager; import com.android.systemui.media.controls.ui.controller.KeyguardMediaController; import com.android.systemui.media.controls.ui.controller.MediaHierarchyManager; @@ -161,7 +139,6 @@ import com.android.systemui.power.shared.model.WakefulnessModel; import com.android.systemui.qs.flags.QSComposeFragment; import com.android.systemui.res.R; import com.android.systemui.scene.shared.flag.SceneContainerFlag; -import com.android.systemui.scene.shared.model.Scenes; import com.android.systemui.settings.brightness.domain.interactor.BrightnessMirrorShowingInteractor; import com.android.systemui.shade.data.repository.FlingInfo; import com.android.systemui.shade.data.repository.ShadeRepository; @@ -251,7 +228,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump public static final String TAG = NotificationPanelView.class.getSimpleName(); private static final boolean DEBUG_LOGCAT = Compile.IS_DEBUG && Log.isLoggable(TAG, Log.DEBUG); - private static final boolean SPEW_LOGCAT = Compile.IS_DEBUG && Log.isLoggable(TAG, Log.VERBOSE); private static final boolean DEBUG_DRAWABLE = false; /** The parallax amount of the quick settings translation when dragging down the panel. */ public static final float QS_PARALLAX_AMOUNT = 0.175f; @@ -319,10 +295,8 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump private final KeyguardUpdateMonitor mUpdateMonitor; private final DeviceEntryFaceAuthInteractor mDeviceEntryFaceAuthInteractor; private final ConversationNotificationManager mConversationNotificationManager; - private final AuthController mAuthController; private final MediaHierarchyManager mMediaHierarchyManager; private final StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; - private final KeyguardStatusViewComponent.Factory mKeyguardStatusViewComponentFactory; private final KeyguardStatusBarViewComponent.Factory mKeyguardStatusBarViewComponentFactory; private final FragmentService mFragmentService; private final IStatusBarService mStatusBarService; @@ -362,17 +336,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump private float mCurrentBackProgress = 0.0f; private boolean mExpanding; private boolean mSplitShadeEnabled; - /** The bottom padding reserved for elements of the keyguard measuring notifications. */ - private float mKeyguardNotificationBottomPadding; - /** - * The top padding from where notification should start in lockscreen. - * Should be static also during animations and should match the Y of the first notification. - */ - private float mKeyguardNotificationTopPadding; - /** Current max allowed keyguard notifications determined by measuring the panel. */ - private int mMaxAllowedKeyguardNotifications; private KeyguardStatusBarViewController mKeyguardStatusBarViewController; - private KeyguardStatusViewController mKeyguardStatusViewController; private NotificationsQuickSettingsContainer mNotificationContainerParent; private final NotificationsQSContainerController mNotificationsQSContainerController; private boolean mAnimateNextPositionUpdate; @@ -429,8 +393,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump Set<Animator> mTestSetOfAnimatorsUsed; private boolean mShowIconsWhenExpanded; - private int mIndicationBottomPadding; - private int mAmbientIndicationBottomPadding; /** Whether the notifications are displayed full width (no margins on the side). */ private boolean mIsFullWidth; private boolean mBlockingExpansionForCurrentTouch; @@ -456,8 +418,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump private int mPanelAlpha; private Runnable mPanelAlphaEndAction; - private float mBottomAreaShadeAlpha; - final ValueAnimator mBottomAreaShadeAlphaAnimator; private final AnimatableProperty mPanelAlphaAnimator = AnimatableProperty.from("panelAlpha", (view, alpha) -> { setAlphaInternal(alpha); @@ -499,11 +459,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump /** Whether a collapse that started on the panel should allow the panel to intercept. */ private boolean mIsPanelCollapseOnQQS; - /** Alpha of the views which only show on the keyguard but not in shade / shade locked. */ - private float mKeyguardOnlyContentAlpha = 1.0f; - /** Y translation of the views that only show on the keyguard but in shade / shade locked. */ - private int mKeyguardOnlyTransitionTranslationY = 0; - private float mUdfpsMaxYBurnInOffset; /** Are we currently in gesture navigation. */ private boolean mIsGestureNavigation; private int mOldLayoutDirection; @@ -570,23 +525,13 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump private boolean mExpandLatencyTracking; private boolean mUseExternalTouch = false; private final DreamingToLockscreenTransitionViewModel mDreamingToLockscreenTransitionViewModel; - private final OccludedToLockscreenTransitionViewModel mOccludedToLockscreenTransitionViewModel; - private final LockscreenToDreamingTransitionViewModel mLockscreenToDreamingTransitionViewModel; - private final GoneToDreamingTransitionViewModel mGoneToDreamingTransitionViewModel; - private final LockscreenToOccludedTransitionViewModel mLockscreenToOccludedTransitionViewModel; - private final PrimaryBouncerToGoneTransitionViewModel mPrimaryBouncerToGoneTransitionViewModel; private final SharedNotificationContainerInteractor mSharedNotificationContainerInteractor; private final ActiveNotificationsInteractor mActiveNotificationsInteractor; private final KeyguardTransitionInteractor mKeyguardTransitionInteractor; private final KeyguardInteractor mKeyguardInteractor; private final PowerInteractor mPowerInteractor; - private final KeyguardViewConfigurator mKeyguardViewConfigurator; private final CoroutineDispatcher mMainDispatcher; private boolean mIsAnyMultiShadeExpanded; - private boolean mIsOcclusionTransitionRunning = false; - private int mDreamingToLockscreenTransitionTranslationY; - private int mLockscreenToDreamingTransitionTranslationY; - private int mGoneToDreamingTransitionTranslationY; private boolean mForceFlingAnimationForTest = false; private final SplitShadeStateController mSplitShadeStateController; private final Runnable mFlingCollapseRunnable = () -> fling(0, false /* expand */, @@ -601,37 +546,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump } }; - private final Consumer<TransitionStep> mDreamingToLockscreenTransition = - (TransitionStep step) -> { - mIsOcclusionTransitionRunning = - step.getTransitionState() == TransitionState.RUNNING; - }; - - private final Consumer<TransitionStep> mOccludedToLockscreenTransition = - (TransitionStep step) -> { - mIsOcclusionTransitionRunning = - step.getTransitionState() == TransitionState.RUNNING; - }; - - private final Consumer<TransitionStep> mLockscreenToDreamingTransition = - (TransitionStep step) -> { - mIsOcclusionTransitionRunning = - step.getTransitionState() == TransitionState.RUNNING; - }; - - private final Consumer<TransitionStep> mGoneToDreamingTransition = - (TransitionStep step) -> { - mIsOcclusionTransitionRunning = - step.getTransitionState() == TransitionState.RUNNING; - }; - - - private final Consumer<TransitionStep> mLockscreenToOccludedTransition = - (TransitionStep step) -> { - mIsOcclusionTransitionRunning = - step.getTransitionState() == TransitionState.RUNNING; - }; - private final ActivityStarter mActivityStarter; private final BrightnessMirrorShowingInteractor mBrightnessMirrorShowingInteractor; @@ -668,10 +582,8 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump NotificationGutsManager gutsManager, NotificationsQSContainerController notificationsQSContainerController, NotificationStackScrollLayoutController notificationStackScrollLayoutController, - KeyguardStatusViewComponent.Factory keyguardStatusViewComponentFactory, KeyguardStatusBarViewComponent.Factory keyguardStatusBarViewComponentFactory, LockscreenShadeTransitionController lockscreenShadeTransitionController, - AuthController authController, ScrimController scrimController, UserManager userManager, MediaDataManager mediaDataManager, @@ -701,11 +613,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump KeyguardClockInteractor keyguardClockInteractor, AlternateBouncerInteractor alternateBouncerInteractor, DreamingToLockscreenTransitionViewModel dreamingToLockscreenTransitionViewModel, - OccludedToLockscreenTransitionViewModel occludedToLockscreenTransitionViewModel, - LockscreenToDreamingTransitionViewModel lockscreenToDreamingTransitionViewModel, - GoneToDreamingTransitionViewModel goneToDreamingTransitionViewModel, - LockscreenToOccludedTransitionViewModel lockscreenToOccludedTransitionViewModel, - PrimaryBouncerToGoneTransitionViewModel primaryBouncerToGoneTransitionViewModel, @Main CoroutineDispatcher mainDispatcher, KeyguardTransitionInteractor keyguardTransitionInteractor, DumpManager dumpManager, @@ -715,7 +622,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump SharedNotificationContainerInteractor sharedNotificationContainerInteractor, ActiveNotificationsInteractor activeNotificationsInteractor, ShadeAnimationInteractor shadeAnimationInteractor, - KeyguardViewConfigurator keyguardViewConfigurator, DeviceEntryFaceAuthInteractor deviceEntryFaceAuthInteractor, SplitShadeStateController splitShadeStateController, PowerInteractor powerInteractor, @@ -740,17 +646,11 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump mShadeLog = shadeLogger; mGutsManager = gutsManager; mDreamingToLockscreenTransitionViewModel = dreamingToLockscreenTransitionViewModel; - mOccludedToLockscreenTransitionViewModel = occludedToLockscreenTransitionViewModel; - mLockscreenToDreamingTransitionViewModel = lockscreenToDreamingTransitionViewModel; - mGoneToDreamingTransitionViewModel = goneToDreamingTransitionViewModel; - mLockscreenToOccludedTransitionViewModel = lockscreenToOccludedTransitionViewModel; - mPrimaryBouncerToGoneTransitionViewModel = primaryBouncerToGoneTransitionViewModel; mKeyguardTransitionInteractor = keyguardTransitionInteractor; mSharedNotificationContainerInteractor = sharedNotificationContainerInteractor; mActiveNotificationsInteractor = activeNotificationsInteractor; mKeyguardInteractor = keyguardInteractor; mPowerInteractor = powerInteractor; - mKeyguardViewConfigurator = keyguardViewConfigurator; mClockPositionAlgorithm = keyguardClockPositionAlgorithm; mNaturalScrollingSettingObserver = naturalScrollingSettingObserver; mView.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() { @@ -813,7 +713,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump mNavigationBarController = navigationBarController; mNotificationsQSContainerController.init(); mNotificationStackScrollLayoutController = notificationStackScrollLayoutController; - mKeyguardStatusViewComponentFactory = keyguardStatusViewComponentFactory; mKeyguardStatusBarViewComponentFactory = keyguardStatusBarViewComponentFactory; mDepthController = notificationShadeDepthController; mContentResolver = contentResolver; @@ -852,16 +751,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump quickSettingsController.setFlingQsWithoutClickListener(this::onFlingQsWithoutClick); quickSettingsController.setExpansionHeightSetToMaxListener(this::onExpansionHeightSetToMax); shadeExpansionStateManager.addStateListener(this::onPanelStateChanged); - - mBottomAreaShadeAlphaAnimator = ValueAnimator.ofFloat(1f, 0); - mBottomAreaShadeAlphaAnimator.addUpdateListener(animation -> { - mBottomAreaShadeAlpha = (float) animation.getAnimatedValue(); - updateKeyguardBottomAreaAlpha(); - }); - mBottomAreaShadeAlphaAnimator.setDuration(160); - mBottomAreaShadeAlphaAnimator.setInterpolator(Interpolators.ALPHA_OUT); mConversationNotificationManager = conversationNotificationManager; - mAuthController = authController; mScreenOffAnimationController = screenOffAnimationController; mUnlockedScreenOffAnimationController = unlockedScreenOffAnimationController; mLastDownEvents = new NPVCDownEventState.Buffer(MAX_DOWN_EVENT_BUFFER_SIZE); @@ -950,28 +840,9 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump instantCollapse(); } else { mView.animate().cancel(); - if (!MigrateClocksToBlueprint.isEnabled()) { - mView.animate() - .alpha(0f) - .setStartDelay(0) - // Translate up by 4%. - .translationY(mView.getHeight() * -0.04f) - // This start delay is to give us time to animate out before - // the launcher icons animation starts, so use that as our - // duration. - .setDuration(unlockAnimationStartDelay) - .setInterpolator(EMPHASIZED_ACCELERATE) - .withEndAction(() -> { - instantCollapse(); - mView.setAlpha(1f); - mView.setTranslationY(0f); - }) - .start(); - } else { - mView.postDelayed(() -> { - instantCollapse(); - }, unlockAnimationStartDelay); - } + mView.postDelayed(() -> { + instantCollapse(); + }, unlockAnimationStartDelay); } } } @@ -979,7 +850,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump @VisibleForTesting void onFinishInflate() { loadDimens(); - mKeyguardStatusBarViewController = mKeyguardStatusBarViewComponentFactory.build( mView.findViewById(R.id.keyguard_header), @@ -987,7 +857,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump .getKeyguardStatusBarViewController(); mKeyguardStatusBarViewController.init(); mNotificationContainerParent = mView.findViewById(R.id.notification_container_parent); - updateStatusViewController(); mNotificationStackScrollLayoutController.setOnHeightChangedListener( new NsslHeightChangedListener()); mNotificationStackScrollLayoutController.setOnEmptySpaceClickListener( @@ -1020,89 +889,17 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump () -> collapse(/* delayed= */ false , /* speedUpFactor= */ 1.0f)); // Dreaming->Lockscreen - collectFlow( - mView, - mKeyguardTransitionInteractor.transition( - Edge.Companion.create(DREAMING, LOCKSCREEN)), - mDreamingToLockscreenTransition, - mMainDispatcher); collectFlow(mView, mDreamingToLockscreenTransitionViewModel.getLockscreenAlpha(), setDreamLockscreenTransitionAlpha(mNotificationStackScrollLayoutController), mMainDispatcher); - collectFlow(mView, mDreamingToLockscreenTransitionViewModel.lockscreenTranslationY( - mDreamingToLockscreenTransitionTranslationY), - setTransitionY(mNotificationStackScrollLayoutController), mMainDispatcher); - // Occluded->Lockscreen - collectFlow(mView, mKeyguardTransitionInteractor.transition( - Edge.Companion.create(OCCLUDED, LOCKSCREEN)), - mOccludedToLockscreenTransition, mMainDispatcher); - if (!MigrateClocksToBlueprint.isEnabled()) { - collectFlow(mView, mOccludedToLockscreenTransitionViewModel.getLockscreenAlpha(), - setTransitionAlpha(mNotificationStackScrollLayoutController), mMainDispatcher); - collectFlow(mView, - mOccludedToLockscreenTransitionViewModel.getLockscreenTranslationY(), - setTransitionY(mNotificationStackScrollLayoutController), mMainDispatcher); - } - - // Lockscreen->Dreaming - collectFlow(mView, mKeyguardTransitionInteractor.transition( - Edge.Companion.create(LOCKSCREEN, DREAMING)), - mLockscreenToDreamingTransition, mMainDispatcher); - if (!MigrateClocksToBlueprint.isEnabled()) { - collectFlow(mView, mLockscreenToDreamingTransitionViewModel.getLockscreenAlpha(), - setDreamLockscreenTransitionAlpha(mNotificationStackScrollLayoutController), - mMainDispatcher); - } - collectFlow(mView, mLockscreenToDreamingTransitionViewModel.lockscreenTranslationY( - mLockscreenToDreamingTransitionTranslationY), - setTransitionY(mNotificationStackScrollLayoutController), mMainDispatcher); - - // Gone->Dreaming - collectFlow(mView, mKeyguardTransitionInteractor.transition( - Edge.Companion.create(Scenes.Gone, DREAMING), - Edge.Companion.create(GONE, DREAMING)), - mGoneToDreamingTransition, mMainDispatcher); - if (!MigrateClocksToBlueprint.isEnabled()) { - collectFlow(mView, mGoneToDreamingTransitionViewModel.getLockscreenAlpha(), - setTransitionAlpha(mNotificationStackScrollLayoutController), mMainDispatcher); - } - collectFlow(mView, mGoneToDreamingTransitionViewModel.lockscreenTranslationY( - mGoneToDreamingTransitionTranslationY), - setTransitionY(mNotificationStackScrollLayoutController), mMainDispatcher); - - // Lockscreen->Occluded collectFlow(mView, mKeyguardTransitionInteractor.transition( - Edge.Companion.create(LOCKSCREEN, OCCLUDED)), - mLockscreenToOccludedTransition, mMainDispatcher); - if (!MigrateClocksToBlueprint.isEnabled()) { - collectFlow(mView, mLockscreenToOccludedTransitionViewModel.getLockscreenAlpha(), - setTransitionAlpha(mNotificationStackScrollLayoutController), mMainDispatcher); - collectFlow(mView, mLockscreenToOccludedTransitionViewModel.getLockscreenTranslationY(), - setTransitionY(mNotificationStackScrollLayoutController), mMainDispatcher); - } - - // Primary bouncer->Gone (ensures lockscreen content is not visible on successful auth) - if (!MigrateClocksToBlueprint.isEnabled()) { - collectFlow(mView, mPrimaryBouncerToGoneTransitionViewModel.getLockscreenAlpha(), - setTransitionAlpha(mNotificationStackScrollLayoutController, - /* excludeNotifications=*/ true), mMainDispatcher); - collectFlow(mView, mPrimaryBouncerToGoneTransitionViewModel.getNotificationAlpha(), - (Float alpha) -> { - mNotificationStackScrollLayoutController.setMaxAlphaForKeyguard(alpha, - "mPrimaryBouncerToGoneTransitionViewModel.getNotificationAlpha()"); - }, mMainDispatcher); - } - - if (MigrateClocksToBlueprint.isEnabled()) { - collectFlow(mView, mKeyguardTransitionInteractor.transition( - Edge.Companion.create(AOD, LOCKSCREEN)), - (TransitionStep step) -> { - if (step.getTransitionState() == TransitionState.FINISHED) { - updateExpandedHeightToMaxHeight(); - } - }, mMainDispatcher); - } + Edge.Companion.create(AOD, LOCKSCREEN)), + (TransitionStep step) -> { + if (step.getTransitionState() == TransitionState.FINISHED) { + updateExpandedHeightToMaxHeight(); + } + }, mMainDispatcher); if (com.android.systemui.Flags.bouncerUiRevamp()) { collectFlow(mView, mKeyguardInteractor.primaryBouncerShowing, @@ -1138,22 +935,13 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump mStatusBarMinHeight = SystemBarUtils.getStatusBarHeight(mView.getContext()); mStatusBarHeaderHeightKeyguard = Utils.getStatusBarHeaderHeightKeyguard(mView.getContext()); mClockPositionAlgorithm.loadDimens(mView.getContext(), mResources); - mIndicationBottomPadding = mResources.getDimensionPixelSize( - R.dimen.keyguard_indication_bottom_padding); int statusbarHeight = SystemBarUtils.getStatusBarHeight(mView.getContext()); mHeadsUpInset = statusbarHeight + mResources.getDimensionPixelSize( R.dimen.heads_up_status_bar_padding); mMaxOverscrollAmountForPulse = mResources.getDimensionPixelSize( R.dimen.pulse_expansion_max_top_overshoot); - mUdfpsMaxYBurnInOffset = mResources.getDimensionPixelSize(R.dimen.udfps_burn_in_offset_y); mSplitShadeScrimTransitionDistance = mResources.getDimensionPixelSize( R.dimen.split_shade_scrim_transition_distance); - mDreamingToLockscreenTransitionTranslationY = mResources.getDimensionPixelSize( - R.dimen.dreaming_to_lockscreen_transition_lockscreen_translation_y); - mLockscreenToDreamingTransitionTranslationY = mResources.getDimensionPixelSize( - R.dimen.lockscreen_to_dreaming_transition_lockscreen_translation_y); - mGoneToDreamingTransitionTranslationY = mResources.getDimensionPixelSize( - R.dimen.gone_to_dreaming_transition_lockscreen_translation_y); // TODO (b/265193930): remove this and make QsController listen to NotificationPanelViews mQsController.loadDimens(); } @@ -1174,37 +962,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump } } - /** Updates the StatusBarViewController and updates any that depend on it. */ - public void updateStatusViewController() { - // Re-associate the KeyguardStatusViewController - if (MigrateClocksToBlueprint.isEnabled()) { - // Need a shared controller until mKeyguardStatusViewController can be removed from - // here, due to important state being set in that controller. Rebind in order to pick - // up config changes - mKeyguardStatusViewController = - mKeyguardViewConfigurator.getKeyguardStatusViewController(); - } else { - KeyguardStatusView keyguardStatusView = mView.getRootView().findViewById( - R.id.keyguard_status_view); - KeyguardStatusViewComponent statusViewComponent = - mKeyguardStatusViewComponentFactory.build(keyguardStatusView, - mView.getContext().getDisplay()); - mKeyguardStatusViewController = statusViewComponent.getKeyguardStatusViewController(); - mKeyguardStatusViewController.init(); - - mKeyguardStatusViewController.setSplitShadeEnabled(mSplitShadeEnabled); - mKeyguardStatusViewController.getView().addOnLayoutChangeListener( - (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> { - int oldHeight = oldBottom - oldTop; - if (v.getHeight() != oldHeight) { - mNotificationStackScrollLayoutController.animateNextTopPaddingChange(); - } - }); - - updateClockAppearance(); - } - } - @Override public void updateResources() { Trace.beginSection("NSSLC#updateResources"); @@ -1233,16 +990,9 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump private void onSplitShadeEnabledChanged() { mShadeLog.logSplitShadeChanged(mSplitShadeEnabled); - if (!MigrateClocksToBlueprint.isEnabled()) { - mKeyguardStatusViewController.setSplitShadeEnabled(mSplitShadeEnabled); - } // Reset any left over overscroll state. It is a rare corner case but can happen. mQsController.setOverScrollAmount(0); mScrimController.setNotificationsOverScrollAmount(0); - if (!MigrateClocksToBlueprint.isEnabled()) { - mNotificationStackScrollLayoutController.setOverExpansion(0); - mNotificationStackScrollLayoutController.setOverScrollAmount(0); - } // when we switch between split shade and regular shade we want to enforce setting qs to // the default state: expanded for split shade and collapsed otherwise @@ -1260,9 +1010,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump } updateClockAppearance(); mQsController.updateQsState(); - if (!MigrateClocksToBlueprint.isEnabled() && !FooterViewRefactor.isEnabled()) { - mNotificationStackScrollLayoutController.updateFooter(); - } } private View reInflateStub(int viewId, int stubId, int layoutId, boolean enabled) { @@ -1291,45 +1038,9 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump @VisibleForTesting void reInflateViews() { debugLog("reInflateViews"); - // Re-inflate the status view group. - if (!MigrateClocksToBlueprint.isEnabled()) { - KeyguardStatusView keyguardStatusView = - mNotificationContainerParent.findViewById(R.id.keyguard_status_view); - int statusIndex = mNotificationContainerParent.indexOfChild(keyguardStatusView); - mNotificationContainerParent.removeView(keyguardStatusView); - keyguardStatusView = (KeyguardStatusView) mLayoutInflater.inflate( - R.layout.keyguard_status_view, mNotificationContainerParent, false); - mNotificationContainerParent.addView(keyguardStatusView, statusIndex); - - attachSplitShadeMediaPlayerContainer( - keyguardStatusView.findViewById(R.id.status_view_media_container)); - } - - // we need to update KeyguardStatusView constraints after reinflating it updateResources(); - updateStatusViewController(); mStatusBarStateListener.onDozeAmountChanged(mStatusBarStateController.getDozeAmount(), mStatusBarStateController.getInterpolatedDozeAmount()); - - if (!MigrateClocksToBlueprint.isEnabled()) { - mKeyguardStatusViewController.setKeyguardStatusViewVisibility( - mBarState, - false, - false, - mBarState); - } - } - - private void attachSplitShadeMediaPlayerContainer(FrameLayout container) { - if (MigrateClocksToBlueprint.isEnabled()) { - return; - } - mKeyguardMediaController.attachSplitShadeContainer(container); - } - - @VisibleForTesting - void setMaxDisplayedNotifications(int maxAllowed) { - mMaxAllowedKeyguardNotifications = maxAllowed; } @VisibleForTesting @@ -1337,33 +1048,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump return mIsFlinging; } - private void updateMaxDisplayedNotifications(boolean recompute) { - if (MigrateClocksToBlueprint.isEnabled()) { - return; - } - - if (recompute) { - setMaxDisplayedNotifications(Math.max(computeMaxKeyguardNotifications(), 1)); - } else { - if (SPEW_LOGCAT) Log.d(TAG, "Skipping computeMaxKeyguardNotifications() by request"); - } - - if (isKeyguardShowing() && !mKeyguardBypassController.getBypassEnabled()) { - mNotificationStackScrollLayoutController.setMaxDisplayedNotifications( - mMaxAllowedKeyguardNotifications); - mNotificationStackScrollLayoutController.setKeyguardBottomPaddingForDebug( - mKeyguardNotificationBottomPadding); - } else { - // no max when not on the keyguard - mNotificationStackScrollLayoutController.setMaxDisplayedNotifications(-1); - mNotificationStackScrollLayoutController.setKeyguardBottomPaddingForDebug(-1f); - } - } - - private boolean shouldAvoidChangingNotificationsCount() { - return mUnlockedScreenOffAnimationController.isAnimationPlaying(); - } - /** Sets a listener to be notified when the shade starts opening or finishes closing. */ public void setOpenCloseListener(OpenCloseListener openCloseListener) { SceneContainerFlag.assertInLegacyMode(); @@ -1443,68 +1127,28 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump } private void updateClockAppearance() { - boolean bypassEnabled = mKeyguardBypassController.getBypassEnabled(); - boolean shouldAnimateClockChange = mScreenOffAnimationController.shouldAnimateClockChange(); - if (MigrateClocksToBlueprint.isEnabled()) { - mKeyguardClockInteractor.setClockSize(computeDesiredClockSize()); - } else { - mKeyguardStatusViewController.displayClock(computeDesiredClockSize(), - shouldAnimateClockChange); - } + mKeyguardClockInteractor.setClockSize(computeDesiredClockSize()); updateKeyguardStatusViewAlignment(/* animate= */true); - float expandedFraction = - mScreenOffAnimationController.shouldExpandNotifications() - ? 1.0f : getExpandedFraction(); + float darkAmount = mScreenOffAnimationController.shouldExpandNotifications() ? 1.0f : mInterpolatedDarkAmount; - float udfpsAodTopLocation = -1f; - if (mUpdateMonitor.isUdfpsEnrolled() && mAuthController.getUdfpsLocation() != null) { - udfpsAodTopLocation = mAuthController.getUdfpsLocation().y - - mAuthController.getUdfpsRadius() - mUdfpsMaxYBurnInOffset; - } - mClockPositionAlgorithm.setup( - mStatusBarHeaderHeightKeyguard, - expandedFraction, - mKeyguardStatusViewController.getLockscreenHeight(), darkAmount, mOverStretchAmount, - bypassEnabled, + mKeyguardBypassController.getBypassEnabled(), mQsController.getHeaderHeight(), - mQsController.computeExpansionFraction(), - mDisplayTopInset, - mSplitShadeEnabled, - udfpsAodTopLocation, - mKeyguardStatusViewController.getClockBottom(mStatusBarHeaderHeightKeyguard), - mKeyguardStatusViewController.isClockTopAligned()); + mSplitShadeEnabled); mClockPositionAlgorithm.run(mClockPositionResult); - if (!MigrateClocksToBlueprint.isEnabled()) { - mKeyguardStatusViewController.setLockscreenClockY( - mClockPositionAlgorithm.getExpandedPreferredClockY()); - } - - boolean animate = !SceneContainerFlag.isEnabled() - && mNotificationStackScrollLayoutController.isAddOrRemoveAnimationPending(); - boolean animateClock = (animate || mAnimateNextPositionUpdate) && shouldAnimateClockChange; - - if (!MigrateClocksToBlueprint.isEnabled()) { - mKeyguardStatusViewController.updatePosition( - mClockPositionResult.clockX, mClockPositionResult.clockY, - mClockPositionResult.clockScale, animateClock); - } - updateNotificationTranslucency(); - updateClock(); } KeyguardClockPositionAlgorithm.Result getClockPositionResult() { return mClockPositionResult; } - @ClockSize - private int computeDesiredClockSize() { + private ClockSize computeDesiredClockSize() { if (shouldForceSmallClock()) { - return SMALL; + return ClockSize.SMALL; } if (mSplitShadeEnabled) { @@ -1513,34 +1157,22 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump return computeDesiredClockSizeForSingleShade(); } - @ClockSize - private int computeDesiredClockSizeForSingleShade() { + private ClockSize computeDesiredClockSizeForSingleShade() { if (hasVisibleNotifications()) { - return SMALL; + return ClockSize.SMALL; } - return LARGE; + return ClockSize.LARGE; } - @ClockSize - private int computeDesiredClockSizeForSplitShade() { + private ClockSize computeDesiredClockSizeForSplitShade() { // Media is not visible to the user on AOD. boolean isMediaVisibleToUser = mMediaDataManager.hasActiveMediaOrRecommendation() && !isOnAod(); if (isMediaVisibleToUser) { // When media is visible, it overlaps with the large clock. Use small clock instead. - return SMALL; - } - // To prevent the weather clock from overlapping with the notification shelf on AOD, we use - // the small clock here - // With migrateClocksToBlueprint, weather clock will have behaviors similar to other clocks - if (!MigrateClocksToBlueprint.isEnabled()) { - boolean bypassEnabled = mKeyguardBypassController.getBypassEnabled(); - if (mKeyguardStatusViewController.isLargeClockBlockingNotificationShelf() - && hasVisibleNotifications() && (isOnAod() || bypassEnabled)) { - return SMALL; - } + return ClockSize.SMALL; } - return LARGE; + return ClockSize.LARGE; } private boolean shouldForceSmallClock() { @@ -1553,13 +1185,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump private void updateKeyguardStatusViewAlignment(boolean animate) { boolean shouldBeCentered = shouldKeyguardStatusViewBeCentered(); mKeyguardUnfoldTransition.ifPresent(t -> t.setStatusViewCentered(shouldBeCentered)); - if (MigrateClocksToBlueprint.isEnabled()) { - mKeyguardInteractor.setClockShouldBeCentered(shouldBeCentered); - return; - } - ConstraintLayout layout = mNotificationContainerParent; - mKeyguardStatusViewController.updateAlignment( - layout, mSplitShadeEnabled, shouldBeCentered, animate); + mKeyguardInteractor.setClockShouldBeCentered(shouldBeCentered); } private boolean shouldKeyguardStatusViewBeCentered() { @@ -1588,7 +1214,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump return mDozing && mDozeParameters.getAlwaysOn(); } - private boolean hasVisibleNotifications() { if (FooterViewRefactor.isEnabled()) { return mActiveNotificationsInteractor.getAreAnyNotificationsPresentValue() @@ -1600,121 +1225,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump } } - /** Returns space between top of lock icon and bottom of NotificationStackScrollLayout. */ - private float getLockIconPadding() { - float lockIconPadding = 0f; - View deviceEntryIconView = mKeyguardViewConfigurator.getKeyguardRootView() - .findViewById(R.id.device_entry_icon_view); - if (deviceEntryIconView != null) { - lockIconPadding = mNotificationStackScrollLayoutController.getBottom() - - deviceEntryIconView.getTop(); - } - return lockIconPadding; - } - - /** Returns space available to show notifications on lockscreen. */ - @VisibleForTesting - float getVerticalSpaceForLockscreenNotifications() { - final float lockIconPadding = getLockIconPadding(); - - float bottomPadding = Math.max(lockIconPadding, - Math.max(mIndicationBottomPadding, mAmbientIndicationBottomPadding)); - mKeyguardNotificationBottomPadding = bottomPadding; - - float staticTopPadding = mClockPositionAlgorithm.getLockscreenNotifPadding( - mNotificationStackScrollLayoutController.getTop()); - - mKeyguardNotificationTopPadding = staticTopPadding; - - // To debug the available space, enable debug lines in this class. If you change how the - // available space is calculated, please also update those lines. - final float verticalSpace = - mNotificationStackScrollLayoutController.getHeight() - - staticTopPadding - - bottomPadding; - - if (SPEW_LOGCAT) { - Log.i(TAG, "\n"); - Log.i(TAG, "staticTopPadding[" + staticTopPadding - + "] = Clock.padding[" - + mClockPositionAlgorithm.getLockscreenNotifPadding( - mNotificationStackScrollLayoutController.getTop()) - + "]" - ); - Log.i(TAG, "bottomPadding[" + bottomPadding - + "] = max(ambientIndicationBottomPadding[" + mAmbientIndicationBottomPadding - + "], mIndicationBottomPadding[" + mIndicationBottomPadding - + "], lockIconPadding[" + lockIconPadding - + "])" - ); - Log.i(TAG, "verticalSpaceForNotifications[" + verticalSpace - + "] = NSSL.height[" + mNotificationStackScrollLayoutController.getHeight() - + "] - staticTopPadding[" + staticTopPadding - + "] - bottomPadding[" + bottomPadding - + "]" - ); - } - return verticalSpace; - } - - /** Returns extra space available to show the shelf on lockscreen */ - @VisibleForTesting - float getVerticalSpaceForLockscreenShelf() { - if (mSplitShadeEnabled) { - return 0f; - } - final float lockIconPadding = getLockIconPadding(); - - final float noShelfOverlapBottomPadding = - Math.max(mIndicationBottomPadding, mAmbientIndicationBottomPadding); - - final float extraSpaceForShelf = lockIconPadding - noShelfOverlapBottomPadding; - - if (extraSpaceForShelf > 0f) { - return Math.min(getShelfHeight(), extraSpaceForShelf); - } - return 0f; - } - - /** - * @return Maximum number of notifications that can fit on keyguard. - */ - @VisibleForTesting - int computeMaxKeyguardNotifications() { - if (mAmbientState.getFractionToShade() > 0) { - if (SPEW_LOGCAT) { - Log.v(TAG, "Internally skipping computeMaxKeyguardNotifications()" - + " fractionToShade=" + mAmbientState.getFractionToShade() - ); - } - return mMaxAllowedKeyguardNotifications; - } - return mNotificationStackSizeCalculator.computeMaxKeyguardNotifications( - mNotificationStackScrollLayoutController.getView(), - getVerticalSpaceForLockscreenNotifications(), - getVerticalSpaceForLockscreenShelf(), - getShelfHeight() - ); - } - - private int getShelfHeight() { - return mNotificationStackScrollLayoutController.getShelfHeight(); - } - - private void updateClock() { - if (mIsOcclusionTransitionRunning) { - return; - } - float alpha = mClockPositionResult.clockAlpha * mKeyguardOnlyContentAlpha; - mKeyguardStatusViewController.setAlpha(alpha); - if (MigrateClocksToBlueprint.isEnabled()) { - // TODO (b/296373478) This is for split shade media movement. - } else { - mKeyguardStatusViewController - .setTranslationY(mKeyguardOnlyTransitionTranslationY, /* excludeMedia= */true); - } - } - @Override public void transitionToExpandedShade(long delay) { mNotificationStackScrollLayoutController.goToFullShade(delay); @@ -2156,17 +1666,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump return mPowerInteractor.getDetailedWakefulness().getValue(); } - @VisibleForTesting - void maybeAnimateBottomAreaAlpha() { - mBottomAreaShadeAlphaAnimator.cancel(); - if (mBarState == StatusBarState.SHADE_LOCKED) { - mBottomAreaShadeAlphaAnimator.setFloatValues(mBottomAreaShadeAlpha, 0.0f); - mBottomAreaShadeAlphaAnimator.start(); - } else { - mBottomAreaShadeAlpha = 1f; - } - } - /** * When the back gesture triggers a fully-expanded shade --> QQS shade collapse transition, * the expansionFraction goes down from 1.0 --> 0.0 (collapsing), so the current "squish" amount @@ -2246,7 +1745,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump } if (!mKeyguardBypassController.getBypassEnabled()) { - if (MigrateClocksToBlueprint.isEnabled() && !mSplitShadeEnabled) { + if (!mSplitShadeEnabled) { return (int) mKeyguardInteractor.getNotificationContainerBounds() .getValue().getTop(); } @@ -2268,23 +1767,11 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump return mBarState == KEYGUARD; } - float getKeyguardNotificationTopPadding() { - return mKeyguardNotificationTopPadding; - } - - float getKeyguardNotificationBottomPadding() { - return mKeyguardNotificationBottomPadding; - } - void requestScrollerTopPaddingUpdate(boolean animate) { if (!SceneContainerFlag.isEnabled()) { float padding = mQsController.calculateNotificationsTopPadding(mIsExpandingOrCollapsing, getKeyguardNotificationStaticPadding(), mExpandedFraction); - if (MigrateClocksToBlueprint.isEnabled()) { - mSharedNotificationContainerInteractor.setTopPosition(padding); - } else { - mNotificationStackScrollLayoutController.updateTopPadding(padding, animate); - } + mSharedNotificationContainerInteractor.setTopPosition(padding); } if (isKeyguardShowing() @@ -2295,27 +1782,10 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump } @Override - public void setKeyguardTransitionProgress(float keyguardAlpha, int keyguardTranslationY) { - mKeyguardOnlyContentAlpha = Interpolators.ALPHA_IN.getInterpolation(keyguardAlpha); - mKeyguardOnlyTransitionTranslationY = keyguardTranslationY; - if (mBarState == KEYGUARD) { - // If the animator is running, it's already fading out the content and this is a reset - mBottomAreaShadeAlpha = mKeyguardOnlyContentAlpha; - updateKeyguardBottomAreaAlpha(); - } - updateClock(); - } - - @Override public void setKeyguardStatusBarAlpha(float alpha) { mKeyguardStatusBarViewController.setAlpha(alpha); } - /** */ - float getKeyguardOnlyContentAlpha() { - return mKeyguardOnlyContentAlpha; - } - @VisibleForTesting boolean canCollapsePanelOnTouch() { if (!mQsController.getExpanded() && mBarState == KEYGUARD) { @@ -2416,7 +1886,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump } updateExpandedHeight(expandedHeight); updateHeader(); - updateNotificationTranslucency(); updatePanelExpanded(); updateGestureExclusionRect(); if (DEBUG_DRAWABLE) { @@ -2454,35 +1923,14 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump int maxHeight = mNotificationStackScrollLayoutController.getHeight() - emptyBottomMargin; if (mBarState == KEYGUARD) { - int minKeyguardPanelBottom = mClockPositionAlgorithm.getLockscreenStatusViewHeight() - + mNotificationStackScrollLayoutController.getIntrinsicContentHeight(); + int minKeyguardPanelBottom = mNotificationStackScrollLayoutController + .getIntrinsicContentHeight(); return Math.max(maxHeight, minKeyguardPanelBottom); } else { return maxHeight; } } - private void updateNotificationTranslucency() { - if (mIsOcclusionTransitionRunning) { - return; - } - - if (!MigrateClocksToBlueprint.isEnabled()) { - float alpha = 1f; - if (mClosingWithAlphaFadeOut && !mExpandingFromHeadsUp - && !mHeadsUpManager.hasPinnedHeadsUp()) { - alpha = getFadeoutAlpha(); - } - if (mBarState == KEYGUARD - && !mKeyguardBypassController.getBypassEnabled() - && !mQsController.getFullyExpanded()) { - alpha *= mClockPositionResult.clockAlpha; - } - mNotificationStackScrollLayoutController.setMaxAlphaForKeyguard(alpha, - "NPVC.updateNotificationTranslucency()"); - } - } - private float getFadeoutAlpha() { float alpha; if (mQsController.getMinExpansionHeight() == 0) { @@ -2502,28 +1950,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump mQsController.updateExpansion(); } - private void updateKeyguardBottomAreaAlpha() { - if (MigrateClocksToBlueprint.isEnabled()) { - return; - } - if (mIsOcclusionTransitionRunning) { - return; - } - // There are two possible panel expansion behaviors: - // • User dragging up to unlock: we want to fade out as quick as possible - // (ALPHA_EXPANSION_THRESHOLD) to avoid seeing the bouncer over the bottom area. - // • User tapping on lock screen: bouncer won't be visible but panel expansion will - // change due to "unlock hint animation." In this case, fading out the bottom area - // would also hide the message that says "swipe to unlock," we don't want to do that. - float expansionAlpha = MathUtils.constrainedMap(0f, 1f, - KeyguardBouncerConstants.ALPHA_EXPANSION_THRESHOLD, 1f, - getExpandedFraction()); - - float alpha = Math.min(expansionAlpha, 1 - mQsController.computeExpansionFraction()); - alpha *= mBottomAreaShadeAlpha; - mKeyguardInteractor.setAlpha(alpha); - } - private void onExpandingFinished() { if (!SceneContainerFlag.isEnabled()) { mNotificationStackScrollLayoutController.onExpansionStopped(); @@ -2734,13 +2160,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump } } - @Override - public void onScreenTurningOn() { - if (!MigrateClocksToBlueprint.isEnabled()) { - mKeyguardStatusViewController.dozeTimeTick(); - } - } - private void onMiddleClicked() { switch (mBarState) { case KEYGUARD: @@ -2846,7 +2265,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump if (!SceneContainerFlag.isEnabled()) { mNotificationStackScrollLayoutController.setExpandedHeight(expandedHeight); } - updateKeyguardBottomAreaAlpha(); updateStatusBarIcons(); } @@ -2973,10 +2391,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump mKeyguardStatusBarViewController.setDozing(mDozing); mQsController.setDozing(mDozing); - if (dozing) { - mBottomAreaShadeAlphaAnimator.cancel(); - } - if (mBarState == KEYGUARD || mBarState == StatusBarState.SHADE_LOCKED) { updateDozingVisibilities(animate); } @@ -3006,32 +2420,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump updateKeyguardStatusViewAlignment(/* animate= */ true); } - @Override - public void setAmbientIndicationTop(int ambientIndicationTop, boolean ambientTextVisible) { - int ambientIndicationBottomPadding = 0; - if (ambientTextVisible) { - int stackBottom = mNotificationStackScrollLayoutController.getBottom(); - ambientIndicationBottomPadding = stackBottom - ambientIndicationTop; - } - if (mAmbientIndicationBottomPadding != ambientIndicationBottomPadding) { - mAmbientIndicationBottomPadding = ambientIndicationBottomPadding; - updateMaxDisplayedNotifications(true); - } - } - - public void dozeTimeTick() { - if (!MigrateClocksToBlueprint.isEnabled()) { - mKeyguardStatusViewController.dozeTimeTick(); - } - if (mInterpolatedDarkAmount > 0) { - positionClockAndNotifications(); - } - } - - void setStatusAccessibilityImportance(int mode) { - mKeyguardStatusViewController.setStatusAccessibilityImportance(mode); - } - public void performHapticFeedback(int constant) { if (msdlFeedback()) { MSDLToken token; @@ -3095,12 +2483,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump /** Updates the views to the initial state for the fold to AOD animation. */ @Override public void prepareFoldToAodAnimation() { - if (MigrateClocksToBlueprint.isEnabled()) { - setDozing(true /* dozing */, false /* animate */); - } else { - // Force show AOD UI even if we are not locked - showAodUi(); - } + setDozing(true /* dozing */, false /* animate */); // Move the content of the AOD all the way to the left // so we can animate to the initial position @@ -3120,14 +2503,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump @Override public void startFoldToAodAnimation( Runnable startAction, Runnable endAction, Runnable cancelAction) { - if (MigrateClocksToBlueprint.isEnabled()) { - return; - } - buildViewAnimator(startAction, endAction, cancelAction) - .setUpdateListener(anim -> mKeyguardStatusViewController - .animateFoldToAod(anim.getAnimatedFraction())) - .start(); } /** @@ -3173,13 +2549,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump resetAlpha(); resetTranslation(); } - - /** Returns the NotificationPanelView. */ - @Override - public ViewGroup getView() { - // TODO(b/254878364): remove this method, or at least reduce references to it. - return mView; - } } @Override @@ -3207,11 +2576,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump ipw.print("isTracking()="); ipw.println(isTracking()); ipw.print("mExpanding="); ipw.println(mExpanding); ipw.print("mSplitShadeEnabled="); ipw.println(mSplitShadeEnabled); - ipw.print("mKeyguardNotificationBottomPadding="); - ipw.println(mKeyguardNotificationBottomPadding); - ipw.print("mKeyguardNotificationTopPadding="); ipw.println(mKeyguardNotificationTopPadding); - ipw.print("mMaxAllowedKeyguardNotifications="); - ipw.println(mMaxAllowedKeyguardNotifications); ipw.print("mAnimateNextPositionUpdate="); ipw.println(mAnimateNextPositionUpdate); ipw.print("isPanelExpanded()="); ipw.println(isPanelExpanded()); ipw.print("mDozing="); ipw.println(mDozing); @@ -3235,8 +2599,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump ipw.print("mClosingWithAlphaFadeOut="); ipw.println(mClosingWithAlphaFadeOut); ipw.print("mHeadsUpAnimatingAway="); ipw.println(mHeadsUpAnimatingAway); ipw.print("mShowIconsWhenExpanded="); ipw.println(mShowIconsWhenExpanded); - ipw.print("mIndicationBottomPadding="); ipw.println(mIndicationBottomPadding); - ipw.print("mAmbientIndicationBottomPadding="); ipw.println(mAmbientIndicationBottomPadding); ipw.print("mIsFullWidth="); ipw.println(mIsFullWidth); ipw.print("mBlockingExpansionForCurrentTouch="); ipw.println(mBlockingExpansionForCurrentTouch); @@ -3247,16 +2609,11 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump ipw.print("mPulsing="); ipw.println(mPulsing); ipw.print("mStackScrollerMeasuringPass="); ipw.println(mStackScrollerMeasuringPass); ipw.print("mPanelAlpha="); ipw.println(mPanelAlpha); - ipw.print("mBottomAreaShadeAlpha="); ipw.println(mBottomAreaShadeAlpha); ipw.print("mHeadsUpInset="); ipw.println(mHeadsUpInset); ipw.print("mHeadsUpPinnedMode="); ipw.println(mHeadsUpPinnedMode); ipw.print("mAllowExpandForSmallExpansion="); ipw.println(mAllowExpandForSmallExpansion); ipw.print("mMaxOverscrollAmountForPulse="); ipw.println(mMaxOverscrollAmountForPulse); ipw.print("mIsPanelCollapseOnQQS="); ipw.println(mIsPanelCollapseOnQQS); - ipw.print("mKeyguardOnlyContentAlpha="); ipw.println(mKeyguardOnlyContentAlpha); - ipw.print("mKeyguardOnlyTransitionTranslationY="); - ipw.println(mKeyguardOnlyTransitionTranslationY); - ipw.print("mUdfpsMaxYBurnInOffset="); ipw.println(mUdfpsMaxYBurnInOffset); ipw.print("mIsGestureNavigation="); ipw.println(mIsGestureNavigation); ipw.print("mOldLayoutDirection="); ipw.println(mOldLayoutDirection); ipw.print("mMinFraction="); ipw.println(mMinFraction); @@ -3325,7 +2682,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump mGestureRecorder = recorder; mHideExpandedRunnable = hideExpandedRunnable; - updateMaxDisplayedNotifications(true); } @Override @@ -3691,18 +3047,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump mExpandLatencyTracking = false; } float maxPanelHeight = getMaxPanelTransitionDistance(); - if (mHeightAnimator == null && !MigrateClocksToBlueprint.isEnabled()) { - // MigrateClocksToBlueprint - There is an edge case where swiping up slightly, - // and then swiping down will trigger overscroll logic. Even without this flag - // enabled, the notifications can then run into UDFPS. At this point it is - // safer to remove overscroll for this one case to prevent overlap. - - // Split shade has its own overscroll logic - if (isTracking()) { - float overExpansionPixels = Math.max(0, h - maxPanelHeight); - setOverExpansionInternal(overExpansionPixels, true /* isFromGesture */); - } - } mExpandedHeight = Math.min(h, maxPanelHeight); // If we are closing the panel and we are almost there due to a slow decelerating // interpolator, abort the animation. @@ -4019,9 +3363,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump void onQsExpansionChanged(boolean expanded) { updateExpandedHeightToMaxHeight(); - setStatusAccessibilityImportance(expanded - ? View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS - : View.IMPORTANT_FOR_ACCESSIBILITY_AUTO); updateSystemUiStateFlags(); NavigationBarView navigationBarView = mNavigationBarController.getNavigationBarView(mDisplayId); @@ -4036,7 +3377,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump mKeyguardStatusBarViewController.updateViewState(); int barState = getBarState(); if (barState == SHADE_LOCKED || barState == KEYGUARD) { - updateKeyguardBottomAreaAlpha(); positionClockAndNotifications(); } @@ -4060,10 +3400,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump mKeyguardInteractor.setQuickSettingsVisible(qsVisible); } - // The padding on this area is large enough that - // we can use a cheaper clipping strategy - mKeyguardStatusViewController.setClipBounds( - clipStatusView ? lastQsClipBounds : null); if (mSplitShadeEnabled) { mKeyguardStatusBarViewController.setNoTopClipping(); } else { @@ -4104,9 +3440,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump == firstRow))) { requestScrollerTopPaddingUpdate(false /* animate */); } - if (isKeyguardShowing()) { - updateMaxDisplayedNotifications(true); - } updateExpandedHeightToMaxHeight(); } @@ -4128,7 +3461,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump public void onHeadsUpPinnedModeChanged(final boolean inPinnedMode) { if (inPinnedMode) { mHeadsUpExistenceChangedRunnable.run(); - updateNotificationTranslucency(); } else { setHeadsUpAnimatingAway(true); mNotificationStackScrollLayoutController.runAfterAnimationFinished( @@ -4190,28 +3522,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump int oldState = mBarState; boolean keyguardShowing = statusBarState == KEYGUARD; - if (mDozeParameters.shouldDelayKeyguardShow() - && oldState == StatusBarState.SHADE - && statusBarState == KEYGUARD) { - // This means we're doing the screen off animation - position the keyguard status - // view where it'll be on AOD, so we can animate it in. - if (!MigrateClocksToBlueprint.isEnabled()) { - mKeyguardStatusViewController.updatePosition( - mClockPositionResult.clockX, - mClockPositionResult.clockYFullyDozing, - mClockPositionResult.clockScale, - false /* animate */); - } - } - - if (!MigrateClocksToBlueprint.isEnabled()) { - mKeyguardStatusViewController.setKeyguardStatusViewVisibility( - statusBarState, - keyguardFadingAway, - goingToFullShade, - mBarState); - } - // TODO: maybe add a listener for barstate mBarState = statusBarState; mQsController.setBarState(statusBarState); @@ -4273,10 +3583,8 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump updateDozingVisibilities(false /* animate */); } - updateMaxDisplayedNotifications(false); // The update needs to happen after the headerSlide in above, otherwise the translation // would reset - maybeAnimateBottomAreaAlpha(); mQsController.updateQsState(); } @@ -4311,12 +3619,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump public void showAodUi() { setDozing(true /* dozing */, false /* animate */); mStatusBarStateController.setUpcomingState(KEYGUARD); - - if (MigrateClocksToBlueprint.isEnabled()) { - mStatusBarStateController.setState(KEYGUARD); - } else { - mStatusBarStateListener.onStateChanged(KEYGUARD); - } + mStatusBarStateController.setState(KEYGUARD); mStatusBarStateListener.onDozeAmountChanged(1f, 1f); setExpandedFraction(1f); } @@ -4370,14 +3673,8 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump fling(mUpdateFlingVelocity); mUpdateFlingOnLayout = false; } - updateMaxDisplayedNotifications(!shouldAvoidChangingNotificationsCount()); setIsFullWidth(mNotificationStackScrollLayoutController.getWidth() == mView.getWidth()); - // Update Clock Pivot (used by anti-burnin transformations) - if (!MigrateClocksToBlueprint.isEnabled()) { - mKeyguardStatusViewController.updatePivot(mView.getWidth(), mView.getHeight()); - } - int oldMaxHeight = mQsController.updateHeightsOnShadeLayoutChange(); positionClockAndNotifications(); mQsController.handleShadeLayoutChanged(oldMaxHeight); @@ -4457,36 +3754,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump // Also animate the status bar's alpha during transitions between the lockscreen and // dreams. mKeyguardStatusBarViewController.setAlpha(alpha); - setTransitionAlpha(stackScroller).accept(alpha); - }; - } - - private Consumer<Float> setTransitionAlpha( - NotificationStackScrollLayoutController stackScroller) { - return setTransitionAlpha(stackScroller, /* excludeNotifications= */ false); - } - - private Consumer<Float> setTransitionAlpha( - NotificationStackScrollLayoutController stackScroller, - boolean excludeNotifications) { - return (Float alpha) -> { - mKeyguardStatusViewController.setAlpha(alpha); - if (!excludeNotifications) { - stackScroller.setMaxAlphaForKeyguard(alpha, "NPVC.setTransitionAlpha()"); - } - - mKeyguardInteractor.setAlpha(alpha); - }; - } - - private Consumer<Float> setTransitionY( - NotificationStackScrollLayoutController stackScroller) { - return (Float translationY) -> { - if (!MigrateClocksToBlueprint.isEnabled()) { - mKeyguardStatusViewController.setTranslationY(translationY, - /* excludeMedia= */false); - stackScroller.setTranslationY(translationY); - } }; } @@ -4514,7 +3781,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump */ @Override public boolean onInterceptTouchEvent(MotionEvent event) { - if (MigrateClocksToBlueprint.isEnabled() && !mUseExternalTouch) { + if (!mUseExternalTouch) { return false; } @@ -4583,9 +3850,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump switch (event.getActionMasked()) { case MotionEvent.ACTION_DOWN: - if (!MigrateClocksToBlueprint.isEnabled()) { - mCentralSurfaces.userActivity(); - } mAnimatingOnDown = mHeightAnimator != null && !mIsSpringBackAnimation; mMinExpandHeight = 0.0f; mDownTime = mSystemClock.uptimeMillis(); @@ -4681,7 +3945,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump */ @Override public boolean onTouchEvent(MotionEvent event) { - if (MigrateClocksToBlueprint.isEnabled() && !mUseExternalTouch) { + if (!mUseExternalTouch) { return false; } diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationsQSContainerController.kt b/packages/SystemUI/src/com/android/systemui/shade/NotificationsQSContainerController.kt index 58111576574e..7299f092640f 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationsQSContainerController.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationsQSContainerController.kt @@ -27,7 +27,6 @@ import androidx.constraintlayout.widget.ConstraintSet.START import androidx.constraintlayout.widget.ConstraintSet.TOP import androidx.lifecycle.lifecycleScope import com.android.app.tracing.coroutines.launchTraced as launch -import com.android.systemui.customization.R as customR import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.fragments.FragmentService @@ -271,7 +270,6 @@ constructor( ensureAllViewsHaveIds(mView) val constraintSet = ConstraintSet() constraintSet.clone(mView) - setKeyguardStatusViewConstraints(constraintSet) setQsConstraints(constraintSet) setLargeScreenShadeHeaderConstraints(constraintSet) mView.applyConstraints(constraintSet) @@ -295,15 +293,6 @@ constructor( } } - private fun setKeyguardStatusViewConstraints(constraintSet: ConstraintSet) { - val statusViewMarginHorizontal = - resources.getDimensionPixelSize(customR.dimen.status_view_margin_horizontal) - constraintSet.apply { - setMargin(R.id.keyguard_status_view, START, statusViewMarginHorizontal) - setMargin(R.id.keyguard_status_view, END, statusViewMarginHorizontal) - } - } - private fun ensureAllViewsHaveIds(parentView: ViewGroup) { for (i in 0 until parentView.childCount) { val childView = parentView.getChildAt(i) diff --git a/packages/SystemUI/src/com/android/systemui/shade/QuickSettingsControllerImpl.java b/packages/SystemUI/src/com/android/systemui/shade/QuickSettingsControllerImpl.java index 4fb43fdcfdae..c88e7b827881 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/QuickSettingsControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/shade/QuickSettingsControllerImpl.java @@ -1199,7 +1199,6 @@ public class QuickSettingsControllerImpl implements QuickSettingsController, Dum !mSplitShadeEnabled && qsExpansionFraction == 0 && qsPanelBottomY > 0; final boolean qsVisible = qsExpansionFraction > 0; final boolean qsOrQqsVisible = qqsVisible || qsVisible; - checkCorrectScrimVisibility(qsExpansionFraction); int top = calculateTopClippingBound(qsPanelBottomY); int bottom = calculateBottomClippingBound(top); @@ -1403,21 +1402,6 @@ public class QuickSettingsControllerImpl implements QuickSettingsController, Dum } } - private void checkCorrectScrimVisibility(float expansionFraction) { - // issues with scrims visible on keyguard occur only in split shade - if (mSplitShadeEnabled) { - // TODO (b/265193930): remove dependency on NPVC - boolean keyguardViewsVisible = mBarState == KEYGUARD - && mPanelViewControllerLazy.get().getKeyguardOnlyContentAlpha() == 1; - // expansionFraction == 1 means scrims are fully visible as their size/visibility depend - // on QS expansion - if (expansionFraction == 1 && keyguardViewsVisible) { - Log.wtf(TAG, - "Incorrect state, scrim is visible at the same time when clock is visible"); - } - } - } - @Override public float calculateNotificationsTopPadding(boolean isShadeExpanding, int keyguardNotificationStaticPadding, float expandedFraction) { diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeSurface.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeSurface.kt index 6069705be5fb..6d66a7fc0f3e 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeSurface.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeSurface.kt @@ -75,9 +75,6 @@ interface ShadeSurface : /** Sets the view's alpha to max. */ fun resetAlpha() - /** @see com.android.systemui.keyguard.ScreenLifecycle.Observer.onScreenTurningOn */ - fun onScreenTurningOn() - /** * Called when the device's theme changes. * diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeSurfaceImpl.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeSurfaceImpl.kt index 9b971d7740f2..110100eeec76 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeSurfaceImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeSurfaceImpl.kt @@ -65,10 +65,6 @@ class ShadeSurfaceImpl @Inject constructor() : ShadeSurface, ShadeViewController // Do nothing } - override fun onScreenTurningOn() { - // Do nothing - } - override fun onThemeChanged() { // Do nothing } diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeViewController.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeViewController.kt index b085aec3de2f..879008325141 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeViewController.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeViewController.kt @@ -16,7 +16,6 @@ package com.android.systemui.shade import android.view.MotionEvent -import android.view.ViewGroup import com.android.systemui.power.shared.model.WakefulnessModel import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow import com.android.systemui.statusbar.phone.HeadsUpAppearanceController @@ -53,10 +52,6 @@ interface ShadeViewController { @Deprecated("Does nothing when scene container is enabled.") fun setQsScrimEnabled(qsScrimEnabled: Boolean) - /** Sets the top spacing for the ambient indicator. */ - @Deprecated("Does nothing when scene container is enabled.") - fun setAmbientIndicationTop(ambientIndicationTop: Int, ambientTextVisible: Boolean) - /** Updates notification panel-specific flags on [SysUiState]. */ @Deprecated("Does nothing when scene container is enabled.") fun updateSystemUiStateFlags() @@ -169,9 +164,6 @@ interface ShadeFoldAnimator { /** Cancels fold to AOD transition and resets view state. */ @Deprecated("Used by the Keyguard Fold Transition. Needs flexiglass equivalent.") fun cancelFoldToAodAnimation() - - /** Returns the main view of the shade. */ - @Deprecated("Not used when migrateClocksToBlueprint enabled.") val view: ViewGroup? } /** diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeViewControllerEmptyImpl.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeViewControllerEmptyImpl.kt index f65d3780b21e..2976a1fd1658 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeViewControllerEmptyImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeViewControllerEmptyImpl.kt @@ -17,7 +17,6 @@ package com.android.systemui.shade import android.view.MotionEvent -import android.view.ViewGroup import com.android.systemui.shade.domain.interactor.PanelExpansionInteractor import com.android.systemui.shade.domain.interactor.ShadeBackActionInteractor import com.android.systemui.shade.domain.interactor.ShadeLockscreenInteractor @@ -55,8 +54,6 @@ open class ShadeViewControllerEmptyImpl @Inject constructor() : override fun startExpandLatencyTracking() {} - override fun dozeTimeTick() {} - override fun resetViews(animate: Boolean) {} override val barState: Int = 0 @@ -74,8 +71,6 @@ open class ShadeViewControllerEmptyImpl @Inject constructor() : override fun setQsScrimEnabled(qsScrimEnabled: Boolean) {} - override fun setAmbientIndicationTop(ambientIndicationTop: Int, ambientTextVisible: Boolean) {} - override fun updateSystemUiStateFlags() {} override fun updateTouchableRegion() {} @@ -84,9 +79,6 @@ open class ShadeViewControllerEmptyImpl @Inject constructor() : @Deprecated("Not supported by scenes") override fun resetViewGroupFade() {} - @Deprecated("Not supported by scenes") - override fun setKeyguardTransitionProgress(keyguardAlpha: Float, keyguardTranslationY: Int) {} - @Deprecated("Not supported by scenes") override fun setOverStretchAmount(amount: Float) {} @Deprecated("TODO(b/325072511) delete this") @@ -146,6 +138,4 @@ class ShadeFoldAnimatorEmptyImpl : ShadeFoldAnimator { ) {} override fun cancelFoldToAodAnimation() {} - - override val view: ViewGroup? = null } diff --git a/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeLockscreenInteractor.kt b/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeLockscreenInteractor.kt index f538d7446453..049589d2d251 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeLockscreenInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeLockscreenInteractor.kt @@ -38,9 +38,6 @@ interface ShadeLockscreenInteractor { */ @Deprecated("Use ShadeInteractor instead") val isExpanded: Boolean - /** Called once every minute while dozing. */ - fun dozeTimeTick() - /** * Do not let the user drag the shade up and down for the current touch session. This is * necessary to avoid shade expansion while/after the bouncer is dismissed. @@ -59,13 +56,6 @@ interface ShadeLockscreenInteractor { /** @see ViewGroupFadeHelper.reset */ @Deprecated("Not supported by scenes") fun resetViewGroupFade() - /** - * Set the alpha and translationY of the keyguard elements which only show on the lockscreen, - * but not in shade locked / shade. This is used when dragging down to the full shade. - */ - @Deprecated("Not supported by scenes") - fun setKeyguardTransitionProgress(keyguardAlpha: Float, keyguardTranslationY: Int) - /** Sets the overstretch amount in raw pixels when dragging down. */ @Deprecated("Not supported by scenes") fun setOverStretchAmount(amount: Float) diff --git a/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeLockscreenInteractorImpl.kt b/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeLockscreenInteractorImpl.kt index d712ece7f144..14934b31a06f 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeLockscreenInteractorImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeLockscreenInteractorImpl.kt @@ -54,10 +54,6 @@ constructor( override val isExpanded get() = shadeInteractor.isAnyExpanded.value - override fun dozeTimeTick() { - // TODO("b/383591086") Implement replacement or delete - } - @Deprecated("Not supported by scenes") override fun blockExpansionForCurrentTouch() { // TODO("b/324280998") Implement replacement or delete @@ -93,11 +89,6 @@ constructor( } @Deprecated("Not supported by scenes") - override fun setKeyguardTransitionProgress(keyguardAlpha: Float, keyguardTranslationY: Int) { - // Now handled elsewhere. Do nothing. - } - - @Deprecated("Not supported by scenes") override fun setOverStretchAmount(amount: Float) { // Now handled elsewhere. Do nothing. } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeKeyguardTransitionController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeKeyguardTransitionController.kt index 72f2aa5aa10b..31e5df9e668a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeKeyguardTransitionController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeKeyguardTransitionController.kt @@ -17,14 +17,19 @@ import dagger.assisted.AssistedInject class LockscreenShadeKeyguardTransitionController @AssistedInject constructor( - private val mediaHierarchyManager: MediaHierarchyManager, - @Assisted private val shadeLockscreenInteractor: ShadeLockscreenInteractor, - context: Context, - configurationController: ConfigurationController, - dumpManager: DumpManager, - splitShadeStateController: SplitShadeStateController -) : AbstractLockscreenShadeTransitionController(context, configurationController, dumpManager, - splitShadeStateController) { + private val mediaHierarchyManager: MediaHierarchyManager, + @Assisted private val shadeLockscreenInteractor: ShadeLockscreenInteractor, + context: Context, + configurationController: ConfigurationController, + dumpManager: DumpManager, + splitShadeStateController: SplitShadeStateController, +) : + AbstractLockscreenShadeTransitionController( + context, + configurationController, + dumpManager, + splitShadeStateController, + ) { /** * Distance that the full shade transition takes in order for the keyguard content on @@ -32,15 +37,6 @@ constructor( */ private var alphaTransitionDistance = 0 - /** - * Distance that the full shade transition takes in order for the keyguard elements to fully - * translate into their final position - */ - private var keyguardTransitionDistance = 0 - - /** The amount of vertical offset for the keyguard during the full shade transition. */ - private var keyguardTransitionOffset = 0 - /** The amount of alpha that was last set on the keyguard elements. */ private var alpha = 0f @@ -50,49 +46,21 @@ constructor( /** The amount of alpha that was last set on the keyguard status bar. */ private var statusBarAlpha = 0f - /** The amount of translationY that was last set on the keyguard elements. */ - private var translationY = 0 - - /** The latest progress [0,1] of the translationY progress. */ - private var translationYProgress = 0f - override fun updateResources() { alphaTransitionDistance = context.resources.getDimensionPixelSize( - R.dimen.lockscreen_shade_npvc_keyguard_content_alpha_transition_distance) - keyguardTransitionDistance = - context.resources.getDimensionPixelSize( - R.dimen.lockscreen_shade_keyguard_transition_distance) - keyguardTransitionOffset = - context.resources.getDimensionPixelSize( - R.dimen.lockscreen_shade_keyguard_transition_vertical_offset) + R.dimen.lockscreen_shade_npvc_keyguard_content_alpha_transition_distance + ) } override fun onDragDownAmountChanged(dragDownAmount: Float) { alphaProgress = MathUtils.saturate(dragDownAmount / alphaTransitionDistance) alpha = 1f - alphaProgress - translationY = calculateKeyguardTranslationY(dragDownAmount) - shadeLockscreenInteractor.setKeyguardTransitionProgress(alpha, translationY) statusBarAlpha = if (useSplitShade) alpha else -1f shadeLockscreenInteractor.setKeyguardStatusBarAlpha(statusBarAlpha) } - private fun calculateKeyguardTranslationY(dragDownAmount: Float): Int { - if (!useSplitShade) { - return 0 - } - // On split-shade, the translationY of the keyguard should stay in sync with the - // translation of media. - if (mediaHierarchyManager.isCurrentlyInGuidedTransformation()) { - return mediaHierarchyManager.getGuidedTransformationTranslationY() - } - // When media is not showing, apply the default distance - translationYProgress = MathUtils.saturate(dragDownAmount / keyguardTransitionDistance) - val translationY = translationYProgress * keyguardTransitionOffset - return translationY.toInt() - } - override fun dump(indentingPrintWriter: IndentingPrintWriter) { indentingPrintWriter.let { it.println("LockscreenShadeKeyguardTransitionController:") @@ -100,8 +68,6 @@ constructor( it.println("Resources:") it.increaseIndent() it.println("alphaTransitionDistance: $alphaTransitionDistance") - it.println("keyguardTransitionDistance: $keyguardTransitionDistance") - it.println("keyguardTransitionOffset: $keyguardTransitionOffset") it.decreaseIndent() it.println("State:") it.increaseIndent() @@ -109,8 +75,6 @@ constructor( it.println("alpha: $alpha") it.println("alphaProgress: $alphaProgress") it.println("statusBarAlpha: $statusBarAlpha") - it.println("translationProgress: $translationYProgress") - it.println("translationY: $translationY") } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java index 233559c7e689..2bc417e4aada 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java @@ -2662,7 +2662,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { @Override public void onScreenTurningOn() { mFalsingCollector.onScreenTurningOn(); - mShadeSurface.onScreenTurningOn(); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeServiceHost.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeServiceHost.java index 57e26d708f26..6922de5739ab 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeServiceHost.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeServiceHost.java @@ -340,7 +340,6 @@ public final class DozeServiceHost implements DozeHost { public void dozeTimeTick() { TraceUtils.trace("DozeServiceHost#dozeTimeTick", () -> { mDozeInteractor.dozeTimeTick(); - mShadeLockscreenInteractor.dozeTimeTick(); mAuthController.dozeTimeTick(); if (mAmbientIndicationContainer instanceof DozeReceiver) { ((DozeReceiver) mAmbientIndicationContainer).dozeTimeTick(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java index 518923eec5ca..656ab0d7c938 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java @@ -16,23 +16,14 @@ package com.android.systemui.statusbar.phone; -import static com.android.systemui.doze.util.BurnInHelperKt.getBurnInOffset; -import static com.android.systemui.doze.util.BurnInHelperKt.getBurnInScale; -import static com.android.systemui.statusbar.notification.NotificationUtils.interpolate; - import android.content.Context; import android.content.res.Resources; -import android.util.MathUtils; -import com.android.app.animation.Interpolators; -import com.android.keyguard.BouncerPanelExpansionCalculator; -import com.android.keyguard.KeyguardStatusView; import com.android.systemui.log.LogBuffer; import com.android.systemui.log.core.Logger; import com.android.systemui.log.dagger.KeyguardClockLog; import com.android.systemui.res.R; import com.android.systemui.shade.LargeScreenHeaderHelper; -import com.android.systemui.shade.ShadeViewController; import javax.inject.Inject; @@ -44,31 +35,6 @@ public class KeyguardClockPositionAlgorithm { private static final boolean DEBUG = false; /** - * Margin between the bottom of the status view and the notification shade. - */ - private int mStatusViewBottomMargin; - - /** - * Height of {@link KeyguardStatusView}. - */ - private int mKeyguardStatusHeight; - - /** - * Minimum top margin to avoid overlap with status bar or multi-user switcher avatar. - */ - private int mMinTopMargin; - - /** - * Minimum top inset (in pixels) to avoid overlap with any display cutouts. - */ - private int mCutoutTopInset = 0; - - /** - * Recommended distance from the status bar. - */ - private int mContainerTopPadding; - - /** * Top margin of notifications introduced by presence of split shade header / status bar */ private int mSplitShadeTopNotificationsMargin; @@ -79,35 +45,10 @@ public class KeyguardClockPositionAlgorithm { private int mSplitShadeTargetTopMargin; /** - * @see ShadeViewController#getExpandedFraction() - */ - private float mPanelExpansion; - - /** - * Max burn-in prevention x translation. - */ - private int mMaxBurnInPreventionOffsetX; - - /** - * Max burn-in prevention y translation for clock layouts. - */ - private int mMaxBurnInPreventionOffsetYClock; - - /** - * Current burn-in prevention y translation. - */ - private float mCurrentBurnInOffsetY; - - /** * Doze/AOD transition amount. */ private float mDarkAmount; - /** - * How visible the quick settings panel is. - */ - private float mQsExpansion; - private float mOverStretchAmount; /** @@ -123,25 +64,6 @@ public class KeyguardClockPositionAlgorithm { private boolean mIsSplitShade; - /** - * Top location of the udfps icon. This includes the worst case (highest) burn-in - * offset that would make the top physically highest on the screen. - * - * Set to -1 if udfps is not enrolled on the device. - */ - private float mUdfpsTop; - - /** - * Bottom y-position of the currently visible clock - */ - private float mClockBottom; - - /** - * If true, try to keep clock aligned to the top of the display. Else, assume the clock - * is center aligned. - */ - private boolean mIsClockTopAligned; - private Logger mLogger; @Inject @@ -151,230 +73,52 @@ public class KeyguardClockPositionAlgorithm { /** Refreshes the dimension values. */ public void loadDimens(Context context, Resources res) { - mStatusViewBottomMargin = - res.getDimensionPixelSize(R.dimen.keyguard_status_view_bottom_margin); mSplitShadeTopNotificationsMargin = LargeScreenHeaderHelper.getLargeScreenHeaderHeight(context); mSplitShadeTargetTopMargin = res.getDimensionPixelSize(R.dimen.keyguard_split_shade_top_margin); - - mContainerTopPadding = - res.getDimensionPixelSize(R.dimen.keyguard_clock_top_margin); - mMaxBurnInPreventionOffsetX = res.getDimensionPixelSize( - R.dimen.burn_in_prevention_offset_x); - mMaxBurnInPreventionOffsetYClock = res.getDimensionPixelSize( - R.dimen.burn_in_prevention_offset_y_clock); } /** * Sets up algorithm values. */ - public void setup(int keyguardStatusBarHeaderHeight, float panelExpansion, - int keyguardStatusHeight, float dark, float overStretchAmount, boolean bypassEnabled, - int unlockedStackScrollerPadding, float qsExpansion, int cutoutTopInset, - boolean isSplitShade, float udfpsTop, float clockBottom, boolean isClockTopAligned) { - mMinTopMargin = keyguardStatusBarHeaderHeight + mContainerTopPadding; - mPanelExpansion = BouncerPanelExpansionCalculator - .getKeyguardClockScaledExpansion(panelExpansion); - mKeyguardStatusHeight = keyguardStatusHeight + mStatusViewBottomMargin; + public void setup(float dark, float overStretchAmount, boolean bypassEnabled, + int unlockedStackScrollerPadding, boolean isSplitShade) { mDarkAmount = dark; mOverStretchAmount = overStretchAmount; mBypassEnabled = bypassEnabled; mUnlockedStackScrollerPadding = unlockedStackScrollerPadding; - mQsExpansion = qsExpansion; - mCutoutTopInset = cutoutTopInset; mIsSplitShade = isSplitShade; - mUdfpsTop = udfpsTop; - mClockBottom = clockBottom; - mIsClockTopAligned = isClockTopAligned; } public void run(Result result) { - final int y = getClockY(mPanelExpansion, mDarkAmount); - result.clockY = y; - result.clockYFullyDozing = getClockY( - 1.0f /* panelExpansion */, 1.0f /* darkAmount */); - result.clockAlpha = getClockAlpha(y); - result.stackScrollerPadding = getStackScrollerPadding(y); + result.stackScrollerPadding = getStackScrollerPadding(); result.stackScrollerPaddingExpanded = getStackScrollerPaddingExpanded(); - result.clockX = (int) interpolate(0, burnInPreventionOffsetX(), mDarkAmount); - result.clockScale = interpolate(getBurnInScale(), 1.0f, 1.0f - mDarkAmount); } private int getStackScrollerPaddingExpanded() { if (mBypassEnabled) { return mUnlockedStackScrollerPadding; } else if (mIsSplitShade) { - return getClockY(1.0f, mDarkAmount); + return mSplitShadeTargetTopMargin; } else { - return getClockY(1.0f, mDarkAmount) + mKeyguardStatusHeight; + return 0; } } - private int getStackScrollerPadding(int clockYPosition) { + private int getStackScrollerPadding() { if (mBypassEnabled) { return (int) (mUnlockedStackScrollerPadding + mOverStretchAmount); } else if (mIsSplitShade) { // mCurrentBurnInOffsetY is subtracted to make notifications not follow clock adjustment // for burn-in. It can make pulsing notification go too high and it will get clipped - return clockYPosition - mSplitShadeTopNotificationsMargin - - (int) mCurrentBurnInOffsetY; + return mSplitShadeTargetTopMargin - mSplitShadeTopNotificationsMargin; } else { - return clockYPosition + mKeyguardStatusHeight; + return 0; } } - /** - * @param nsslTop NotificationStackScrollLayout top, which is below top of the srceen. - * @return Distance from nsslTop to top of the first view in the lockscreen shade. - */ - public float getLockscreenNotifPadding(float nsslTop) { - if (mBypassEnabled) { - return mUnlockedStackScrollerPadding - nsslTop; - } else if (mIsSplitShade) { - return mSplitShadeTargetTopMargin - nsslTop; - } else { - // Non-bypass portrait shade already uses values from nsslTop - // so we don't need to subtract it here. - return mMinTopMargin + mKeyguardStatusHeight; - } - } - - /** - * give the static topMargin, used for lockscreen clocks to get the initial translationY - * to do counter translation - */ - public int getExpandedPreferredClockY() { - if (mIsSplitShade) { - return mSplitShadeTargetTopMargin; - } else { - return mMinTopMargin; - } - } - - public int getLockscreenStatusViewHeight() { - return mKeyguardStatusHeight; - } - - private int getClockY(float panelExpansion, float darkAmount) { - float clockYRegular = getExpandedPreferredClockY(); - - // Dividing the height creates a smoother transition when the user swipes up to unlock - float clockYBouncer = -mKeyguardStatusHeight / 3.0f; - - // Move clock up while collapsing the shade - float shadeExpansion = Interpolators.FAST_OUT_LINEAR_IN.getInterpolation(panelExpansion); - float clockY = MathUtils.lerp(clockYBouncer, clockYRegular, shadeExpansion); - - // This will keep the clock at the top but out of the cutout area - float shift = 0; - if (clockY - mMaxBurnInPreventionOffsetYClock < mCutoutTopInset) { - shift = mCutoutTopInset - (clockY - mMaxBurnInPreventionOffsetYClock); - } - - int burnInPreventionOffsetY = mMaxBurnInPreventionOffsetYClock; // requested offset - final boolean hasUdfps = mUdfpsTop > -1; - if (hasUdfps && !mIsClockTopAligned) { - // ensure clock doesn't overlap with the udfps icon - if (mUdfpsTop < mClockBottom) { - // sometimes the clock textView extends beyond udfps, so let's just use the - // space above the KeyguardStatusView/clock as our burn-in offset - burnInPreventionOffsetY = (int) (clockY - mCutoutTopInset) / 2; - if (mMaxBurnInPreventionOffsetYClock < burnInPreventionOffsetY) { - burnInPreventionOffsetY = mMaxBurnInPreventionOffsetYClock; - } - shift = -burnInPreventionOffsetY; - } else { - float upperSpace = clockY - mCutoutTopInset; - float lowerSpace = mUdfpsTop - mClockBottom; - // center the burn-in offset within the upper + lower space - burnInPreventionOffsetY = (int) (lowerSpace + upperSpace) / 2; - if (mMaxBurnInPreventionOffsetYClock < burnInPreventionOffsetY) { - burnInPreventionOffsetY = mMaxBurnInPreventionOffsetYClock; - } - shift = (lowerSpace - upperSpace) / 2; - } - } - - float fullyDarkBurnInOffset = burnInPreventionOffsetY(burnInPreventionOffsetY); - float clockYDark = clockY + fullyDarkBurnInOffset + shift; - mCurrentBurnInOffsetY = MathUtils.lerp(0, fullyDarkBurnInOffset, darkAmount); - - if (DEBUG) { - final float finalShift = shift; - final float finalBurnInPreventionOffsetY = burnInPreventionOffsetY; - mLogger.i(msg -> { - final String inputs = "panelExpansion: " + panelExpansion - + " darkAmount: " + darkAmount; - final String outputs = "clockY: " + clockY - + " burnInPreventionOffsetY: " + finalBurnInPreventionOffsetY - + " fullyDarkBurnInOffset: " + fullyDarkBurnInOffset - + " shift: " + finalShift - + " mOverStretchAmount: " + mOverStretchAmount - + " mCurrentBurnInOffsetY: " + mCurrentBurnInOffsetY; - return inputs + " -> " + outputs; - }, msg -> { - return kotlin.Unit.INSTANCE; - }); - } - return (int) (MathUtils.lerp(clockY, clockYDark, darkAmount) + mOverStretchAmount); - } - - /** - * We might want to fade out the clock when the user is swiping up. - * One exception is when the bouncer will become visible, in this cause the clock - * should always persist. - * - * @param y Current clock Y. - * @return Alpha from 0 to 1. - */ - private float getClockAlpha(int y) { - float alphaKeyguard = Math.max(0, y / Math.max(1f, getClockY(1f, mDarkAmount))); - if (!mIsSplitShade) { - // in split shade QS are always expanded so this factor shouldn't apply - float qsAlphaFactor = MathUtils.saturate(mQsExpansion / 0.3f); - qsAlphaFactor = 1f - qsAlphaFactor; - alphaKeyguard *= qsAlphaFactor; - } - alphaKeyguard = Interpolators.ACCELERATE.getInterpolation(alphaKeyguard); - return MathUtils.lerp(alphaKeyguard, 1f, mDarkAmount); - } - - private float burnInPreventionOffsetY(int offset) { - return getBurnInOffset(offset * 2, false /* xAxis */) - offset; - } - - private float burnInPreventionOffsetX() { - return getBurnInOffset(mMaxBurnInPreventionOffsetX, true /* xAxis */); - } - public static class Result { - - /** - * The x translation of the clock. - */ - public int clockX; - - /** - * The y translation of the clock. - */ - public int clockY; - - /** - * The y translation of the clock when we're fully dozing. - */ - public int clockYFullyDozing; - - /** - * The alpha value of the clock. - */ - public float clockAlpha; - - /** - * Amount to scale the large clock (0.0 - 1.0) - */ - public float clockScale; - /** * The top padding of the stack scroller, in pixels. */ diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt index c53558ea7fd2..76f10b1c2a8b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt @@ -21,7 +21,6 @@ import com.android.systemui.DejankUtils import com.android.systemui.Flags.lightRevealMigration import com.android.systemui.dagger.SysUISingleton import com.android.systemui.keyguard.KeyguardViewMediator -import com.android.systemui.keyguard.MigrateClocksToBlueprint import com.android.systemui.keyguard.WakefulnessLifecycle import com.android.systemui.shade.ShadeViewController import com.android.systemui.shade.domain.interactor.PanelExpansionInteractor @@ -87,7 +86,6 @@ constructor( private var animatorDurationScale = 1f private var shouldAnimateInKeyguard = false private var lightRevealAnimationPlaying = false - private var aodUiAnimationPlaying = false /** * The result of our decision whether to play the screen off animation in @@ -131,7 +129,7 @@ constructor( override fun onAnimationStart(animation: Animator) { interactionJankMonitor.begin( notifShadeWindowControllerLazy.get().windowRootView, - CUJ_SCREEN_OFF + CUJ_SCREEN_OFF, ) } } @@ -155,7 +153,7 @@ constructor( override fun initialize( centralSurfaces: CentralSurfaces, shadeViewController: ShadeViewController, - lightRevealScrim: LightRevealScrim + lightRevealScrim: LightRevealScrim, ) { this.initialized = true this.lightRevealScrim = lightRevealScrim @@ -165,7 +163,7 @@ constructor( globalSettings.registerContentObserverSync( Settings.Global.getUriFor(Settings.Global.ANIMATOR_DURATION_SCALE), /* notify for descendants */ false, - animatorDurationScaleObserver + animatorDurationScaleObserver, ) wakefulnessLifecycle.addObserver(this) } @@ -203,7 +201,7 @@ constructor( AnimatableProperty.Y, currentY, AnimationProperties().setDuration(duration.toLong()), - true /* animate */ + true, /* animate */ ) // Cancel any existing CUJs before starting the animation @@ -217,8 +215,6 @@ constructor( .setDelay(0) .setDuration(duration.toLong()) .setAnimationEndAction { - aodUiAnimationPlaying = false - // Lock the keyguard if it was waiting for the screen off animation to end. keyguardViewMediatorLazy.get().maybeHandlePendingLock() @@ -239,17 +235,16 @@ constructor( // will not be called, which is what we want since that will finish the // screen off animation and show the lockscreen, which we don't want if we // were cancelled. - aodUiAnimationPlaying = false decidedToAnimateGoingToSleep = null interactionJankMonitor.cancel(CUJ_SCREEN_OFF_SHOW_AOD) } .setCustomInterpolator(View.ALPHA, Interpolators.FAST_OUT_SLOW_IN), - true /* animate */ + true, /* animate */ ) val builder = InteractionJankMonitor.Configuration.Builder.withView( InteractionJankMonitor.CUJ_SCREEN_OFF_SHOW_AOD, - checkNotNull(notifShadeWindowControllerLazy.get().windowRootView) + checkNotNull(notifShadeWindowControllerLazy.get().windowRootView), ) .setTag(statusBarStateControllerImpl.getClockId()) @@ -267,11 +262,6 @@ constructor( } override fun onFinishedWakingUp() { - // Set this to false in onFinishedWakingUp rather than onStartedWakingUp so that other - // observers (such as CentralSurfaces) can ask us whether we were playing the screen off - // animation and reset accordingly. - aodUiAnimationPlaying = false - // If we can't control the screen off animation, we shouldn't mess with the // CentralSurfaces's keyguard state unnecessarily. if (dozeParameters.get().canControlUnlockedScreenOff()) { @@ -313,19 +303,12 @@ constructor( !powerManager.isInteractive(Display.DEFAULT_DISPLAY) && shouldAnimateInKeyguard ) { - if (!MigrateClocksToBlueprint.isEnabled) { - // Tracking this state should no longer be relevant, as the - // isInteractive - // check covers it - aodUiAnimationPlaying = true - } - // Show AOD. That'll cause the KeyguardVisibilityHelper to call // #animateInKeyguard. shadeLockscreenInteractorLazy.get().showAodUi() } }, - (ANIMATE_IN_KEYGUARD_DELAY * animatorDurationScale).toLong() + (ANIMATE_IN_KEYGUARD_DELAY * animatorDurationScale).toLong(), ) return true @@ -362,7 +345,7 @@ constructor( if ( Settings.Global.getString( context.contentResolver, - Settings.Global.ANIMATOR_DURATION_SCALE + Settings.Global.ANIMATOR_DURATION_SCALE, ) == "0" ) { return false @@ -408,7 +391,7 @@ constructor( * AOD UI. */ override fun isAnimationPlaying(): Boolean { - return isScreenOffLightRevealAnimationPlaying() || aodUiAnimationPlaying + return isScreenOffLightRevealAnimationPlaying() } override fun shouldAnimateInKeyguard(): Boolean = shouldAnimateInKeyguard diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardQsUserSwitchController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardQsUserSwitchController.java index 8b60ee56d5f8..b966005975ff 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardQsUserSwitchController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardQsUserSwitchController.java @@ -32,16 +32,13 @@ import android.widget.FrameLayout; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.logging.UiEventLogger; import com.android.keyguard.KeyguardConstants; -import com.android.keyguard.KeyguardVisibilityHelper; import com.android.keyguard.dagger.KeyguardUserSwitcherScope; import com.android.settingslib.drawable.CircleFramedDrawable; import com.android.systemui.animation.Expandable; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.plugins.FalsingManager; -import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.qs.user.UserSwitchDialogController; import com.android.systemui.res.R; -import com.android.systemui.statusbar.SysuiStatusBarStateController; import com.android.systemui.statusbar.notification.AnimatableProperty; import com.android.systemui.statusbar.notification.PropertyAnimator; import com.android.systemui.statusbar.notification.stack.AnimationProperties; @@ -57,6 +54,7 @@ import javax.inject.Inject; /** * Manages the user switch on the Keyguard that is used for opening the QS user panel. + * TODO: b/384064264 - Move to blueprint sections */ @KeyguardUserSwitcherScope public class KeyguardQsUserSwitchController extends ViewController<FrameLayout> { @@ -73,9 +71,7 @@ public class KeyguardQsUserSwitchController extends ViewController<FrameLayout> private BaseUserSwitcherAdapter mAdapter; private final KeyguardStateController mKeyguardStateController; private final FalsingManager mFalsingManager; - protected final SysuiStatusBarStateController mStatusBarStateController; private final ConfigurationController mConfigurationController; - private final KeyguardVisibilityHelper mKeyguardVisibilityHelper; private final UserSwitchDialogController mUserSwitchDialogController; private final UiEventLogger mUiEventLogger; @VisibleForTesting @@ -84,26 +80,6 @@ public class KeyguardQsUserSwitchController extends ViewController<FrameLayout> UserRecord mCurrentUser; private boolean mIsKeyguardShowing; - // State info for the user switch and keyguard - private int mBarState; - - private final StatusBarStateController.StateListener mStatusBarStateListener = - new StatusBarStateController.StateListener() { - @Override - public void onStateChanged(int newState) { - boolean goingToFullShade = mStatusBarStateController.goingToFullShade(); - boolean keyguardFadingAway = mKeyguardStateController.isKeyguardFadingAway(); - int oldState = mBarState; - mBarState = newState; - - setKeyguardQsUserSwitchVisibility( - newState, - keyguardFadingAway, - goingToFullShade, - oldState); - } - }; - private ConfigurationController.ConfigurationListener mConfigurationListener = new ConfigurationController.ConfigurationListener() { @@ -144,7 +120,6 @@ public class KeyguardQsUserSwitchController extends ViewController<FrameLayout> KeyguardStateController keyguardStateController, FalsingManager falsingManager, ConfigurationController configurationController, - SysuiStatusBarStateController statusBarStateController, DozeParameters dozeParameters, ScreenOffAnimationController screenOffAnimationController, UserSwitchDialogController userSwitchDialogController, @@ -157,11 +132,6 @@ public class KeyguardQsUserSwitchController extends ViewController<FrameLayout> mKeyguardStateController = keyguardStateController; mFalsingManager = falsingManager; mConfigurationController = configurationController; - mStatusBarStateController = statusBarStateController; - mKeyguardVisibilityHelper = new KeyguardVisibilityHelper(mView, - keyguardStateController, dozeParameters, - screenOffAnimationController, /* animateYPos= */ false, - /* logBuffer= */ null); mUserSwitchDialogController = userSwitchDialogController; mUiEventLogger = uiEventLogger; } @@ -184,9 +154,6 @@ public class KeyguardQsUserSwitchController extends ViewController<FrameLayout> if (mFalsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) { return; } - if (isListAnimating()) { - return; - } // Tapping anywhere in the view will open the user switcher mUiEventLogger.log( @@ -212,7 +179,6 @@ public class KeyguardQsUserSwitchController extends ViewController<FrameLayout> if (DEBUG) Log.d(TAG, "onViewAttached"); mAdapter.registerDataSetObserver(mDataSetObserver); mDataSetObserver.onChanged(); - mStatusBarStateController.addCallback(mStatusBarStateListener); mConfigurationController.addCallback(mConfigurationListener); mKeyguardStateController.addCallback(mKeyguardStateCallback); // Force update when view attached in case configuration changed while the view was detached @@ -225,7 +191,6 @@ public class KeyguardQsUserSwitchController extends ViewController<FrameLayout> if (DEBUG) Log.d(TAG, "onViewDetached"); mAdapter.unregisterDataSetObserver(mDataSetObserver); - mStatusBarStateController.removeCallback(mStatusBarStateListener); mConfigurationController.removeCallback(mConfigurationListener); mKeyguardStateController.removeCallback(mKeyguardStateCallback); } @@ -333,18 +298,6 @@ public class KeyguardQsUserSwitchController extends ViewController<FrameLayout> } /** - * Set the visibility of the user avatar view based on some new state. - */ - public void setKeyguardQsUserSwitchVisibility( - int statusBarState, - boolean keyguardFadingAway, - boolean goingToFullShade, - int oldStatusBarState) { - mKeyguardVisibilityHelper.setViewVisibility( - statusBarState, keyguardFadingAway, goingToFullShade, oldStatusBarState); - } - - /** * Update position of the view with an optional animation */ public void updatePosition(int x, int y, boolean animate) { @@ -357,12 +310,6 @@ public class KeyguardQsUserSwitchController extends ViewController<FrameLayout> * Set keyguard user avatar view alpha. */ public void setAlpha(float alpha) { - if (!mKeyguardVisibilityHelper.isVisibilityAnimating()) { - mView.setAlpha(alpha); - } - } - - private boolean isListAnimating() { - return mKeyguardVisibilityHelper.isVisibilityAnimating(); + mView.setAlpha(alpha); } } diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardStatusViewControllerTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardStatusViewControllerTest.java deleted file mode 100644 index 8e441a3db242..000000000000 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardStatusViewControllerTest.java +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Copyright (C) 2020 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.keyguard; - -import static junit.framework.Assert.assertEquals; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import android.animation.AnimatorTestRule; -import android.platform.test.annotations.DisableFlags; -import android.testing.AndroidTestingRunner; -import android.testing.TestableLooper; -import android.view.View; - -import androidx.test.filters.SmallTest; - -import com.android.app.animation.Interpolators; -import com.android.systemui.Flags; -import com.android.systemui.animation.ViewHierarchyAnimator; -import com.android.systemui.plugins.clocks.ClockConfig; -import com.android.systemui.plugins.clocks.ClockController; -import com.android.systemui.res.R; -import com.android.systemui.statusbar.notification.AnimatableProperty; -import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.ArgumentCaptor; - -import java.lang.reflect.Field; - -@SmallTest -@TestableLooper.RunWithLooper(setAsMainLooper = true) -@RunWith(AndroidTestingRunner.class) -public class KeyguardStatusViewControllerTest extends KeyguardStatusViewControllerBaseTest { - - @Rule - public final AnimatorTestRule mAnimatorTestRule = new AnimatorTestRule(this); - - @Test - public void dozeTimeTick_updatesSlice() { - mController.dozeTimeTick(); - verify(mKeyguardSliceViewController).refresh(); - } - - @Test - public void dozeTimeTick_updatesClock() { - mController.dozeTimeTick(); - verify(mKeyguardClockSwitchController).refresh(); - } - - @Test - public void setTranslationYExcludingMedia_forwardsCallToView() { - float translationY = 123f; - - mController.setTranslationY(translationY, /* excludeMedia= */true); - - verify(mKeyguardStatusView).setChildrenTranslationY(translationY, /* excludeMedia= */true); - } - - @Test - @DisableFlags(Flags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT) - public void onLocaleListChangedNotifiesClockSwitchController() { - ArgumentCaptor<ConfigurationListener> configurationListenerArgumentCaptor = - ArgumentCaptor.forClass(ConfigurationListener.class); - - mController.onViewAttached(); - verify(mConfigurationController).addCallback(configurationListenerArgumentCaptor.capture()); - - configurationListenerArgumentCaptor.getValue().onLocaleListChanged(); - verify(mKeyguardClockSwitchController).onLocaleListChanged(); - } - - @Test - public void updatePosition_primaryClockAnimation() { - ClockController mockClock = mock(ClockController.class); - when(mKeyguardClockSwitchController.getClock()).thenReturn(mockClock); - when(mockClock.getConfig()).thenReturn(new ClockConfig("MOCK", "", "", false, true, false)); - - mController.updatePosition(10, 15, 20f, true); - - verify(mControllerMock).setProperty(AnimatableProperty.Y, 15f, true); - verify(mKeyguardClockSwitchController).updatePosition( - 10, 20f, KeyguardStatusViewController.CLOCK_ANIMATION_PROPERTIES, true); - verify(mControllerMock).setProperty(AnimatableProperty.SCALE_X, 1f, true); - verify(mControllerMock).setProperty(AnimatableProperty.SCALE_Y, 1f, true); - } - - @Test - public void updatePosition_alternateClockAnimation() { - ClockController mockClock = mock(ClockController.class); - when(mKeyguardClockSwitchController.getClock()).thenReturn(mockClock); - when(mockClock.getConfig()).thenReturn(new ClockConfig("MOCK", "", "", true, true, false)); - - mController.updatePosition(10, 15, 20f, true); - - verify(mControllerMock).setProperty(AnimatableProperty.Y, 15f, true); - verify(mKeyguardClockSwitchController).updatePosition( - 10, 1f, KeyguardStatusViewController.CLOCK_ANIMATION_PROPERTIES, true); - verify(mControllerMock).setProperty(AnimatableProperty.SCALE_X, 20f, true); - verify(mControllerMock).setProperty(AnimatableProperty.SCALE_Y, 20f, true); - } - - @Test - public void splitShadeEnabledPassedToClockSwitchController() { - mController.setSplitShadeEnabled(true); - verify(mKeyguardClockSwitchController, times(1)).setSplitShadeEnabled(true); - verify(mKeyguardClockSwitchController, times(0)).setSplitShadeEnabled(false); - } - - @Test - public void splitShadeDisabledPassedToClockSwitchController() { - mController.setSplitShadeEnabled(false); - verify(mKeyguardClockSwitchController, times(1)).setSplitShadeEnabled(false); - verify(mKeyguardClockSwitchController, times(0)).setSplitShadeEnabled(true); - } - - @Test - public void onInit_addsOnLayoutChangeListenerToClockSwitch() { - when(mKeyguardStatusView.findViewById(R.id.status_view_media_container)).thenReturn( - mMediaHostContainer); - - mController.onInit(); - - ArgumentCaptor<View.OnLayoutChangeListener> captor = - ArgumentCaptor.forClass(View.OnLayoutChangeListener.class); - verify(mKeyguardClockSwitch).addOnLayoutChangeListener(captor.capture()); - } - - @Test - public void clockSwitchHeightChanged_animatesMediaHostContainer() { - when(mKeyguardStatusView.findViewById(R.id.status_view_media_container)).thenReturn( - mMediaHostContainer); - - mController.onInit(); - - ArgumentCaptor<View.OnLayoutChangeListener> captor = - ArgumentCaptor.forClass(View.OnLayoutChangeListener.class); - verify(mKeyguardClockSwitch).addOnLayoutChangeListener(captor.capture()); - - // Above here is the same as `onInit_addsOnLayoutChangeListenerToClockSwitch`. - // Below here is the actual test. - - ViewHierarchyAnimator.Companion animator = ViewHierarchyAnimator.Companion; - ViewHierarchyAnimator.Companion spiedAnimator = spy(animator); - setCompanion(spiedAnimator); - - View.OnLayoutChangeListener listener = captor.getValue(); - - mController.setSplitShadeEnabled(true); - when(mKeyguardClockSwitch.getSplitShadeCentered()).thenReturn(false); - when(mKeyguardUpdateMonitor.isKeyguardVisible()).thenReturn(true); - when(mMediaHostContainer.getVisibility()).thenReturn(View.VISIBLE); - when(mMediaHostContainer.getHeight()).thenReturn(200); - - when(mKeyguardClockSwitch.getHeight()).thenReturn(0); - listener.onLayoutChange(mKeyguardClockSwitch, /* left= */ 0, /* top= */ 0, /* right= */ - 0, /* bottom= */ 0, /* oldLeft= */ 0, /* oldTop= */ 0, /* oldRight= */ - 0, /* oldBottom = */ 200); - verify(spiedAnimator).animateNextUpdate(mMediaHostContainer, - Interpolators.STANDARD, /* duration= */ 500L, /* animateChildren= */ false); - - // Resets ViewHierarchyAnimator.Companion to its original value - setCompanion(animator); - } - - @Test - public void clockSwitchHeightNotChanged_doesNotAnimateMediaOutputContainer() { - when(mKeyguardStatusView.findViewById(R.id.status_view_media_container)).thenReturn( - mMediaHostContainer); - - mController.onInit(); - - ArgumentCaptor<View.OnLayoutChangeListener> captor = - ArgumentCaptor.forClass(View.OnLayoutChangeListener.class); - verify(mKeyguardClockSwitch).addOnLayoutChangeListener(captor.capture()); - - // Above here is the same as `onInit_addsOnLayoutChangeListenerToClockSwitch`. - // Below here is the actual test. - - ViewHierarchyAnimator.Companion animator = ViewHierarchyAnimator.Companion; - ViewHierarchyAnimator.Companion spiedAnimator = spy(animator); - setCompanion(spiedAnimator); - - View.OnLayoutChangeListener listener = captor.getValue(); - - mController.setSplitShadeEnabled(true); - when(mKeyguardClockSwitch.getSplitShadeCentered()).thenReturn(false); - when(mKeyguardUpdateMonitor.isKeyguardVisible()).thenReturn(true); - when(mMediaHostContainer.getVisibility()).thenReturn(View.VISIBLE); - when(mMediaHostContainer.getHeight()).thenReturn(200); - - when(mKeyguardClockSwitch.getHeight()).thenReturn(200); - listener.onLayoutChange(mKeyguardClockSwitch, /* left= */ 0, /* top= */ 0, /* right= */ - 0, /* bottom= */ 0, /* oldLeft= */ 0, /* oldTop= */ 0, /* oldRight= */ - 0, /* oldBottom = */ 200); - verify(spiedAnimator, never()).animateNextUpdate(any(), any(), anyLong(), anyBoolean()); - - // Resets ViewHierarchyAnimator.Companion to its original value - setCompanion(animator); - } - - private void setCompanion(ViewHierarchyAnimator.Companion companion) { - try { - Field field = ViewHierarchyAnimator.class.getDeclaredField("Companion"); - field.setAccessible(true); - field.set(null, companion); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - @Test - @DisableFlags(Flags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT) - public void statusAreaHeightChange_animatesHeightOutputChange() { - // Init & Capture Layout Listener - mController.onInit(); - mController.onViewAttached(); - - when(mDozeParameters.getAlwaysOn()).thenReturn(true); - ArgumentCaptor<View.OnLayoutChangeListener> captor = - ArgumentCaptor.forClass(View.OnLayoutChangeListener.class); - verify(mKeyguardStatusAreaView).addOnLayoutChangeListener(captor.capture()); - View.OnLayoutChangeListener listener = captor.getValue(); - - // Setup and validate initial height - when(mKeyguardStatusView.getHeight()).thenReturn(200); - when(mKeyguardClockSwitchController.getNotificationIconAreaHeight()).thenReturn(10); - assertEquals(190, mController.getLockscreenHeight()); - - // Trigger Change and validate value unchanged immediately - when(mKeyguardStatusAreaView.getHeight()).thenReturn(100); - when(mKeyguardStatusView.getHeight()).thenReturn(300); // Include child height - listener.onLayoutChange(mKeyguardStatusAreaView, - /* new layout */ 100, 300, 200, 400, - /* old layout */ 100, 300, 200, 300); - assertEquals(190, mController.getLockscreenHeight()); - - // Complete animation, validate height increased - mAnimatorTestRule.advanceTimeBy(200); - assertEquals(290, mController.getLockscreenHeight()); - } -} diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationsQSContainerControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationsQSContainerControllerTest.kt index 4850b0f67857..24f8843e935d 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationsQSContainerControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationsQSContainerControllerTest.kt @@ -16,7 +16,6 @@ package com.android.systemui.shade -import android.platform.test.annotations.EnableFlags import android.testing.AndroidTestingRunner import android.testing.TestableLooper import android.view.View @@ -27,7 +26,6 @@ import androidx.annotation.IdRes import androidx.constraintlayout.widget.ConstraintLayout import androidx.constraintlayout.widget.ConstraintSet import androidx.test.filters.SmallTest -import com.android.systemui.Flags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT import com.android.systemui.SysuiTestCase import com.android.systemui.fragments.FragmentHostManager import com.android.systemui.fragments.FragmentService @@ -68,7 +66,6 @@ import org.mockito.MockitoAnnotations @RunWith(AndroidTestingRunner::class) @TestableLooper.RunWithLooper(setAsMainLooper = true) @SmallTest -@EnableFlags(FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT) class NotificationsQSContainerControllerTest : SysuiTestCase() { private val view = mock<NotificationsQuickSettingsContainer>() @@ -120,7 +117,7 @@ class NotificationsQSContainerControllerTest : SysuiTestCase() { delayableExecutor, notificationStackScrollLayoutController, ResourcesSplitShadeStateController(), - largeScreenHeaderHelperLazy = { largeScreenHeaderHelper } + largeScreenHeaderHelperLazy = { largeScreenHeaderHelper }, ) overrideResource(R.dimen.split_shade_notifications_scrim_margin_bottom, SCRIM_MARGIN) @@ -205,23 +202,23 @@ class NotificationsQSContainerControllerTest : SysuiTestCase() { given( taskbarVisible = true, navigationMode = GESTURES_NAVIGATION, - insets = windowInsets().withStableBottom() + insets = windowInsets().withStableBottom(), ) then( expectedContainerPadding = 0, // taskbar should disappear when shade is expanded expectedNotificationsMargin = NOTIFICATIONS_MARGIN, - expectedQsPadding = NOTIFICATIONS_MARGIN - QS_PADDING_OFFSET + expectedQsPadding = NOTIFICATIONS_MARGIN - QS_PADDING_OFFSET, ) given( taskbarVisible = true, navigationMode = BUTTONS_NAVIGATION, - insets = windowInsets().withStableBottom() + insets = windowInsets().withStableBottom(), ) then( expectedContainerPadding = STABLE_INSET_BOTTOM, expectedNotificationsMargin = NOTIFICATIONS_MARGIN, - expectedQsPadding = NOTIFICATIONS_MARGIN - QS_PADDING_OFFSET + expectedQsPadding = NOTIFICATIONS_MARGIN - QS_PADDING_OFFSET, ) } @@ -233,22 +230,22 @@ class NotificationsQSContainerControllerTest : SysuiTestCase() { given( taskbarVisible = false, navigationMode = GESTURES_NAVIGATION, - insets = windowInsets().withStableBottom() + insets = windowInsets().withStableBottom(), ) then( expectedContainerPadding = 0, - expectedQsPadding = NOTIFICATIONS_MARGIN - QS_PADDING_OFFSET + expectedQsPadding = NOTIFICATIONS_MARGIN - QS_PADDING_OFFSET, ) given( taskbarVisible = false, navigationMode = BUTTONS_NAVIGATION, - insets = windowInsets().withStableBottom() + insets = windowInsets().withStableBottom(), ) then( expectedContainerPadding = 0, // qs goes full height as it's not obscuring nav buttons expectedNotificationsMargin = STABLE_INSET_BOTTOM + NOTIFICATIONS_MARGIN, - expectedQsPadding = STABLE_INSET_BOTTOM + NOTIFICATIONS_MARGIN - QS_PADDING_OFFSET + expectedQsPadding = STABLE_INSET_BOTTOM + NOTIFICATIONS_MARGIN - QS_PADDING_OFFSET, ) } @@ -259,22 +256,22 @@ class NotificationsQSContainerControllerTest : SysuiTestCase() { given( taskbarVisible = false, navigationMode = GESTURES_NAVIGATION, - insets = windowInsets().withCutout() + insets = windowInsets().withCutout(), ) then( expectedContainerPadding = CUTOUT_HEIGHT, - expectedQsPadding = NOTIFICATIONS_MARGIN - QS_PADDING_OFFSET + expectedQsPadding = NOTIFICATIONS_MARGIN - QS_PADDING_OFFSET, ) given( taskbarVisible = false, navigationMode = BUTTONS_NAVIGATION, - insets = windowInsets().withCutout().withStableBottom() + insets = windowInsets().withCutout().withStableBottom(), ) then( expectedContainerPadding = 0, expectedNotificationsMargin = STABLE_INSET_BOTTOM + NOTIFICATIONS_MARGIN, - expectedQsPadding = STABLE_INSET_BOTTOM + NOTIFICATIONS_MARGIN - QS_PADDING_OFFSET + expectedQsPadding = STABLE_INSET_BOTTOM + NOTIFICATIONS_MARGIN - QS_PADDING_OFFSET, ) } @@ -285,18 +282,18 @@ class NotificationsQSContainerControllerTest : SysuiTestCase() { given( taskbarVisible = true, navigationMode = GESTURES_NAVIGATION, - insets = windowInsets().withStableBottom() + insets = windowInsets().withStableBottom(), ) then(expectedContainerPadding = 0, expectedQsPadding = STABLE_INSET_BOTTOM) given( taskbarVisible = true, navigationMode = BUTTONS_NAVIGATION, - insets = windowInsets().withStableBottom() + insets = windowInsets().withStableBottom(), ) then( expectedContainerPadding = STABLE_INSET_BOTTOM, - expectedQsPadding = STABLE_INSET_BOTTOM + expectedQsPadding = STABLE_INSET_BOTTOM, ) } @@ -310,19 +307,19 @@ class NotificationsQSContainerControllerTest : SysuiTestCase() { given( taskbarVisible = false, navigationMode = GESTURES_NAVIGATION, - insets = windowInsets().withCutout().withStableBottom() + insets = windowInsets().withCutout().withStableBottom(), ) then(expectedContainerPadding = CUTOUT_HEIGHT, expectedQsPadding = STABLE_INSET_BOTTOM) given( taskbarVisible = false, navigationMode = BUTTONS_NAVIGATION, - insets = windowInsets().withStableBottom() + insets = windowInsets().withStableBottom(), ) then( expectedContainerPadding = 0, expectedNotificationsMargin = STABLE_INSET_BOTTOM + NOTIFICATIONS_MARGIN, - expectedQsPadding = STABLE_INSET_BOTTOM + expectedQsPadding = STABLE_INSET_BOTTOM, ) } @@ -335,7 +332,7 @@ class NotificationsQSContainerControllerTest : SysuiTestCase() { given( taskbarVisible = false, navigationMode = GESTURES_NAVIGATION, - insets = windowInsets().withStableBottom() + insets = windowInsets().withStableBottom(), ) then(expectedContainerPadding = 0, expectedNotificationsMargin = 0) @@ -351,7 +348,7 @@ class NotificationsQSContainerControllerTest : SysuiTestCase() { given( taskbarVisible = false, navigationMode = GESTURES_NAVIGATION, - insets = windowInsets().withStableBottom() + insets = windowInsets().withStableBottom(), ) then(expectedContainerPadding = 0) @@ -467,7 +464,7 @@ class NotificationsQSContainerControllerTest : SysuiTestCase() { delayableExecutor, notificationStackScrollLayoutController, ResourcesSplitShadeStateController(), - largeScreenHeaderHelperLazy = { largeScreenHeaderHelper } + largeScreenHeaderHelperLazy = { largeScreenHeaderHelper }, ) controller.updateConstraints() @@ -483,7 +480,7 @@ class NotificationsQSContainerControllerTest : SysuiTestCase() { taskbarVisible = false, navigationMode = GESTURES_NAVIGATION, insets = emptyInsets(), - applyImmediately = false + applyImmediately = false, ) fakeSystemClock.advanceTime(INSET_DEBOUNCE_MILLIS / 2) windowInsetsCallback.accept(windowInsets().withStableBottom()) @@ -550,7 +547,7 @@ class NotificationsQSContainerControllerTest : SysuiTestCase() { taskbarVisible: Boolean, navigationMode: Int, insets: WindowInsets, - applyImmediately: Boolean = true + applyImmediately: Boolean = true, ) { Mockito.clearInvocations(view) taskbarVisibilityCallback.onTaskbarStatusUpdated(taskbarVisible, false) @@ -565,7 +562,7 @@ class NotificationsQSContainerControllerTest : SysuiTestCase() { fun then( expectedContainerPadding: Int, expectedNotificationsMargin: Int = NOTIFICATIONS_MARGIN, - expectedQsPadding: Int = 0 + expectedQsPadding: Int = 0, ) { verify(view).setPadding(anyInt(), anyInt(), anyInt(), eq(expectedContainerPadding)) verify(view).setNotificationsMarginBottom(expectedNotificationsMargin) @@ -597,7 +594,7 @@ class NotificationsQSContainerControllerTest : SysuiTestCase() { val layoutParams = ConstraintLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, - ViewGroup.LayoutParams.WRAP_CONTENT + ViewGroup.LayoutParams.WRAP_CONTENT, ) // required as cloning ConstraintSet fails if view doesn't have layout params view.layoutParams = layoutParams diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/LockscreenShadeTransitionControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/LockscreenShadeTransitionControllerTest.kt index 3a46d038f946..cfc00a918f61 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/LockscreenShadeTransitionControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/LockscreenShadeTransitionControllerTest.kt @@ -364,79 +364,6 @@ class LockscreenShadeTransitionControllerTest : SysuiTestCase() { } @Test - fun setDragAmount_setsKeyguardTransitionProgress() = - testScope.runTest { - transitionController.dragDownAmount = 10f - - verify(shadeLockscreenInteractor).setKeyguardTransitionProgress(anyFloat(), anyInt()) - } - - @Test - fun setDragAmount_setsKeyguardAlphaBasedOnDistance() = - testScope.runTest { - val alphaDistance = - context.resources.getDimensionPixelSize( - R.dimen.lockscreen_shade_npvc_keyguard_content_alpha_transition_distance - ) - transitionController.dragDownAmount = 10f - - val expectedAlpha = 1 - 10f / alphaDistance - verify(shadeLockscreenInteractor) - .setKeyguardTransitionProgress(eq(expectedAlpha), anyInt()) - } - - @Test - fun setDragAmount_notInSplitShade_setsKeyguardTranslationToZero() = - testScope.runTest { - val mediaTranslationY = 123 - disableSplitShade() - whenever(mediaHierarchyManager.isCurrentlyInGuidedTransformation()).thenReturn(true) - whenever(mediaHierarchyManager.getGuidedTransformationTranslationY()) - .thenReturn(mediaTranslationY) - - transitionController.dragDownAmount = 10f - - verify(shadeLockscreenInteractor).setKeyguardTransitionProgress(anyFloat(), eq(0)) - } - - @Test - fun setDragAmount_inSplitShade_setsKeyguardTranslationBasedOnMediaTranslation() = - testScope.runTest { - val mediaTranslationY = 123 - enableSplitShade() - whenever(mediaHierarchyManager.isCurrentlyInGuidedTransformation()).thenReturn(true) - whenever(mediaHierarchyManager.getGuidedTransformationTranslationY()) - .thenReturn(mediaTranslationY) - - transitionController.dragDownAmount = 10f - - verify(shadeLockscreenInteractor) - .setKeyguardTransitionProgress(anyFloat(), eq(mediaTranslationY)) - } - - @Test - fun setDragAmount_inSplitShade_mediaNotShowing_setsKeyguardTranslationBasedOnDistance() = - testScope.runTest { - enableSplitShade() - whenever(mediaHierarchyManager.isCurrentlyInGuidedTransformation()).thenReturn(false) - whenever(mediaHierarchyManager.getGuidedTransformationTranslationY()).thenReturn(123) - - transitionController.dragDownAmount = 10f - - val distance = - context.resources.getDimensionPixelSize( - R.dimen.lockscreen_shade_keyguard_transition_distance - ) - val offset = - context.resources.getDimensionPixelSize( - R.dimen.lockscreen_shade_keyguard_transition_vertical_offset - ) - val expectedTranslation = 10f / distance * offset - verify(shadeLockscreenInteractor) - .setKeyguardTransitionProgress(anyFloat(), eq(expectedTranslation.toInt())) - } - - @Test fun setDragDownAmount_setsValueOnMediaHierarchyManager() = testScope.runTest { transitionController.dragDownAmount = 10f diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithmTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithmTest.java index 9d6eb798df17..b17a58f9d8e3 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithmTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithmTest.java @@ -49,11 +49,7 @@ import org.mockito.quality.Strictness; @SmallTest @RunWith(AndroidJUnit4.class) public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { - private static final int SCREEN_HEIGHT = 2000; - private static final int EMPTY_HEIGHT = 0; private static final float ZERO_DRAG = 0.f; - private static final float OPAQUE = 1.f; - private static final float TRANSPARENT = 0.f; @Mock private Resources mResources; @@ -62,18 +58,10 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { private MockitoSession mStaticMockSession; - private float mPanelExpansion; - private int mKeyguardStatusBarHeaderHeight; - private int mKeyguardStatusHeight; private float mDark; - private float mQsExpansion; - private int mCutoutTopInset = 0; private boolean mIsSplitShade = false; private boolean mBypassEnabled = false; private int mUnlockedStackScrollerPadding = 0; - private float mUdfpsTop = -1; - private float mClockBottom = SCREEN_HEIGHT / 2; - private boolean mClockTopAligned; @Before public void setUp() { @@ -98,118 +86,9 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { } @Test - public void clockPositionTopOfScreenOnAOD() { - // GIVEN on AOD and clock has 0 height - givenAOD(); - mKeyguardStatusHeight = EMPTY_HEIGHT; - // WHEN the clock position algorithm is run - positionClock(); - // THEN the clock Y position is the top of the screen - assertThat(mClockPosition.clockY).isEqualTo(0); - // AND the clock is opaque and positioned on the left. - assertThat(mClockPosition.clockX).isEqualTo(0); - assertThat(mClockPosition.clockAlpha).isEqualTo(OPAQUE); - } - - @Test - public void clockPositionBelowCutout() { - // GIVEN on AOD and clock has 0 height - givenAOD(); - mKeyguardStatusHeight = EMPTY_HEIGHT; - mCutoutTopInset = 300; - // WHEN the clock position algorithm is run - positionClock(); - // THEN the clock Y position is below the cutout - assertThat(mClockPosition.clockY).isEqualTo(300); - // AND the clock is opaque and positioned on the left. - assertThat(mClockPosition.clockX).isEqualTo(0); - assertThat(mClockPosition.clockAlpha).isEqualTo(OPAQUE); - } - - @Test - public void clockPositionAdjustsForKeyguardStatusOnAOD() { - // GIVEN on AOD with a clock of height 100 - givenAOD(); - mKeyguardStatusHeight = 100; - // WHEN the clock position algorithm is run - positionClock(); - // THEN the clock Y position is at the top - assertThat(mClockPosition.clockY).isEqualTo(0); - // AND the clock is opaque and positioned on the left. - assertThat(mClockPosition.clockX).isEqualTo(0); - assertThat(mClockPosition.clockAlpha).isEqualTo(OPAQUE); - } - - @Test - public void clockPositionLargeClockOnAOD() { - // GIVEN on AOD with a full screen clock - givenAOD(); - mKeyguardStatusHeight = SCREEN_HEIGHT; - // WHEN the clock position algorithm is run - positionClock(); - // THEN the clock Y position doesn't overflow the screen. - assertThat(mClockPosition.clockY).isEqualTo(0); - // AND the clock is opaque and positioned on the left. - assertThat(mClockPosition.clockX).isEqualTo(0); - assertThat(mClockPosition.clockAlpha).isEqualTo(OPAQUE); - } - - @Test - public void clockPositionTopOfScreenOnLockScreen() { - // GIVEN on lock screen with clock of 0 height - givenLockScreen(); - mKeyguardStatusHeight = EMPTY_HEIGHT; - // WHEN the clock position algorithm is run - positionClock(); - // THEN the clock Y position is the top of the screen - assertThat(mClockPosition.clockY).isEqualTo(0); - // AND the clock is positioned on the left. - assertThat(mClockPosition.clockX).isEqualTo(0); - } - - @Test - public void clockPositionWithPartialDragOnLockScreen() { - // GIVEN dragging up on lock screen - givenLockScreen(); - mKeyguardStatusHeight = EMPTY_HEIGHT; - mPanelExpansion = 0.5f; - // WHEN the clock position algorithm is run - positionClock(); - // THEN the clock Y position adjusts with drag gesture. - assertThat(mClockPosition.clockY).isLessThan(1000); - // AND the clock is positioned on the left and not fully opaque. - assertThat(mClockPosition.clockX).isEqualTo(0); - assertThat(mClockPosition.clockAlpha).isLessThan(OPAQUE); - } - - @Test - public void clockPositionWithFullDragOnLockScreen() { - // GIVEN the lock screen is dragged up - givenLockScreen(); - mKeyguardStatusHeight = EMPTY_HEIGHT; - mPanelExpansion = 0.f; - // WHEN the clock position algorithm is run - positionClock(); - // THEN the clock is transparent. - assertThat(mClockPosition.clockAlpha).isEqualTo(TRANSPARENT); - } - - @Test - public void largeClockOnLockScreenIsTransparent() { - // GIVEN on lock screen with a full screen clock - givenLockScreen(); - mKeyguardStatusHeight = SCREEN_HEIGHT; - // WHEN the clock position algorithm is run - positionClock(); - // THEN the clock is transparent - assertThat(mClockPosition.clockAlpha).isEqualTo(TRANSPARENT); - } - - @Test public void notifPositionTopOfScreenOnAOD() { // GIVEN on AOD and clock has 0 height givenAOD(); - mKeyguardStatusHeight = EMPTY_HEIGHT; // WHEN the position algorithm is run positionClock(); // THEN the notif padding is 0 (top of screen) @@ -217,53 +96,9 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { } @Test - public void notifPositionIndependentOfKeyguardStatusHeightOnAOD() { - // GIVEN on AOD and clock has a nonzero height - givenAOD(); - mKeyguardStatusHeight = 100; - // WHEN the position algorithm is run - positionClock(); - // THEN the notif padding adjusts for keyguard status height - assertThat(mClockPosition.stackScrollerPadding).isEqualTo(100); - } - - @Test - public void notifPositionWithLargeClockOnAOD() { - // GIVEN on AOD and clock has a nonzero height - givenAOD(); - mKeyguardStatusHeight = SCREEN_HEIGHT; - // WHEN the position algorithm is run - positionClock(); - // THEN the notif padding is, unfortunately, the entire screen. - assertThat(mClockPosition.stackScrollerPadding).isEqualTo(SCREEN_HEIGHT); - } - - @Test - public void notifPositionMiddleOfScreenOnLockScreen() { - // GIVEN on lock screen and clock has 0 height - givenLockScreen(); - mKeyguardStatusHeight = EMPTY_HEIGHT; - // WHEN the position algorithm is run - positionClock(); - // THEN the notif are placed to the top of the screen - assertThat(mClockPosition.stackScrollerPadding).isEqualTo(0); - } - - @Test - public void notifPositionAdjustsForClockHeightOnLockScreen() { - // GIVEN on lock screen and stack scroller has a nonzero height - givenLockScreen(); - mKeyguardStatusHeight = 200; - // WHEN the position algorithm is run - positionClock(); - assertThat(mClockPosition.stackScrollerPadding).isEqualTo(200); - } - - @Test public void notifPositionAlignedWithClockInSplitShadeMode() { givenLockScreen(); mIsSplitShade = true; - mKeyguardStatusHeight = 200; // WHEN the position algorithm is run positionClock(); // THEN the notif padding DOESN'T adjust for keyguard status height. @@ -284,17 +119,6 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { } @Test - public void clockPositionedDependingOnMarginInSplitShade() { - setSplitShadeTopMargin(400); - givenLockScreen(); - mIsSplitShade = true; - // WHEN the position algorithm is run - positionClock(); - - assertThat(mClockPosition.clockY).isEqualTo(400); - } - - @Test public void notifPaddingMakesUpToFullMarginInSplitShade_usesHelper() { int keyguardSplitShadeTopMargin = 100; int largeScreenHeaderHeightHelper = 50; @@ -316,259 +140,15 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { } @Test - public void notifPaddingExpandedAlignedWithClockInSplitShadeMode() { - givenLockScreen(); - mIsSplitShade = true; - mKeyguardStatusHeight = 200; - // WHEN the position algorithm is run - positionClock(); - // THEN the padding DOESN'T adjust for keyguard status height. - assertThat(mClockPosition.stackScrollerPaddingExpanded) - .isEqualTo(mClockPosition.clockY); - } - - @Test - public void notifPadding_splitShade() { - givenLockScreen(); - mIsSplitShade = true; - mKeyguardStatusHeight = 200; - // WHEN the position algorithm is run - positionClock(); - // THEN the padding DOESN'T adjust for keyguard status height. - assertThat(mClockPositionAlgorithm.getLockscreenNotifPadding(/* nsslTop= */ 10)) - .isEqualTo(mKeyguardStatusBarHeaderHeight - 10); - } - - @Test - public void notifPadding_portraitShade_bypassOff() { - givenLockScreen(); - mIsSplitShade = false; - mBypassEnabled = false; - - mKeyguardStatusBarHeaderHeight = 100; - when(mResources.getDimensionPixelSize(R.dimen.keyguard_clock_top_margin)) - .thenReturn(0); - - mKeyguardStatusHeight = 200; - - // WHEN the position algorithm is run - positionClock(); - - // THEN padding = 300 = mMinTopMargin(100) + mKeyguardStatusHeight(200) - assertThat(mClockPositionAlgorithm.getLockscreenNotifPadding(/* nsslTop= */ 50)) - .isEqualTo(300); - } - - @Test - public void notifPadding_portraitShade_bypassOn() { - givenLockScreen(); - mIsSplitShade = false; - mBypassEnabled = true; - mUnlockedStackScrollerPadding = 200; - - // WHEN the position algorithm is run - positionClock(); - - // THEN padding = 150 = mUnlockedStackScrollerPadding(200) - nsslTop(50) - assertThat(mClockPositionAlgorithm.getLockscreenNotifPadding(/* nsslTop= */ 50)) - .isEqualTo(150); - } - - @Test - public void notifPositionWithLargeClockOnLockScreen() { - // GIVEN on lock screen and clock has a nonzero height - givenLockScreen(); - mKeyguardStatusHeight = SCREEN_HEIGHT; - // WHEN the position algorithm is run - positionClock(); - // THEN the notif padding is below keyguard status area - assertThat(mClockPosition.stackScrollerPadding).isEqualTo(SCREEN_HEIGHT); - } - - @Test public void notifPositionWithFullDragOnLockScreen() { // GIVEN the lock screen is dragged up givenLockScreen(); - mKeyguardStatusHeight = EMPTY_HEIGHT; - mPanelExpansion = 0.f; // WHEN the clock position algorithm is run positionClock(); // THEN the notif padding is zero. assertThat(mClockPosition.stackScrollerPadding).isEqualTo(0); } - @Test - public void notifPositionWithLargeClockFullDragOnLockScreen() { - // GIVEN the lock screen is dragged up and a full screen clock - givenLockScreen(); - mKeyguardStatusHeight = SCREEN_HEIGHT; - mPanelExpansion = 0.f; - // WHEN the clock position algorithm is run - positionClock(); - assertThat(mClockPosition.stackScrollerPadding).isEqualTo( - (int) (mKeyguardStatusHeight * .667f)); - } - - @Test - public void clockHiddenWhenQsIsExpanded() { - // GIVEN on the lock screen with visible notifications - givenLockScreen(); - mQsExpansion = 1; - // WHEN the clock position algorithm is run - positionClock(); - // THEN the clock is transparent. - assertThat(mClockPosition.clockAlpha).isEqualTo(TRANSPARENT); - } - - @Test - public void clockNotHiddenWhenQsIsExpandedInSplitShade() { - // GIVEN on the split lock screen with QS expansion - givenLockScreen(); - mIsSplitShade = true; - setSplitShadeTopMargin(100); - mQsExpansion = 1; - - // WHEN the clock position algorithm is run - positionClock(); - - assertThat(mClockPosition.clockAlpha).isEqualTo(1); - } - - @Test - public void clockPositionMinimizesBurnInMovementToAvoidUdfpsOnAOD() { - // GIVEN a center aligned clock - mClockTopAligned = false; - - // GIVEN the clock + udfps are 100px apart - mClockBottom = SCREEN_HEIGHT - 500; - mUdfpsTop = SCREEN_HEIGHT - 400; - - // GIVEN it's AOD and the burn-in y value is 200 - givenAOD(); - givenMaxBurnInOffset(200); - - // WHEN the clock position algorithm is run with the highest burn in offset - givenHighestBurnInOffset(); - positionClock(); - - // THEN the worst-case clock Y position is shifted only by 100 (not the full 200), - // so that it's at the same location as mUdfpsTop - assertThat(mClockPosition.clockY).isEqualTo(100); - - // WHEN the clock position algorithm is run with the lowest burn in offset - givenLowestBurnInOffset(); - positionClock(); - - // THEN lowest case starts at 0 - assertThat(mClockPosition.clockY).isEqualTo(0); - } - - @Test - public void clockPositionShiftsToAvoidUdfpsOnAOD_usesSpaceAboveClock() { - // GIVEN a center aligned clock - mClockTopAligned = false; - - // GIVEN there's space at the top of the screen on LS (that's available to be used for - // burn-in on AOD) - mKeyguardStatusBarHeaderHeight = 150; - - // GIVEN the bottom of the clock is beyond the top of UDFPS - mClockBottom = SCREEN_HEIGHT - 300; - mUdfpsTop = SCREEN_HEIGHT - 400; - - // GIVEN it's AOD and the burn-in y value is 200 - givenAOD(); - givenMaxBurnInOffset(200); - - // WHEN the clock position algorithm is run with the highest burn in offset - givenHighestBurnInOffset(); - positionClock(); - - // THEN the algo should shift the clock up and use the area above the clock for - // burn-in since the burn in offset > space above clock - assertThat(mClockPosition.clockY).isEqualTo(mKeyguardStatusBarHeaderHeight); - - // WHEN the clock position algorithm is run with the lowest burn in offset - givenLowestBurnInOffset(); - positionClock(); - - // THEN lowest case starts at mCutoutTopInset (0 in this case) - assertThat(mClockPosition.clockY).isEqualTo(mCutoutTopInset); - } - - @Test - public void clockPositionShiftsToAvoidUdfpsOnAOD_usesMaxBurnInOffset() { - // GIVEN a center aligned clock - mClockTopAligned = false; - - // GIVEN there's 200px space at the top of the screen on LS (that's available to be used for - // burn-in on AOD) but 50px are taken up by the cutout - mKeyguardStatusBarHeaderHeight = 200; - mCutoutTopInset = 50; - - // GIVEN the bottom of the clock is beyond the top of UDFPS - mClockBottom = SCREEN_HEIGHT - 300; - mUdfpsTop = SCREEN_HEIGHT - 400; - - // GIVEN it's AOD and the burn-in y value is only 25px (less than space above clock) - givenAOD(); - int maxYBurnInOffset = 25; - givenMaxBurnInOffset(maxYBurnInOffset); - - // WHEN the clock position algorithm is run with the highest burn in offset - givenHighestBurnInOffset(); - positionClock(); - - // THEN the algo should shift the clock up and use the area above the clock for - // burn-in - assertThat(mClockPosition.clockY).isEqualTo(mKeyguardStatusBarHeaderHeight); - - // WHEN the clock position algorithm is run with the lowest burn in offset - givenLowestBurnInOffset(); - positionClock(); - - // THEN lowest case starts above mKeyguardStatusBarHeaderHeight - assertThat(mClockPosition.clockY).isEqualTo( - mKeyguardStatusBarHeaderHeight - 2 * maxYBurnInOffset); - } - - @Test - public void clockPositionShiftsToMaximizeUdfpsBurnInMovement() { - // GIVEN a center aligned clock - mClockTopAligned = false; - - // GIVEN there's 200px space at the top of the screen on LS (that's available to be used for - // burn-in on AOD) but 50px are taken up by the cutout - mKeyguardStatusBarHeaderHeight = 200; - mCutoutTopInset = 50; - int upperSpaceAvailable = mKeyguardStatusBarHeaderHeight - mCutoutTopInset; - - // GIVEN the bottom of the clock and the top of UDFPS are 100px apart - mClockBottom = SCREEN_HEIGHT - 500; - mUdfpsTop = SCREEN_HEIGHT - 400; - float lowerSpaceAvailable = mUdfpsTop - mClockBottom; - - // GIVEN it's AOD and the burn-in y value is 200 - givenAOD(); - givenMaxBurnInOffset(200); - - // WHEN the clock position algorithm is run with the highest burn in offset - givenHighestBurnInOffset(); - positionClock(); - - // THEN the algo should shift the clock up and use both the area above - // the clock and below the clock (vertically centered in its allowed area) - assertThat(mClockPosition.clockY).isEqualTo( - (int) (mCutoutTopInset + upperSpaceAvailable + lowerSpaceAvailable)); - - // WHEN the clock position algorithm is run with the lowest burn in offset - givenLowestBurnInOffset(); - positionClock(); - - // THEN lowest case starts at mCutoutTopInset - assertThat(mClockPosition.clockY).isEqualTo(mCutoutTopInset); - } - private void setSplitShadeTopMargin(int value) { when(mResources.getDimensionPixelSize(R.dimen.keyguard_split_shade_top_margin)) .thenReturn(value); @@ -579,10 +159,6 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { when(BurnInHelperKt.getBurnInOffset(anyInt(), anyBoolean())).then(returnsFirstArg()); } - private void givenLowestBurnInOffset() { - when(BurnInHelperKt.getBurnInOffset(anyInt(), anyBoolean())).thenReturn(0); - } - private void givenMaxBurnInOffset(int offset) { when(mResources.getDimensionPixelSize(R.dimen.burn_in_prevention_offset_y_clock)) .thenReturn(offset); @@ -590,12 +166,10 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { } private void givenAOD() { - mPanelExpansion = 1.f; mDark = 1.f; } private void givenLockScreen() { - mPanelExpansion = 1.f; mDark = 0.f; } @@ -606,19 +180,11 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { */ private void positionClock() { mClockPositionAlgorithm.setup( - mKeyguardStatusBarHeaderHeight, - mPanelExpansion, - mKeyguardStatusHeight, mDark, ZERO_DRAG, mBypassEnabled, mUnlockedStackScrollerPadding, - mQsExpansion, - mCutoutTopInset, - mIsSplitShade, - mUdfpsTop, - mClockBottom, - mClockTopAligned); + mIsSplitShade); mClockPositionAlgorithm.run(mClockPosition); } } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/flags/EnableSceneContainer.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/flags/EnableSceneContainer.kt index 4513cc086513..dad85697ef1d 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/flags/EnableSceneContainer.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/flags/EnableSceneContainer.kt @@ -18,7 +18,6 @@ package com.android.systemui.flags import android.platform.test.annotations.EnableFlags import com.android.systemui.Flags.FLAG_KEYGUARD_WM_STATE_REFACTOR -import com.android.systemui.Flags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT import com.android.systemui.Flags.FLAG_NOTIFICATION_AVALANCHE_THROTTLE_HUN import com.android.systemui.Flags.FLAG_PREDICTIVE_BACK_SYSUI import com.android.systemui.Flags.FLAG_SCENE_CONTAINER @@ -29,7 +28,6 @@ import com.android.systemui.Flags.FLAG_SCENE_CONTAINER */ @EnableFlags( FLAG_KEYGUARD_WM_STATE_REFACTOR, - FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT, FLAG_NOTIFICATION_AVALANCHE_THROTTLE_HUN, FLAG_PREDICTIVE_BACK_SYSUI, FLAG_SCENE_CONTAINER, diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/KeyguardBlueprintRepositoryKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/KeyguardBlueprintRepositoryKosmos.kt index 49a8c1866aa2..6df2318c6935 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/KeyguardBlueprintRepositoryKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/KeyguardBlueprintRepositoryKosmos.kt @@ -59,7 +59,6 @@ val Kosmos.defaultKeyguardBlueprint by defaultShortcutsSection = mock(), defaultAmbientIndicationAreaSection = Optional.of(mock()), defaultSettingsPopupMenuSection = mock(), - defaultStatusViewSection = mock(), defaultStatusBarSection = mock(), defaultNotificationStackScrollLayoutSection = mock(), aodNotificationIconsSection = mock(), @@ -81,7 +80,6 @@ val Kosmos.splitShadeBlueprint by defaultShortcutsSection = mock(), defaultAmbientIndicationAreaSection = Optional.of(mock()), defaultSettingsPopupMenuSection = mock(), - defaultStatusViewSection = mock(), defaultStatusBarSection = mock(), splitShadeNotificationStackScrollLayoutSection = mock(), splitShadeGuidelines = mock(), diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/ui/viewmodel/AodAlphaViewModelKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/ui/viewmodel/AodAlphaViewModelKosmos.kt deleted file mode 100644 index 24201d75424e..000000000000 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/ui/viewmodel/AodAlphaViewModelKosmos.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2023 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@file:OptIn(ExperimentalCoroutinesApi::class) - -package com.android.systemui.keyguard.ui.viewmodel - -import com.android.systemui.keyguard.domain.interactor.keyguardInteractor -import com.android.systemui.keyguard.domain.interactor.keyguardTransitionInteractor -import com.android.systemui.kosmos.Kosmos -import com.android.systemui.kosmos.Kosmos.Fixture -import com.android.systemui.scene.domain.interactor.sceneInteractor -import kotlinx.coroutines.ExperimentalCoroutinesApi - -val Kosmos.aodAlphaViewModel by Fixture { - AodAlphaViewModel( - keyguardTransitionInteractor = keyguardTransitionInteractor, - goneToAodTransitionViewModel = goneToAodTransitionViewModel, - goneToDozingTransitionViewModel = goneToDozingTransitionViewModel, - keyguardInteractor = keyguardInteractor, - sceneInteractor = sceneInteractor, - ) -} diff --git a/services/core/java/com/android/server/input/InputSettingsObserver.java b/services/core/java/com/android/server/input/InputSettingsObserver.java index bf08563db30d..56cb6f49f6c4 100644 --- a/services/core/java/com/android/server/input/InputSettingsObserver.java +++ b/services/core/java/com/android/server/input/InputSettingsObserver.java @@ -69,6 +69,8 @@ class InputSettingsObserver extends ContentObserver { Map.entry(Settings.System.getUriFor( Settings.System.MOUSE_SWAP_PRIMARY_BUTTON), (reason) -> updateMouseSwapPrimaryButton()), + Map.entry(Settings.System.getUriFor(Settings.System.MOUSE_SCROLLING_ACCELERATION), + (reason) -> updateMouseScrollingAcceleration()), Map.entry(Settings.System.getUriFor(Settings.System.TOUCHPAD_POINTER_SPEED), (reason) -> updateTouchpadPointerSpeed()), Map.entry(Settings.System.getUriFor(Settings.System.TOUCHPAD_NATURAL_SCROLLING), @@ -184,6 +186,11 @@ class InputSettingsObserver extends ContentObserver { InputSettings.isMouseSwapPrimaryButtonEnabled(mContext)); } + private void updateMouseScrollingAcceleration() { + mNative.setMouseScrollingAccelerationEnabled( + InputSettings.isMouseScrollingAccelerationEnabled(mContext)); + } + private void updateTouchpadPointerSpeed() { mNative.setTouchpadPointerSpeed( constrainPointerSpeedValue(InputSettings.getTouchpadPointerSpeed(mContext))); diff --git a/services/core/java/com/android/server/input/NativeInputManagerService.java b/services/core/java/com/android/server/input/NativeInputManagerService.java index c72f7c076a83..ab5a680867e9 100644 --- a/services/core/java/com/android/server/input/NativeInputManagerService.java +++ b/services/core/java/com/android/server/input/NativeInputManagerService.java @@ -134,6 +134,8 @@ interface NativeInputManagerService { void setMouseReverseVerticalScrollingEnabled(boolean enabled); + void setMouseScrollingAccelerationEnabled(boolean enabled); + void setMouseSwapPrimaryButtonEnabled(boolean enabled); void setTouchpadPointerSpeed(int speed); @@ -421,6 +423,9 @@ interface NativeInputManagerService { public native void setMouseReverseVerticalScrollingEnabled(boolean enabled); @Override + public native void setMouseScrollingAccelerationEnabled(boolean enabled); + + @Override public native void setMouseSwapPrimaryButtonEnabled(boolean enabled); @Override diff --git a/services/core/jni/com_android_server_input_InputManagerService.cpp b/services/core/jni/com_android_server_input_InputManagerService.cpp index 2403934cbeb8..813fec1454a7 100644 --- a/services/core/jni/com_android_server_input_InputManagerService.cpp +++ b/services/core/jni/com_android_server_input_InputManagerService.cpp @@ -343,6 +343,7 @@ public: void setPointerSpeed(int32_t speed); void setMousePointerAccelerationEnabled(ui::LogicalDisplayId displayId, bool enabled); void setMouseReverseVerticalScrollingEnabled(bool enabled); + void setMouseScrollingAccelerationEnabled(bool enabled); void setMouseSwapPrimaryButtonEnabled(bool enabled); void setTouchpadPointerSpeed(int32_t speed); void setTouchpadNaturalScrollingEnabled(bool enabled); @@ -492,6 +493,9 @@ private: // True if stylus button reporting through motion events is enabled. bool stylusButtonMotionEventsEnabled{true}; + // True if mouse scrolling acceleration is enabled. + bool mouseScrollingAccelerationEnabled{true}; + // True if mouse vertical scrolling is reversed. bool mouseReverseVerticalScrollingEnabled{false}; @@ -828,6 +832,10 @@ void NativeInputManager::getReaderConfiguration(InputReaderConfiguration* outCon mLocked.pointerDisplayId) == 0 ? android::os::IInputConstants::DEFAULT_POINTER_ACCELERATION : 1; + outConfig->wheelVelocityControlParameters.acceleration = + mLocked.mouseScrollingAccelerationEnabled + ? android::os::IInputConstants::DEFAULT_MOUSE_WHEEL_ACCELERATION + : 1; outConfig->pointerGesturesEnabled = mLocked.pointerGesturesEnabled; outConfig->pointerCaptureRequest = mLocked.pointerCaptureRequest; @@ -1420,6 +1428,21 @@ void NativeInputManager::setMouseReverseVerticalScrollingEnabled(bool enabled) { InputReaderConfiguration::Change::MOUSE_SETTINGS); } +void NativeInputManager::setMouseScrollingAccelerationEnabled(bool enabled) { + { // acquire lock + std::scoped_lock _l(mLock); + + if (mLocked.mouseScrollingAccelerationEnabled == enabled) { + return; + } + + mLocked.mouseScrollingAccelerationEnabled = enabled; + } // release lock + + mInputManager->getReader().requestRefreshConfiguration( + InputReaderConfiguration::Change::POINTER_SPEED); +} + void NativeInputManager::setMouseSwapPrimaryButtonEnabled(bool enabled) { { // acquire lock std::scoped_lock _l(mLock); @@ -3179,6 +3202,12 @@ static jint nativeGetLastUsedInputDeviceId(JNIEnv* env, jobject nativeImplObj) { return static_cast<jint>(im->getInputManager()->getReader().getLastUsedInputDeviceId()); } +static void nativeSetMouseScrollingAccelerationEnabled(JNIEnv* env, jobject nativeImplObj, + bool enabled) { + NativeInputManager* im = getNativeInputManager(env, nativeImplObj); + im->setMouseScrollingAccelerationEnabled(enabled); +} + static void nativeSetMouseReverseVerticalScrollingEnabled(JNIEnv* env, jobject nativeImplObj, bool enabled) { NativeInputManager* im = getNativeInputManager(env, nativeImplObj); @@ -3248,6 +3277,8 @@ static const JNINativeMethod gInputManagerMethods[] = { (void*)nativeSetMousePointerAccelerationEnabled}, {"setMouseReverseVerticalScrollingEnabled", "(Z)V", (void*)nativeSetMouseReverseVerticalScrollingEnabled}, + {"setMouseScrollingAccelerationEnabled", "(Z)V", + (void*)nativeSetMouseScrollingAccelerationEnabled}, {"setMouseSwapPrimaryButtonEnabled", "(Z)V", (void*)nativeSetMouseSwapPrimaryButtonEnabled}, {"setTouchpadPointerSpeed", "(I)V", (void*)nativeSetTouchpadPointerSpeed}, {"setTouchpadNaturalScrollingEnabled", "(Z)V", diff --git a/services/core/jni/com_android_server_tv_TvKeys.h b/services/core/jni/com_android_server_tv_TvKeys.h index b3ee263190c6..babdb4ccac94 100644 --- a/services/core/jni/com_android_server_tv_TvKeys.h +++ b/services/core/jni/com_android_server_tv_TvKeys.h @@ -91,8 +91,11 @@ static Key KEYS[] = { {KEY_TEXT, AKEYCODE_TV_TELETEXT}, {KEY_SUBTITLE, AKEYCODE_CAPTIONS}, {KEY_PVR, AKEYCODE_DVR}, + {KEY_VIDEO, AKEYCODE_TV_INPUT}, {KEY_AUDIO, AKEYCODE_MEDIA_AUDIO_TRACK}, + {KEY_AUDIO_DESC, AKEYCODE_TV_AUDIO_DESCRIPTION}, {KEY_OPTION, AKEYCODE_SETTINGS}, + {KEY_DOT, AKEYCODE_PERIOD}, // Gamepad buttons {KEY_UP, AKEYCODE_DPAD_UP}, diff --git a/tests/FlickerTests/test-apps/app-helpers/src/com/android/server/wm/flicker/helpers/DesktopModeAppHelper.kt b/tests/FlickerTests/test-apps/app-helpers/src/com/android/server/wm/flicker/helpers/DesktopModeAppHelper.kt index 2db8b1e18ec8..0824874f2a36 100644 --- a/tests/FlickerTests/test-apps/app-helpers/src/com/android/server/wm/flicker/helpers/DesktopModeAppHelper.kt +++ b/tests/FlickerTests/test-apps/app-helpers/src/com/android/server/wm/flicker/helpers/DesktopModeAppHelper.kt @@ -28,6 +28,7 @@ import android.tools.device.apphelpers.IStandardAppHelper import android.tools.helpers.SYSTEMUI_PACKAGE import android.tools.traces.parsers.WindowManagerStateHelper import android.tools.traces.wm.WindowingMode +import android.view.KeyEvent.KEYCODE_EQUALS import android.view.KeyEvent.KEYCODE_LEFT_BRACKET import android.view.KeyEvent.KEYCODE_MINUS import android.view.KeyEvent.KEYCODE_RIGHT_BRACKET @@ -147,10 +148,19 @@ open class DesktopModeAppHelper(private val innerHelper: IStandardAppHelper) : } /** Click maximise button on the app header for the given app. */ - fun maximiseDesktopApp(wmHelper: WindowManagerStateHelper, device: UiDevice) { - val caption = getCaptionForTheApp(wmHelper, device) - val maximizeButton = getMaximizeButtonForTheApp(caption) - maximizeButton.click() + fun maximiseDesktopApp( + wmHelper: WindowManagerStateHelper, + device: UiDevice, + usingKeyboard: Boolean = false + ) { + if (usingKeyboard) { + val keyEventHelper = KeyEventHelper(getInstrumentation()) + keyEventHelper.press(KEYCODE_EQUALS, META_META_ON) + } else { + val caption = getCaptionForTheApp(wmHelper, device) + val maximizeButton = getMaximizeButtonForTheApp(caption) + maximizeButton.click() + } wmHelper.StateSyncBuilder().withAppTransitionIdle().waitForAndVerify() } |