Merge "ViewGroup: Fix dispatching of generic motion events" into main
diff --git a/core/api/module-lib-current.txt b/core/api/module-lib-current.txt
index c1f6219..3baa92c 100644
--- a/core/api/module-lib-current.txt
+++ b/core/api/module-lib-current.txt
@@ -6,6 +6,7 @@
     field public static final String CONTROL_AUTOMOTIVE_GNSS = "android.permission.CONTROL_AUTOMOTIVE_GNSS";
     field public static final String GET_INTENT_SENDER_INTENT = "android.permission.GET_INTENT_SENDER_INTENT";
     field public static final String MAKE_UID_VISIBLE = "android.permission.MAKE_UID_VISIBLE";
+    field public static final String USE_COMPANION_TRANSPORTS = "android.permission.USE_COMPANION_TRANSPORTS";
   }
 
 }
@@ -80,6 +81,29 @@
 
 }
 
+package android.companion {
+
+  public final class CompanionDeviceManager {
+    method @RequiresPermission(android.Manifest.permission.USE_COMPANION_TRANSPORTS) public void addOnMessageReceivedListener(@NonNull java.util.concurrent.Executor, int, @NonNull android.companion.CompanionDeviceManager.OnMessageReceivedListener);
+    method @RequiresPermission(android.Manifest.permission.USE_COMPANION_TRANSPORTS) public void addOnTransportsChangedListener(@NonNull java.util.concurrent.Executor, @NonNull android.companion.CompanionDeviceManager.OnTransportsChangedListener);
+    method @RequiresPermission(android.Manifest.permission.USE_COMPANION_TRANSPORTS) public void removeOnMessageReceivedListener(int, @NonNull android.companion.CompanionDeviceManager.OnMessageReceivedListener);
+    method @RequiresPermission(android.Manifest.permission.USE_COMPANION_TRANSPORTS) public void removeOnTransportsChangedListener(@NonNull android.companion.CompanionDeviceManager.OnTransportsChangedListener);
+    method @RequiresPermission(android.Manifest.permission.USE_COMPANION_TRANSPORTS) public void sendMessage(int, @NonNull byte[], @NonNull int[]);
+    field public static final int MESSAGE_REQUEST_CONTEXT_SYNC = 1667729539; // 0x63678883
+    field public static final int MESSAGE_REQUEST_PERMISSION_RESTORE = 1669491075; // 0x63826983
+    field public static final int MESSAGE_REQUEST_REMOTE_AUTHENTICATION = 1669494629; // 0x63827765
+  }
+
+  public static interface CompanionDeviceManager.OnMessageReceivedListener {
+    method public void onMessageReceived(int, @NonNull byte[]);
+  }
+
+  public static interface CompanionDeviceManager.OnTransportsChangedListener {
+    method public void onTransportsChanged(@NonNull java.util.List<android.companion.AssociationInfo>);
+  }
+
+}
+
 package android.content {
 
   public abstract class ContentProvider implements android.content.ComponentCallbacks2 {
diff --git a/core/api/test-current.txt b/core/api/test-current.txt
index 3fb9fd9..833d9c6 100644
--- a/core/api/test-current.txt
+++ b/core/api/test-current.txt
@@ -839,6 +839,7 @@
 
   public final class CompanionDeviceManager {
     method @RequiresPermission("android.permission.MANAGE_COMPANION_DEVICES") public void enableSecureTransport(boolean);
+    field public static final int MESSAGE_REQUEST_PING = 1669362552; // 0x63807378
   }
 
   public abstract class CompanionDeviceService extends android.app.Service {
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 58c2548..a09d7dc 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -203,6 +203,7 @@
 import android.window.SizeConfigurationBuckets;
 import android.window.SplashScreen;
 import android.window.SplashScreenView;
+import android.window.WindowContextInfo;
 import android.window.WindowProviderService;
 import android.window.WindowTokenClientController;
 
@@ -6248,10 +6249,9 @@
     }
 
     @Override
-    public void handleWindowContextConfigurationChanged(@NonNull IBinder clientToken,
-            @NonNull Configuration configuration, int displayId) {
-        WindowTokenClientController.getInstance().onWindowContextConfigurationChanged(clientToken,
-                configuration, displayId);
+    public void handleWindowContextInfoChanged(@NonNull IBinder clientToken,
+            @NonNull WindowContextInfo info) {
+        WindowTokenClientController.getInstance().onWindowContextInfoChanged(clientToken, info);
     }
 
     @Override
diff --git a/core/java/android/app/ClientTransactionHandler.java b/core/java/android/app/ClientTransactionHandler.java
index f7a43f4..6753cb8 100644
--- a/core/java/android/app/ClientTransactionHandler.java
+++ b/core/java/android/app/ClientTransactionHandler.java
@@ -28,6 +28,7 @@
 import android.util.MergedConfiguration;
 import android.view.SurfaceControl;
 import android.window.SplashScreenView.SplashScreenViewParcelable;
+import android.window.WindowContextInfo;
 
 import com.android.internal.annotations.VisibleForTesting;
 import com.android.internal.content.ReferrerIntent;
@@ -163,9 +164,9 @@
     public abstract void handleActivityConfigurationChanged(@NonNull ActivityClientRecord r,
             Configuration overrideConfig, int displayId);
 
-    /** Deliver {@link android.window.WindowContext} configuration change. */
-    public abstract void handleWindowContextConfigurationChanged(@NonNull IBinder clientToken,
-            @NonNull Configuration configuration, int displayId);
+    /** Deliver {@link android.window.WindowContextInfo} change. */
+    public abstract void handleWindowContextInfoChanged(@NonNull IBinder clientToken,
+            @NonNull WindowContextInfo info);
 
     /** Deliver {@link android.window.WindowContext} window removal event. */
     public abstract void handleWindowContextWindowRemoval(@NonNull IBinder clientToken);
diff --git a/core/java/android/app/servertransaction/WindowContextConfigurationChangeItem.java b/core/java/android/app/servertransaction/WindowContextConfigurationChangeItem.java
deleted file mode 100644
index 3ac642f..0000000
--- a/core/java/android/app/servertransaction/WindowContextConfigurationChangeItem.java
+++ /dev/null
@@ -1,135 +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 android.app.servertransaction;
-
-import static android.view.Display.INVALID_DISPLAY;
-
-import static java.util.Objects.requireNonNull;
-
-import android.annotation.NonNull;
-import android.annotation.Nullable;
-import android.app.ClientTransactionHandler;
-import android.content.res.Configuration;
-import android.os.IBinder;
-import android.os.Parcel;
-
-import java.util.Objects;
-
-/**
- * {@link android.window.WindowContext} configuration change message.
- * @hide
- */
-public class WindowContextConfigurationChangeItem extends ClientTransactionItem {
-
-    @Nullable
-    private IBinder mClientToken;
-    @Nullable
-    private Configuration mConfiguration;
-    private int mDisplayId;
-
-    @Override
-    public void execute(@NonNull ClientTransactionHandler client, @NonNull IBinder token,
-            @NonNull PendingTransactionActions pendingActions) {
-        client.handleWindowContextConfigurationChanged(mClientToken, mConfiguration, mDisplayId);
-    }
-
-    // ObjectPoolItem implementation
-
-    private WindowContextConfigurationChangeItem() {}
-
-    /** Obtains an instance initialized with provided params. */
-    public static WindowContextConfigurationChangeItem obtain(
-            @NonNull IBinder clientToken, @NonNull Configuration config, int displayId) {
-        WindowContextConfigurationChangeItem instance =
-                ObjectPool.obtain(WindowContextConfigurationChangeItem.class);
-        if (instance == null) {
-            instance = new WindowContextConfigurationChangeItem();
-        }
-        instance.mClientToken = requireNonNull(clientToken);
-        instance.mConfiguration = requireNonNull(config);
-        instance.mDisplayId = displayId;
-
-        return instance;
-    }
-
-    @Override
-    public void recycle() {
-        mClientToken = null;
-        mConfiguration = null;
-        mDisplayId = INVALID_DISPLAY;
-        ObjectPool.recycle(this);
-    }
-
-    // Parcelable implementation
-
-    /** Writes to Parcel. */
-    @Override
-    public void writeToParcel(@NonNull Parcel dest, int flags) {
-        dest.writeStrongBinder(mClientToken);
-        dest.writeTypedObject(mConfiguration, flags);
-        dest.writeInt(mDisplayId);
-    }
-
-    /** Reads from Parcel. */
-    private WindowContextConfigurationChangeItem(@NonNull Parcel in) {
-        mClientToken = in.readStrongBinder();
-        mConfiguration = in.readTypedObject(Configuration.CREATOR);
-        mDisplayId = in.readInt();
-    }
-
-    public static final @NonNull Creator<WindowContextConfigurationChangeItem> CREATOR =
-            new Creator<>() {
-                public WindowContextConfigurationChangeItem createFromParcel(Parcel in) {
-                    return new WindowContextConfigurationChangeItem(in);
-                }
-
-                public WindowContextConfigurationChangeItem[] newArray(int size) {
-                    return new WindowContextConfigurationChangeItem[size];
-                }
-    };
-
-    @Override
-    public boolean equals(@Nullable Object o) {
-        if (this == o) {
-            return true;
-        }
-        if (o == null || getClass() != o.getClass()) {
-            return false;
-        }
-        final WindowContextConfigurationChangeItem other = (WindowContextConfigurationChangeItem) o;
-        return Objects.equals(mClientToken, other.mClientToken)
-                && Objects.equals(mConfiguration, other.mConfiguration)
-                && mDisplayId == other.mDisplayId;
-    }
-
-    @Override
-    public int hashCode() {
-        int result = 17;
-        result = 31 * result + Objects.hashCode(mClientToken);
-        result = 31 * result + Objects.hashCode(mConfiguration);
-        result = 31 * result + mDisplayId;
-        return result;
-    }
-
-    @Override
-    public String toString() {
-        return "WindowContextConfigurationChangeItem{clientToken=" + mClientToken
-                + ", config=" + mConfiguration
-                + ", displayId=" + mDisplayId
-                + "}";
-    }
-}
diff --git a/core/java/android/app/servertransaction/WindowContextInfoChangeItem.java b/core/java/android/app/servertransaction/WindowContextInfoChangeItem.java
new file mode 100644
index 0000000..74721d5
--- /dev/null
+++ b/core/java/android/app/servertransaction/WindowContextInfoChangeItem.java
@@ -0,0 +1,126 @@
+/*
+ * 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 android.app.servertransaction;
+
+import static java.util.Objects.requireNonNull;
+
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.app.ClientTransactionHandler;
+import android.content.res.Configuration;
+import android.os.IBinder;
+import android.os.Parcel;
+import android.window.WindowContextInfo;
+
+import java.util.Objects;
+
+/**
+ * {@link android.window.WindowContext} configuration change message.
+ * @hide
+ */
+public class WindowContextInfoChangeItem extends ClientTransactionItem {
+
+    @Nullable
+    private IBinder mClientToken;
+    @Nullable
+    private WindowContextInfo mInfo;
+
+    @Override
+    public void execute(@NonNull ClientTransactionHandler client, @NonNull IBinder token,
+            @NonNull PendingTransactionActions pendingActions) {
+        client.handleWindowContextInfoChanged(mClientToken, mInfo);
+    }
+
+    // ObjectPoolItem implementation
+
+    private WindowContextInfoChangeItem() {}
+
+    /** Obtains an instance initialized with provided params. */
+    public static WindowContextInfoChangeItem obtain(
+            @NonNull IBinder clientToken, @NonNull Configuration config, int displayId) {
+        WindowContextInfoChangeItem instance =
+                ObjectPool.obtain(WindowContextInfoChangeItem.class);
+        if (instance == null) {
+            instance = new WindowContextInfoChangeItem();
+        }
+        instance.mClientToken = requireNonNull(clientToken);
+        instance.mInfo = new WindowContextInfo(config, displayId);
+
+        return instance;
+    }
+
+    @Override
+    public void recycle() {
+        mClientToken = null;
+        mInfo = null;
+        ObjectPool.recycle(this);
+    }
+
+    // Parcelable implementation
+
+    /** Writes to Parcel. */
+    @Override
+    public void writeToParcel(@NonNull Parcel dest, int flags) {
+        dest.writeStrongBinder(mClientToken);
+        dest.writeTypedObject(mInfo, flags);
+    }
+
+    /** Reads from Parcel. */
+    private WindowContextInfoChangeItem(@NonNull Parcel in) {
+        mClientToken = in.readStrongBinder();
+        mInfo = in.readTypedObject(WindowContextInfo.CREATOR);
+    }
+
+    public static final @NonNull Creator<WindowContextInfoChangeItem> CREATOR =
+            new Creator<>() {
+                public WindowContextInfoChangeItem createFromParcel(Parcel in) {
+                    return new WindowContextInfoChangeItem(in);
+                }
+
+                public WindowContextInfoChangeItem[] newArray(int size) {
+                    return new WindowContextInfoChangeItem[size];
+                }
+    };
+
+    @Override
+    public boolean equals(@Nullable Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+        final WindowContextInfoChangeItem other = (WindowContextInfoChangeItem) o;
+        return Objects.equals(mClientToken, other.mClientToken)
+                && Objects.equals(mInfo, other.mInfo);
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 17;
+        result = 31 * result + Objects.hashCode(mClientToken);
+        result = 31 * result + Objects.hashCode(mInfo);
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        return "WindowContextInfoChangeItem{clientToken=" + mClientToken
+                + ", info=" + mInfo
+                + "}";
+    }
+}
diff --git a/core/java/android/companion/CompanionDeviceManager.java b/core/java/android/companion/CompanionDeviceManager.java
index e45fa19..69e1653 100644
--- a/core/java/android/companion/CompanionDeviceManager.java
+++ b/core/java/android/companion/CompanionDeviceManager.java
@@ -20,7 +20,9 @@
 import static android.Manifest.permission.REQUEST_COMPANION_PROFILE_AUTOMOTIVE_PROJECTION;
 import static android.Manifest.permission.REQUEST_COMPANION_PROFILE_COMPUTER;
 import static android.Manifest.permission.REQUEST_COMPANION_PROFILE_WATCH;
+import static android.annotation.SystemApi.Client.MODULE_LIBRARIES;
 
+import android.annotation.CallbackExecutor;
 import android.annotation.IntDef;
 import android.annotation.NonNull;
 import android.annotation.Nullable;
@@ -209,6 +211,34 @@
     public static final String EXTRA_ASSOCIATION = "android.companion.extra.ASSOCIATION";
 
     /**
+     * Test message type without a designated callback.
+     *
+     * @hide
+     */
+    @TestApi public static final int MESSAGE_REQUEST_PING = 0x63807378; // ?PIN
+    /**
+     * Message header assigned to the remote authentication handshakes.
+     *
+     * @hide
+     */
+    @SystemApi(client = MODULE_LIBRARIES)
+    public static final int MESSAGE_REQUEST_REMOTE_AUTHENTICATION = 0x63827765; // ?RMA
+    /**
+     * Message header assigned to the telecom context sync metadata.
+     *
+     * @hide
+     */
+    @SystemApi(client = MODULE_LIBRARIES)
+    public static final int MESSAGE_REQUEST_CONTEXT_SYNC = 0x63678883; // ?CXS
+    /**
+     * Message header assigned to the permission restore request.
+     *
+     * @hide
+     */
+    @SystemApi(client = MODULE_LIBRARIES)
+    public static final int MESSAGE_REQUEST_PERMISSION_RESTORE = 0x63826983; // ?RES
+
+    /**
      * Callback for applications to receive updates about and the outcome of
      * {@link AssociationRequest} issued via {@code associate()} call.
      *
@@ -797,28 +827,36 @@
     }
 
     /**
-     * Listener for any changes to {@link com.android.server.companion.transport.Transport}.
+     * Listener for any changes to the list of attached transports.
+     *
+     * @see com.android.server.companion.transport.Transport
      *
      * @hide
      */
+    @SystemApi(client = MODULE_LIBRARIES)
     public interface OnTransportsChangedListener {
         /**
-         * Invoked when a change occurs to any of the transports
+         * Invoked when a transport is attached or detached.
          *
-         * @param associations all the associations which have connected transports
+         * @param associations all the associations which have connected transports.
          */
         void onTransportsChanged(@NonNull List<AssociationInfo> associations);
     }
 
     /**
-     * Register a listener for any changes to
-     * {@link com.android.server.companion.transport.Transport}. Your app will receive a callback to
-     * {@link OnTransportsChangedListener} immediately with all the existing transports.
+     * Adds a listener for any changes to the list of attached transports.
+     * {@link OnTransportsChangedListener#onTransportsChanged(List)} will be triggered with a list
+     * of existing transports when a transport is detached or a new transport is attached.
+     *
+     * @see com.android.server.companion.transport.Transport
      *
      * @hide
      */
+    @SystemApi(client = MODULE_LIBRARIES)
+    @RequiresPermission(android.Manifest.permission.USE_COMPANION_TRANSPORTS)
     public void addOnTransportsChangedListener(
-            @NonNull Executor executor, @NonNull OnTransportsChangedListener listener) {
+            @NonNull @CallbackExecutor Executor executor,
+            @NonNull OnTransportsChangedListener listener) {
         final OnTransportsChangedListenerProxy proxy = new OnTransportsChangedListenerProxy(
                 executor, listener);
         try {
@@ -829,11 +867,14 @@
     }
 
     /**
-     * Unregister a listener to stop receiving any changes to
-     * {@link com.android.server.companion.transport.Transport}.
+     * Removes the registered listener for any changes to the list of attached transports.
+     *
+     * @see com.android.server.companion.transport.Transport
      *
      * @hide
      */
+    @SystemApi(client = MODULE_LIBRARIES)
+    @RequiresPermission(android.Manifest.permission.USE_COMPANION_TRANSPORTS)
     public void removeOnTransportsChangedListener(
             @NonNull OnTransportsChangedListener listener) {
         final OnTransportsChangedListenerProxy proxy = new OnTransportsChangedListenerProxy(
@@ -846,11 +887,16 @@
     }
 
     /**
-     * Send a message to remote devices
+     * Sends a message to associated remote devices. The target associations must already have a
+     * connected transport.
+     *
+     * @see #attachSystemDataTransport(int, InputStream, OutputStream)
      *
      * @hide
      */
-    public void sendMessage(int messageType, byte[] data, int[] associationIds) {
+    @SystemApi(client = MODULE_LIBRARIES)
+    @RequiresPermission(android.Manifest.permission.USE_COMPANION_TRANSPORTS)
+    public void sendMessage(int messageType, @NonNull byte[] data, @NonNull int[] associationIds) {
         try {
             mService.sendMessage(messageType, data, associationIds);
         } catch (RemoteException e) {
@@ -859,28 +905,30 @@
     }
 
     /**
-     * Listener when a message is received for the registered message type
+     * Listener that triggers a callback when a message is received through a connected transport.
      *
      * @see #addOnMessageReceivedListener(Executor, int, OnMessageReceivedListener)
      *
      * @hide
      */
+    @SystemApi(client = MODULE_LIBRARIES)
     public interface OnMessageReceivedListener {
         /**
-         * Called when a message is received
+         * Called when a message is received.
          */
-        void onMessageReceived(int associationId, byte[] data);
+        void onMessageReceived(int associationId, @NonNull byte[] data);
     }
 
     /**
-     * Register a listener to receive callbacks when a message is received by the given type
-     *
-     * @see com.android.server.companion.transport.Transport for supported message types
+     * Adds a listener to trigger callbacks when messages of given type are received.
      *
      * @hide
      */
-    public void addOnMessageReceivedListener(@NonNull Executor executor, int messageType,
-            OnMessageReceivedListener listener) {
+    @SystemApi(client = MODULE_LIBRARIES)
+    @RequiresPermission(android.Manifest.permission.USE_COMPANION_TRANSPORTS)
+    public void addOnMessageReceivedListener(
+            @NonNull @CallbackExecutor Executor executor, int messageType,
+            @NonNull OnMessageReceivedListener listener) {
         final OnMessageReceivedListenerProxy proxy = new OnMessageReceivedListenerProxy(
                 executor, listener);
         try {
@@ -891,15 +939,14 @@
     }
 
     /**
-     * Unregister a listener to stop receiving callbacks when a message is received by the given
-     * type
-     *
-     * @see com.android.server.companion.transport.Transport for supported message types
+     * Removes the registered listener for received messages of given type.
      *
      * @hide
      */
+    @SystemApi(client = MODULE_LIBRARIES)
+    @RequiresPermission(android.Manifest.permission.USE_COMPANION_TRANSPORTS)
     public void removeOnMessageReceivedListener(int messageType,
-            OnMessageReceivedListener listener) {
+            @NonNull OnMessageReceivedListener listener) {
         final OnMessageReceivedListenerProxy proxy = new OnMessageReceivedListenerProxy(
                 null, listener);
         try {
diff --git a/core/java/android/companion/ICompanionDeviceManager.aidl b/core/java/android/companion/ICompanionDeviceManager.aidl
index 2318e30..463dba2 100644
--- a/core/java/android/companion/ICompanionDeviceManager.aidl
+++ b/core/java/android/companion/ICompanionDeviceManager.aidl
@@ -74,14 +74,19 @@
     @EnforcePermission("MANAGE_COMPANION_DEVICES")
     void removeOnAssociationsChangedListener(IOnAssociationsChangedListener listener, int userId);
 
+    @EnforcePermission("USE_COMPANION_TRANSPORTS")
     void addOnTransportsChangedListener(IOnTransportsChangedListener listener);
 
+    @EnforcePermission("USE_COMPANION_TRANSPORTS")
     void removeOnTransportsChangedListener(IOnTransportsChangedListener listener);
 
+    @EnforcePermission("USE_COMPANION_TRANSPORTS")
     void sendMessage(int messageType, in byte[] data, in int[] associationIds);
 
+    @EnforcePermission("USE_COMPANION_TRANSPORTS")
     void addOnMessageReceivedListener(int messageType, IOnMessageReceivedListener listener);
 
+    @EnforcePermission("USE_COMPANION_TRANSPORTS")
     void removeOnMessageReceivedListener(int messageType, IOnMessageReceivedListener listener);
 
     void notifyDeviceAppeared(int associationId);
diff --git a/core/java/android/os/CombinedVibration.java b/core/java/android/os/CombinedVibration.java
index db1a741..f32a1f8 100644
--- a/core/java/android/os/CombinedVibration.java
+++ b/core/java/android/os/CombinedVibration.java
@@ -24,7 +24,9 @@
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Locale;
 import java.util.Objects;
+import java.util.StringJoiner;
 
 /**
  * A CombinedVibration describes a combination of haptic effects to be performed by one or more
@@ -151,6 +153,13 @@
     public abstract boolean hasVibrator(int vibratorId);
 
     /**
+     * Returns a compact version of the {@link #toString()} result for debugging purposes.
+     *
+     * @hide
+     */
+    public abstract String toDebugString();
+
+    /**
      * Adapts a {@link VibrationEffect} to a specific device vibrator using the ID.
      *
      * <p>This can be used for adapting effects to the capabilities of the specific device vibrator
@@ -437,6 +446,13 @@
             return "Mono{mEffect=" + mEffect + '}';
         }
 
+        /** @hide */
+        @Override
+        public String toDebugString() {
+            // Simplify vibration string, use the single effect to represent it.
+            return mEffect.toDebugString();
+        }
+
         @Override
         public int describeContents() {
             return 0;
@@ -619,6 +635,17 @@
             return "Stereo{mEffects=" + mEffects + '}';
         }
 
+        /** @hide */
+        @Override
+        public String toDebugString() {
+            StringJoiner sj = new StringJoiner(",", "Stereo{", "}");
+            for (int i = 0; i < mEffects.size(); i++) {
+                sj.add(String.format(Locale.ROOT, "vibrator(id=%d): %s",
+                        mEffects.keyAt(i), mEffects.valueAt(i).toDebugString()));
+            }
+            return sj.toString();
+        }
+
         @Override
         public int describeContents() {
             return 0;
@@ -833,6 +860,17 @@
             return "Sequential{mEffects=" + mEffects + ", mDelays=" + mDelays + '}';
         }
 
+        /** @hide */
+        @Override
+        public String toDebugString() {
+            StringJoiner sj = new StringJoiner(",", "Sequential{", "}");
+            for (int i = 0; i < mEffects.size(); i++) {
+                sj.add(String.format(Locale.ROOT, "delayMs=%d, effect=%s",
+                        mDelays.get(i), mEffects.get(i).toDebugString()));
+            }
+            return sj.toString();
+        }
+
         @Override
         public int describeContents() {
             return 0;
diff --git a/core/java/android/os/PerformanceHintManager.java b/core/java/android/os/PerformanceHintManager.java
index f79d6e6..977ef60 100644
--- a/core/java/android/os/PerformanceHintManager.java
+++ b/core/java/android/os/PerformanceHintManager.java
@@ -29,6 +29,7 @@
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.ref.Reference;
+import java.util.Objects;
 
 
 /** The PerformanceHintManager allows apps to send performance hint to system. */
@@ -239,6 +240,7 @@
             if (mNativeSessionPtr == 0) {
                 return;
             }
+            Objects.requireNonNull(tids, "tids cannot be null");
             if (tids.length == 0) {
                 throw new IllegalArgumentException("Thread id list can't be empty.");
             }
diff --git a/core/java/android/os/VibrationAttributes.java b/core/java/android/os/VibrationAttributes.java
index b2d62eb..98f9dff 100644
--- a/core/java/android/os/VibrationAttributes.java
+++ b/core/java/android/os/VibrationAttributes.java
@@ -336,10 +336,11 @@
 
     @Override
     public String toString() {
-        return "VibrationAttributes:"
-                + " Usage=" + usageToString()
-                + " Audio Usage= " + AudioAttributes.usageToString(mOriginalAudioUsage)
-                + " Flags=" + mFlags;
+        return "VibrationAttributes{"
+                + "mUsage=" + usageToString()
+                + ", mAudioUsage= " + AudioAttributes.usageToString(mOriginalAudioUsage)
+                + ", mFlags=" + mFlags
+                + '}';
     }
 
     /** @hide */
diff --git a/core/java/android/os/VibrationEffect.java b/core/java/android/os/VibrationEffect.java
index 0461b2e..b24b45d 100644
--- a/core/java/android/os/VibrationEffect.java
+++ b/core/java/android/os/VibrationEffect.java
@@ -44,7 +44,9 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import java.util.Locale;
 import java.util.Objects;
+import java.util.StringJoiner;
 
 /**
  * A VibrationEffect describes a haptic effect to be performed by a {@link Vibrator}.
@@ -232,11 +234,11 @@
      * Computes a legacy vibration pattern (i.e. a pattern with duration values for "off/on"
      * vibration components) that is equivalent to this VibrationEffect.
      *
-     * <p>All non-repeating effects created with {@link #createWaveform(int[], int)} are convertible
-     * into an equivalent vibration pattern with this method. It is not guaranteed that an effect
-     * created with other means becomes converted into an equivalent legacy vibration pattern, even
-     * if it has an equivalent vibration pattern. If this method is unable to create an equivalent
-     * vibration pattern for such effects, it will return {@code null}.
+     * <p>All non-repeating effects created with {@link #createWaveform(long[], int)} are
+     * convertible into an equivalent vibration pattern with this method. It is not guaranteed that
+     * an effect created with other means becomes converted into an equivalent legacy vibration
+     * pattern, even if it has an equivalent vibration pattern. If this method is unable to create
+     * an equivalent vibration pattern for such effects, it will return {@code null}.
      *
      * <p>Note that a valid equivalent long[] pattern cannot be created for an effect that has any
      * form of repeating behavior, regardless of how the effect was created. For repeating effects,
@@ -245,7 +247,7 @@
      * @return a long array representing a vibration pattern equivalent to the VibrationEffect, if
      *               the method successfully derived a vibration pattern equivalent to the effect
      *               (this will always be the case if the effect was created via
-     *               {@link #createWaveform(int[], int)} and is non-repeating). Otherwise, returns
+     *               {@link #createWaveform(long[], int)} and is non-repeating). Otherwise, returns
      *               {@code null}.
      * @hide
      */
@@ -629,6 +631,13 @@
         return MathUtils.constrain(a * fx, 0f, 1f);
     }
 
+    /**
+     * Returns a compact version of the {@link #toString()} result for debugging purposes.
+     *
+     * @hide
+     */
+    public abstract String toDebugString();
+
     /** @hide */
     public static String effectIdToString(int effectId) {
         switch (effectId) {
@@ -925,6 +934,23 @@
                     + "}";
         }
 
+        /** @hide */
+        @Override
+        public String toDebugString() {
+            if (mSegments.size() == 1 && mRepeatIndex < 0) {
+                // Simplify effect string, use the single segment to represent it.
+                return mSegments.get(0).toDebugString();
+            }
+            StringJoiner sj = new StringJoiner(",", "[", "]");
+            for (int i = 0; i < mSegments.size(); i++) {
+                sj.add(mSegments.get(i).toDebugString());
+            }
+            if (mRepeatIndex >= 0) {
+                return String.format(Locale.ROOT, "%s, repeat=%d", sj, mRepeatIndex);
+            }
+            return sj.toString();
+        }
+
         @Override
         public int describeContents() {
             return 0;
@@ -953,7 +979,7 @@
         /**
          * Casts a provided {@link VibrationEffectSegment} to a {@link StepSegment} and returns it,
          * only if it can possibly be a segment for an effect created via
-         * {@link #createWaveform(int[], int)}. Otherwise, returns {@code null}.
+         * {@link #createWaveform(long[], int)}. Otherwise, returns {@code null}.
          */
         @Nullable
         private static StepSegment castToValidStepSegmentForOffOnTimingsOrNull(
@@ -1250,23 +1276,23 @@
         public static String primitiveToString(@PrimitiveType int id) {
             switch (id) {
                 case PRIMITIVE_NOOP:
-                    return "PRIMITIVE_NOOP";
+                    return "NOOP";
                 case PRIMITIVE_CLICK:
-                    return "PRIMITIVE_CLICK";
+                    return "CLICK";
                 case PRIMITIVE_THUD:
-                    return "PRIMITIVE_THUD";
+                    return "THUD";
                 case PRIMITIVE_SPIN:
-                    return "PRIMITIVE_SPIN";
+                    return "SPIN";
                 case PRIMITIVE_QUICK_RISE:
-                    return "PRIMITIVE_QUICK_RISE";
+                    return "QUICK_RISE";
                 case PRIMITIVE_SLOW_RISE:
-                    return "PRIMITIVE_SLOW_RISE";
+                    return "SLOW_RISE";
                 case PRIMITIVE_QUICK_FALL:
-                    return "PRIMITIVE_QUICK_FALL";
+                    return "QUICK_FALL";
                 case PRIMITIVE_TICK:
-                    return "PRIMITIVE_TICK";
+                    return "TICK";
                 case PRIMITIVE_LOW_TICK:
-                    return "PRIMITIVE_LOW_TICK";
+                    return "LOW_TICK";
                 default:
                     return Integer.toString(id);
             }
diff --git a/core/java/android/os/VibratorInfo.java b/core/java/android/os/VibratorInfo.java
index 71ec096..02e6856 100644
--- a/core/java/android/os/VibratorInfo.java
+++ b/core/java/android/os/VibratorInfo.java
@@ -20,6 +20,7 @@
 import android.annotation.Nullable;
 import android.hardware.vibrator.Braking;
 import android.hardware.vibrator.IVibrator;
+import android.util.IndentingPrintWriter;
 import android.util.MathUtils;
 import android.util.Range;
 import android.util.SparseBooleanArray;
@@ -207,6 +208,25 @@
                 + '}';
     }
 
+    /** @hide */
+    public void dump(IndentingPrintWriter pw) {
+        pw.println("VibratorInfo:");
+        pw.increaseIndent();
+        pw.println("id = " + mId);
+        pw.println("capabilities = " + Arrays.toString(getCapabilitiesNames()));
+        pw.println("capabilitiesFlags = " + Long.toBinaryString(mCapabilities));
+        pw.println("supportedEffects = " + Arrays.toString(getSupportedEffectsNames()));
+        pw.println("supportedPrimitives = " + Arrays.toString(getSupportedPrimitivesNames()));
+        pw.println("supportedBraking = " + Arrays.toString(getSupportedBrakingNames()));
+        pw.println("primitiveDelayMax = " + mPrimitiveDelayMax);
+        pw.println("compositionSizeMax = " + mCompositionSizeMax);
+        pw.println("pwlePrimitiveDurationMax = " + mPwlePrimitiveDurationMax);
+        pw.println("pwleSizeMax = " + mPwleSizeMax);
+        pw.println("q-factor = " + mQFactor);
+        pw.println("frequencyProfile = " + mFrequencyProfile);
+        pw.decreaseIndent();
+    }
+
     /** Return the id of this vibrator. */
     public int getId() {
         return mId;
@@ -370,7 +390,7 @@
      * Gets the resonant frequency of the vibrator.
      *
      * @return the resonant frequency of the vibrator, or {@link Float#NaN NaN} if it's unknown or
-     *         this vibrator is a composite of multiple physical devices.
+     * this vibrator is a composite of multiple physical devices.
      */
     public float getResonantFrequencyHz() {
         return mFrequencyProfile.mResonantFrequencyHz;
@@ -380,7 +400,7 @@
      * Gets the <a href="https://en.wikipedia.org/wiki/Q_factor">Q factor</a> of the vibrator.
      *
      * @return the Q factor of the vibrator, or {@link Float#NaN NaN} if it's unknown or
-     *         this vibrator is a composite of multiple physical devices.
+     * this vibrator is a composite of multiple physical devices.
      */
     public float getQFactor() {
         return mQFactor;
diff --git a/core/java/android/os/vibrator/PrebakedSegment.java b/core/java/android/os/vibrator/PrebakedSegment.java
index da2ee6c..42b6c2da 100644
--- a/core/java/android/os/vibrator/PrebakedSegment.java
+++ b/core/java/android/os/vibrator/PrebakedSegment.java
@@ -119,12 +119,6 @@
     }
 
     /** @hide */
-    @Override
-    public boolean hasNonZeroAmplitude() {
-        return true;
-    }
-
-    /** @hide */
     @NonNull
     @Override
     public PrebakedSegment resolve(int defaultAmplitude) {
@@ -209,6 +203,15 @@
                 + "}";
     }
 
+    /** @hide */
+    @Override
+    public String toDebugString() {
+        return String.format("Prebaked=%s(%s, %s fallback)",
+                VibrationEffect.effectIdToString(mEffectId),
+                VibrationEffect.effectStrengthToString(mEffectStrength),
+                mFallback ? "with" : "no");
+    }
+
     @Override
     public int describeContents() {
         return 0;
diff --git a/core/java/android/os/vibrator/PrimitiveSegment.java b/core/java/android/os/vibrator/PrimitiveSegment.java
index e1fa97b..c52a09c 100644
--- a/core/java/android/os/vibrator/PrimitiveSegment.java
+++ b/core/java/android/os/vibrator/PrimitiveSegment.java
@@ -88,13 +88,6 @@
     }
 
     /** @hide */
-    @Override
-    public boolean hasNonZeroAmplitude() {
-        // Every primitive plays a vibration with a non-zero amplitude, even at scale == 0.
-        return true;
-    }
-
-    /** @hide */
     @NonNull
     @Override
     public PrimitiveSegment resolve(int defaultAmplitude) {
@@ -147,6 +140,13 @@
                 + '}';
     }
 
+    /** @hide */
+    @Override
+    public String toDebugString() {
+        return String.format("Primitive=%s(scale=%.2f, delay=%dms)",
+                VibrationEffect.Composition.primitiveToString(mPrimitiveId), mScale, mDelay);
+    }
+
     @Override
     public boolean equals(@Nullable Object o) {
         if (this == o) return true;
diff --git a/core/java/android/os/vibrator/RampSegment.java b/core/java/android/os/vibrator/RampSegment.java
index 034962a..e997bcd 100644
--- a/core/java/android/os/vibrator/RampSegment.java
+++ b/core/java/android/os/vibrator/RampSegment.java
@@ -125,12 +125,6 @@
 
     /** @hide */
     @Override
-    public boolean hasNonZeroAmplitude() {
-        return mStartAmplitude > 0 || mEndAmplitude > 0;
-    }
-
-    /** @hide */
-    @Override
     public void validate() {
         VibrationEffectSegment.checkFrequencyArgument(mStartFrequencyHz, "startFrequencyHz");
         VibrationEffectSegment.checkFrequencyArgument(mEndFrequencyHz, "endFrequencyHz");
@@ -185,6 +179,17 @@
                 + "}";
     }
 
+    /** @hide */
+    @Override
+    public String toDebugString() {
+        return String.format("Ramp=%dms(amplitude=%.2f%s to %.2f%s)",
+                mDuration,
+                mStartAmplitude,
+                Float.compare(mStartFrequencyHz, 0) == 0 ? "" : " @ " + mStartFrequencyHz + "Hz",
+                mEndAmplitude,
+                Float.compare(mEndFrequencyHz, 0) == 0 ? "" : " @ " + mEndFrequencyHz + "Hz");
+    }
+
     @Override
     public int describeContents() {
         return 0;
diff --git a/core/java/android/os/vibrator/StepSegment.java b/core/java/android/os/vibrator/StepSegment.java
index 817187e..a585aa8 100644
--- a/core/java/android/os/vibrator/StepSegment.java
+++ b/core/java/android/os/vibrator/StepSegment.java
@@ -101,13 +101,6 @@
 
     /** @hide */
     @Override
-    public boolean hasNonZeroAmplitude() {
-        // DEFAULT_AMPLITUDE == -1 is still a non-zero amplitude that will be resolved later.
-        return Float.compare(mAmplitude, 0) != 0;
-    }
-
-    /** @hide */
-    @Override
     public void validate() {
         VibrationEffectSegment.checkFrequencyArgument(mFrequencyHz, "frequencyHz");
         VibrationEffectSegment.checkDurationArgument(mDuration, "duration");
@@ -168,6 +161,13 @@
                 + "}";
     }
 
+    /** @hide */
+    @Override
+    public String toDebugString() {
+        return String.format("Step=%dms(amplitude=%.2f%s)", mDuration, mAmplitude,
+                Float.compare(mFrequencyHz, 0) == 0 ? "" : " @ " + mFrequencyHz + "Hz");
+    }
+
     @Override
     public int describeContents() {
         return 0;
diff --git a/core/java/android/os/vibrator/VibrationConfig.java b/core/java/android/os/vibrator/VibrationConfig.java
index 4790d81..bde334a 100644
--- a/core/java/android/os/vibrator/VibrationConfig.java
+++ b/core/java/android/os/vibrator/VibrationConfig.java
@@ -32,6 +32,9 @@
 import android.os.VibrationAttributes;
 import android.os.Vibrator;
 import android.os.Vibrator.VibrationIntensity;
+import android.util.IndentingPrintWriter;
+
+import java.io.PrintWriter;
 
 /**
  * List of device-specific internal vibration configuration loaded from platform config.xml.
@@ -191,4 +194,18 @@
                 + ", mDefaultRingIntensity=" + mDefaultRingVibrationIntensity
                 + "}";
     }
+
+    /**
+     * Write current settings into given {@link PrintWriter}, skipping the default settings.
+     *
+     * @hide
+     */
+    public void dumpWithoutDefaultSettings(IndentingPrintWriter pw) {
+        pw.println("VibrationConfig:");
+        pw.increaseIndent();
+        pw.println("hapticChannelMaxAmplitude = " + mHapticChannelMaxVibrationAmplitude);
+        pw.println("rampStepDurationMs = " + mRampStepDurationMs);
+        pw.println("rampDownDurationMs = " + mRampDownDurationMs);
+        pw.decreaseIndent();
+    }
 }
diff --git a/core/java/android/os/vibrator/VibrationEffectSegment.java b/core/java/android/os/vibrator/VibrationEffectSegment.java
index 75a055f..3b286a7 100644
--- a/core/java/android/os/vibrator/VibrationEffectSegment.java
+++ b/core/java/android/os/vibrator/VibrationEffectSegment.java
@@ -76,13 +76,6 @@
     public abstract boolean isHapticFeedbackCandidate();
 
     /**
-     * Returns true if this segment plays at a non-zero amplitude at some point.
-     *
-     * @hide
-     */
-    public abstract boolean hasNonZeroAmplitude();
-
-    /**
      * Validates the segment, throwing exceptions if any parameter is invalid.
      *
      * @hide
@@ -123,6 +116,13 @@
     public abstract <T extends VibrationEffectSegment> T applyEffectStrength(int effectStrength);
 
     /**
+     * Returns a compact version of the {@link #toString()} result for debugging purposes.
+     *
+     * @hide
+     */
+    public abstract String toDebugString();
+
+    /**
      * Checks the given frequency argument is valid to represent a vibration effect frequency in
      * hertz, i.e. a finite non-negative value.
      *
diff --git a/core/java/android/provider/CallLog.java b/core/java/android/provider/CallLog.java
index 3c5757d..5d6dfc7 100644
--- a/core/java/android/provider/CallLog.java
+++ b/core/java/android/provider/CallLog.java
@@ -63,6 +63,7 @@
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.util.List;
+import java.util.Locale;
 import java.util.Objects;
 import java.util.concurrent.Executor;
 
@@ -1956,9 +1957,8 @@
                     userManager.isUserUnlocked(user) ? CONTENT_URI : SHADOW_CONTENT_URI,
                     user.getIdentifier());
 
-            if (VERBOSE_LOG) {
-                Log.v(LOG_TAG, String.format("Inserting to %s", uri));
-            }
+            Log.i(LOG_TAG, String.format(Locale.getDefault(),
+                    "addEntryAndRemoveExpiredEntries: provider uri=%s", uri));
 
             try {
                 // When cleaning up the call log, try to delete older call long entries on a per
diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl
index c1474eb..d3b7a5b 100644
--- a/core/java/android/view/IWindowManager.aidl
+++ b/core/java/android/view/IWindowManager.aidl
@@ -71,6 +71,7 @@
 import android.window.ISurfaceSyncGroupCompletedListener;
 import android.window.ITaskFpsCallback;
 import android.window.ScreenCapture;
+import android.window.WindowContextInfo;
 
 /**
  * System private interface to the window manager.
@@ -858,10 +859,10 @@
      * @param displayId The display associated with the window context
      * @param options A bundle used to pass window-related options and choose the right DisplayArea
      *
-     * @return the DisplayArea's {@link android.app.res.Configuration} if the WindowContext is
-     * attached to the DisplayArea successfully. {@code null}, otherwise.
+     * @return the {@link WindowContextInfo} of the DisplayArea if the WindowContext is attached to
+     * the DisplayArea successfully. {@code null}, otherwise.
      */
-    @nullable Configuration attachWindowContextToDisplayArea(in IApplicationThread appThread,
+    @nullable WindowContextInfo attachWindowContextToDisplayArea(in IApplicationThread appThread,
             IBinder clientToken, int type, int displayId, in @nullable Bundle options);
 
     /**
@@ -879,13 +880,15 @@
      * the WindowContext's token}
      * @param token the WindowToken to attach
      *
+     * @return the {@link WindowContextInfo} of the WindowToken if the WindowContext is attached to
+     * the WindowToken successfully. {@code null}, otherwise.
      * @throws IllegalArgumentException if the {@code clientToken} have not been attached to
      * the server or the WindowContext's type doesn't match WindowToken {@code token}'s type.
      *
      * @see #attachWindowContextToDisplayArea(IBinder, int, int, Bundle)
      */
-    void attachWindowContextToWindowToken(in IApplicationThread appThread, IBinder clientToken,
-            IBinder token);
+    @nullable WindowContextInfo  attachWindowContextToWindowToken(in IApplicationThread appThread,
+            IBinder clientToken, IBinder token);
 
     /**
      * Attaches a {@code clientToken} to associate with DisplayContent.
@@ -899,11 +902,11 @@
      * the WindowContext's token}
      * @param displayId The display associated with the window context
      *
-     * @return the DisplayContent's {@link android.app.res.Configuration} if the Context is
-     * attached to the DisplayContent successfully. {@code null}, otherwise.
+     * @return the {@link WindowContextInfo} of the DisplayContent if the WindowContext is attached
+     * to the DisplayContent successfully. {@code null}, otherwise.
      * @throws android.view.WindowManager.InvalidDisplayException if the display ID is invalid
      */
-    @nullable Configuration attachWindowContextToDisplayContent(in IApplicationThread appThread,
+    @nullable WindowContextInfo attachWindowContextToDisplayContent(in IApplicationThread appThread,
             IBinder clientToken, int displayId);
 
     /**
diff --git a/core/java/android/view/WindowManagerGlobal.java b/core/java/android/view/WindowManagerGlobal.java
index 6aa8506..d20d95d 100644
--- a/core/java/android/view/WindowManagerGlobal.java
+++ b/core/java/android/view/WindowManagerGlobal.java
@@ -34,7 +34,6 @@
 import android.util.Log;
 import android.view.inputmethod.InputMethodManager;
 
-import com.android.internal.annotations.VisibleForTesting;
 import com.android.internal.util.FastPrintWriter;
 
 import java.io.FileDescriptor;
@@ -165,6 +164,7 @@
         }
     }
 
+    @Nullable
     @UnsupportedAppUsage
     public static IWindowManager getWindowManagerService() {
         synchronized (WindowManagerGlobal.class) {
@@ -172,6 +172,7 @@
                 sWindowManagerService = IWindowManager.Stub.asInterface(
                         ServiceManager.getService("window"));
                 try {
+                    // Can be null if this is called before WindowManagerService is initialized.
                     if (sWindowManagerService != null) {
                         ValueAnimator.setDurationScale(
                                 sWindowManagerService.getCurrentAnimatorScale());
@@ -185,15 +186,6 @@
         }
     }
 
-    /** Overrides the {@link #getWindowManagerService()} for test only. */
-    @VisibleForTesting
-    public static void overrideWindowManagerServiceForTesting(
-            @NonNull IWindowManager windowManager) {
-        synchronized (WindowManagerGlobal.class) {
-            sWindowManagerService = windowManager;
-        }
-    }
-
     @UnsupportedAppUsage
     public static IWindowSession getWindowSession() {
         synchronized (WindowManagerGlobal.class) {
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index 6ad1960..03364b6 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -916,6 +916,8 @@
         }
     }
 
+    private DifferentialMotionFlingHelper mDifferentialMotionFlingHelper;
+
     public AbsListView(Context context) {
         super(context);
         setupDeviceConfigProperties();
@@ -4488,17 +4490,22 @@
     public boolean onGenericMotionEvent(MotionEvent event) {
         switch (event.getAction()) {
             case MotionEvent.ACTION_SCROLL:
-                final float axisValue;
+                final int axis;
                 if (event.isFromSource(InputDevice.SOURCE_CLASS_POINTER)) {
-                    axisValue = event.getAxisValue(MotionEvent.AXIS_VSCROLL);
+                    axis = MotionEvent.AXIS_VSCROLL;
                 } else if (event.isFromSource(InputDevice.SOURCE_ROTARY_ENCODER)) {
-                    axisValue = event.getAxisValue(MotionEvent.AXIS_SCROLL);
+                    axis = MotionEvent.AXIS_SCROLL;
                 } else {
-                    axisValue = 0;
+                    axis = -1;
                 }
 
+                final float axisValue = (axis == -1) ? 0 : event.getAxisValue(axis);
                 final int delta = Math.round(axisValue * mVerticalScrollFactor);
                 if (delta != 0) {
+                    // Tracks whether or not we should attempt fling for this event.
+                    // Fling should not be attempted if the view is already at the limit of scroll,
+                    // since it conflicts with EdgeEffect.
+                    boolean shouldAttemptFling = true;
                     // If we're moving down, we want the top item. If we're moving up, bottom item.
                     final int motionIndex = delta > 0 ? 0 : getChildCount() - 1;
 
@@ -4511,6 +4518,10 @@
                     final int overscrollMode = getOverScrollMode();
 
                     if (!trackMotionScroll(delta, delta)) {
+                        if (shouldAttemptFling) {
+                            initDifferentialFlingHelperIfNotExists();
+                            mDifferentialMotionFlingHelper.onMotionEvent(event, axis);
+                        }
                         return true;
                     } else if (!event.isFromSource(InputDevice.SOURCE_MOUSE) && motionView != null
                             && (overscrollMode == OVER_SCROLL_ALWAYS
@@ -4677,6 +4688,14 @@
         }
     }
 
+    private void initDifferentialFlingHelperIfNotExists() {
+        if (mDifferentialMotionFlingHelper == null) {
+            mDifferentialMotionFlingHelper =
+                    new DifferentialMotionFlingHelper(
+                            mContext, new DifferentialFlingTarget());
+        }
+    }
+
     private void recycleVelocityTracker() {
         if (mVelocityTracker != null) {
             mVelocityTracker.recycle();
@@ -8197,4 +8216,26 @@
             }
         }
     }
+
+    private class DifferentialFlingTarget
+            implements DifferentialMotionFlingHelper.DifferentialMotionFlingTarget {
+        @Override
+        public boolean startDifferentialMotionFling(float velocity) {
+            stopDifferentialMotionFling();
+            fling((int) velocity);
+            return true;
+        }
+
+        @Override
+        public void stopDifferentialMotionFling() {
+            if (mFlingRunnable != null) {
+                mFlingRunnable.endFling();
+            }
+        }
+
+        @Override
+        public float getScaledScrollFactor() {
+            return -mVerticalScrollFactor;
+        }
+    }
 }
diff --git a/core/java/android/widget/DifferentialMotionFlingHelper.java b/core/java/android/widget/DifferentialMotionFlingHelper.java
new file mode 100644
index 0000000..95d24ec
--- /dev/null
+++ b/core/java/android/widget/DifferentialMotionFlingHelper.java
@@ -0,0 +1,249 @@
+/*
+ * 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.
+ */
+
+package android.widget;
+
+import android.annotation.Nullable;
+import android.content.Context;
+import android.view.MotionEvent;
+import android.view.VelocityTracker;
+import android.view.ViewConfiguration;
+
+import com.android.internal.annotations.VisibleForTesting;
+
+/**
+ * Helper for controlling differential motion flings.
+ *
+ * <p><b>Differential motion</b> here refers to motions that report change in position instead of
+ * absolution position. For instance, differential data points of 2, -1, 5 represent: there was
+ * a movement by "2" units, then by "-1" units, then by "5" units. Examples of motions reported
+ * differentially include motions from {@link MotionEvent#AXIS_SCROLL}.
+ *
+ * <p>The client should call {@link #onMotionEvent} when a differential motion event happens on
+ * the target View (that is, the View on which we want to fling), and this class processes the event
+ * to orchestrate fling.
+ *
+ * <p>Note that this helper class currently works to control fling only in one direction at a time.
+ * As such, it works independently of horizontal/vertical orientations. It requests its client to
+ * start/stop fling, and it's up to the client to choose the fling direction based on its specific
+ * internal configurations and/or preferences.
+ *
+ * @hide
+ */
+public class DifferentialMotionFlingHelper {
+    private final Context mContext;
+    private final DifferentialMotionFlingTarget mTarget;
+
+    private final FlingVelocityThresholdCalculator mVelocityThresholdCalculator;
+    private final DifferentialVelocityProvider mVelocityProvider;
+
+    @Nullable private VelocityTracker mVelocityTracker;
+
+    private float mLastFlingVelocity;
+
+    private int mLastProcessedAxis = -1;
+    private int mLastProcessedSource = -1;
+    private int mLastProcessedDeviceId = -1;
+
+    // Initialize min and max to +infinity and 0, to effectively disable fling at start.
+    private final int[] mFlingVelocityThresholds = new int[] {Integer.MAX_VALUE, 0};
+
+    /** Interface to calculate the fling velocity thresholds. Helps fake during testing. */
+    @VisibleForTesting
+    public interface FlingVelocityThresholdCalculator {
+        /**
+         * Calculates the fling velocity thresholds (in pixels/second) and puts them in a provided
+         * store.
+         *
+         * @param context the context associated with the View that may be flung.
+         * @param store an at-least size-2 int array. The method will overwrite positions 0 and 1
+         *             with the min and max fling velocities, respectively.
+         * @param event the event that may trigger fling.
+         * @param axis the axis being processed for the event.
+         */
+        void calculateFlingVelocityThresholds(
+                Context context, int[] store, MotionEvent event, int axis);
+    }
+
+    /**
+     * Interface to provide velocity. Helps fake during testing.
+     *
+     * <p>The client should call {@link #getCurrentVelocity(VelocityTracker, MotionEvent, int)} each
+     * time it wants to consider a {@link MotionEvent} towards the latest velocity, and the
+     * interface handles providing velocity that accounts for the latest and all past events.
+     */
+    @VisibleForTesting
+    public interface DifferentialVelocityProvider {
+        /**
+         * Returns the latest velocity.
+         *
+         * @param vt the {@link VelocityTracker} to be used to compute velocity.
+         * @param event the latest event to be considered in the velocity computations.
+         * @param axis the axis being processed for the event.
+         * @return the calculated, latest velocity.
+         */
+        float getCurrentVelocity(VelocityTracker vt, MotionEvent event, int axis);
+    }
+
+    /**
+     * Represents an entity that may be flung by a differential motion or an entity that initiates
+     * fling on a target View.
+     */
+    public interface DifferentialMotionFlingTarget {
+        /**
+         * Start flinging on the target View by a given velocity.
+         *
+         * @param velocity the fling velocity, in pixels/second.
+         * @return {@code true} if fling was successfully initiated, {@code false} otherwise.
+         */
+        boolean startDifferentialMotionFling(float velocity);
+
+        /** Stop any ongoing fling on the target View that is caused by a differential motion. */
+        void stopDifferentialMotionFling();
+
+        /**
+         * Returns the scaled scroll factor to be used for differential motions. This is the
+         * value that the raw {@link MotionEvent} values should be multiplied with to get pixels.
+         *
+         * <p>This usually is one of the values provided by {@link ViewConfiguration}. It is
+         * up to the client to choose and provide any value as per its internal configuration.
+         *
+         * @see ViewConfiguration#getScaledHorizontalScrollFactor()
+         * @see ViewConfiguration#getScaledVerticalScrollFactor()
+         */
+        float getScaledScrollFactor();
+    }
+
+    /** Constructs an instance for a given {@link DifferentialMotionFlingTarget}. */
+    public DifferentialMotionFlingHelper(
+            Context context,
+            DifferentialMotionFlingTarget target) {
+        this(context,
+                target,
+                DifferentialMotionFlingHelper::calculateFlingVelocityThresholds,
+                DifferentialMotionFlingHelper::getCurrentVelocity);
+    }
+
+    @VisibleForTesting
+    public DifferentialMotionFlingHelper(
+            Context context,
+            DifferentialMotionFlingTarget target,
+            FlingVelocityThresholdCalculator velocityThresholdCalculator,
+            DifferentialVelocityProvider velocityProvider) {
+        mContext = context;
+        mTarget = target;
+        mVelocityThresholdCalculator = velocityThresholdCalculator;
+        mVelocityProvider = velocityProvider;
+    }
+
+    /**
+     * Called to report when a differential motion happens on the View that's the target for fling.
+     *
+     * @param event the {@link MotionEvent} being reported.
+     * @param axis the axis being processed by the target View.
+     */
+    public void onMotionEvent(MotionEvent event, int axis) {
+        boolean flingParamsChanged = calculateFlingVelocityThresholds(event, axis);
+        if (mFlingVelocityThresholds[0] == Integer.MAX_VALUE) {
+            // Integer.MAX_VALUE means that the device does not support fling for the current
+            // configuration. Do not proceed any further.
+            recycleVelocityTracker();
+            return;
+        }
+
+        float scaledVelocity =
+                getCurrentVelocity(event, axis) * mTarget.getScaledScrollFactor();
+
+        float velocityDirection = Math.signum(scaledVelocity);
+        // Stop ongoing fling if there has been state changes affecting fling, or if the current
+        // velocity (if non-zero) is opposite of the velocity that last caused fling.
+        if (flingParamsChanged
+                || (velocityDirection != Math.signum(mLastFlingVelocity)
+                    && velocityDirection != 0)) {
+            mTarget.stopDifferentialMotionFling();
+        }
+
+        if (Math.abs(scaledVelocity) < mFlingVelocityThresholds[0]) {
+            return;
+        }
+
+        // Clamp the scaled velocity between [-max, max].
+        // e.g. if max=100, and vel=200
+        // vel = max(-100, min(200, 100)) = max(-100, 100) = 100
+        // e.g. if max=100, and vel=-200
+        // vel = max(-100, min(-200, 100)) = max(-100, -200) = -100
+        scaledVelocity =
+                Math.max(
+                        -mFlingVelocityThresholds[1],
+                        Math.min(scaledVelocity, mFlingVelocityThresholds[1]));
+
+        boolean flung = mTarget.startDifferentialMotionFling(scaledVelocity);
+        mLastFlingVelocity = flung ? scaledVelocity : 0;
+    }
+
+    /**
+     * Calculates fling velocity thresholds based on the provided event and axis, and returns {@code
+     * true} if there has been a change of any params that may affect fling velocity thresholds.
+     */
+    private boolean calculateFlingVelocityThresholds(MotionEvent event, int axis) {
+        int source = event.getSource();
+        int deviceId = event.getDeviceId();
+        if (mLastProcessedSource != source
+                || mLastProcessedDeviceId != deviceId
+                || mLastProcessedAxis != axis) {
+            mVelocityThresholdCalculator.calculateFlingVelocityThresholds(
+                    mContext, mFlingVelocityThresholds, event, axis);
+            // Save data about this processing so that we don't have to re-process fling thresholds
+            // for similar parameters.
+            mLastProcessedSource = source;
+            mLastProcessedDeviceId = deviceId;
+            mLastProcessedAxis = axis;
+            return true;
+        }
+        return false;
+    }
+
+    private static void calculateFlingVelocityThresholds(
+            Context context, int[] buffer, MotionEvent event, int axis) {
+        int source = event.getSource();
+        int deviceId = event.getDeviceId();
+
+        ViewConfiguration vc = ViewConfiguration.get(context);
+        buffer[0] = vc.getScaledMinimumFlingVelocity(deviceId, axis, source);
+        buffer[1] = vc.getScaledMaximumFlingVelocity(deviceId, axis, source);
+    }
+
+    private float getCurrentVelocity(MotionEvent event, int axis) {
+        if (mVelocityTracker == null) {
+            mVelocityTracker = VelocityTracker.obtain();
+        }
+
+        return mVelocityProvider.getCurrentVelocity(mVelocityTracker, event, axis);
+    }
+
+    private void recycleVelocityTracker() {
+        if (mVelocityTracker != null) {
+            mVelocityTracker.recycle();
+            mVelocityTracker = null;
+        }
+    }
+
+    private static float getCurrentVelocity(VelocityTracker vt, MotionEvent event, int axis) {
+        vt.addMovement(event);
+        vt.computeCurrentVelocity(1000);
+        return vt.getAxisVelocity(axis);
+    }
+}
diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java
index 58f6613..f99f138 100644
--- a/core/java/android/widget/Editor.java
+++ b/core/java/android/widget/Editor.java
@@ -8207,7 +8207,8 @@
          */
         void beforeSetText() {
             // TextView#setText is called because our call to
-            // TextView#setTransformationMethodInternal in enterInsertMode() or exitInsertMode().
+            // TextView#setTransformationMethodInternal in enterInsertMode(), exitInsertMode() or
+            // updateTransformationMethod().
             // Do nothing in this case.
             if (mUpdatingTransformationMethod) {
                 return;
@@ -8218,22 +8219,28 @@
         }
 
         /**
-         * Notify the {@link InsertModeController} before the TextView's
-         * {@link TransformationMethod} is updated. If it's not in the insert mode,
-         * the given method is directly returned. Otherwise, it will wrap the given transformation
-         * method with an {@link InsertModeTransformationMethod} and then return.
+         * Notify the {@link InsertModeController} that TextView#setTransformationMethod is called.
+         * If it's not in the insert mode, the given transformation method is directly set to the
+         * TextView. Otherwise, it will wrap the given transformation method with an
+         * {@link InsertModeTransformationMethod} and then set it on the TextView.
          *
-         * @param oldTransformationMethod the new {@link TransformationMethod} to be set on the
+         * @param transformationMethod the new {@link TransformationMethod} to be set on the
          *                             TextView.
-         * @return the updated {@link TransformationMethod} to be set on the Textview.
          */
-        TransformationMethod updateTransformationMethod(
-                TransformationMethod oldTransformationMethod) {
-            if (!mIsInsertModeActive) return oldTransformationMethod;
+        void updateTransformationMethod(TransformationMethod transformationMethod) {
+            if (!mIsInsertModeActive) {
+                setTransformationMethod(transformationMethod, /* updateText */ true);
+                return;
+            }
 
+            // Changing TransformationMethod will reset selection range to [0, 0), we need to
+            // manually restore the old selection range.
+            final int selectionStart = mTextView.getSelectionStart();
+            final int selectionEnd = mTextView.getSelectionEnd();
             mInsertModeTransformationMethod = mInsertModeTransformationMethod.update(
-                    oldTransformationMethod, mTextView.isSingleLine());
-            return mInsertModeTransformationMethod;
+                    transformationMethod, mTextView.isSingleLine());
+            setTransformationMethod(mInsertModeTransformationMethod, /* updateText */ true);
+            Selection.setSelection((Spannable) mTextView.getText(), selectionStart, selectionEnd);
         }
     }
 
@@ -8259,18 +8266,11 @@
      * @param method the {@link TransformationMethod} to be set on the TextView.
      */
     void setTransformationMethod(TransformationMethod method) {
-        if (mInsertModeController == null || !mInsertModeController.mIsInsertModeActive) {
+        if (mInsertModeController == null) {
             mTextView.setTransformationMethodInternal(method, /* updateText */ true);
             return;
         }
-
-        // Changing TransformationMethod will reset selection range to [0, 0), we need to
-        // manually restore the old selection range.
-        final int selectionStart = mTextView.getSelectionStart();
-        final int selectionEnd = mTextView.getSelectionEnd();
-        method = mInsertModeController.updateTransformationMethod(method);
-        mTextView.setTransformationMethodInternal(method, /* updateText */ true);
-        Selection.setSelection((Spannable) mTextView.getText(), selectionStart, selectionEnd);
+        mInsertModeController.updateTransformationMethod(method);
     }
 
     /**
diff --git a/core/java/android/widget/ScrollView.java b/core/java/android/widget/ScrollView.java
index cb5dbe6..eeb6b43 100644
--- a/core/java/android/widget/ScrollView.java
+++ b/core/java/android/widget/ScrollView.java
@@ -204,6 +204,8 @@
     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
     private StrictMode.Span mFlingStrictSpan = null;
 
+    private DifferentialMotionFlingHelper mDifferentialMotionFlingHelper;
+
     /**
      * Sentinel value for no current active pointer.
      * Used by {@link #mActivePointerId}.
@@ -594,6 +596,14 @@
         }
     }
 
+    private void initDifferentialFlingHelperIfNotExists() {
+        if (mDifferentialMotionFlingHelper == null) {
+            mDifferentialMotionFlingHelper =
+                    new DifferentialMotionFlingHelper(
+                            mContext, new DifferentialFlingTarget());
+        }
+    }
+
     private void recycleVelocityTracker() {
         if (mVelocityTracker != null) {
             mVelocityTracker.recycle();
@@ -942,17 +952,22 @@
     public boolean onGenericMotionEvent(MotionEvent event) {
         switch (event.getAction()) {
             case MotionEvent.ACTION_SCROLL:
-                final float axisValue;
+                final int axis;
                 if (event.isFromSource(InputDevice.SOURCE_CLASS_POINTER)) {
-                    axisValue = event.getAxisValue(MotionEvent.AXIS_VSCROLL);
+                    axis = MotionEvent.AXIS_VSCROLL;
                 } else if (event.isFromSource(InputDevice.SOURCE_ROTARY_ENCODER)) {
-                    axisValue = event.getAxisValue(MotionEvent.AXIS_SCROLL);
+                    axis = MotionEvent.AXIS_SCROLL;
                 } else {
-                    axisValue = 0;
+                    axis = -1;
                 }
 
+                final float axisValue = (axis == -1) ? 0 : event.getAxisValue(axis);
                 final int delta = Math.round(axisValue * mVerticalScrollFactor);
                 if (delta != 0) {
+                    // Tracks whether or not we should attempt fling for this event.
+                    // Fling should not be attempted if the view is already at the limit of scroll,
+                    // since it conflicts with EdgeEffect.
+                    boolean shouldAttemptFling = true;
                     final int range = getScrollRange();
                     int oldScrollY = mScrollY;
                     int newScrollY = oldScrollY - delta;
@@ -971,6 +986,7 @@
                             absorbed = true;
                         }
                         newScrollY = 0;
+                        shouldAttemptFling = false;
                     } else if (newScrollY > range) {
                         if (canOverscroll) {
                             mEdgeGlowBottom.onPullDistance(
@@ -980,9 +996,14 @@
                             absorbed = true;
                         }
                         newScrollY = range;
+                        shouldAttemptFling = false;
                     }
                     if (newScrollY != oldScrollY) {
                         super.scrollTo(mScrollX, newScrollY);
+                        if (shouldAttemptFling) {
+                            initDifferentialFlingHelperIfNotExists();
+                            mDifferentialMotionFlingHelper.onMotionEvent(event, axis);
+                        }
                         return true;
                     }
                     if (absorbed) {
@@ -2126,4 +2147,23 @@
         };
     }
 
+    private class DifferentialFlingTarget
+            implements DifferentialMotionFlingHelper.DifferentialMotionFlingTarget {
+        @Override
+        public boolean startDifferentialMotionFling(float velocity) {
+            stopDifferentialMotionFling();
+            fling((int) velocity);
+            return true;
+        }
+
+        @Override
+        public void stopDifferentialMotionFling() {
+            mScroller.abortAnimation();
+        }
+
+        @Override
+        public float getScaledScrollFactor() {
+            return -mVerticalScrollFactor;
+        }
+    }
 }
diff --git a/core/java/android/window/WindowContextController.java b/core/java/android/window/WindowContextController.java
index 99e63ec..c9ac245 100644
--- a/core/java/android/window/WindowContextController.java
+++ b/core/java/android/window/WindowContextController.java
@@ -86,6 +86,7 @@
      * @param token The token used to attach to a window manager node. It is usually from
      *              {@link Context#getWindowContextToken()}.
      */
+    @VisibleForTesting
     public WindowContextController(@NonNull WindowTokenClient token) {
         mToken = token;
     }
@@ -104,7 +105,7 @@
             throw new IllegalStateException("A Window Context can be only attached to "
                     + "a DisplayArea once.");
         }
-        mAttachedToDisplayArea = WindowTokenClientController.getInstance().attachToDisplayArea(
+        mAttachedToDisplayArea = getWindowTokenClientController().attachToDisplayArea(
                 mToken, type, displayId, options)
                 ? AttachStatus.STATUS_ATTACHED : AttachStatus.STATUS_FAILED;
         if (mAttachedToDisplayArea == AttachStatus.STATUS_FAILED) {
@@ -136,22 +137,31 @@
      * @see WindowProviderService#attachToWindowToken(IBinder))
      * @see IWindowManager#attachWindowContextToWindowToken
      */
-    public void attachToWindowToken(IBinder windowToken) {
+    public void attachToWindowToken(@NonNull IBinder windowToken) {
         if (mAttachedToDisplayArea != AttachStatus.STATUS_ATTACHED) {
             throw new IllegalStateException("The Window Context should have been attached"
                     + " to a DisplayArea. AttachToDisplayArea:" + mAttachedToDisplayArea);
         }
-        WindowTokenClientController.getInstance().attachToWindowToken(mToken, windowToken);
+        if (!getWindowTokenClientController().attachToWindowToken(mToken, windowToken)) {
+            Log.e(TAG, "attachToWindowToken fail");
+        }
     }
 
     /** Detaches the window context from the node it's currently associated with. */
     public void detachIfNeeded() {
         if (mAttachedToDisplayArea == AttachStatus.STATUS_ATTACHED) {
-            WindowTokenClientController.getInstance().detachIfNeeded(mToken);
+            getWindowTokenClientController().detachIfNeeded(mToken);
             mAttachedToDisplayArea = AttachStatus.STATUS_DETACHED;
             if (DEBUG_ATTACH) {
                 Log.d(TAG, "Detach Window Context.");
             }
         }
     }
+
+    /** Gets the {@link WindowTokenClientController}. */
+    @VisibleForTesting
+    @NonNull
+    public WindowTokenClientController getWindowTokenClientController() {
+        return WindowTokenClientController.getInstance();
+    }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/scene/shared/model/SceneContainerNames.kt b/core/java/android/window/WindowContextInfo.aidl
similarity index 75%
rename from packages/SystemUI/src/com/android/systemui/scene/shared/model/SceneContainerNames.kt
rename to core/java/android/window/WindowContextInfo.aidl
index 64f5087..360431c 100644
--- a/packages/SystemUI/src/com/android/systemui/scene/shared/model/SceneContainerNames.kt
+++ b/core/java/android/window/WindowContextInfo.aidl
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2023 The Android Open Source Project
+ * 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.
@@ -14,8 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.systemui.scene.shared.model
+package android.window;
 
-object SceneContainerNames {
-    const val SYSTEM_UI_DEFAULT = "system_ui"
-}
+/** @hide */
+parcelable WindowContextInfo;
\ No newline at end of file
diff --git a/core/java/android/window/WindowContextInfo.java b/core/java/android/window/WindowContextInfo.java
new file mode 100644
index 0000000..3c21cd4
--- /dev/null
+++ b/core/java/android/window/WindowContextInfo.java
@@ -0,0 +1,117 @@
+/*
+ * 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 android.window;
+
+import static java.util.Objects.requireNonNull;
+
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.content.res.Configuration;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.util.Objects;
+
+/**
+ * Stores information about a particular window that a {@link WindowContext} is attached to.
+ * @hide
+ */
+public class WindowContextInfo implements Parcelable {
+
+    /**
+     * Configuration of the window.
+     */
+    @NonNull
+    private final Configuration mConfiguration;
+
+    /**
+     * The display id that the window is attached to.
+     */
+    private final int mDisplayId;
+
+    public WindowContextInfo(@NonNull Configuration configuration, int displayId) {
+        mConfiguration = requireNonNull(configuration);
+        mDisplayId = displayId;
+    }
+
+    @NonNull
+    public Configuration getConfiguration() {
+        return mConfiguration;
+    }
+
+    public int getDisplayId() {
+        return mDisplayId;
+    }
+
+    // Parcelable implementation
+
+    /** Writes to Parcel. */
+    @Override
+    public void writeToParcel(@NonNull Parcel dest, int flags) {
+        dest.writeTypedObject(mConfiguration, flags);
+        dest.writeInt(mDisplayId);
+    }
+
+    /** Reads from Parcel. */
+    private WindowContextInfo(@NonNull Parcel in) {
+        mConfiguration = in.readTypedObject(Configuration.CREATOR);
+        mDisplayId = in.readInt();
+    }
+
+    public static final @NonNull Creator<WindowContextInfo> CREATOR = new Creator<>() {
+        public WindowContextInfo createFromParcel(Parcel in) {
+            return new WindowContextInfo(in);
+        }
+
+        public WindowContextInfo[] newArray(int size) {
+            return new WindowContextInfo[size];
+        }
+    };
+
+    @Override
+    public int describeContents() {
+        return 0;
+    }
+
+    @Override
+    public boolean equals(@Nullable Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+        final WindowContextInfo other = (WindowContextInfo) o;
+        return Objects.equals(mConfiguration, other.mConfiguration)
+                && mDisplayId == other.mDisplayId;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 17;
+        result = 31 * result + Objects.hashCode(mConfiguration);
+        result = 31 * result + mDisplayId;
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        return "WindowContextInfo{config=" + mConfiguration
+                + ", displayId=" + mDisplayId
+                + "}";
+    }
+}
diff --git a/core/java/android/window/WindowTokenClient.java b/core/java/android/window/WindowTokenClient.java
index 7458563..6a32529 100644
--- a/core/java/android/window/WindowTokenClient.java
+++ b/core/java/android/window/WindowTokenClient.java
@@ -99,6 +99,13 @@
     @Override
     public void onConfigurationChanged(Configuration newConfig, int newDisplayId) {
         // TODO(b/290876897): No need to post on mHandler after migrating to ClientTransaction
+        postOnConfigurationChanged(newConfig, newDisplayId);
+    }
+
+    /**
+     * Posts an {@link #onConfigurationChanged} to the main thread.
+     */
+    public void postOnConfigurationChanged(@NonNull Configuration newConfig, int newDisplayId) {
         mHandler.post(PooledLambda.obtainRunnable(this::onConfigurationChanged, newConfig,
                 newDisplayId, true /* shouldReportConfigChange */).recycleOnUse());
     }
@@ -162,7 +169,6 @@
                 windowContext.dispatchConfigurationChanged(newConfig);
             }
 
-
             if (shouldReportConfigChange && diff != 0
                     && context instanceof WindowProviderService) {
                 final WindowProviderService windowProviderService = (WindowProviderService) context;
diff --git a/core/java/android/window/WindowTokenClientController.java b/core/java/android/window/WindowTokenClientController.java
index 4484707..7a84123 100644
--- a/core/java/android/window/WindowTokenClientController.java
+++ b/core/java/android/window/WindowTokenClientController.java
@@ -17,22 +17,21 @@
 package android.window;
 
 import static android.view.WindowManager.LayoutParams.WindowType;
-import static android.view.WindowManagerGlobal.getWindowManagerService;
 
 import android.annotation.NonNull;
 import android.annotation.Nullable;
 import android.app.ActivityThread;
 import android.app.IApplicationThread;
-import android.app.servertransaction.WindowContextConfigurationChangeItem;
+import android.app.servertransaction.WindowContextInfoChangeItem;
 import android.app.servertransaction.WindowContextWindowRemovalItem;
 import android.content.Context;
-import android.content.res.Configuration;
 import android.os.Bundle;
 import android.os.IBinder;
 import android.os.RemoteException;
 import android.util.ArrayMap;
 import android.util.Log;
 import android.view.IWindowManager;
+import android.view.WindowManagerGlobal;
 
 import com.android.internal.annotations.GuardedBy;
 import com.android.internal.annotations.VisibleForTesting;
@@ -56,6 +55,7 @@
     private final ArrayMap<IBinder, WindowTokenClient> mWindowTokenClientMap = new ArrayMap<>();
 
     /** Gets the singleton controller. */
+    @NonNull
     public static WindowTokenClientController getInstance() {
         synchronized (WindowTokenClientController.class) {
             if (sController == null) {
@@ -75,6 +75,7 @@
 
     /** Creates a new instance for test only. */
     @VisibleForTesting
+    @NonNull
     public static WindowTokenClientController createInstanceForTesting() {
         return new WindowTokenClientController();
     }
@@ -92,17 +93,17 @@
      */
     public boolean attachToDisplayArea(@NonNull WindowTokenClient client,
             @WindowType int type, int displayId, @Nullable Bundle options) {
-        final Configuration configuration;
+        final WindowContextInfo info;
         try {
-            configuration = getWindowManagerService().attachWindowContextToDisplayArea(
+            info = getWindowManagerService().attachWindowContextToDisplayArea(
                     mAppThread, client, type, displayId, options);
         } catch (RemoteException e) {
             throw e.rethrowFromSystemServer();
         }
-        if (configuration == null) {
+        if (info == null) {
             return false;
         }
-        onWindowContextTokenAttached(client, displayId, configuration);
+        onWindowContextTokenAttached(client, info, false /* shouldReportConfigChange */);
         return true;
     }
 
@@ -119,16 +120,16 @@
         if (wms == null) {
             return false;
         }
-        final Configuration configuration;
+        final WindowContextInfo info;
         try {
-            configuration = wms.attachWindowContextToDisplayContent(mAppThread, client, displayId);
+            info = wms.attachWindowContextToDisplayContent(mAppThread, client, displayId);
         } catch (RemoteException e) {
             throw e.rethrowFromSystemServer();
         }
-        if (configuration == null) {
+        if (info == null) {
             return false;
         }
-        onWindowContextTokenAttached(client, displayId, configuration);
+        onWindowContextTokenAttached(client, info, false /* shouldReportConfigChange */);
         return true;
     }
 
@@ -137,19 +138,23 @@
      *
      * @param client The {@link WindowTokenClient} to attach.
      * @param windowToken the window token to associated with
+     * @return {@code true} if attaching successfully.
      */
-    public void attachToWindowToken(@NonNull WindowTokenClient client,
+    public boolean attachToWindowToken(@NonNull WindowTokenClient client,
             @NonNull IBinder windowToken) {
+        final WindowContextInfo info;
         try {
-            getWindowManagerService().attachWindowContextToWindowToken(
+            info = getWindowManagerService().attachWindowContextToWindowToken(
                     mAppThread, client, windowToken);
         } catch (RemoteException e) {
             throw e.rethrowFromSystemServer();
         }
-        // We don't report configuration change for now.
-        synchronized (mLock) {
-            mWindowTokenClientMap.put(client.asBinder(), client);
+        if (info == null) {
+            return false;
         }
+        // We currently report configuration for WindowToken after attached.
+        onWindowContextTokenAttached(client, info, true /* shouldReportConfigChange */);
+        return true;
     }
 
     /** Detaches a {@link WindowTokenClient} from associated WindowContainer if there's one. */
@@ -166,21 +171,30 @@
         }
     }
 
-    private void onWindowContextTokenAttached(@NonNull WindowTokenClient client, int displayId,
-            @NonNull Configuration configuration) {
+    private void onWindowContextTokenAttached(@NonNull WindowTokenClient client,
+            @NonNull WindowContextInfo info, boolean shouldReportConfigChange) {
         synchronized (mLock) {
             mWindowTokenClientMap.put(client.asBinder(), client);
         }
-        client.onConfigurationChanged(configuration, displayId,
-                false /* shouldReportConfigChange */);
+        if (shouldReportConfigChange) {
+            // Should trigger an #onConfigurationChanged callback to the WindowContext. Post the
+            // dispatch in the next loop to prevent the callback from being dispatched before
+            // #onCreate or WindowContext creation..
+            client.postOnConfigurationChanged(info.getConfiguration(), info.getDisplayId());
+        } else {
+            // Apply the config change directly in case users get stale values after WindowContext
+            // creation.
+            client.onConfigurationChanged(info.getConfiguration(), info.getDisplayId(),
+                    false /* shouldReportConfigChange */);
+        }
     }
 
-    /** Called when receives {@link WindowContextConfigurationChangeItem}. */
-    public void onWindowContextConfigurationChanged(@NonNull IBinder clientToken,
-            @NonNull Configuration configuration, int displayId) {
+    /** Called when receives {@link WindowContextInfoChangeItem}. */
+    public void onWindowContextInfoChanged(@NonNull IBinder clientToken,
+            @NonNull WindowContextInfo info) {
         final WindowTokenClient windowTokenClient = getWindowTokenClient(clientToken);
         if (windowTokenClient != null) {
-            windowTokenClient.onConfigurationChanged(configuration, displayId);
+            windowTokenClient.onConfigurationChanged(info.getConfiguration(), info.getDisplayId());
         }
     }
 
@@ -203,4 +217,11 @@
         }
         return windowTokenClient;
     }
+
+    /** Gets the {@link IWindowManager}. */
+    @VisibleForTesting
+    @Nullable
+    public IWindowManager getWindowManagerService() {
+        return WindowManagerGlobal.getWindowManagerService();
+    }
 }
diff --git a/core/java/com/android/internal/infra/TEST_MAPPING b/core/java/com/android/internal/infra/TEST_MAPPING
index 3de107e..ddfd0ed 100644
--- a/core/java/com/android/internal/infra/TEST_MAPPING
+++ b/core/java/com/android/internal/infra/TEST_MAPPING
@@ -1,14 +1,22 @@
 {
   "presubmit": [
     {
-      "name": "CtsRoleTestCases"
+      "name": "CtsRoleTestCases",
+      "options": [
+          {
+              "exclude-annotation": "android.platform.test.annotations.FlakyTest"
+          }
+      ]
     },
     {
       "name": "CtsPermissionTestCases",
       "options": [
-        {
-          "include-filter": "android.permission.cts.PermissionControllerTest"
-        }
+          {
+            "include-filter": "android.permission.cts.PermissionControllerTest"
+          },
+          {
+            "exclude-annotation": "android.platform.test.annotations.FlakyTest"
+          }
       ]
     },
     {
diff --git a/core/jni/android_os_PerformanceHintManager.cpp b/core/jni/android_os_PerformanceHintManager.cpp
index d8a2497..ffe844d 100644
--- a/core/jni/android_os_PerformanceHintManager.cpp
+++ b/core/jni/android_os_PerformanceHintManager.cpp
@@ -41,7 +41,7 @@
 typedef void (*APH_reportActualWorkDuration)(APerformanceHintSession*, int64_t);
 typedef void (*APH_closeSession)(APerformanceHintSession* session);
 typedef void (*APH_sendHint)(APerformanceHintSession*, int32_t);
-typedef void (*APH_setThreads)(APerformanceHintSession*, const pid_t*, size_t);
+typedef int (*APH_setThreads)(APerformanceHintSession*, const pid_t*, size_t);
 typedef void (*APH_getThreadIds)(APerformanceHintSession*, int32_t* const, size_t* const);
 
 bool gAPerformanceHintBindingInitialized = false;
@@ -112,6 +112,20 @@
 
 } // namespace
 
+static void throwExceptionForErrno(JNIEnv* env, int err, const std::string& msg) {
+    switch (err) {
+        case EINVAL:
+            jniThrowExceptionFmt(env, "java/lang/IllegalArgumentException", msg.c_str());
+            break;
+        case EPERM:
+            jniThrowExceptionFmt(env, "java/lang/SecurityException", msg.c_str());
+            break;
+        default:
+            jniThrowException(env, "java/lang/RuntimeException", msg.c_str());
+            break;
+    }
+}
+
 static jlong nativeAcquireManager(JNIEnv* env, jclass clazz) {
     ensureAPerformanceHintBindingInitialized();
     return reinterpret_cast<jlong>(gAPH_getManagerFn());
@@ -174,8 +188,11 @@
     for (size_t i = 0; i < tidsArray.size(); ++i) {
         tidsVector.push_back(static_cast<int32_t>(tidsArray[i]));
     }
-    gAPH_setThreadsFn(reinterpret_cast<APerformanceHintSession*>(nativeSessionPtr),
-                      tidsVector.data(), tidsVector.size());
+    int err = gAPH_setThreadsFn(reinterpret_cast<APerformanceHintSession*>(nativeSessionPtr),
+                                tidsVector.data(), tidsVector.size());
+    if (err != 0) {
+        throwExceptionForErrno(env, err, "Failed to set threads for hint session");
+    }
 }
 
 // This call should only be used for validation in tests only. This call will initiate two IPC
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index baa47da..b29a4e6 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -5631,6 +5631,12 @@
                 android:description="@string/permdesc_deliverCompanionMessages"
                 android:protectionLevel="normal" />
 
+    <!-- @hide @SystemApi(client=android.annotation.SystemApi.Client.MODULE_LIBRARIES)
+         Allows an application to send and receive messages via CDM transports.
+    -->
+    <permission android:name="android.permission.USE_COMPANION_TRANSPORTS"
+        android:protectionLevel="signature|module" />
+
     <!-- Allows an application to create new companion device associations.
          @SystemApi
          @hide -->
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 54dff08..64be87b 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -3938,8 +3938,14 @@
     <!-- Flag indicating device support for EAP SIM, AKA, AKA' -->
     <bool name="config_eap_sim_based_auth_supported">true</bool>
 
+    <!-- How long history of recent vibrations should be kept for the dumpsys. -->
+    <integer name="config_recentVibrationsDumpSizeLimit">20</integer>
+
     <!-- How long history of previous vibrations should be kept for the dumpsys. -->
-    <integer name="config_previousVibrationsDumpLimit">50</integer>
+    <integer name="config_previousVibrationsDumpSizeLimit">50</integer>
+
+    <!-- How close vibration request should be when they're aggregated for dumpsys, in ms. -->
+    <integer name="config_previousVibrationsDumpAggregationTimeMillisLimit">1000</integer>
 
     <!-- The default vibration strength, must be between 1 and 255 inclusive. -->
     <integer name="config_defaultVibrationAmplitude">255</integer>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 9da0f17..3aae3ca 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -2038,7 +2038,9 @@
   <java-symbol type="integer" name="config_notificationsBatteryNearlyFullLevel" />
   <java-symbol type="integer" name="config_notificationServiceArchiveSize" />
   <java-symbol type="dimen" name="config_rotaryEncoderAxisScrollTickInterval" />
-  <java-symbol type="integer" name="config_previousVibrationsDumpLimit" />
+  <java-symbol type="integer" name="config_recentVibrationsDumpSizeLimit" />
+  <java-symbol type="integer" name="config_previousVibrationsDumpSizeLimit" />
+  <java-symbol type="integer" name="config_previousVibrationsDumpAggregationTimeMillisLimit" />
   <java-symbol type="integer" name="config_defaultVibrationAmplitude" />
   <java-symbol type="dimen" name="config_hapticChannelMaxVibrationAmplitude" />
   <java-symbol type="integer" name="config_vibrationWaveformRampStepDuration" />
diff --git a/core/tests/coretests/src/android/app/activity/ActivityThreadTest.java b/core/tests/coretests/src/android/app/activity/ActivityThreadTest.java
index 8da6d74..c904d96 100644
--- a/core/tests/coretests/src/android/app/activity/ActivityThreadTest.java
+++ b/core/tests/coretests/src/android/app/activity/ActivityThreadTest.java
@@ -64,6 +64,7 @@
 import android.util.MergedConfiguration;
 import android.view.Display;
 import android.view.View;
+import android.window.WindowContextInfo;
 import android.window.WindowTokenClientController;
 
 import androidx.test.filters.MediumTest;
@@ -753,13 +754,12 @@
         WindowTokenClientController.overrideForTesting(windowTokenClientController);
         final IBinder clientToken = mock(IBinder.class);
         final Configuration configuration = new Configuration();
+        final WindowContextInfo info = new WindowContextInfo(configuration, DEFAULT_DISPLAY);
 
         InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> activityThread
-                .handleWindowContextConfigurationChanged(
-                        clientToken, configuration, DEFAULT_DISPLAY));
+                .handleWindowContextInfoChanged(clientToken, info));
 
-        verify(windowTokenClientController).onWindowContextConfigurationChanged(
-                clientToken, configuration, DEFAULT_DISPLAY);
+        verify(windowTokenClientController).onWindowContextInfoChanged(clientToken, info);
     }
 
     @Test
diff --git a/core/tests/coretests/src/android/app/servertransaction/WindowContextConfigurationChangeItemTest.java b/core/tests/coretests/src/android/app/servertransaction/WindowContextInfoChangeItemTest.java
similarity index 79%
rename from core/tests/coretests/src/android/app/servertransaction/WindowContextConfigurationChangeItemTest.java
rename to core/tests/coretests/src/android/app/servertransaction/WindowContextInfoChangeItemTest.java
index 7811e1a..37a517e 100644
--- a/core/tests/coretests/src/android/app/servertransaction/WindowContextConfigurationChangeItemTest.java
+++ b/core/tests/coretests/src/android/app/servertransaction/WindowContextInfoChangeItemTest.java
@@ -23,6 +23,7 @@
 import android.app.ClientTransactionHandler;
 import android.content.res.Configuration;
 import android.os.IBinder;
+import android.window.WindowContextInfo;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -30,12 +31,12 @@
 import org.mockito.MockitoAnnotations;
 
 /**
- * Tests for {@link WindowContextConfigurationChangeItem}.
+ * Tests for {@link WindowContextInfoChangeItem}.
  *
  * Build/Install/Run:
- *  atest FrameworksCoreTests:WindowContextConfigurationChangeItemTest
+ *  atest FrameworksCoreTests:WindowContextInfoChangeItemTest
  */
-public class WindowContextConfigurationChangeItemTest {
+public class WindowContextInfoChangeItemTest {
 
     @Mock
     private ClientTransactionHandler mHandler;
@@ -55,11 +56,11 @@
 
     @Test
     public void testExecute() {
-        final WindowContextConfigurationChangeItem item = WindowContextConfigurationChangeItem
+        final WindowContextInfoChangeItem item = WindowContextInfoChangeItem
                 .obtain(mClientToken, mConfiguration, DEFAULT_DISPLAY);
         item.execute(mHandler, mToken, mPendingActions);
 
-        verify(mHandler).handleWindowContextConfigurationChanged(mClientToken, mConfiguration,
-                DEFAULT_DISPLAY);
+        verify(mHandler).handleWindowContextInfoChanged(mClientToken,
+                new WindowContextInfo(mConfiguration, DEFAULT_DISPLAY));
     }
 }
diff --git a/core/tests/coretests/src/android/os/PerformanceHintManagerTest.java b/core/tests/coretests/src/android/os/PerformanceHintManagerTest.java
index 7eefbbc..2c03fdc 100644
--- a/core/tests/coretests/src/android/os/PerformanceHintManagerTest.java
+++ b/core/tests/coretests/src/android/os/PerformanceHintManagerTest.java
@@ -139,11 +139,20 @@
     }
 
     @Test
-    public void testSetThreadsWithIllegalArgument() {
+    public void testSetThreads_emptyTids() {
         Session session = createSession();
         assumeNotNull(session);
         assertThrows(IllegalArgumentException.class, () -> {
-            session.setThreads(new int[] { });
+            session.setThreads(new int[]{});
+        });
+    }
+
+    @Test
+    public void testSetThreads_invalidTids() {
+        Session session = createSession();
+        assumeNotNull(session);
+        assertThrows(SecurityException.class, () -> {
+            session.setThreads(new int[]{-1});
         });
     }
 }
diff --git a/core/tests/coretests/src/android/widget/DifferentialMotionFlingHelperTest.java b/core/tests/coretests/src/android/widget/DifferentialMotionFlingHelperTest.java
new file mode 100644
index 0000000..51c8bc0
--- /dev/null
+++ b/core/tests/coretests/src/android/widget/DifferentialMotionFlingHelperTest.java
@@ -0,0 +1,186 @@
+/*
+ * 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.
+ */
+
+package android.widget;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+import android.view.MotionEvent;
+
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.SmallTest;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@SmallTest
+@RunWith(AndroidJUnit4.class)
+public class DifferentialMotionFlingHelperTest {
+    private int mMinVelocity = 0;
+    private int mMaxVelocity = Integer.MAX_VALUE;
+    /** A fake velocity value that's going to be returned from the velocity provider. */
+    private float mVelocity;
+    private boolean mVelocityCalculated;
+
+    private final DifferentialMotionFlingHelper.DifferentialVelocityProvider mVelocityProvider =
+            (vt, event, axis) -> {
+                mVelocityCalculated = true;
+                return mVelocity;
+            };
+
+    private final DifferentialMotionFlingHelper.FlingVelocityThresholdCalculator
+            mVelocityThresholdCalculator =
+                    (ctx, buffer, event, axis) -> {
+                        buffer[0] = mMinVelocity;
+                        buffer[1] = mMaxVelocity;
+                    };
+
+    private final TestDifferentialMotionFlingTarget mFlingTarget =
+            new TestDifferentialMotionFlingTarget();
+
+    private DifferentialMotionFlingHelper mFlingHelper;
+
+    @Before
+    public void setUp() throws Exception {
+        mFlingHelper = new DifferentialMotionFlingHelper(
+                ApplicationProvider.getApplicationContext(),
+                mFlingTarget,
+                mVelocityThresholdCalculator,
+                mVelocityProvider);
+    }
+
+    @Test
+    public void deviceDoesNotSupportFling_noVelocityCalculated() {
+        mMinVelocity = Integer.MAX_VALUE;
+        mMaxVelocity = Integer.MIN_VALUE;
+
+        deliverEventWithVelocity(createPointerEvent(), MotionEvent.AXIS_VSCROLL, 60);
+
+        assertFalse(mVelocityCalculated);
+    }
+
+    @Test
+    public void flingVelocityOppositeToPrevious_stopsOngoingFling() {
+        deliverEventWithVelocity(createRotaryEncoderEvent(), MotionEvent.AXIS_SCROLL, 50);
+        deliverEventWithVelocity(createRotaryEncoderEvent(), MotionEvent.AXIS_SCROLL, -10);
+
+        // One stop on the initial event, and second stop due to opposite velocities.
+        assertEquals(2, mFlingTarget.mNumStops);
+    }
+
+    @Test
+    public void flingParamsChanged_stopsOngoingFling() {
+        deliverEventWithVelocity(createPointerEvent(), MotionEvent.AXIS_VSCROLL, 50);
+        deliverEventWithVelocity(createRotaryEncoderEvent(), MotionEvent.AXIS_SCROLL, 10);
+
+        // One stop on the initial event, and second stop due to changed axis/source.
+        assertEquals(2, mFlingTarget.mNumStops);
+    }
+
+    @Test
+    public void positiveFlingVelocityTooLow_doesNotGenerateFling() {
+        mMinVelocity = 50;
+        mMaxVelocity = 100;
+        deliverEventWithVelocity(createPointerEvent(), MotionEvent.AXIS_VSCROLL, 20);
+
+        assertEquals(0, mFlingTarget.mLastFlingVelocity, /* delta= */ 0);
+    }
+
+    @Test
+    public void negativeFlingVelocityTooLow_doesNotGenerateFling() {
+        mMinVelocity = 50;
+        mMaxVelocity = 100;
+        deliverEventWithVelocity(createPointerEvent(), MotionEvent.AXIS_VSCROLL, -20);
+
+        assertEquals(0, mFlingTarget.mLastFlingVelocity, /* delta= */ 0);
+    }
+
+    @Test
+    public void positiveFlingVelocityAboveMinimum_generateFlings() {
+        mMinVelocity = 50;
+        mMaxVelocity = 100;
+        deliverEventWithVelocity(createPointerEvent(), MotionEvent.AXIS_VSCROLL, 60);
+
+        assertEquals(60, mFlingTarget.mLastFlingVelocity, /* delta= */ 0);
+    }
+
+    @Test
+    public void negativeFlingVelocityAboveMinimum_generateFlings() {
+        mMinVelocity = 50;
+        mMaxVelocity = 100;
+        deliverEventWithVelocity(createPointerEvent(), MotionEvent.AXIS_VSCROLL, -60);
+
+        assertEquals(-60, mFlingTarget.mLastFlingVelocity, /* delta= */ 0);
+    }
+
+    @Test
+    public void positiveFlingVelocityAboveMaximum_velocityClamped() {
+        mMinVelocity = 50;
+        mMaxVelocity = 100;
+        deliverEventWithVelocity(createPointerEvent(), MotionEvent.AXIS_VSCROLL, 3000);
+
+        assertEquals(100, mFlingTarget.mLastFlingVelocity, /* delta= */ 0);
+    }
+
+    @Test
+    public void negativeFlingVelocityAboveMaximum_velocityClamped() {
+        mMinVelocity = 50;
+        mMaxVelocity = 100;
+        deliverEventWithVelocity(createPointerEvent(), MotionEvent.AXIS_VSCROLL, -3000);
+
+        assertEquals(-100, mFlingTarget.mLastFlingVelocity, /* delta= */ 0);
+    }
+
+    private MotionEvent createRotaryEncoderEvent() {
+        return MotionEventUtils.createRotaryEvent(-2);
+    }
+
+    private MotionEvent createPointerEvent() {
+        return MotionEventUtils.createGenericPointerEvent(/* hScroll= */ 0, /* vScroll= */ -1);
+
+    }
+
+    private void deliverEventWithVelocity(MotionEvent ev, int axis, float velocity) {
+        mVelocity = velocity;
+        mFlingHelper.onMotionEvent(ev, axis);
+        ev.recycle();
+    }
+
+    private static class TestDifferentialMotionFlingTarget
+            implements DifferentialMotionFlingHelper.DifferentialMotionFlingTarget {
+        float mLastFlingVelocity = 0;
+        int mNumStops = 0;
+
+        @Override
+        public boolean startDifferentialMotionFling(float velocity) {
+            mLastFlingVelocity = velocity;
+            return true;
+        }
+
+        @Override
+        public void stopDifferentialMotionFling() {
+            mNumStops++;
+        }
+
+        @Override
+        public float getScaledScrollFactor() {
+            return 1;
+        }
+    }
+}
diff --git a/core/tests/coretests/src/android/widget/MotionEventUtils.java b/core/tests/coretests/src/android/widget/MotionEventUtils.java
new file mode 100644
index 0000000..275efa3
--- /dev/null
+++ b/core/tests/coretests/src/android/widget/MotionEventUtils.java
@@ -0,0 +1,69 @@
+/*
+ * 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.
+ */
+
+package android.widget;
+
+import static android.view.InputDevice.SOURCE_CLASS_POINTER;
+import static android.view.InputDevice.SOURCE_ROTARY_ENCODER;
+import static android.view.MotionEvent.ACTION_SCROLL;
+import static android.view.MotionEvent.AXIS_HSCROLL;
+import static android.view.MotionEvent.AXIS_SCROLL;
+import static android.view.MotionEvent.AXIS_VSCROLL;
+
+import android.view.MotionEvent;
+
+/** Test utilities for {@link MotionEvent}s. */
+public class MotionEventUtils {
+
+    /** Creates a test {@link MotionEvent} from a {@link SOURCE_ROTARY_ENCODER}. */
+    public static MotionEvent createRotaryEvent(float scroll) {
+        MotionEvent.PointerCoords coords = new MotionEvent.PointerCoords();
+        coords.setAxisValue(AXIS_SCROLL, scroll);
+
+        return createGenericMotionEvent(SOURCE_ROTARY_ENCODER, ACTION_SCROLL, coords);
+    }
+
+    /** Creates a test {@link MotionEvent} from a {@link SOURCE_CLASS_POINTER}. */
+    public static MotionEvent createGenericPointerEvent(float hScroll, float vScroll) {
+        MotionEvent.PointerCoords coords = new MotionEvent.PointerCoords();
+        coords.setAxisValue(AXIS_HSCROLL, hScroll);
+        coords.setAxisValue(AXIS_VSCROLL, vScroll);
+
+        return createGenericMotionEvent(SOURCE_CLASS_POINTER, ACTION_SCROLL, coords);
+    }
+
+    private static MotionEvent createGenericMotionEvent(
+            int source, int action, MotionEvent.PointerCoords coords) {
+        MotionEvent.PointerProperties props = new MotionEvent.PointerProperties();
+        props.id = 0;
+
+        return MotionEvent.obtain(
+                /* downTime= */ 0,
+                /* eventTime= */ 100,
+                action,
+                /* pointerCount= */ 1,
+                new MotionEvent.PointerProperties[] {props},
+                new MotionEvent.PointerCoords[] {coords},
+                /* metaState= */ 0,
+                /* buttonState= */ 0,
+                /* xPrecision= */ 0,
+                /* yPrecision= */ 0,
+                /* deviceId= */ 1,
+                /* edgeFlags= */ 0,
+                source,
+                /* flags= */ 0);
+    }
+}
diff --git a/core/tests/coretests/src/android/window/WindowContextControllerTest.java b/core/tests/coretests/src/android/window/WindowContextControllerTest.java
index 940c067..30c0f2b 100644
--- a/core/tests/coretests/src/android/window/WindowContextControllerTest.java
+++ b/core/tests/coretests/src/android/window/WindowContextControllerTest.java
@@ -28,6 +28,7 @@
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 
 import android.os.Binder;
@@ -36,7 +37,6 @@
 import androidx.test.filters.SmallTest;
 import androidx.test.runner.AndroidJUnit4;
 
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -62,24 +62,16 @@
     @Mock
     private WindowTokenClient mMockToken;
 
-    private WindowTokenClientController mOriginalController;
-
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
-        mController = new WindowContextController(mMockToken);
+        mController = spy(new WindowContextController(mMockToken));
+        doReturn(mWindowTokenClientController).when(mController).getWindowTokenClientController();
         doNothing().when(mMockToken).onConfigurationChanged(any(), anyInt(), anyBoolean());
-        mOriginalController = WindowTokenClientController.getInstance();
-        WindowTokenClientController.overrideForTesting(mWindowTokenClientController);
         doReturn(true).when(mWindowTokenClientController).attachToDisplayArea(
                 eq(mMockToken), anyInt(), anyInt(), any());
     }
 
-    @After
-    public void tearDown() {
-        WindowTokenClientController.overrideForTesting(mOriginalController);
-    }
-
     @Test(expected = IllegalStateException.class)
     public void testAttachToDisplayAreaTwiceThrowException() {
         mController.attachToDisplayArea(TYPE_APPLICATION_OVERLAY, DEFAULT_DISPLAY,
diff --git a/core/tests/coretests/src/android/window/WindowTokenClientControllerTest.java b/core/tests/coretests/src/android/window/WindowTokenClientControllerTest.java
index 767dd8c..7bd6f05 100644
--- a/core/tests/coretests/src/android/window/WindowTokenClientControllerTest.java
+++ b/core/tests/coretests/src/android/window/WindowTokenClientControllerTest.java
@@ -35,11 +35,9 @@
 import android.os.RemoteException;
 import android.platform.test.annotations.Presubmit;
 import android.view.IWindowManager;
-import android.view.WindowManagerGlobal;
 
 import androidx.test.filters.SmallTest;
 
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
@@ -66,22 +64,16 @@
     // Can't mock final class.
     private final Configuration mConfiguration = new Configuration();
 
-    private IWindowManager mOriginalWindowManagerService;
-
+    private WindowContextInfo mWindowContextInfo;
     private WindowTokenClientController mController;
 
     @Before
     public void setup() {
         MockitoAnnotations.initMocks(this);
-        mOriginalWindowManagerService = WindowManagerGlobal.getWindowManagerService();
-        WindowManagerGlobal.overrideWindowManagerServiceForTesting(mWindowManagerService);
         doReturn(mClientToken).when(mWindowTokenClient).asBinder();
         mController = spy(WindowTokenClientController.createInstanceForTesting());
-    }
-
-    @After
-    public void tearDown() {
-        WindowManagerGlobal.overrideWindowManagerServiceForTesting(mOriginalWindowManagerService);
+        doReturn(mWindowManagerService).when(mController).getWindowManagerService();
+        mWindowContextInfo = new WindowContextInfo(mConfiguration, DEFAULT_DISPLAY);
     }
 
     @Test
@@ -96,7 +88,7 @@
                 TYPE_APPLICATION_OVERLAY, DEFAULT_DISPLAY, null /* options */);
         verify(mWindowTokenClient, never()).onConfigurationChanged(any(), anyInt(), anyBoolean());
 
-        doReturn(mConfiguration).when(mWindowManagerService).attachWindowContextToDisplayArea(
+        doReturn(mWindowContextInfo).when(mWindowManagerService).attachWindowContextToDisplayArea(
                 any(), any(), anyInt(), anyInt(), any());
 
         assertTrue(mController.attachToDisplayArea(mWindowTokenClient, TYPE_APPLICATION_OVERLAY,
@@ -119,13 +111,13 @@
 
         verify(mWindowManagerService, never()).detachWindowContext(any());
 
-        doReturn(mConfiguration).when(mWindowManagerService).attachWindowContextToDisplayArea(
+        doReturn(mWindowContextInfo).when(mWindowManagerService).attachWindowContextToDisplayArea(
                 any(), any(), anyInt(), anyInt(), any());
         mController.attachToDisplayArea(mWindowTokenClient, TYPE_APPLICATION_OVERLAY,
                 DEFAULT_DISPLAY, null /* options */);
         mController.detachIfNeeded(mWindowTokenClient);
 
-        verify(mWindowManagerService).detachWindowContext(any());
+        verify(mWindowManagerService).detachWindowContext(mWindowTokenClient);
     }
 
     @Test
@@ -139,8 +131,8 @@
                 DEFAULT_DISPLAY);
         verify(mWindowTokenClient, never()).onConfigurationChanged(any(), anyInt(), anyBoolean());
 
-        doReturn(mConfiguration).when(mWindowManagerService).attachWindowContextToDisplayContent(
-                any(), any(), anyInt());
+        doReturn(mWindowContextInfo).when(mWindowManagerService)
+                .attachWindowContextToDisplayContent(any(), any(), anyInt());
 
         assertTrue(mController.attachToDisplayContent(mWindowTokenClient, DEFAULT_DISPLAY));
         verify(mWindowTokenClient).onConfigurationChanged(mConfiguration, DEFAULT_DISPLAY,
@@ -160,21 +152,30 @@
 
         verify(mWindowManagerService, never()).detachWindowContext(any());
 
-        doReturn(mConfiguration).when(mWindowManagerService).attachWindowContextToDisplayContent(
-                any(), any(), anyInt());
+        doReturn(mWindowContextInfo).when(mWindowManagerService)
+                .attachWindowContextToDisplayContent(any(), any(), anyInt());
         mController.attachToDisplayContent(mWindowTokenClient, DEFAULT_DISPLAY);
         mController.detachIfNeeded(mWindowTokenClient);
 
-        verify(mWindowManagerService).detachWindowContext(any());
+        verify(mWindowManagerService).detachWindowContext(mWindowTokenClient);
     }
 
     @Test
     public void testAttachToWindowToken() throws RemoteException {
-        mController.attachToWindowToken(mWindowTokenClient, mWindowToken);
+        doReturn(null).when(mWindowManagerService).attachWindowContextToWindowToken(
+                any(), any(), any());
 
+        assertFalse(mController.attachToWindowToken(mWindowTokenClient, mWindowToken));
         verify(mWindowManagerService).attachWindowContextToWindowToken(
                 ActivityThread.currentActivityThread().getApplicationThread(), mWindowTokenClient,
                 mWindowToken);
+        verify(mWindowTokenClient, never()).onConfigurationChanged(any(), anyInt(), anyBoolean());
+
+        doReturn(mWindowContextInfo).when(mWindowManagerService)
+                .attachWindowContextToWindowToken(any(), any(), any());
+
+        assertTrue(mController.attachToWindowToken(mWindowTokenClient, mWindowToken));
+        verify(mWindowTokenClient).postOnConfigurationChanged(mConfiguration, DEFAULT_DISPLAY);
     }
 
     @Test
@@ -183,35 +184,59 @@
 
         verify(mWindowManagerService, never()).detachWindowContext(any());
 
+        doReturn(null).when(mWindowManagerService).attachWindowContextToWindowToken(
+                any(), any(), any());
         mController.attachToWindowToken(mWindowTokenClient, mWindowToken);
         mController.detachIfNeeded(mWindowTokenClient);
 
-        verify(mWindowManagerService).detachWindowContext(any());
+        verify(mWindowManagerService, never()).detachWindowContext(any());
+
+        doReturn(mWindowContextInfo).when(mWindowManagerService).attachWindowContextToWindowToken(
+                any(), any(), any());
+        mController.attachToWindowToken(mWindowTokenClient, mWindowToken);
+        mController.detachIfNeeded(mWindowTokenClient);
+
+        verify(mWindowManagerService).detachWindowContext(mWindowTokenClient);
     }
 
     @Test
-    public void testOnWindowContextConfigurationChanged() {
-        mController.onWindowContextConfigurationChanged(
-                mClientToken, mConfiguration, DEFAULT_DISPLAY);
+    public void testOnWindowContextInfoChanged() throws RemoteException {
+        doReturn(mWindowContextInfo).when(mWindowManagerService)
+                .attachWindowContextToWindowToken(any(), any(), any());
+
+        // No invoke if not attached.
+        mController.onWindowContextInfoChanged(mClientToken, mWindowContextInfo);
 
         verify(mWindowTokenClient, never()).onConfigurationChanged(any(), anyInt());
 
-        mController.attachToWindowToken(mWindowTokenClient, mWindowToken);
+        // Invoke postOnConfigurationChanged when attached
+        assertTrue(mController.attachToWindowToken(mWindowTokenClient, mWindowToken));
 
-        mController.onWindowContextConfigurationChanged(
-                mClientToken, mConfiguration, DEFAULT_DISPLAY);
+        verify(mWindowTokenClient).postOnConfigurationChanged(mConfiguration, DEFAULT_DISPLAY);
 
-        verify(mWindowTokenClient).onConfigurationChanged(mConfiguration, DEFAULT_DISPLAY);
+        // Invoke onConfigurationChanged when onWindowContextInfoChanged
+        mController.onWindowContextInfoChanged(
+                mClientToken, new WindowContextInfo(mConfiguration, DEFAULT_DISPLAY + 1));
+
+        verify(mWindowTokenClient).onConfigurationChanged(mConfiguration, DEFAULT_DISPLAY + 1);
     }
 
     @Test
-    public void testOnWindowContextWindowRemoved() {
+    public void testOnWindowContextWindowRemoved() throws RemoteException {
+        doReturn(mWindowContextInfo).when(mWindowManagerService)
+                .attachWindowContextToWindowToken(any(), any(), any());
+
+        // No invoke if not attached.
         mController.onWindowContextWindowRemoved(mClientToken);
 
         verify(mWindowTokenClient, never()).onWindowTokenRemoved();
 
+        // No invoke if not onWindowTokenRemoved.
         mController.attachToWindowToken(mWindowTokenClient, mWindowToken);
 
+        verify(mWindowTokenClient, never()).onWindowTokenRemoved();
+
+        // Invoke onWindowTokenRemoved when onWindowContextWindowRemoved
         mController.onWindowContextWindowRemoved(mClientToken);
 
         verify(mWindowTokenClient).onWindowTokenRemoved();
diff --git a/core/tests/vibrator/src/android/os/vibrator/PrebakedSegmentTest.java b/core/tests/vibrator/src/android/os/vibrator/PrebakedSegmentTest.java
index 3231192..8268077 100644
--- a/core/tests/vibrator/src/android/os/vibrator/PrebakedSegmentTest.java
+++ b/core/tests/vibrator/src/android/os/vibrator/PrebakedSegmentTest.java
@@ -45,7 +45,6 @@
                 VibrationEffect.EFFECT_CLICK, true, VibrationEffect.EFFECT_STRENGTH_MEDIUM);
 
         assertEquals(-1, prebaked.getDuration());
-        assertTrue(prebaked.hasNonZeroAmplitude());
         assertEquals(VibrationEffect.EFFECT_CLICK, prebaked.getEffectId());
         assertEquals(VibrationEffect.EFFECT_STRENGTH_MEDIUM, prebaked.getEffectStrength());
         assertTrue(prebaked.shouldFallback());
diff --git a/core/tests/vibrator/src/android/os/vibrator/PrimitiveSegmentTest.java b/core/tests/vibrator/src/android/os/vibrator/PrimitiveSegmentTest.java
index 955d6ac..6f5adcd 100644
--- a/core/tests/vibrator/src/android/os/vibrator/PrimitiveSegmentTest.java
+++ b/core/tests/vibrator/src/android/os/vibrator/PrimitiveSegmentTest.java
@@ -46,7 +46,6 @@
                 VibrationEffect.Composition.PRIMITIVE_CLICK, 1, 10);
 
         assertEquals(-1, primitive.getDuration());
-        assertTrue(primitive.hasNonZeroAmplitude());
         assertEquals(VibrationEffect.Composition.PRIMITIVE_CLICK, primitive.getPrimitiveId());
         assertEquals(10, primitive.getDelay());
         assertEquals(1f, primitive.getScale(), TOLERANCE);
diff --git a/core/tests/vibrator/src/android/os/vibrator/RampSegmentTest.java b/core/tests/vibrator/src/android/os/vibrator/RampSegmentTest.java
index dcbb56e..68870e5 100644
--- a/core/tests/vibrator/src/android/os/vibrator/RampSegmentTest.java
+++ b/core/tests/vibrator/src/android/os/vibrator/RampSegmentTest.java
@@ -54,7 +54,6 @@
                 /* startFrequencyHz= */ 100, /* endFrequencyHz= */ 200, /* duration= */ 100);
 
         assertEquals(100L, ramp.getDuration());
-        assertTrue(ramp.hasNonZeroAmplitude());
         assertEquals(1f, ramp.getStartAmplitude());
         assertEquals(0f, ramp.getEndAmplitude());
         assertEquals(100f, ramp.getStartFrequencyHz());
@@ -96,13 +95,6 @@
     }
 
     @Test
-    public void testHasNonZeroAmplitude() {
-        assertTrue(new RampSegment(0, 1, 0, 0, 0).hasNonZeroAmplitude());
-        assertTrue(new RampSegment(0.01f, 0, 0, 0, 0).hasNonZeroAmplitude());
-        assertFalse(new RampSegment(0, 0, 0, 0, 0).hasNonZeroAmplitude());
-    }
-
-    @Test
     public void testResolve() {
         RampSegment ramp = new RampSegment(0, 1, 0, 0, 0);
         assertSame(ramp, ramp.resolve(100));
diff --git a/core/tests/vibrator/src/android/os/vibrator/StepSegmentTest.java b/core/tests/vibrator/src/android/os/vibrator/StepSegmentTest.java
index f9f1c08..34bb892 100644
--- a/core/tests/vibrator/src/android/os/vibrator/StepSegmentTest.java
+++ b/core/tests/vibrator/src/android/os/vibrator/StepSegmentTest.java
@@ -52,7 +52,6 @@
                 /* duration= */ 100);
 
         assertEquals(100, step.getDuration());
-        assertTrue(step.hasNonZeroAmplitude());
         assertEquals(1f, step.getAmplitude());
         assertEquals(1f, step.getFrequencyHz());
     }
@@ -87,14 +86,6 @@
     }
 
     @Test
-    public void testHasNonZeroAmplitude() {
-        assertTrue(new StepSegment(1f, 0, 0).hasNonZeroAmplitude());
-        assertTrue(new StepSegment(0.01f, 0, 0).hasNonZeroAmplitude());
-        assertTrue(new StepSegment(VibrationEffect.DEFAULT_AMPLITUDE, 0, 0).hasNonZeroAmplitude());
-        assertFalse(new StepSegment(0, 0, 0).hasNonZeroAmplitude());
-    }
-
-    @Test
     public void testResolve() {
         StepSegment original = new StepSegment(VibrationEffect.DEFAULT_AMPLITUDE, 0, 0);
         assertEquals(1f, original.resolve(VibrationEffect.MAX_AMPLITUDE).getAmplitude());
diff --git a/data/etc/com.android.systemui.xml b/data/etc/com.android.systemui.xml
index 43683ff..c6a9033 100644
--- a/data/etc/com.android.systemui.xml
+++ b/data/etc/com.android.systemui.xml
@@ -87,5 +87,6 @@
         <permission name="android.permission.SET_UNRESTRICTED_KEEP_CLEAR_AREAS" />
         <permission name="android.permission.READ_SEARCH_INDEXABLES" />
         <permission name="android.permission.ACCESS_AMBIENT_CONTEXT_EVENT"/>
+        <permission name="android.permission.QUERY_CLONED_APPS"/>
     </privapp-permissions>
 </permissions>
diff --git a/libs/WindowManager/Shell/Android.bp b/libs/WindowManager/Shell/Android.bp
index 8bd500e..e9abc7e 100644
--- a/libs/WindowManager/Shell/Android.bp
+++ b/libs/WindowManager/Shell/Android.bp
@@ -150,6 +150,7 @@
     ],
     static_libs: [
         "androidx.appcompat_appcompat",
+        "androidx.core_core-animation",
         "androidx.arch.core_core-runtime",
         "androidx-constraintlayout_constraintlayout",
         "androidx.dynamicanimation_dynamicanimation",
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/animation/FlingAnimationUtils.java b/libs/WindowManager/Shell/src/com/android/wm/shell/animation/FlingAnimationUtils.java
index 798250d..26edd7d 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/animation/FlingAnimationUtils.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/animation/FlingAnimationUtils.java
@@ -117,6 +117,20 @@
      * @param endValue  the end value of the animator
      * @param velocity  the current velocity of the motion
      */
+    public void apply(androidx.core.animation.Animator animator,
+            float currValue, float endValue, float velocity) {
+        apply(animator, currValue, endValue, velocity, Math.abs(endValue - currValue));
+    }
+
+    /**
+     * Applies the interpolator and length to the animator, such that the fling animation is
+     * consistent with the finger motion.
+     *
+     * @param animator  the animator to apply
+     * @param currValue the current value
+     * @param endValue  the end value of the animator
+     * @param velocity  the current velocity of the motion
+     */
     public void apply(ViewPropertyAnimator animator, float currValue, float endValue,
             float velocity) {
         apply(animator, currValue, endValue, velocity, Math.abs(endValue - currValue));
@@ -152,6 +166,24 @@
      * @param maxDistance the maximum distance for this interaction; the maximum animation length
      *                    gets multiplied by the ratio between the actual distance and this value
      */
+    public void apply(androidx.core.animation.Animator animator,
+            float currValue, float endValue, float velocity, float maxDistance) {
+        AnimatorProperties properties = getProperties(currValue, endValue, velocity, maxDistance);
+        animator.setDuration(properties.mDuration);
+        animator.setInterpolator(properties.getInterpolator());
+    }
+
+    /**
+     * Applies the interpolator and length to the animator, such that the fling animation is
+     * consistent with the finger motion.
+     *
+     * @param animator    the animator to apply
+     * @param currValue   the current value
+     * @param endValue    the end value of the animator
+     * @param velocity    the current velocity of the motion
+     * @param maxDistance the maximum distance for this interaction; the maximum animation length
+     *                    gets multiplied by the ratio between the actual distance and this value
+     */
     public void apply(ViewPropertyAnimator animator, float currValue, float endValue,
             float velocity, float maxDistance) {
         AnimatorProperties properties = getProperties(currValue, endValue, velocity,
@@ -367,6 +399,11 @@
     private static class AnimatorProperties {
         Interpolator mInterpolator;
         long mDuration;
+
+        /** Get an AndroidX interpolator wrapper of the current mInterpolator */
+        public androidx.core.animation.Interpolator getInterpolator() {
+            return mInterpolator::getInterpolation;
+        }
     }
 
     /** Builder for {@link #FlingAnimationUtils}. */
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleDataRepository.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleDataRepository.kt
index 896a334..df12999 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleDataRepository.kt
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleDataRepository.kt
@@ -103,7 +103,8 @@
      * Removes all entities that don't have a user in the activeUsers list, if any entities were
      * removed it persists the new list to disk.
      */
-    private fun filterForActiveUsersAndPersist(
+    @VisibleForTesting
+    fun filterForActiveUsersAndPersist(
             activeUsers: List<Int>,
             entitiesByUser: SparseArray<List<BubbleEntity>>
     ): SparseArray<List<BubbleEntity>> {
@@ -167,7 +168,8 @@
      * Job C resumes and reaches yield() and is then cancelled
      * Job D resumes and performs another blocking I/O
      */
-    private fun persistToDisk(
+    @VisibleForTesting
+    fun persistToDisk(
             entitiesByUser: SparseArray<List<BubbleEntity>> = volatileRepository.bubbles
     ) {
         val prev = job
@@ -188,7 +190,6 @@
      *           bubbles.
      */
     @SuppressLint("WrongConstant")
-    @VisibleForTesting
     fun loadBubbles(
             userId: Int,
             currentUsers: List<Int>,
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 f8d7b6b..9bc28a46 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
@@ -730,7 +730,7 @@
      *
      * @param taskInfo the task being dragged.
      * @param position position of surface when drag ends.
-     * @param y the Y position of the motion event.
+     * @param y the Y position of the top edge of the task
      * @param windowDecor the window decoration for the task being dragged
      */
     fun onDragPositioningEnd(
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java
index 5b9e47f..7d82dc17 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java
@@ -352,6 +352,10 @@
                             mMainExecutor.executeDelayed(
                                     mMovePipInResponseToKeepClearAreasChangeCallback,
                                     PIP_KEEP_CLEAR_AREAS_DELAY);
+
+                            ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
+                                    "onKeepClearAreasChanged: restricted=%s, unrestricted=%s",
+                                    restricted, unrestricted);
                         }
                     }
                 }
@@ -950,6 +954,8 @@
     }
 
     private void setLauncherKeepClearAreaHeight(boolean visible, int height) {
+        ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
+                "setLauncherKeepClearAreaHeight: visible=%b, height=%d", visible, height);
         if (visible) {
             Rect rect = new Rect(
                     0, mPipBoundsState.getDisplayBounds().bottom - height,
@@ -1007,9 +1013,10 @@
             int launcherRotation, Rect hotseatKeepClearArea) {
 
         if (mEnablePipKeepClearAlgorithm) {
-            // pre-emptively add the keep clear area for Hotseat, so that it is taken into account
+            // preemptively add the keep clear area for Hotseat, so that it is taken into account
             // when calculating the entry destination bounds of PiP window
-            mPipBoundsState.getRestrictedKeepClearAreas().add(hotseatKeepClearArea);
+            mPipBoundsState.addNamedUnrestrictedKeepClearArea(LAUNCHER_KEEP_CLEAR_AREA_TAG,
+                    hotseatKeepClearArea);
         } else {
             int shelfHeight = hotseatKeepClearArea.height();
             setShelfHeightLocked(shelfHeight > 0 /* visible */, shelfHeight);
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java
index 2d7e6a6..ea9976d 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java
@@ -429,10 +429,10 @@
                         mDragPointerId = e.getPointerId(0);
                     }
                     final int dragPointerIdx = e.findPointerIndex(mDragPointerId);
-                    mDesktopTasksController.ifPresent(c -> c.onDragPositioningMove(taskInfo,
-                            decoration.mTaskSurface, e.getRawY(dragPointerIdx)));
-                    mDragPositioningCallback.onDragPositioningMove(
+                    final Rect newTaskBounds = mDragPositioningCallback.onDragPositioningMove(
                             e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx));
+                    mDesktopTasksController.ifPresent(c -> c.onDragPositioningMove(taskInfo,
+                            decoration.mTaskSurface, newTaskBounds.top));
                     mIsDragging = true;
                     mShouldClick = false;
                     return true;
@@ -458,10 +458,10 @@
                     final Point position = new Point(
                             (int) (e.getRawX(dragPointerIdx) - e.getX(dragPointerIdx)),
                             (int) (e.getRawY(dragPointerIdx) - e.getY(dragPointerIdx)));
-                    mDragPositioningCallback.onDragPositioningEnd(
+                    final Rect newTaskBounds = mDragPositioningCallback.onDragPositioningEnd(
                             e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx));
                     mDesktopTasksController.ifPresent(c -> c.onDragPositioningEnd(taskInfo,
-                            position, e.getRawY(), mWindowDecorByTaskId.get(mTaskId)));
+                            position, newTaskBounds.top, mWindowDecorByTaskId.get(mTaskId)));
                     mIsDragging = false;
                     return true;
                 }
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DragPositioningCallback.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DragPositioningCallback.java
index 941617d..1669cf4 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DragPositioningCallback.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DragPositioningCallback.java
@@ -17,6 +17,7 @@
 package com.android.wm.shell.windowdecor;
 
 import android.annotation.IntDef;
+import android.graphics.Rect;
 
 /**
  * Callback called when receiving drag-resize or drag-move related input events.
@@ -46,13 +47,15 @@
      * Called when the pointer moves during a drag-resize or drag-move.
      * @param x x coordinate in window decoration coordinate system of the new pointer location
      * @param y y coordinate in window decoration coordinate system of the new pointer location
+     * @return the updated task bounds
      */
-    void onDragPositioningMove(float x, float y);
+    Rect onDragPositioningMove(float x, float y);
 
     /**
      * Called when a drag-resize or drag-move stops.
      * @param x x coordinate in window decoration coordinate system where the drag resize stops
      * @param y y coordinate in window decoration coordinate system where the drag resize stops
+     * @return the final bounds for the dragged task
      */
-    void onDragPositioningEnd(float x, float y);
+    Rect onDragPositioningEnd(float x, float y);
 }
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/FluidResizeTaskPositioner.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/FluidResizeTaskPositioner.java
index e1b6db5..e0ee252 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/FluidResizeTaskPositioner.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/FluidResizeTaskPositioner.java
@@ -85,7 +85,7 @@
     }
 
     @Override
-    public void onDragPositioningMove(float x, float y) {
+    public Rect onDragPositioningMove(float x, float y) {
         final WindowContainerTransaction wct = new WindowContainerTransaction();
         PointF delta = DragPositioningCallbackUtility.calculateDelta(x, y, mRepositionStartPoint);
         if (isResizing() && DragPositioningCallbackUtility.changeBounds(mCtrlType,
@@ -106,10 +106,11 @@
                     mRepositionTaskBounds, mTaskBoundsAtDragStart, mRepositionStartPoint, t, x, y);
             t.apply();
         }
+        return new Rect(mRepositionTaskBounds);
     }
 
     @Override
-    public void onDragPositioningEnd(float x, float y) {
+    public Rect onDragPositioningEnd(float x, float y) {
         // If task has been resized or task was dragged into area outside of
         // mDisallowedAreaForEndBounds, apply WCT to finish it.
         if (isResizing() && mHasDragResized) {
@@ -136,6 +137,7 @@
         mRepositionStartPoint.set(0, 0);
         mCtrlType = CTRL_TYPE_UNDEFINED;
         mHasDragResized = false;
+        return new Rect(mRepositionTaskBounds);
     }
 
     private boolean isResizing() {
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/VeiledResizeTaskPositioner.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/VeiledResizeTaskPositioner.java
index ae3b5eb..fb05c69 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/VeiledResizeTaskPositioner.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/VeiledResizeTaskPositioner.java
@@ -105,7 +105,7 @@
     }
 
     @Override
-    public void onDragPositioningMove(float x, float y) {
+    public Rect onDragPositioningMove(float x, float y) {
         PointF delta = DragPositioningCallbackUtility.calculateDelta(x, y, mRepositionStartPoint);
         if (isResizing() && DragPositioningCallbackUtility.changeBounds(mCtrlType,
                 mRepositionTaskBounds, mTaskBoundsAtDragStart, mStableBounds, delta,
@@ -117,10 +117,11 @@
                     mRepositionTaskBounds, mTaskBoundsAtDragStart, mRepositionStartPoint, t, x, y);
             t.apply();
         }
+        return new Rect(mRepositionTaskBounds);
     }
 
     @Override
-    public void onDragPositioningEnd(float x, float y) {
+    public Rect onDragPositioningEnd(float x, float y) {
         PointF delta = DragPositioningCallbackUtility.calculateDelta(x, y,
                 mRepositionStartPoint);
         if (isResizing()) {
@@ -151,6 +152,7 @@
         mCtrlType = CTRL_TYPE_UNDEFINED;
         mTaskBoundsAtDragStart.setEmpty();
         mRepositionStartPoint.set(0, 0);
+        return new Rect(mRepositionTaskBounds);
     }
 
     private boolean isResizing() {
diff --git a/libs/WindowManager/Shell/tests/flicker/Android.bp b/libs/WindowManager/Shell/tests/flicker/Android.bp
index 0947723..dfbadae 100644
--- a/libs/WindowManager/Shell/tests/flicker/Android.bp
+++ b/libs/WindowManager/Shell/tests/flicker/Android.bp
@@ -51,14 +51,18 @@
 }
 
 filegroup {
-    name: "WMShellFlickerTestsSplitScreenEnter-src",
+    name: "WMShellFlickerTestsSplitScreenGroup1-src",
     srcs: [
-        "src/com/android/wm/shell/flicker/splitscreen/Enter*.kt",
+        "src/com/android/wm/shell/flicker/splitscreen/A*.kt",
+        "src/com/android/wm/shell/flicker/splitscreen/B*.kt",
+        "src/com/android/wm/shell/flicker/splitscreen/C*.kt",
+        "src/com/android/wm/shell/flicker/splitscreen/D*.kt",
+        "src/com/android/wm/shell/flicker/splitscreen/E*.kt",
     ],
 }
 
 filegroup {
-    name: "WMShellFlickerTestsSplitScreenOther-src",
+    name: "WMShellFlickerTestsSplitScreenGroup2-src",
     srcs: [
         "src/com/android/wm/shell/flicker/splitscreen/*.kt",
     ],
@@ -135,8 +139,8 @@
     exclude_srcs: [
         ":WMShellFlickerTestsBubbles-src",
         ":WMShellFlickerTestsPip-src",
-        ":WMShellFlickerTestsSplitScreenEnter-src",
-        ":WMShellFlickerTestsSplitScreenOther-src",
+        ":WMShellFlickerTestsSplitScreenGroup1-src",
+        ":WMShellFlickerTestsSplitScreenGroup2-src",
         ":WMShellFlickerTestsSplitScreenBase-src",
         ":WMShellFlickerServiceTests-src",
     ],
@@ -167,7 +171,7 @@
 }
 
 android_test {
-    name: "WMShellFlickerTestsSplitScreenEnter",
+    name: "WMShellFlickerTestsSplitScreenGroup1",
     defaults: ["WMShellFlickerTestsDefault"],
     additional_manifests: ["manifests/AndroidManifestSplitScreen.xml"],
     package_name: "com.android.wm.shell.flicker.splitscreen",
@@ -175,12 +179,12 @@
     srcs: [
         ":WMShellFlickerTestsBase-src",
         ":WMShellFlickerTestsSplitScreenBase-src",
-        ":WMShellFlickerTestsSplitScreenEnter-src",
+        ":WMShellFlickerTestsSplitScreenGroup1-src",
     ],
 }
 
 android_test {
-    name: "WMShellFlickerTestsSplitScreenOther",
+    name: "WMShellFlickerTestsSplitScreenGroup2",
     defaults: ["WMShellFlickerTestsDefault"],
     additional_manifests: ["manifests/AndroidManifestSplitScreen.xml"],
     package_name: "com.android.wm.shell.flicker.splitscreen",
@@ -188,10 +192,10 @@
     srcs: [
         ":WMShellFlickerTestsBase-src",
         ":WMShellFlickerTestsSplitScreenBase-src",
-        ":WMShellFlickerTestsSplitScreenOther-src",
+        ":WMShellFlickerTestsSplitScreenGroup2-src",
     ],
     exclude_srcs: [
-        ":WMShellFlickerTestsSplitScreenEnter-src",
+        ":WMShellFlickerTestsSplitScreenGroup1-src",
     ],
 }
 
diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/MovePipDownOnShelfHeightChange.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/MovePipDownOnShelfHeightChange.kt
index 13aa758..5efa51b 100644
--- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/MovePipDownOnShelfHeightChange.kt
+++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/MovePipDownOnShelfHeightChange.kt
@@ -16,7 +16,7 @@
 
 package com.android.wm.shell.flicker.pip
 
-import android.platform.test.annotations.FlakyTest
+import android.platform.test.annotations.Presubmit
 import android.tools.device.flicker.junit.FlickerParametersRunnerFactory
 import android.tools.device.flicker.legacy.FlickerBuilder
 import android.tools.device.flicker.legacy.LegacyFlickerTest
@@ -63,10 +63,12 @@
     }
 
     /** Checks that the visible region of [pipApp] window always moves down during the animation. */
-    @FlakyTest(bugId = 292813143) @Test fun pipWindowMovesDown() = pipWindowMoves(Direction.DOWN)
+    @Presubmit
+    @Test
+    fun pipWindowMovesDown() = pipWindowMoves(Direction.DOWN)
 
     /** Checks that the visible region of [pipApp] layer always moves down during the animation. */
-    @FlakyTest(bugId = 292813143)
+    @Presubmit
     @Test
     fun pipLayerMovesDown() = pipLayerMoves(Direction.DOWN)
 }
diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/UnlockKeyguardToSplitScreen.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/UnlockKeyguardToSplitScreen.kt
index 851391d..10dceba 100644
--- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/UnlockKeyguardToSplitScreen.kt
+++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/UnlockKeyguardToSplitScreen.kt
@@ -16,9 +16,13 @@
 
 package com.android.wm.shell.flicker.splitscreen
 
+import android.platform.test.annotations.FlakyTest
 import android.platform.test.annotations.Postsubmit
+import android.platform.test.annotations.Presubmit
 import android.tools.common.NavBar
+import android.tools.common.flicker.subject.layers.LayersTraceSubject
 import android.tools.common.flicker.subject.region.RegionSubject
+import android.tools.common.traces.component.ComponentNameMatcher.Companion.WALLPAPER_BBQ_WRAPPER
 import android.tools.device.flicker.junit.FlickerParametersRunnerFactory
 import android.tools.device.flicker.legacy.FlickerBuilder
 import android.tools.device.flicker.legacy.LegacyFlickerTest
@@ -57,6 +61,21 @@
         }
 
     @Test
+    @FlakyTest(bugId = 293578017)
+    override fun visibleLayersShownMoreThanOneConsecutiveEntry() =
+        super.visibleLayersShownMoreThanOneConsecutiveEntry()
+
+    // TODO(b/293578017) remove once that bug is resolve
+    @Test
+    @Presubmit
+    fun visibleLayersShownMoreThanOneConsecutiveEntry_withoutWallpaper() =
+        flicker.assertLayers { this.visibleLayersShownMoreThanOneConsecutiveEntry(
+            LayersTraceSubject.VISIBLE_FOR_MORE_THAN_ONE_ENTRY_IGNORE_LAYERS + listOf(
+                WALLPAPER_BBQ_WRAPPER
+            )
+        ) }
+
+    @Test
     fun splitScreenDividerIsVisibleAtEnd() {
         flicker.assertLayersEnd { this.isVisible(SPLIT_SCREEN_DIVIDER_COMPONENT) }
     }
diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/utils/CommonAssertions.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/utils/CommonAssertions.kt
index e5c124c..f1cb37e 100644
--- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/utils/CommonAssertions.kt
+++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/utils/CommonAssertions.kt
@@ -265,6 +265,7 @@
         val dividerRegion =
             layer(SPLIT_SCREEN_DIVIDER_COMPONENT)?.visibleRegion?.region
                 ?: error("$SPLIT_SCREEN_DIVIDER_COMPONENT component not found")
+        visibleRegion(component).isNotEmpty()
         visibleRegion(component)
             .coversAtMost(
                 if (displayBounds.width > displayBounds.height) {
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/BubbleDataRepositoryTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/BubbleDataRepositoryTest.kt
index 6d9d62d..0e05e01 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/BubbleDataRepositoryTest.kt
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/BubbleDataRepositoryTest.kt
@@ -18,18 +18,22 @@
 
 import android.app.ActivityTaskManager
 import android.content.pm.LauncherApps
-import android.content.pm.ShortcutInfo
+import android.os.Handler
+import android.os.Looper
 import android.util.SparseArray
 import com.android.wm.shell.ShellTestCase
 import com.android.wm.shell.bubbles.storage.BubbleEntity
 import com.android.wm.shell.bubbles.storage.BubblePersistentRepository
-import com.android.wm.shell.common.ShellExecutor
+import com.android.wm.shell.common.HandlerExecutor
 import com.google.common.truth.Truth.assertThat
 import org.junit.After
 import org.junit.Before
 import org.junit.Test
+import org.mockito.Mockito
 import org.mockito.Mockito.mock
+import org.mockito.Mockito.never
 import org.mockito.Mockito.spy
+import org.mockito.Mockito.verify
 
 class BubbleDataRepositoryTest : ShellTestCase() {
 
@@ -118,7 +122,8 @@
         )
     )
 
-    private val mainExecutor = mock(ShellExecutor::class.java)
+    private val testHandler = Handler(Looper.getMainLooper())
+    private val mainExecutor = HandlerExecutor(testHandler)
     private val launcherApps = mock(LauncherApps::class.java)
 
     private val persistedBubbles = SparseArray<List<BubbleEntity>>()
@@ -128,13 +133,11 @@
 
     @Before
     fun setup() {
-        persistentRepository = spy(BubblePersistentRepository(mContext))
-        dataRepository = BubbleDataRepository(launcherApps, mainExecutor, persistentRepository)
+        persistentRepository = BubblePersistentRepository(mContext)
+        dataRepository = spy(BubbleDataRepository(launcherApps, mainExecutor, persistentRepository))
 
-        // Add the bubbles to the persistent repository
         persistedBubbles.put(0, user0BubbleEntities)
         persistedBubbles.put(1, user1BubbleEntities)
-        persistentRepository.persistsToDisk(persistedBubbles)
     }
 
     @After
@@ -144,47 +147,58 @@
     }
 
     @Test
-    fun testLoadBubbles_invalidParent() {
-        val activeUserIds = listOf(10, 1, 12) // Missing user 0 in persistedBubbles
-        dataRepository.loadBubbles(1, activeUserIds) {
-            // Verify that user 0 has been removed from the persisted list
-            val entitiesByUser = persistentRepository.readFromDisk()
-            assertThat(entitiesByUser.get(0)).isNull()
-        }
+    fun testFilterForActiveUsersAndPersist_allValid() {
+        // Matches all the users in user0BubbleEntities & user1BubbleEntities
+        val activeUserIds = listOf(0, 10, 1, 12)
+
+        val validEntitiesByUser = dataRepository.filterForActiveUsersAndPersist(
+            activeUserIds, persistedBubbles)
+
+        // No invalid users, so no changes
+        assertThat(persistedBubbles).isEqualTo(validEntitiesByUser)
+
+        // No invalid users, so no persist to disk happened
+        verify(dataRepository, never()).persistToDisk(
+            any(SparseArray<List<BubbleEntity>>()::class.java))
     }
 
     @Test
-    fun testLoadBubbles_invalidChild() {
+    fun testFilterForActiveUsersAndPersist_invalidParent() {
+        // When we start, we do have user 0 bubbles.
+        assertThat(persistedBubbles.get(0)).isNotEmpty()
+
+        val activeUserIds = listOf(10, 1, 12) // Missing user 0
+        val validEntitiesByUser = dataRepository.filterForActiveUsersAndPersist(
+            activeUserIds, persistedBubbles)
+
+        // We no longer have any user 0 bubbles.
+        assertThat(validEntitiesByUser.get(0)).isNull()
+        // User 1 bubbles should be the same.
+        assertThat(validEntitiesByUser.get(1)).isEqualTo(user1BubbleEntities)
+
+        // Verify that persist to disk happened with the new valid entities list.
+        verify(dataRepository).persistToDisk(validEntitiesByUser)
+    }
+
+    @Test
+    fun testFilterForActiveUsersAndPersist_invalidChild() {
+        // Build a list to compare against (remove all user 12 bubbles)
+        val (user1EntitiesWithUser12, user1EntitiesWithoutUser12) =
+            user1BubbleEntities.partition { it.userId == 12 }
+
+        // Verify we start with user 12 bubbles
+        assertThat(persistedBubbles.get(1).containsAll(user1EntitiesWithUser12)).isTrue()
+
         val activeUserIds = listOf(0, 10, 1) // Missing user 1's child user 12
-        dataRepository.loadBubbles(1, activeUserIds) {
-            // Build a list to compare against
-            val user1BubblesWithoutUser12 = mutableListOf<Bubble>()
-            val user1EntitiesWithoutUser12 = mutableListOf<BubbleEntity>()
-            for (entity in user1BubbleEntities) {
-                if (entity.userId != 12) {
-                    user1BubblesWithoutUser12.add(entity.toBubble())
-                    user1EntitiesWithoutUser12.add(entity)
-                }
-            }
+        val validEntitiesByUser = dataRepository.filterForActiveUsersAndPersist(
+            activeUserIds, persistedBubbles)
 
-            // Verify that user 12 has been removed from the persisted list
-            val entitiesByUser = persistentRepository.readFromDisk()
-            assertThat(entitiesByUser.get(1)).isEqualTo(user1EntitiesWithoutUser12)
-        }
+        // We no longer have any user 12 bubbles.
+        assertThat(validEntitiesByUser.get(1)).isEqualTo(user1EntitiesWithoutUser12)
+
+        // Verify that persist to disk happened with the new valid entities list.
+        verify(dataRepository).persistToDisk(validEntitiesByUser)
     }
 
-    private fun BubbleEntity.toBubble(): Bubble {
-        return Bubble(
-            key,
-            mock(ShortcutInfo::class.java),
-            desiredHeight,
-            desiredHeightResId,
-            title,
-            taskId,
-            locus,
-            isDismissable,
-            mainExecutor,
-            mock(Bubbles.BubbleMetadataFlagListener::class.java)
-        )
-    }
+    fun <T> any(type: Class<T>): T = Mockito.any<T>(type)
 }
\ No newline at end of file
diff --git a/native/android/performance_hint.cpp b/native/android/performance_hint.cpp
index b3628fa..6198f40 100644
--- a/native/android/performance_hint.cpp
+++ b/native/android/performance_hint.cpp
@@ -274,9 +274,10 @@
     binder::Status ret = mHintManager->setHintSessionThreads(mHintSession, tids);
     if (!ret.isOk()) {
         ALOGE("%s: failed: %s", __FUNCTION__, ret.exceptionMessage().c_str());
-        if (ret.exceptionCode() == binder::Status::Exception::EX_SECURITY ||
-            ret.exceptionCode() == binder::Status::Exception::EX_ILLEGAL_ARGUMENT) {
+        if (ret.exceptionCode() == binder::Status::Exception::EX_ILLEGAL_ARGUMENT) {
             return EINVAL;
+        } else if (ret.exceptionCode() == binder::Status::Exception::EX_SECURITY) {
+            return EPERM;
         }
         return EPIPE;
     }
diff --git a/native/android/tests/performance_hint/PerformanceHintNativeTest.cpp b/native/android/tests/performance_hint/PerformanceHintNativeTest.cpp
index 791adfd..6f7562b 100644
--- a/native/android/tests/performance_hint/PerformanceHintNativeTest.cpp
+++ b/native/android/tests/performance_hint/PerformanceHintNativeTest.cpp
@@ -178,4 +178,15 @@
             .WillOnce(Return(Status()));
     result = APerformanceHint_setThreads(session, newTids.data(), newTids.size());
     EXPECT_EQ(0, result);
+
+    testing::Mock::VerifyAndClearExpectations(mMockIHintManager);
+    std::vector<int32_t> invalidTids;
+    auto status = Status::fromExceptionCode(binder::Status::Exception::EX_SECURITY);
+    invalidTids.push_back(4);
+    invalidTids.push_back(6);
+    EXPECT_CALL(*mMockIHintManager, setHintSessionThreads(_, Eq(invalidTids)))
+            .Times(Exactly(1))
+            .WillOnce(Return(status));
+    result = APerformanceHint_setThreads(session, invalidTids.data(), invalidTids.size());
+    EXPECT_EQ(EPERM, result);
 }
diff --git a/packages/PackageInstaller/src/com/android/packageinstaller/EventResultPersister.java b/packages/PackageInstaller/src/com/android/packageinstaller/EventResultPersister.java
index 8639f47..0d1475a 100644
--- a/packages/PackageInstaller/src/com/android/packageinstaller/EventResultPersister.java
+++ b/packages/PackageInstaller/src/com/android/packageinstaller/EventResultPersister.java
@@ -16,6 +16,8 @@
 
 package com.android.packageinstaller;
 
+import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
+
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.PackageInstaller;
@@ -186,7 +188,9 @@
         int status = intent.getIntExtra(PackageInstaller.EXTRA_STATUS, 0);
 
         if (status == PackageInstaller.STATUS_PENDING_USER_ACTION) {
-            context.startActivity(intent.getParcelableExtra(Intent.EXTRA_INTENT));
+            Intent intentToStart = intent.getParcelableExtra(Intent.EXTRA_INTENT);
+            intentToStart.addFlags(FLAG_ACTIVITY_NEW_TASK);
+            context.startActivity(intentToStart);
 
             return;
         }
diff --git a/packages/SettingsLib/Android.bp b/packages/SettingsLib/Android.bp
index c244ca0..3d35bad 100644
--- a/packages/SettingsLib/Android.bp
+++ b/packages/SettingsLib/Android.bp
@@ -58,6 +58,7 @@
         "setupdesign",
         "zxing-core-1.7",
         "androidx.room_room-runtime",
+        "settingslib_flags_lib",
 
     ],
 
@@ -88,3 +89,16 @@
         "SettingsLib",
     ],
 }
+
+aconfig_declarations {
+    name: "settingslib_media_flags",
+    package: "com.android.settingslib.media.flags",
+    srcs: [
+        "aconfig/settingslib_media_flag_declarations.aconfig",
+    ],
+}
+
+java_aconfig_library {
+    name: "settingslib_flags_lib",
+    aconfig_declarations: "settingslib_media_flags",
+}
diff --git a/packages/SettingsLib/AndroidManifest.xml b/packages/SettingsLib/AndroidManifest.xml
index 13f8a37..322d6cf 100644
--- a/packages/SettingsLib/AndroidManifest.xml
+++ b/packages/SettingsLib/AndroidManifest.xml
@@ -18,6 +18,8 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.android.settingslib">
 
+    <uses-permission android:name="android.permission.READ_DEVICE_CONFIG" />
+
     <application>
         <activity
             android:name="com.android.settingslib.users.AvatarPickerActivity"
diff --git a/packages/SettingsLib/Spa/gradle/libs.versions.toml b/packages/SettingsLib/Spa/gradle/libs.versions.toml
index 9a16df8..ee40b02 100644
--- a/packages/SettingsLib/Spa/gradle/libs.versions.toml
+++ b/packages/SettingsLib/Spa/gradle/libs.versions.toml
@@ -15,7 +15,7 @@
 #
 
 [versions]
-agp = "8.0.2"
+agp = "8.1.0"
 dexmaker-mockito = "2.28.3"
 kotlin = "1.8.10"
 truth = "1.1"
diff --git a/packages/SettingsLib/Spa/gradle/wrapper/gradle-wrapper.jar b/packages/SettingsLib/Spa/gradle/wrapper/gradle-wrapper.jar
index e708b1c..c1962a7 100644
--- a/packages/SettingsLib/Spa/gradle/wrapper/gradle-wrapper.jar
+++ b/packages/SettingsLib/Spa/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/packages/SettingsLib/Spa/gradle/wrapper/gradle-wrapper.properties b/packages/SettingsLib/Spa/gradle/wrapper/gradle-wrapper.properties
index 33f49e3..5b0ac44 100644
--- a/packages/SettingsLib/Spa/gradle/wrapper/gradle-wrapper.properties
+++ b/packages/SettingsLib/Spa/gradle/wrapper/gradle-wrapper.properties
@@ -15,7 +15,7 @@
 #
 
 distributionBase=GRADLE_USER_HOME
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
 distributionPath=wrapper/dists
-zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
 zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/packages/SettingsLib/Spa/gradlew b/packages/SettingsLib/Spa/gradlew
index 4f906e0..aeb74cb 100755
--- a/packages/SettingsLib/Spa/gradlew
+++ b/packages/SettingsLib/Spa/gradlew
@@ -1,7 +1,7 @@
-#!/usr/bin/env sh
+#!/bin/sh
 
 #
-# Copyright 2015 the original author or authors.
+# Copyright © 2015-2021 the original authors.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -17,67 +17,98 @@
 #
 
 ##############################################################################
-##
-##  Gradle start up script for UN*X
-##
+#
+#   Gradle start up script for POSIX generated by Gradle.
+#
+#   Important for running:
+#
+#   (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+#       noncompliant, but you have some other compliant shell such as ksh or
+#       bash, then to run this script, type that shell name before the whole
+#       command line, like:
+#
+#           ksh Gradle
+#
+#       Busybox and similar reduced shells will NOT work, because this script
+#       requires all of these POSIX shell features:
+#         * functions;
+#         * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+#           «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+#         * compound commands having a testable exit status, especially «case»;
+#         * various built-in commands including «command», «set», and «ulimit».
+#
+#   Important for patching:
+#
+#   (2) This script targets any POSIX shell, so it avoids extensions provided
+#       by Bash, Ksh, etc; in particular arrays are avoided.
+#
+#       The "traditional" practice of packing multiple parameters into a
+#       space-separated string is a well documented source of bugs and security
+#       problems, so this is (mostly) avoided, by progressively accumulating
+#       options in "$@", and eventually passing that to Java.
+#
+#       Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+#       and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+#       see the in-line comments for details.
+#
+#       There are tweaks for specific operating systems such as AIX, CygWin,
+#       Darwin, MinGW, and NonStop.
+#
+#   (3) This script is generated from the Groovy template
+#       https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+#       within the Gradle project.
+#
+#       You can find Gradle at https://github.com/gradle/gradle/.
+#
 ##############################################################################
 
 # Attempt to set APP_HOME
+
 # Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
-    ls=`ls -ld "$PRG"`
-    link=`expr "$ls" : '.*-> \(.*\)$'`
-    if expr "$link" : '/.*' > /dev/null; then
-        PRG="$link"
-    else
-        PRG=`dirname "$PRG"`"/$link"
-    fi
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+    APP_HOME=${app_path%"${app_path##*/}"}  # leaves a trailing /; empty if no leading path
+    [ -h "$app_path" ]
+do
+    ls=$( ls -ld "$app_path" )
+    link=${ls#*' -> '}
+    case $link in             #(
+      /*)   app_path=$link ;; #(
+      *)    app_path=$APP_HOME$link ;;
+    esac
 done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
 
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+# This is normally unused
+# shellcheck disable=SC2034
+APP_BASE_NAME=${0##*/}
+APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
 
 # Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
+MAX_FD=maximum
 
 warn () {
     echo "$*"
-}
+} >&2
 
 die () {
     echo
     echo "$*"
     echo
     exit 1
-}
+} >&2
 
 # OS specific support (must be 'true' or 'false').
 cygwin=false
 msys=false
 darwin=false
 nonstop=false
-case "`uname`" in
-  CYGWIN* )
-    cygwin=true
-    ;;
-  Darwin* )
-    darwin=true
-    ;;
-  MINGW* )
-    msys=true
-    ;;
-  NONSTOP* )
-    nonstop=true
-    ;;
+case "$( uname )" in                #(
+  CYGWIN* )         cygwin=true  ;; #(
+  Darwin* )         darwin=true  ;; #(
+  MSYS* | MINGW* )  msys=true    ;; #(
+  NONSTOP* )        nonstop=true ;;
 esac
 
 CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
@@ -87,9 +118,9 @@
 if [ -n "$JAVA_HOME" ] ; then
     if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
         # IBM's JDK on AIX uses strange locations for the executables
-        JAVACMD="$JAVA_HOME/jre/sh/java"
+        JAVACMD=$JAVA_HOME/jre/sh/java
     else
-        JAVACMD="$JAVA_HOME/bin/java"
+        JAVACMD=$JAVA_HOME/bin/java
     fi
     if [ ! -x "$JAVACMD" ] ; then
         die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@@ -98,7 +129,7 @@
 location of your Java installation."
     fi
 else
-    JAVACMD="java"
+    JAVACMD=java
     which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
 
 Please set the JAVA_HOME variable in your environment to match the
@@ -106,80 +137,109 @@
 fi
 
 # Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
-    MAX_FD_LIMIT=`ulimit -H -n`
-    if [ $? -eq 0 ] ; then
-        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
-            MAX_FD="$MAX_FD_LIMIT"
-        fi
-        ulimit -n $MAX_FD
-        if [ $? -ne 0 ] ; then
-            warn "Could not set maximum file descriptor limit: $MAX_FD"
-        fi
-    else
-        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
-    fi
-fi
-
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
-    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
-
-# For Cygwin or MSYS, switch paths to Windows format before running java
-if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
-    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
-    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
-
-    JAVACMD=`cygpath --unix "$JAVACMD"`
-
-    # We build the pattern for arguments to be converted via cygpath
-    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
-    SEP=""
-    for dir in $ROOTDIRSRAW ; do
-        ROOTDIRS="$ROOTDIRS$SEP$dir"
-        SEP="|"
-    done
-    OURCYGPATTERN="(^($ROOTDIRS))"
-    # Add a user-defined pattern to the cygpath arguments
-    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
-        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
-    fi
-    # Now convert the arguments - kludge to limit ourselves to /bin/sh
-    i=0
-    for arg in "$@" ; do
-        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
-        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
-
-        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
-            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
-        else
-            eval `echo args$i`="\"$arg\""
-        fi
-        i=`expr $i + 1`
-    done
-    case $i in
-        0) set -- ;;
-        1) set -- "$args0" ;;
-        2) set -- "$args0" "$args1" ;;
-        3) set -- "$args0" "$args1" "$args2" ;;
-        4) set -- "$args0" "$args1" "$args2" "$args3" ;;
-        5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
-        6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
-        7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
-        8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
-        9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+    case $MAX_FD in #(
+      max*)
+        # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
+        # shellcheck disable=SC3045
+        MAX_FD=$( ulimit -H -n ) ||
+            warn "Could not query maximum file descriptor limit"
+    esac
+    case $MAX_FD in  #(
+      '' | soft) :;; #(
+      *)
+        # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
+        # shellcheck disable=SC3045
+        ulimit -n "$MAX_FD" ||
+            warn "Could not set maximum file descriptor limit to $MAX_FD"
     esac
 fi
 
-# Escape application args
-save () {
-    for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
-    echo " "
-}
-APP_ARGS=`save "$@"`
+# Collect all arguments for the java command, stacking in reverse order:
+#   * args from the command line
+#   * the main class name
+#   * -classpath
+#   * -D...appname settings
+#   * --module-path (only if needed)
+#   * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
 
-# Collect all arguments for the java command, following the shell quoting and substitution rules
-eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+    APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+    CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+    JAVACMD=$( cygpath --unix "$JAVACMD" )
+
+    # Now convert the arguments - kludge to limit ourselves to /bin/sh
+    for arg do
+        if
+            case $arg in                                #(
+              -*)   false ;;                            # don't mess with options #(
+              /?*)  t=${arg#/} t=/${t%%/*}              # looks like a POSIX filepath
+                    [ -e "$t" ] ;;                      #(
+              *)    false ;;
+            esac
+        then
+            arg=$( cygpath --path --ignore --mixed "$arg" )
+        fi
+        # Roll the args list around exactly as many times as the number of
+        # args, so each arg winds up back in the position where it started, but
+        # possibly modified.
+        #
+        # NB: a `for` loop captures its iteration list before it begins, so
+        # changing the positional parameters here affects neither the number of
+        # iterations, nor the values presented in `arg`.
+        shift                   # remove old arg
+        set -- "$@" "$arg"      # push replacement arg
+    done
+fi
+
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Collect all arguments for the java command;
+#   * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
+#     shell script including quotes and variable substitutions, so put them in
+#     double quotes to make sure that they get re-expanded; and
+#   * put everything else in single quotes, so that it's not re-expanded.
+
+set -- \
+        "-Dorg.gradle.appname=$APP_BASE_NAME" \
+        -classpath "$CLASSPATH" \
+        org.gradle.wrapper.GradleWrapperMain \
+        "$@"
+
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+    die "xargs is not available"
+fi
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+#   readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+#   set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+        printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+        xargs -n1 |
+        sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+        tr '\n' ' '
+    )" '"$@"'
 
 exec "$JAVACMD" "$@"
diff --git a/packages/SettingsLib/Spa/gradlew.bat b/packages/SettingsLib/Spa/gradlew.bat
deleted file mode 100644
index 107acd32..0000000
--- a/packages/SettingsLib/Spa/gradlew.bat
+++ /dev/null
@@ -1,89 +0,0 @@
-@rem
-@rem Copyright 2015 the original author or authors.
-@rem
-@rem Licensed under the Apache License, Version 2.0 (the "License");
-@rem you may not use this file except in compliance with the License.
-@rem You may obtain a copy of the License at
-@rem
-@rem      https://www.apache.org/licenses/LICENSE-2.0
-@rem
-@rem Unless required by applicable law or agreed to in writing, software
-@rem distributed under the License is distributed on an "AS IS" BASIS,
-@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-@rem See the License for the specific language governing permissions and
-@rem limitations under the License.
-@rem
-
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem  Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Resolve any "." and ".." in APP_HOME to make it shorter.
-for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto execute
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto execute
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
diff --git a/packages/SettingsLib/Spa/spa/build.gradle.kts b/packages/SettingsLib/Spa/spa/build.gradle.kts
index 188e7f6..377e72ed 100644
--- a/packages/SettingsLib/Spa/spa/build.gradle.kts
+++ b/packages/SettingsLib/Spa/spa/build.gradle.kts
@@ -52,11 +52,11 @@
 }
 
 dependencies {
-    api("androidx.appcompat:appcompat:1.7.0-alpha02")
+    api("androidx.appcompat:appcompat:1.7.0-alpha03")
     api("androidx.slice:slice-builders:1.1.0-alpha02")
     api("androidx.slice:slice-core:1.1.0-alpha02")
     api("androidx.slice:slice-view:1.1.0-alpha02")
-    api("androidx.compose.material3:material3:1.2.0-alpha03")
+    api("androidx.compose.material3:material3:1.2.0-alpha04")
     api("androidx.compose.material:material-icons-extended:$jetpackComposeVersion")
     api("androidx.compose.runtime:runtime-livedata:$jetpackComposeVersion")
     api("androidx.compose.ui:ui-tooling-preview:$jetpackComposeVersion")
diff --git a/packages/SettingsLib/aconfig/settingslib_media_flag_declarations.aconfig b/packages/SettingsLib/aconfig/settingslib_media_flag_declarations.aconfig
new file mode 100644
index 0000000..0b74fa8
--- /dev/null
+++ b/packages/SettingsLib/aconfig/settingslib_media_flag_declarations.aconfig
@@ -0,0 +1,8 @@
+package: "com.android.settingslib.media.flags"
+
+flag {
+  name: "use_media_router2_for_info_media_manager"
+  namespace: "placeholder_namespace"
+  description: "Gates whether to use a MediaRouter2-based implementation of InfoMediaManager, instead of the legacy MediaRouter2Manager-based implementation."
+  bug: "192657812"
+}
\ No newline at end of file
diff --git a/packages/SettingsLib/src/com/android/settingslib/media/InfoMediaManager.java b/packages/SettingsLib/src/com/android/settingslib/media/InfoMediaManager.java
index 1ea155a6..bf63f5d 100644
--- a/packages/SettingsLib/src/com/android/settingslib/media/InfoMediaManager.java
+++ b/packages/SettingsLib/src/com/android/settingslib/media/InfoMediaManager.java
@@ -62,6 +62,7 @@
 import com.android.internal.annotations.VisibleForTesting;
 import com.android.settingslib.bluetooth.CachedBluetoothDevice;
 import com.android.settingslib.bluetooth.LocalBluetoothManager;
+import com.android.settingslib.media.flags.Flags;
 
 import java.util.ArrayList;
 import java.util.Collections;
@@ -105,6 +106,28 @@
         }
     }
 
+    /** Creates an instance of InfoMediaManager. */
+    public static InfoMediaManager createInstance(
+            Context context,
+            String packageName,
+            Notification notification,
+            LocalBluetoothManager localBluetoothManager) {
+        if (Flags.useMediaRouter2ForInfoMediaManager()) {
+            try {
+                return new RouterInfoMediaManager(
+                        context, packageName, notification, localBluetoothManager);
+            } catch (PackageNotAvailableException ex) {
+                // TODO: b/293578081 - Propagate this exception to callers for proper handling.
+                Log.w(TAG, "Returning a no-op InfoMediaManager for package " + packageName);
+                return new NoOpInfoMediaManager(
+                        context, packageName, notification, localBluetoothManager);
+            }
+        } else {
+            return new ManagerInfoMediaManager(
+                    context, packageName, notification, localBluetoothManager);
+        }
+    }
+
     @Override
     public void startScan() {
         mMediaDevices.clear();
diff --git a/packages/SettingsLib/src/com/android/settingslib/media/LocalMediaManager.java b/packages/SettingsLib/src/com/android/settingslib/media/LocalMediaManager.java
index 4fb0487..fe3ef5d 100644
--- a/packages/SettingsLib/src/com/android/settingslib/media/LocalMediaManager.java
+++ b/packages/SettingsLib/src/com/android/settingslib/media/LocalMediaManager.java
@@ -137,7 +137,7 @@
         }
 
         mInfoMediaManager =
-                new ManagerInfoMediaManager(
+                InfoMediaManager.createInstance(
                         context, packageName, notification, mLocalBluetoothManager);
     }
 
diff --git a/packages/SettingsLib/src/com/android/settingslib/media/NoOpInfoMediaManager.java b/packages/SettingsLib/src/com/android/settingslib/media/NoOpInfoMediaManager.java
new file mode 100644
index 0000000..9d578bc
--- /dev/null
+++ b/packages/SettingsLib/src/com/android/settingslib/media/NoOpInfoMediaManager.java
@@ -0,0 +1,154 @@
+/*
+ * 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.settingslib.media;
+
+import android.app.Notification;
+import android.content.Context;
+import android.media.MediaRoute2Info;
+import android.media.RouteListingPreference;
+import android.media.RoutingSessionInfo;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+import com.android.settingslib.bluetooth.LocalBluetoothManager;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * No-op implementation of {@link InfoMediaManager}.
+ *
+ * <p>This implementation is used when {@link RouterInfoMediaManager} throws a {@link
+ * InfoMediaManager.PackageNotAvailableException}.
+ */
+// TODO - b/293578081: Remove once PackageNotAvailableException is propagated to library clients.
+/* package */ final class NoOpInfoMediaManager extends InfoMediaManager {
+
+    NoOpInfoMediaManager(
+            Context context,
+            String packageName,
+            Notification notification,
+            LocalBluetoothManager localBluetoothManager) {
+        super(context, packageName, notification, localBluetoothManager);
+    }
+
+    @Override
+    public void stopScan() {
+        // Do nothing.
+    }
+
+    @Override
+    protected void startScanOnRouter() {
+        // Do nothing.
+    }
+
+    @Override
+    protected boolean connectDeviceWithoutPackageName(@NonNull MediaDevice device) {
+        return false;
+    }
+
+    @Override
+    protected void transferToRoute(@NonNull MediaRoute2Info route) {
+        // Do nothing.
+    }
+
+    @Override
+    protected void selectRoute(@NonNull MediaRoute2Info route, @NonNull RoutingSessionInfo info) {
+        // Do nothing.
+    }
+
+    @Override
+    protected void deselectRoute(@NonNull MediaRoute2Info route, @NonNull RoutingSessionInfo info) {
+        // Do nothing.
+    }
+
+    @Override
+    protected void releaseSession(@NonNull RoutingSessionInfo sessionInfo) {
+        // Do nothing.
+    }
+
+    @NonNull
+    @Override
+    protected List<MediaRoute2Info> getSelectableRoutes(@NonNull RoutingSessionInfo info) {
+        return Collections.emptyList();
+    }
+
+    @NonNull
+    @Override
+    protected List<MediaRoute2Info> getDeselectableRoutes(@NonNull RoutingSessionInfo info) {
+        return Collections.emptyList();
+    }
+
+    @NonNull
+    @Override
+    protected List<MediaRoute2Info> getSelectedRoutes(@NonNull RoutingSessionInfo info) {
+        return Collections.emptyList();
+    }
+
+    @Override
+    protected void setSessionVolume(@NonNull RoutingSessionInfo info, int volume) {
+        // Do nothing.
+    }
+
+    @Override
+    protected void setRouteVolume(@NonNull MediaRoute2Info route, int volume) {
+        // Do nothing.
+    }
+
+    @Nullable
+    @Override
+    protected RouteListingPreference getRouteListingPreference() {
+        return null;
+    }
+
+    @NonNull
+    @Override
+    protected List<RoutingSessionInfo> getRemoteSessions() {
+        return Collections.emptyList();
+    }
+
+    @NonNull
+    @Override
+    protected List<RoutingSessionInfo> getRoutingSessionsForPackage() {
+        return Collections.emptyList();
+    }
+
+    @Nullable
+    @Override
+    protected RoutingSessionInfo getRoutingSessionById(@NonNull String sessionId) {
+        return null;
+    }
+
+    @NonNull
+    @Override
+    protected List<MediaRoute2Info> getAllRoutes() {
+        return Collections.emptyList();
+    }
+
+    @NonNull
+    @Override
+    protected List<MediaRoute2Info> getAvailableRoutesFromRouter() {
+        return Collections.emptyList();
+    }
+
+    @NonNull
+    @Override
+    protected List<MediaRoute2Info> getTransferableRoutes(@NonNull String packageName) {
+        return Collections.emptyList();
+    }
+}
diff --git a/packages/SettingsLib/tests/integ/Android.bp b/packages/SettingsLib/tests/integ/Android.bp
index ff3eeec..8970deb 100644
--- a/packages/SettingsLib/tests/integ/Android.bp
+++ b/packages/SettingsLib/tests/integ/Android.bp
@@ -48,11 +48,14 @@
         "androidx.test.core",
         "androidx.test.rules",
         "androidx.test.espresso.core",
+        "flag-junit",
         "mockito-target-minus-junit4",
+        "platform-test-annotations",
         "truth-prebuilt",
         "SettingsLibDeviceStateRotationLock",
         "SettingsLibSettingsSpinner",
         "SettingsLibUsageProgressBarPreference",
+        "settingslib_flags_lib",
     ],
 
     dxflags: ["--multi-dex"],
diff --git a/packages/SettingsLib/tests/integ/src/com/android/settingslib/media/InfoMediaManagerIntegTest.java b/packages/SettingsLib/tests/integ/src/com/android/settingslib/media/InfoMediaManagerIntegTest.java
new file mode 100644
index 0000000..c647cbb
--- /dev/null
+++ b/packages/SettingsLib/tests/integ/src/com/android/settingslib/media/InfoMediaManagerIntegTest.java
@@ -0,0 +1,93 @@
+/*
+ * 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.settingslib.media;
+
+import static com.android.settingslib.media.flags.Flags.FLAG_USE_MEDIA_ROUTER2_FOR_INFO_MEDIA_MANAGER;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.Manifest;
+import android.app.UiAutomation;
+import android.content.Context;
+import android.platform.test.annotations.RequiresFlagsDisabled;
+import android.platform.test.annotations.RequiresFlagsEnabled;
+import android.platform.test.flag.junit.CheckFlagsRule;
+import android.platform.test.flag.junit.DeviceFlagsValueProvider;
+
+import androidx.test.platform.app.InstrumentationRegistry;
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+public class InfoMediaManagerIntegTest {
+
+    private static final String FAKE_PACKAGE = "FAKE_PACKAGE";
+
+    private Context mContext;
+    private UiAutomation mUiAutomation;
+
+    @Rule
+    public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
+
+    @Before
+    public void setUp() {
+        mContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
+        mUiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation();
+        mUiAutomation.adoptShellPermissionIdentity(Manifest.permission.MEDIA_CONTENT_CONTROL);
+    }
+
+    @After
+    public void tearDown() {
+        mUiAutomation.dropShellPermissionIdentity();
+    }
+
+    @Test
+    @RequiresFlagsEnabled(FLAG_USE_MEDIA_ROUTER2_FOR_INFO_MEDIA_MANAGER)
+    public void createInstance_withMR2FlagOn_returnsRouterInfoMediaManager() {
+        InfoMediaManager manager =
+                InfoMediaManager.createInstance(mContext, mContext.getPackageName(), null, null);
+        assertThat(manager).isInstanceOf(RouterInfoMediaManager.class);
+    }
+
+    @Test
+    @RequiresFlagsEnabled(FLAG_USE_MEDIA_ROUTER2_FOR_INFO_MEDIA_MANAGER)
+    public void createInstance_withMR2FlagOn_withFakePackage_returnsNoOpInfoMediaManager() {
+        InfoMediaManager manager =
+                InfoMediaManager.createInstance(mContext, FAKE_PACKAGE, null, null);
+        assertThat(manager).isInstanceOf(NoOpInfoMediaManager.class);
+    }
+
+    @Test
+    @RequiresFlagsEnabled(FLAG_USE_MEDIA_ROUTER2_FOR_INFO_MEDIA_MANAGER)
+    public void createInstance_withMR2FlagOn_withNullPackage_returnsRouterInfoMediaManager() {
+        InfoMediaManager manager = InfoMediaManager.createInstance(mContext, null, null, null);
+        assertThat(manager).isInstanceOf(RouterInfoMediaManager.class);
+    }
+
+    @Test
+    @RequiresFlagsDisabled(FLAG_USE_MEDIA_ROUTER2_FOR_INFO_MEDIA_MANAGER)
+    public void createInstance_withMR2FlagOff_returnsManagerInfoMediaManager() {
+        InfoMediaManager manager =
+                InfoMediaManager.createInstance(mContext, mContext.getPackageName(), null, null);
+        assertThat(manager).isInstanceOf(ManagerInfoMediaManager.class);
+    }
+}
diff --git a/packages/Shell/AndroidManifest.xml b/packages/Shell/AndroidManifest.xml
index 368115b..215cc8e 100644
--- a/packages/Shell/AndroidManifest.xml
+++ b/packages/Shell/AndroidManifest.xml
@@ -337,6 +337,7 @@
     <uses-permission android:name="android.permission.REQUEST_COMPANION_PROFILE_WATCH" />
     <uses-permission android:name="android.permission.REQUEST_COMPANION_PROFILE_GLASSES" />
     <uses-permission android:name="android.permission.REQUEST_COMPANION_SELF_MANAGED" />
+    <uses-permission android:name="android.permission.USE_COMPANION_TRANSPORTS" />
 
     <uses-permission android:name="android.permission.MANAGE_APPOPS" />
     <uses-permission android:name="android.permission.WATCH_APPOPS" />
diff --git a/packages/SystemUI/Android.bp b/packages/SystemUI/Android.bp
index 712b737..0474849 100644
--- a/packages/SystemUI/Android.bp
+++ b/packages/SystemUI/Android.bp
@@ -201,6 +201,7 @@
         "lottie",
         "LowLightDreamLib",
         "motion_tool_lib",
+        "IntentResolver-core",
     ],
     manifest: "AndroidManifest.xml",
 
@@ -384,6 +385,7 @@
         "motion_tool_lib",
         "androidx.core_core-animation-testing-nodeps",
         "androidx.compose.ui_ui",
+        "IntentResolver-core",
     ],
 }
 
diff --git a/packages/SystemUI/OWNERS b/packages/SystemUI/OWNERS
index bba926d..0f1f168 100644
--- a/packages/SystemUI/OWNERS
+++ b/packages/SystemUI/OWNERS
@@ -89,7 +89,6 @@
 tracyzhou@google.com
 tsuji@google.com
 twickham@google.com
-vadimt@google.com
 victortulias@google.com
 winsonc@google.com
 wleshner@google.com
diff --git a/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/shaders/SolidColorShader.kt b/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/shaders/SolidColorShader.kt
new file mode 100644
index 0000000..c94fad7
--- /dev/null
+++ b/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/shaders/SolidColorShader.kt
@@ -0,0 +1,36 @@
+/*
+ * 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.surfaceeffects.shaders
+
+import android.graphics.RuntimeShader
+
+/** Simply renders a solid color. */
+class SolidColorShader(color: Int) : RuntimeShader(SHADER) {
+    // language=AGSL
+    private companion object {
+        private const val SHADER =
+            """
+                layout(color) uniform vec4 in_color;
+                vec4 main(vec2 p) {
+                    return in_color;
+                }
+            """
+    }
+
+    init {
+        setColorUniform("in_color", color)
+    }
+}
diff --git a/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/shaders/SparkleShader.kt b/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/shaders/SparkleShader.kt
new file mode 100644
index 0000000..df07856
--- /dev/null
+++ b/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/shaders/SparkleShader.kt
@@ -0,0 +1,115 @@
+/*
+ * 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.surfaceeffects.shaders
+
+import android.graphics.Color
+import android.graphics.RuntimeShader
+import android.graphics.Shader
+import com.android.systemui.surfaceeffects.shaderutil.ShaderUtilLibrary
+
+/**
+ * Renders sparkles based on the luma matte.
+ *
+ * For example, you can pass in simplex noise as the luma matte and have a cloud looking sparkles.
+ *
+ * You may want to utilize this shader by: (Preferred) 1. Create a RuntimeShaderEffect and set the
+ * [RenderEffect] to the target [View].
+ * 2. Create a custom [View], set the shader to the [Paint] and use [Canvas.drawPaint] in [onDraw].
+ */
+class SparkleShader : RuntimeShader(SPARKLE_SHADER) {
+    // language=AGSL
+    companion object {
+        private const val UNIFORMS =
+            """
+            // Used it for RenderEffect. For example:
+            // myView.setRenderEffect(
+            //     RenderEffect.createRuntimeShaderEffect(SparkleShader(), "in_src")
+            // )
+            uniform shader in_src;
+            uniform half in_time;
+            uniform half in_pixelate;
+            uniform shader in_lumaMatte;
+            layout(color) uniform vec4 in_color;
+        """
+        private const val MAIN_SHADER =
+            """vec4 main(vec2 p) {
+            half3 src = in_src.eval(p).rgb;
+            half luma = getLuminosity(in_lumaMatte.eval(p).rgb);
+            half sparkle = sparkles(p - mod(p, in_pixelate), in_time);
+            half3 mask = maskLuminosity(in_color.rgb * sparkle, luma);
+
+            return vec4(src * mask * in_color.a, in_color.a);
+        }
+        """
+        private const val SPARKLE_SHADER = UNIFORMS + ShaderUtilLibrary.SHADER_LIB + MAIN_SHADER
+
+        /** Highly recommended to use this value unless specified by design spec. */
+        const val DEFAULT_SPARKLE_PIXELATE_AMOUNT = 0.8f
+    }
+
+    init {
+        // Initializes the src and luma matte to be white.
+        setInputShader("in_src", SolidColorShader(Color.WHITE))
+        setLumaMatteColor(Color.WHITE)
+    }
+
+    /**
+     * Sets the time of the sparkle animation.
+     *
+     * This is used for animating sparkles. Note that this only makes the sparkles sparkle in place.
+     * In order to move the sparkles in x, y directions, move the luma matte input instead.
+     */
+    fun setTime(time: Float) {
+        setFloatUniform("in_time", time)
+    }
+
+    /**
+     * Sets pixelated amount of the sparkle.
+     *
+     * This value *must* be based on [resources.displayMetrics.density]. Otherwise, this will result
+     * in having different sparkle sizes on different screens.
+     *
+     * Expected to be used as follows:
+     * <pre>
+     *     {@code
+     *     val pixelDensity = context.resources.displayMetrics.density
+     *     // Sparkles will be 0.8 of the pixel size.
+     *     val sparkleShader = SparkleShader().apply { setPixelateAmount(pixelDensity * 0.8f) }
+     *     }
+     * </pre>
+     */
+    fun setPixelateAmount(pixelateAmount: Float) {
+        setFloatUniform("in_pixelate", pixelateAmount)
+    }
+
+    /**
+     * Sets the luma matte for the sparkles. The luminosity determines the sparkle's visibility.
+     * Useful for setting a complex mask (e.g. simplex noise, texture, etc.)
+     */
+    fun setLumaMatte(lumaMatte: Shader) {
+        setInputShader("in_lumaMatte", lumaMatte)
+    }
+
+    /** Sets the luma matte for the sparkles. Useful for setting a solid color. */
+    fun setLumaMatteColor(color: Int) {
+        setInputShader("in_lumaMatte", SolidColorShader(color))
+    }
+
+    /** Sets the color of the sparkles. Expect to have the alpha value encoded. */
+    fun setColor(color: Int) {
+        setColorUniform("in_color", color)
+    }
+}
diff --git a/packages/SystemUI/compose/facade/disabled/src/com/android/systemui/scene/ui/composable/SceneModule.kt b/packages/SystemUI/compose/facade/disabled/src/com/android/systemui/scene/ui/composable/SceneModule.kt
index 5413f90..24064b1 100644
--- a/packages/SystemUI/compose/facade/disabled/src/com/android/systemui/scene/ui/composable/SceneModule.kt
+++ b/packages/SystemUI/compose/facade/disabled/src/com/android/systemui/scene/ui/composable/SceneModule.kt
@@ -17,12 +17,10 @@
 package com.android.systemui.scene.ui.composable
 
 import com.android.systemui.scene.shared.model.Scene
-import com.android.systemui.scene.shared.model.SceneContainerNames
 import dagger.Module
 import dagger.multibindings.Multibinds
-import javax.inject.Named
 
 @Module
 interface SceneModule {
-    @Multibinds @Named(SceneContainerNames.SYSTEM_UI_DEFAULT) fun scenes(): Set<Scene>
+    @Multibinds fun scenes(): Set<Scene>
 }
diff --git a/packages/SystemUI/compose/facade/enabled/src/com/android/systemui/scene/ui/composable/SceneModule.kt b/packages/SystemUI/compose/facade/enabled/src/com/android/systemui/scene/ui/composable/SceneModule.kt
index d364374..3e9b397 100644
--- a/packages/SystemUI/compose/facade/enabled/src/com/android/systemui/scene/ui/composable/SceneModule.kt
+++ b/packages/SystemUI/compose/facade/enabled/src/com/android/systemui/scene/ui/composable/SceneModule.kt
@@ -16,35 +16,29 @@
 
 package com.android.systemui.scene.ui.composable
 
+import android.app.AlertDialog
 import android.content.Context
 import com.android.systemui.bouncer.ui.composable.BouncerScene
-import com.android.systemui.bouncer.ui.viewmodel.BouncerViewModel
+import com.android.systemui.bouncer.ui.composable.BouncerSceneDialogFactory
 import com.android.systemui.dagger.SysUISingleton
 import com.android.systemui.dagger.qualifiers.Application
 import com.android.systemui.keyguard.ui.composable.LockscreenScene
-import com.android.systemui.keyguard.ui.viewmodel.LockscreenSceneViewModel
 import com.android.systemui.qs.ui.composable.QuickSettingsScene
-import com.android.systemui.qs.ui.viewmodel.QuickSettingsSceneViewModel
 import com.android.systemui.scene.shared.model.Scene
-import com.android.systemui.scene.shared.model.SceneContainerNames
 import com.android.systemui.shade.ui.composable.ShadeScene
-import com.android.systemui.shade.ui.viewmodel.ShadeSceneViewModel
 import com.android.systemui.statusbar.phone.SystemUIDialog
 import dagger.Module
 import dagger.Provides
-import javax.inject.Named
-import kotlinx.coroutines.CoroutineScope
 
 @Module
 object SceneModule {
     @Provides
-    @Named(SceneContainerNames.SYSTEM_UI_DEFAULT)
     fun scenes(
-        @Named(SceneContainerNames.SYSTEM_UI_DEFAULT) bouncer: BouncerScene,
-        @Named(SceneContainerNames.SYSTEM_UI_DEFAULT) gone: GoneScene,
-        @Named(SceneContainerNames.SYSTEM_UI_DEFAULT) lockScreen: LockscreenScene,
-        @Named(SceneContainerNames.SYSTEM_UI_DEFAULT) qs: QuickSettingsScene,
-        @Named(SceneContainerNames.SYSTEM_UI_DEFAULT) shade: ShadeScene,
+        bouncer: BouncerScene,
+        gone: GoneScene,
+        lockScreen: LockscreenScene,
+        qs: QuickSettingsScene,
+        shade: ShadeScene,
     ): Set<Scene> {
         return setOf(
             bouncer,
@@ -57,70 +51,11 @@
 
     @Provides
     @SysUISingleton
-    @Named(SceneContainerNames.SYSTEM_UI_DEFAULT)
-    fun bouncerScene(
-        @Application context: Context,
-        viewModelFactory: BouncerViewModel.Factory,
-    ): BouncerScene {
-        return BouncerScene(
-            viewModel =
-                viewModelFactory.create(
-                    containerName = SceneContainerNames.SYSTEM_UI_DEFAULT,
-                ),
-            dialogFactory = { SystemUIDialog(context) },
-        )
-    }
-
-    @Provides
-    @SysUISingleton
-    @Named(SceneContainerNames.SYSTEM_UI_DEFAULT)
-    fun goneScene(): GoneScene {
-        return GoneScene()
-    }
-
-    @Provides
-    @SysUISingleton
-    @Named(SceneContainerNames.SYSTEM_UI_DEFAULT)
-    fun lockscreenScene(
-        @Application applicationScope: CoroutineScope,
-        viewModelFactory: LockscreenSceneViewModel.Factory,
-    ): LockscreenScene {
-        return LockscreenScene(
-            applicationScope = applicationScope,
-            viewModel =
-                viewModelFactory.create(
-                    containerName = SceneContainerNames.SYSTEM_UI_DEFAULT,
-                ),
-        )
-    }
-
-    @Provides
-    @SysUISingleton
-    @Named(SceneContainerNames.SYSTEM_UI_DEFAULT)
-    fun quickSettingsScene(
-        viewModelFactory: QuickSettingsSceneViewModel.Factory,
-    ): QuickSettingsScene {
-        return QuickSettingsScene(
-            viewModel =
-                viewModelFactory.create(
-                    containerName = SceneContainerNames.SYSTEM_UI_DEFAULT,
-                ),
-        )
-    }
-
-    @Provides
-    @SysUISingleton
-    @Named(SceneContainerNames.SYSTEM_UI_DEFAULT)
-    fun shadeScene(
-        @Application applicationScope: CoroutineScope,
-        viewModelFactory: ShadeSceneViewModel.Factory,
-    ): ShadeScene {
-        return ShadeScene(
-            applicationScope = applicationScope,
-            viewModel =
-                viewModelFactory.create(
-                    containerName = SceneContainerNames.SYSTEM_UI_DEFAULT,
-                ),
-        )
+    fun bouncerSceneDialogFactory(@Application context: Context): BouncerSceneDialogFactory {
+        return object : BouncerSceneDialogFactory {
+            override fun invoke(): AlertDialog {
+                return SystemUIDialog(context)
+            }
+        }
     }
 }
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/bouncer/ui/composable/BouncerScene.kt b/packages/SystemUI/compose/features/src/com/android/systemui/bouncer/ui/composable/BouncerScene.kt
index d83596e..6d9497d 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/bouncer/ui/composable/BouncerScene.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/bouncer/ui/composable/BouncerScene.kt
@@ -52,24 +52,27 @@
 import com.android.systemui.bouncer.ui.viewmodel.PasswordBouncerViewModel
 import com.android.systemui.bouncer.ui.viewmodel.PatternBouncerViewModel
 import com.android.systemui.bouncer.ui.viewmodel.PinBouncerViewModel
+import com.android.systemui.dagger.SysUISingleton
 import com.android.systemui.scene.shared.model.SceneKey
 import com.android.systemui.scene.shared.model.SceneModel
 import com.android.systemui.scene.shared.model.UserAction
 import com.android.systemui.scene.ui.composable.ComposableScene
+import javax.inject.Inject
 import kotlinx.coroutines.flow.MutableStateFlow
 import kotlinx.coroutines.flow.StateFlow
 import kotlinx.coroutines.flow.asStateFlow
 
 /** The bouncer scene displays authentication challenges like PIN, password, or pattern. */
-class BouncerScene(
+@SysUISingleton
+class BouncerScene
+@Inject
+constructor(
     private val viewModel: BouncerViewModel,
-    private val dialogFactory: () -> AlertDialog,
+    private val dialogFactory: BouncerSceneDialogFactory,
 ) : ComposableScene {
     override val key = SceneKey.Bouncer
 
-    override fun destinationScenes(
-        containerName: String,
-    ): StateFlow<Map<UserAction, SceneModel>> =
+    override fun destinationScenes(): StateFlow<Map<UserAction, SceneModel>> =
         MutableStateFlow<Map<UserAction, SceneModel>>(
                 mapOf(
                     UserAction.Back to SceneModel(SceneKey.Lockscreen),
@@ -79,7 +82,6 @@
 
     @Composable
     override fun Content(
-        containerName: String,
         modifier: Modifier,
     ) = BouncerScene(viewModel, dialogFactory, modifier)
 }
@@ -87,7 +89,7 @@
 @Composable
 private fun BouncerScene(
     viewModel: BouncerViewModel,
-    dialogFactory: () -> AlertDialog,
+    dialogFactory: BouncerSceneDialogFactory,
     modifier: Modifier = Modifier,
 ) {
     val message: BouncerViewModel.MessageViewModel by viewModel.message.collectAsState()
@@ -175,3 +177,7 @@
         }
     }
 }
+
+interface BouncerSceneDialogFactory {
+    operator fun invoke(): AlertDialog
+}
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/LockscreenScene.kt b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/LockscreenScene.kt
index 1065267..ab7bc26 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/LockscreenScene.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/LockscreenScene.kt
@@ -31,6 +31,7 @@
 import androidx.compose.ui.unit.dp
 import com.android.systemui.common.shared.model.Icon
 import com.android.systemui.common.ui.compose.Icon
+import com.android.systemui.dagger.SysUISingleton
 import com.android.systemui.dagger.qualifiers.Application
 import com.android.systemui.keyguard.ui.viewmodel.LockscreenSceneViewModel
 import com.android.systemui.scene.shared.model.Direction
@@ -38,6 +39,7 @@
 import com.android.systemui.scene.shared.model.SceneModel
 import com.android.systemui.scene.shared.model.UserAction
 import com.android.systemui.scene.ui.composable.ComposableScene
+import javax.inject.Inject
 import kotlinx.coroutines.CoroutineScope
 import kotlinx.coroutines.flow.SharingStarted
 import kotlinx.coroutines.flow.StateFlow
@@ -45,15 +47,16 @@
 import kotlinx.coroutines.flow.stateIn
 
 /** The lock screen scene shows when the device is locked. */
-class LockscreenScene(
+@SysUISingleton
+class LockscreenScene
+@Inject
+constructor(
     @Application private val applicationScope: CoroutineScope,
     private val viewModel: LockscreenSceneViewModel,
 ) : ComposableScene {
     override val key = SceneKey.Lockscreen
 
-    override fun destinationScenes(
-        containerName: String,
-    ): StateFlow<Map<UserAction, SceneModel>> =
+    override fun destinationScenes(): StateFlow<Map<UserAction, SceneModel>> =
         viewModel.upDestinationSceneKey
             .map { pageKey -> destinationScenes(up = pageKey) }
             .stateIn(
@@ -64,7 +67,6 @@
 
     @Composable
     override fun Content(
-        containerName: String,
         modifier: Modifier,
     ) {
         LockscreenScene(
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/people/ui/compose/PeopleScreen.kt b/packages/SystemUI/compose/features/src/com/android/systemui/people/ui/compose/PeopleScreen.kt
index f88fc21..d84e676 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/people/ui/compose/PeopleScreen.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/people/ui/compose/PeopleScreen.kt
@@ -20,7 +20,6 @@
 import androidx.compose.foundation.Image
 import androidx.compose.foundation.clickable
 import androidx.compose.foundation.layout.Column
-import androidx.compose.foundation.layout.PaddingValues
 import androidx.compose.foundation.layout.Row
 import androidx.compose.foundation.layout.Spacer
 import androidx.compose.foundation.layout.fillMaxSize
@@ -28,9 +27,9 @@
 import androidx.compose.foundation.layout.height
 import androidx.compose.foundation.layout.padding
 import androidx.compose.foundation.layout.size
-import androidx.compose.foundation.lazy.LazyColumn
-import androidx.compose.foundation.lazy.LazyListScope
+import androidx.compose.foundation.rememberScrollState
 import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.foundation.verticalScroll
 import androidx.compose.material3.Divider
 import androidx.compose.material3.MaterialTheme
 import androidx.compose.material3.Surface
@@ -39,6 +38,7 @@
 import androidx.compose.runtime.LaunchedEffect
 import androidx.compose.runtime.collectAsState
 import androidx.compose.runtime.getValue
+import androidx.compose.runtime.key
 import androidx.compose.ui.Alignment
 import androidx.compose.ui.Modifier
 import androidx.compose.ui.graphics.asImageBitmap
@@ -134,10 +134,11 @@
             )
         }
 
-        LazyColumn(
-            Modifier.fillMaxWidth().sysuiResTag("scroll_view"),
-            contentPadding =
-                PaddingValues(
+        Column(
+            Modifier.fillMaxWidth()
+                .sysuiResTag("scroll_view")
+                .verticalScroll(rememberScrollState())
+                .padding(
                     top = 16.dp,
                     bottom = PeopleSpacePadding,
                     start = 8.dp,
@@ -151,7 +152,7 @@
 
             if (recentTiles.isNotEmpty()) {
                 if (hasPriorityConversations) {
-                    item { Spacer(Modifier.height(35.dp)) }
+                    Spacer(Modifier.height(35.dp))
                 }
 
                 ConversationList(R.string.recent_conversations, recentTiles, onTileClicked)
@@ -160,33 +161,30 @@
     }
 }
 
-private fun LazyListScope.ConversationList(
+@Composable
+private fun ConversationList(
     @StringRes headerTextResource: Int,
     tiles: List<PeopleTileViewModel>,
     onTileClicked: (PeopleTileViewModel) -> Unit
 ) {
-    item {
-        Text(
-            stringResource(headerTextResource),
-            Modifier.padding(start = 16.dp),
-            style = MaterialTheme.typography.labelLarge,
-            color = LocalAndroidColorScheme.current.deprecated.colorAccentPrimaryVariant,
-        )
+    Text(
+        stringResource(headerTextResource),
+        Modifier.padding(start = 16.dp),
+        style = MaterialTheme.typography.labelLarge,
+        color = LocalAndroidColorScheme.current.deprecated.colorAccentPrimaryVariant,
+    )
 
-        Spacer(Modifier.height(10.dp))
-    }
+    Spacer(Modifier.height(10.dp))
 
     tiles.forEachIndexed { index, tile ->
         if (index > 0) {
-            item {
-                Divider(
-                    color = LocalAndroidColorScheme.current.deprecated.colorBackground,
-                    thickness = 2.dp,
-                )
-            }
+            Divider(
+                color = LocalAndroidColorScheme.current.deprecated.colorBackground,
+                thickness = 2.dp,
+            )
         }
 
-        item(tile.key.toString()) {
+        key(tile.key.toString()) {
             Tile(
                 tile,
                 onTileClicked,
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/qs/ui/composable/QuickSettingsScene.kt b/packages/SystemUI/compose/features/src/com/android/systemui/qs/ui/composable/QuickSettingsScene.kt
index 30b80ca..130395a 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/qs/ui/composable/QuickSettingsScene.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/qs/ui/composable/QuickSettingsScene.kt
@@ -27,25 +27,28 @@
 import androidx.compose.ui.Alignment
 import androidx.compose.ui.Modifier
 import androidx.compose.ui.unit.dp
+import com.android.systemui.dagger.SysUISingleton
 import com.android.systemui.qs.ui.viewmodel.QuickSettingsSceneViewModel
 import com.android.systemui.scene.shared.model.Direction
 import com.android.systemui.scene.shared.model.SceneKey
 import com.android.systemui.scene.shared.model.SceneModel
 import com.android.systemui.scene.shared.model.UserAction
 import com.android.systemui.scene.ui.composable.ComposableScene
+import javax.inject.Inject
 import kotlinx.coroutines.flow.MutableStateFlow
 import kotlinx.coroutines.flow.StateFlow
 import kotlinx.coroutines.flow.asStateFlow
 
 /** The Quick Settings (AKA "QS") scene shows the quick setting tiles. */
-class QuickSettingsScene(
+@SysUISingleton
+class QuickSettingsScene
+@Inject
+constructor(
     private val viewModel: QuickSettingsSceneViewModel,
 ) : ComposableScene {
     override val key = SceneKey.QuickSettings
 
-    override fun destinationScenes(
-        containerName: String,
-    ): StateFlow<Map<UserAction, SceneModel>> =
+    override fun destinationScenes(): StateFlow<Map<UserAction, SceneModel>> =
         MutableStateFlow<Map<UserAction, SceneModel>>(
                 mapOf(
                     UserAction.Swipe(Direction.UP) to SceneModel(SceneKey.Shade),
@@ -55,7 +58,6 @@
 
     @Composable
     override fun Content(
-        containerName: String,
         modifier: Modifier,
     ) {
         QuickSettingsScene(
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/ComposableScene.kt b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/ComposableScene.kt
index 6f3363e..a213666 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/ComposableScene.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/ComposableScene.kt
@@ -22,5 +22,5 @@
 
 /** Compose-capable extension of [Scene]. */
 interface ComposableScene : Scene {
-    @Composable fun Content(containerName: String, modifier: Modifier)
+    @Composable fun Content(modifier: Modifier)
 }
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/GoneScene.kt b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/GoneScene.kt
index 0a4da1d..0070552 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/GoneScene.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/GoneScene.kt
@@ -23,10 +23,12 @@
 import androidx.compose.runtime.Composable
 import androidx.compose.ui.Alignment
 import androidx.compose.ui.Modifier
+import com.android.systemui.dagger.SysUISingleton
 import com.android.systemui.scene.shared.model.Direction
 import com.android.systemui.scene.shared.model.SceneKey
 import com.android.systemui.scene.shared.model.SceneModel
 import com.android.systemui.scene.shared.model.UserAction
+import javax.inject.Inject
 import kotlinx.coroutines.flow.MutableStateFlow
 import kotlinx.coroutines.flow.StateFlow
 import kotlinx.coroutines.flow.asStateFlow
@@ -35,12 +37,11 @@
  * "Gone" is not a real scene but rather the absence of scenes when we want to skip showing any
  * content from the scene framework.
  */
-class GoneScene : ComposableScene {
+@SysUISingleton
+class GoneScene @Inject constructor() : ComposableScene {
     override val key = SceneKey.Gone
 
-    override fun destinationScenes(
-        containerName: String,
-    ): StateFlow<Map<UserAction, SceneModel>> =
+    override fun destinationScenes(): StateFlow<Map<UserAction, SceneModel>> =
         MutableStateFlow<Map<UserAction, SceneModel>>(
                 mapOf(
                     UserAction.Swipe(Direction.DOWN) to SceneModel(SceneKey.Shade),
@@ -50,7 +51,6 @@
 
     @Composable
     override fun Content(
-        containerName: String,
         modifier: Modifier,
     ) {
         /*
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/SceneContainer.kt b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/SceneContainer.kt
index 3298664..49e2bf9 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/SceneContainer.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/SceneContainer.kt
@@ -75,7 +75,6 @@
             if (key == currentSceneKey) {
                 Scene(
                     scene = composableScene,
-                    containerName = viewModel.containerName,
                     onSceneChanged = viewModel::setCurrentScene,
                     modifier = Modifier.fillMaxSize(),
                 )
@@ -88,12 +87,10 @@
 @Composable
 private fun Scene(
     scene: ComposableScene,
-    containerName: String,
     onSceneChanged: (SceneModel) -> Unit,
     modifier: Modifier = Modifier,
 ) {
-    val destinationScenes: Map<UserAction, SceneModel> by
-        scene.destinationScenes(containerName).collectAsState()
+    val destinationScenes: Map<UserAction, SceneModel> by scene.destinationScenes().collectAsState()
     val swipeLeftDestinationScene = destinationScenes[UserAction.Swipe(Direction.LEFT)]
     val swipeUpDestinationScene = destinationScenes[UserAction.Swipe(Direction.UP)]
     val swipeRightDestinationScene = destinationScenes[UserAction.Swipe(Direction.RIGHT)]
@@ -107,7 +104,6 @@
             modifier = Modifier.align(Alignment.Center),
         ) {
             scene.Content(
-                containerName = containerName,
                 modifier = Modifier,
             )
 
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/ShadeScene.kt b/packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/ShadeScene.kt
index 27358f5..b73e0b2 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/ShadeScene.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/ShadeScene.kt
@@ -26,6 +26,7 @@
 import androidx.compose.ui.Alignment
 import androidx.compose.ui.Modifier
 import androidx.compose.ui.unit.dp
+import com.android.systemui.dagger.SysUISingleton
 import com.android.systemui.dagger.qualifiers.Application
 import com.android.systemui.notifications.ui.composable.Notifications
 import com.android.systemui.qs.footer.ui.compose.QuickSettings
@@ -35,6 +36,7 @@
 import com.android.systemui.scene.shared.model.UserAction
 import com.android.systemui.scene.ui.composable.ComposableScene
 import com.android.systemui.shade.ui.viewmodel.ShadeSceneViewModel
+import javax.inject.Inject
 import kotlinx.coroutines.CoroutineScope
 import kotlinx.coroutines.flow.SharingStarted
 import kotlinx.coroutines.flow.StateFlow
@@ -42,15 +44,16 @@
 import kotlinx.coroutines.flow.stateIn
 
 /** The shade scene shows scrolling list of notifications and some of the quick setting tiles. */
-class ShadeScene(
+@SysUISingleton
+class ShadeScene
+@Inject
+constructor(
     @Application private val applicationScope: CoroutineScope,
     private val viewModel: ShadeSceneViewModel,
 ) : ComposableScene {
     override val key = SceneKey.Shade
 
-    override fun destinationScenes(
-        containerName: String,
-    ): StateFlow<Map<UserAction, SceneModel>> =
+    override fun destinationScenes(): StateFlow<Map<UserAction, SceneModel>> =
         viewModel.upDestinationSceneKey
             .map { sceneKey -> destinationScenes(up = sceneKey) }
             .stateIn(
@@ -61,7 +64,6 @@
 
     @Composable
     override fun Content(
-        containerName: String,
         modifier: Modifier,
     ) = ShadeScene(viewModel, modifier)
 
diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_pin_view.xml b/packages/SystemUI/res-keyguard/layout/keyguard_pin_view.xml
index c7d2d81..29e14c5 100644
--- a/packages/SystemUI/res-keyguard/layout/keyguard_pin_view.xml
+++ b/packages/SystemUI/res-keyguard/layout/keyguard_pin_view.xml
@@ -16,202 +16,10 @@
 ** limitations under the License.
 */
 -->
-
-<com.android.keyguard.KeyguardPINView xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:androidprv="http://schemas.android.com/apk/res-auto"
-    android:id="@+id/keyguard_pin_view"
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:layout_gravity="center_horizontal|bottom"
-    android:clipChildren="false"
-    android:clipToPadding="false"
-    android:orientation="vertical"
-    androidprv:layout_maxWidth="@dimen/keyguard_security_width">
-<include layout="@layout/keyguard_bouncer_message_area"/>
+    android:layout_height="match_parent">
 
-<com.android.systemui.bouncer.ui.BouncerMessageView
-    android:id="@+id/bouncer_message_view"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:orientation="vertical" />
+    <include layout="@layout/keyguard_pin_view_portrait" />
 
-<androidx.constraintlayout.widget.ConstraintLayout
-        android:id="@+id/pin_container"
-        android:layout_width="match_parent"
-        android:layout_height="0dp"
-        android:layout_marginBottom="8dp"
-        android:clipChildren="false"
-        android:clipToPadding="false"
-        android:layout_weight="1"
-        android:layoutDirection="ltr"
-        android:orientation="vertical">
-
-        <!-- Set this to be just above key1. It would be better to introduce a barrier above
-             key1/key2/key3, then place this View above that. Sadly, that doesn't work (the Barrier
-             drops to the bottom of the page, and key1/2/3 all shoot up to the top-left). In any
-             case, the Flow should ensure that key1/2/3 all have the same top, so this should be
-             fine. -->
-        <com.android.keyguard.AlphaOptimizedRelativeLayout
-            android:id="@+id/row0"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:paddingBottom="@dimen/num_pad_entry_row_margin_bottom"
-            androidprv:layout_constraintTop_toTopOf="parent"
-            androidprv:layout_constraintEnd_toEndOf="parent"
-            androidprv:layout_constraintStart_toStartOf="parent"
-            androidprv:layout_constraintBottom_toTopOf="@id/key1"
-            androidprv:layout_constraintVertical_bias="0.5">
-
-            <com.android.keyguard.PasswordTextView
-                android:id="@+id/pinEntry"
-                style="@style/Widget.TextView.Password"
-                android:layout_width="@dimen/keyguard_security_width"
-                android:layout_height="@dimen/keyguard_password_height"
-                android:layout_centerHorizontal="true"
-                android:layout_marginRight="72dp"
-                android:contentDescription="@string/keyguard_accessibility_pin_area"
-                androidprv:scaledTextSize="@integer/scaled_password_text_size" />
-        </com.android.keyguard.AlphaOptimizedRelativeLayout>
-
-        <!-- Guideline used to place the top row of keys relative to the screen height. This will be
-             updated in KeyguardPINView to reduce the height of the PIN pad. -->
-        <androidx.constraintlayout.widget.Guideline
-            android:id="@+id/pin_pad_top_guideline"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            androidprv:layout_constraintGuide_percent="0"
-            android:orientation="horizontal" />
-
-        <com.android.keyguard.KeyguardPinFlowView
-            android:id="@+id/flow1"
-            android:layout_width="0dp"
-            android:layout_height="0dp"
-            android:orientation="horizontal"
-            android:clipChildren="false"
-            android:clipToPadding="false"
-
-            androidprv:constraint_referenced_ids="key1,key2,key3,key4,key5,key6,key7,key8,key9,delete_button,key0,key_enter"
-
-            androidprv:flow_horizontalGap="@dimen/num_pad_key_margin_end"
-
-            androidprv:flow_horizontalStyle="packed"
-            androidprv:flow_maxElementsWrap="3"
-
-            androidprv:flow_verticalBias="1.0"
-            androidprv:flow_verticalGap="@dimen/num_pad_entry_row_margin_bottom"
-            androidprv:flow_verticalStyle="packed"
-
-            androidprv:flow_wrapMode="aligned"
-            androidprv:layout_constraintBottom_toBottomOf="parent"
-            androidprv:layout_constraintEnd_toEndOf="parent"
-            androidprv:layout_constraintStart_toStartOf="parent"
-            androidprv:layout_constraintTop_toBottomOf="@id/pin_pad_top_guideline" />
-
-        <com.android.keyguard.NumPadKey
-            android:id="@+id/key1"
-            android:layout_width="0dp"
-            android:layout_height="0dp"
-            android:accessibilityTraversalBefore="@id/key2"
-            androidprv:digit="1"
-            androidprv:textView="@+id/pinEntry" />
-
-        <com.android.keyguard.NumPadKey
-            android:id="@+id/key2"
-            android:layout_width="0dp"
-            android:layout_height="0dp"
-            android:accessibilityTraversalBefore="@id/key3"
-            androidprv:digit="2"
-            androidprv:textView="@+id/pinEntry" />
-
-        <com.android.keyguard.NumPadKey
-            android:id="@+id/key3"
-            android:layout_width="0dp"
-            android:layout_height="0dp"
-            android:accessibilityTraversalBefore="@id/key4"
-            androidprv:digit="3"
-            androidprv:textView="@+id/pinEntry" />
-
-        <com.android.keyguard.NumPadKey
-            android:id="@+id/key4"
-            android:layout_width="0dp"
-            android:layout_height="0dp"
-            android:accessibilityTraversalBefore="@id/key5"
-            androidprv:digit="4"
-            androidprv:textView="@+id/pinEntry" />
-
-        <com.android.keyguard.NumPadKey
-            android:id="@+id/key5"
-            android:layout_width="0dp"
-            android:layout_height="0dp"
-            android:accessibilityTraversalBefore="@id/key6"
-            androidprv:digit="5"
-            androidprv:textView="@+id/pinEntry" />
-
-        <com.android.keyguard.NumPadKey
-            android:id="@+id/key6"
-            android:layout_width="0dp"
-            android:layout_height="0dp"
-            android:accessibilityTraversalBefore="@id/key7"
-            androidprv:digit="6"
-            androidprv:textView="@+id/pinEntry" />
-
-        <com.android.keyguard.NumPadKey
-            android:id="@+id/key7"
-            android:layout_width="0dp"
-            android:layout_height="0dp"
-            android:accessibilityTraversalBefore="@id/key8"
-            androidprv:digit="7"
-            androidprv:textView="@+id/pinEntry" />
-
-
-        <com.android.keyguard.NumPadKey
-            android:id="@+id/key8"
-            android:layout_width="0dp"
-            android:layout_height="0dp"
-            android:accessibilityTraversalBefore="@id/key9"
-            androidprv:digit="8"
-            androidprv:textView="@+id/pinEntry" />
-
-        <com.android.keyguard.NumPadKey
-            android:id="@+id/key9"
-            android:layout_width="0dp"
-            android:layout_height="0dp"
-            android:accessibilityTraversalBefore="@id/delete_button"
-            androidprv:digit="9"
-            androidprv:textView="@+id/pinEntry" />
-
-        <com.android.keyguard.NumPadButton
-            android:id="@+id/delete_button"
-            style="@style/NumPadKey.Delete"
-            android:layout_width="0dp"
-            android:layout_height="0dp"
-            android:accessibilityTraversalBefore="@id/key0"
-            android:contentDescription="@string/keyboardview_keycode_delete" />
-
-        <com.android.keyguard.NumPadKey
-            android:id="@+id/key0"
-            android:layout_width="0dp"
-            android:layout_height="0dp"
-            android:accessibilityTraversalBefore="@id/key_enter"
-            androidprv:digit="0"
-            androidprv:textView="@+id/pinEntry" />
-
-        <com.android.keyguard.NumPadButton
-            android:id="@+id/key_enter"
-            style="@style/NumPadKey.Enter"
-            android:layout_width="0dp"
-            android:layout_height="0dp"
-            android:contentDescription="@string/keyboardview_keycode_enter" />
-</androidx.constraintlayout.widget.ConstraintLayout>
-
-    <include layout="@layout/keyguard_eca"
-             android:id="@+id/keyguard_selector_fade_container"
-             android:layout_width="match_parent"
-             android:layout_height="wrap_content"
-             android:orientation="vertical"
-             android:layout_gravity="bottom|center_horizontal"
-             android:layout_marginTop="@dimen/keyguard_eca_top_margin"
-             android:layout_marginBottom="@dimen/keyguard_eca_bottom_margin"
-             android:gravity="center_horizontal"/>
-
-</com.android.keyguard.KeyguardPINView>
+</FrameLayout>
diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_pin_view_portrait.xml b/packages/SystemUI/res-keyguard/layout/keyguard_pin_view_portrait.xml
new file mode 100644
index 0000000..f3cd9e4
--- /dev/null
+++ b/packages/SystemUI/res-keyguard/layout/keyguard_pin_view_portrait.xml
@@ -0,0 +1,218 @@
+<?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.
+*/
+-->
+
+<com.android.keyguard.KeyguardPINView xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:androidprv="http://schemas.android.com/apk/res-auto"
+    android:id="@+id/keyguard_pin_view"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:layout_gravity="center_horizontal|bottom"
+    android:clipChildren="false"
+    android:clipToPadding="false"
+    android:orientation="vertical"
+    androidprv:layout_maxWidth="@dimen/keyguard_security_width">
+
+    <include layout="@layout/keyguard_bouncer_message_area"/>
+
+    <com.android.systemui.bouncer.ui.BouncerMessageView
+        android:id="@+id/bouncer_message_view"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:orientation="vertical" />
+
+    <androidx.constraintlayout.widget.ConstraintLayout
+        android:id="@+id/pin_container"
+        android:layout_width="match_parent"
+        android:layout_height="0dp"
+        android:layout_marginBottom="8dp"
+        android:clipChildren="false"
+        android:clipToPadding="false"
+        android:layout_weight="1"
+        android:layoutDirection="ltr"
+        android:orientation="vertical">
+
+        <!-- Set this to be just above key1. It would be better to introduce a barrier above
+             key1/key2/key3, then place this View above that. Sadly, that doesn't work (the Barrier
+             drops to the bottom of the page, and key1/2/3 all shoot up to the top-left). In any
+             case, the Flow should ensure that key1/2/3 all have the same top, so this should be
+             fine. -->
+        <com.android.keyguard.AlphaOptimizedRelativeLayout
+            android:id="@+id/row0"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:paddingBottom="@dimen/num_pad_entry_row_margin_bottom"
+            androidprv:layout_constraintTop_toTopOf="parent"
+            androidprv:layout_constraintEnd_toEndOf="parent"
+            androidprv:layout_constraintStart_toStartOf="parent"
+            androidprv:layout_constraintBottom_toTopOf="@id/key1"
+            androidprv:layout_constraintVertical_bias="0.5">
+
+            <com.android.keyguard.PasswordTextView
+                android:id="@+id/pinEntry"
+                style="@style/Widget.TextView.Password"
+                android:layout_width="@dimen/keyguard_security_width"
+                android:layout_height="@dimen/keyguard_password_height"
+                android:layout_centerHorizontal="true"
+                android:layout_marginRight="72dp"
+                android:contentDescription="@string/keyguard_accessibility_pin_area"
+                androidprv:scaledTextSize="@integer/scaled_password_text_size" />
+        </com.android.keyguard.AlphaOptimizedRelativeLayout>
+
+        <!-- Guideline used to place the top row of keys relative to the screen height. This will be
+             updated in KeyguardPINView to reduce the height of the PIN pad. -->
+        <androidx.constraintlayout.widget.Guideline
+            android:id="@+id/pin_pad_top_guideline"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            androidprv:layout_constraintGuide_percent="0"
+            android:orientation="horizontal" />
+
+        <com.android.keyguard.KeyguardPinFlowView
+            android:id="@+id/flow1"
+            android:layout_width="0dp"
+            android:layout_height="0dp"
+            android:orientation="horizontal"
+            android:clipChildren="false"
+            android:clipToPadding="false"
+
+            androidprv:constraint_referenced_ids="key1,key2,key3,key4,key5,key6,key7,key8,key9,delete_button,key0,key_enter"
+
+            androidprv:flow_horizontalGap="@dimen/num_pad_key_margin_end"
+
+            androidprv:flow_horizontalStyle="packed"
+            androidprv:flow_maxElementsWrap="3"
+
+            androidprv:flow_verticalBias="1.0"
+            androidprv:flow_verticalGap="@dimen/num_pad_entry_row_margin_bottom"
+            androidprv:flow_verticalStyle="packed"
+
+            androidprv:flow_wrapMode="aligned"
+            androidprv:layout_constraintBottom_toBottomOf="parent"
+            androidprv:layout_constraintEnd_toEndOf="parent"
+            androidprv:layout_constraintStart_toStartOf="parent"
+            androidprv:layout_constraintTop_toBottomOf="@id/pin_pad_top_guideline" />
+
+        <com.android.keyguard.NumPadKey
+            android:id="@+id/key1"
+            android:layout_width="0dp"
+            android:layout_height="0dp"
+            android:accessibilityTraversalBefore="@id/key2"
+            androidprv:digit="1"
+            androidprv:textView="@+id/pinEntry" />
+
+        <com.android.keyguard.NumPadKey
+            android:id="@+id/key2"
+            android:layout_width="0dp"
+            android:layout_height="0dp"
+            android:accessibilityTraversalBefore="@id/key3"
+            androidprv:digit="2"
+            androidprv:textView="@+id/pinEntry" />
+
+        <com.android.keyguard.NumPadKey
+            android:id="@+id/key3"
+            android:layout_width="0dp"
+            android:layout_height="0dp"
+            android:accessibilityTraversalBefore="@id/key4"
+            androidprv:digit="3"
+            androidprv:textView="@+id/pinEntry" />
+
+        <com.android.keyguard.NumPadKey
+            android:id="@+id/key4"
+            android:layout_width="0dp"
+            android:layout_height="0dp"
+            android:accessibilityTraversalBefore="@id/key5"
+            androidprv:digit="4"
+            androidprv:textView="@+id/pinEntry" />
+
+        <com.android.keyguard.NumPadKey
+            android:id="@+id/key5"
+            android:layout_width="0dp"
+            android:layout_height="0dp"
+            android:accessibilityTraversalBefore="@id/key6"
+            androidprv:digit="5"
+            androidprv:textView="@+id/pinEntry" />
+
+        <com.android.keyguard.NumPadKey
+            android:id="@+id/key6"
+            android:layout_width="0dp"
+            android:layout_height="0dp"
+            android:accessibilityTraversalBefore="@id/key7"
+            androidprv:digit="6"
+            androidprv:textView="@+id/pinEntry" />
+
+        <com.android.keyguard.NumPadKey
+            android:id="@+id/key7"
+            android:layout_width="0dp"
+            android:layout_height="0dp"
+            android:accessibilityTraversalBefore="@id/key8"
+            androidprv:digit="7"
+            androidprv:textView="@+id/pinEntry" />
+
+
+        <com.android.keyguard.NumPadKey
+            android:id="@+id/key8"
+            android:layout_width="0dp"
+            android:layout_height="0dp"
+            android:accessibilityTraversalBefore="@id/key9"
+            androidprv:digit="8"
+            androidprv:textView="@+id/pinEntry" />
+
+        <com.android.keyguard.NumPadKey
+            android:id="@+id/key9"
+            android:layout_width="0dp"
+            android:layout_height="0dp"
+            android:accessibilityTraversalBefore="@id/delete_button"
+            androidprv:digit="9"
+            androidprv:textView="@+id/pinEntry" />
+
+        <com.android.keyguard.NumPadButton
+            android:id="@+id/delete_button"
+            style="@style/NumPadKey.Delete"
+            android:layout_width="0dp"
+            android:layout_height="0dp"
+            android:accessibilityTraversalBefore="@id/key0"
+            android:contentDescription="@string/keyboardview_keycode_delete" />
+
+        <com.android.keyguard.NumPadKey
+            android:id="@+id/key0"
+            android:layout_width="0dp"
+            android:layout_height="0dp"
+            android:accessibilityTraversalBefore="@id/key_enter"
+            androidprv:digit="0"
+            androidprv:textView="@+id/pinEntry" />
+
+        <com.android.keyguard.NumPadButton
+            android:id="@+id/key_enter"
+            style="@style/NumPadKey.Enter"
+            android:layout_width="0dp"
+            android:layout_height="0dp"
+            android:contentDescription="@string/keyboardview_keycode_enter" />
+    </androidx.constraintlayout.widget.ConstraintLayout>
+
+    <include layout="@layout/keyguard_eca"
+        android:id="@+id/keyguard_selector_fade_container"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:orientation="vertical"
+        android:layout_gravity="bottom|center_horizontal"
+        android:layout_marginTop="@dimen/keyguard_eca_top_margin"
+        android:layout_marginBottom="@dimen/keyguard_eca_bottom_margin"
+        android:gravity="center_horizontal"/>
+
+</com.android.keyguard.KeyguardPINView>
diff --git a/packages/SystemUI/res/layout/media_projection_app_selector.xml b/packages/SystemUI/res/layout/media_projection_app_selector.xml
index e474938..5404cfa 100644
--- a/packages/SystemUI/res/layout/media_projection_app_selector.xml
+++ b/packages/SystemUI/res/layout/media_projection_app_selector.xml
@@ -14,7 +14,7 @@
   ~ See the License for the specific language governing permissions and
   ~ limitations under the License.
   -->
-<com.android.internal.widget.ResolverDrawerLayout
+<com.android.intentresolver.widget.ResolverDrawerLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
     android:layout_width="match_parent"
@@ -84,7 +84,7 @@
                 android:id="@*android:id/tabcontent"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content">
-                <com.android.internal.app.ResolverViewPager
+                <com.android.intentresolver.ResolverViewPager
                     android:id="@*android:id/profile_pager"
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content"/>
@@ -92,4 +92,4 @@
         </LinearLayout>
     </TabHost>
 
-</com.android.internal.widget.ResolverDrawerLayout>
+</com.android.intentresolver.widget.ResolverDrawerLayout>
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java
index bc24249..3b09910f 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java
@@ -81,7 +81,6 @@
 import com.android.systemui.plugins.ActivityStarter;
 import com.android.systemui.plugins.FalsingManager;
 import com.android.systemui.scene.domain.interactor.SceneInteractor;
-import com.android.systemui.scene.shared.model.SceneContainerNames;
 import com.android.systemui.scene.shared.model.SceneKey;
 import com.android.systemui.shared.system.SysUiStatsLog;
 import com.android.systemui.statusbar.policy.ConfigurationController;
@@ -476,7 +475,7 @@
         if (mFeatureFlags.isEnabled(Flags.SCENE_CONTAINER)) {
             // When the scene framework transitions from bouncer to gone, we dismiss the keyguard.
             mSceneTransitionCollectionJob = mJavaAdapter.get().alwaysCollectFlow(
-                mSceneInteractor.get().sceneTransitions(SceneContainerNames.SYSTEM_UI_DEFAULT),
+                mSceneInteractor.get().getTransitions(),
                 sceneTransitionModel -> {
                     if (sceneTransitionModel != null
                             && sceneTransitionModel.getFrom() == SceneKey.Bouncer.INSTANCE
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityViewFlipperController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityViewFlipperController.java
index fbacd68..bc5b1ba 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityViewFlipperController.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityViewFlipperController.java
@@ -117,15 +117,19 @@
             KeyguardSecurityCallback keyguardSecurityCallback,
             @Nullable OnViewInflatedCallback onViewInflatedListener) {
         int layoutId = getLayoutIdFor(securityMode);
-        if (layoutId != 0) {
-            if (DEBUG) Log.v(TAG, "inflating on bg thread id = " + layoutId);
+        int viewID = getKeyguardInputViewId(securityMode);
+        if (layoutId != 0 && viewID != 0) {
+            if (DEBUG) {
+                Log.v(TAG, "inflating on bg thread id = "
+                        + layoutId + " . viewID = " + viewID);
+            }
             mAsyncLayoutInflater.inflate(layoutId, mView,
                     (view, resId, parent) -> {
                         mView.addView(view);
                         KeyguardInputViewController<KeyguardInputView> childController =
                                 mKeyguardSecurityViewControllerFactory.create(
-                                        (KeyguardInputView) view, securityMode,
-                                        keyguardSecurityCallback);
+                                        (KeyguardInputView) view.findViewById(viewID),
+                                        securityMode, keyguardSecurityCallback);
                         childController.init();
                         mChildren.add(childController);
                         if (onViewInflatedListener != null) {
@@ -147,6 +151,19 @@
         }
     }
 
+    private int getKeyguardInputViewId(SecurityMode securityMode) {
+        //Keyguard Input View is not the root view of the layout, use these IDs for lookup.
+        switch (securityMode) {
+            case Pattern: return R.id.keyguard_pattern_view;
+            case PIN: return R.id.keyguard_pin_view;
+            case Password: return R.id.keyguard_password_view;
+            case SimPin: return R.id.keyguard_sim_pin_view;
+            case SimPuk: return R.id.keyguard_sim_puk_view;
+            default:
+                return 0;
+        }
+    }
+
     /** Makes the supplied child visible if it is contained win this view, */
     public void show(KeyguardInputViewController<KeyguardInputView> childController) {
         int index = childController.getIndexIn(mView);
diff --git a/packages/SystemUI/src/com/android/systemui/ExpandHelper.java b/packages/SystemUI/src/com/android/systemui/ExpandHelper.java
index f00615b..7c377d2 100644
--- a/packages/SystemUI/src/com/android/systemui/ExpandHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/ExpandHelper.java
@@ -19,9 +19,6 @@
 
 import static com.android.internal.jank.InteractionJankMonitor.CUJ_NOTIFICATION_SHADE_ROW_EXPAND;
 
-import android.animation.Animator;
-import android.animation.AnimatorListenerAdapter;
-import android.animation.ObjectAnimator;
 import android.content.Context;
 import android.util.FloatProperty;
 import android.util.Log;
@@ -34,6 +31,11 @@
 import android.view.View;
 import android.view.ViewConfiguration;
 
+import androidx.annotation.NonNull;
+import androidx.core.animation.Animator;
+import androidx.core.animation.AnimatorListenerAdapter;
+import androidx.core.animation.ObjectAnimator;
+
 import com.android.internal.annotations.VisibleForTesting;
 import com.android.internal.jank.InteractionJankMonitor;
 import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
@@ -616,7 +618,7 @@
                 public boolean mCancelled;
 
                 @Override
-                public void onAnimationEnd(Animator animation) {
+                public void onAnimationEnd(@NonNull Animator animation) {
                     if (!mCancelled) {
                         mCallback.setUserExpandedChild(scaledView, expand);
                         if (!mExpanding) {
@@ -633,7 +635,7 @@
                 }
 
                 @Override
-                public void onAnimationCancel(Animator animation) {
+                public void onAnimationCancel(@NonNull Animator animation) {
                     mCancelled = true;
                 }
             });
diff --git a/packages/SystemUI/src/com/android/systemui/bouncer/domain/interactor/BouncerInteractor.kt b/packages/SystemUI/src/com/android/systemui/bouncer/domain/interactor/BouncerInteractor.kt
index 8e14237..d8cf398 100644
--- a/packages/SystemUI/src/com/android/systemui/bouncer/domain/interactor/BouncerInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/bouncer/domain/interactor/BouncerInteractor.kt
@@ -24,6 +24,7 @@
 import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
 import com.android.systemui.authentication.shared.model.AuthenticationThrottlingModel
 import com.android.systemui.bouncer.data.repository.BouncerRepository
+import com.android.systemui.dagger.SysUISingleton
 import com.android.systemui.dagger.qualifiers.Application
 import com.android.systemui.flags.FeatureFlags
 import com.android.systemui.flags.Flags
@@ -31,9 +32,7 @@
 import com.android.systemui.scene.shared.model.SceneKey
 import com.android.systemui.scene.shared.model.SceneModel
 import com.android.systemui.util.kotlin.pairwise
-import dagger.assisted.Assisted
-import dagger.assisted.AssistedFactory
-import dagger.assisted.AssistedInject
+import javax.inject.Inject
 import kotlin.time.Duration.Companion.milliseconds
 import kotlinx.coroutines.CoroutineScope
 import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -44,8 +43,9 @@
 import kotlinx.coroutines.launch
 
 /** Encapsulates business logic and application state accessing use-cases. */
+@SysUISingleton
 class BouncerInteractor
-@AssistedInject
+@Inject
 constructor(
     @Application private val applicationScope: CoroutineScope,
     @Application private val applicationContext: Context,
@@ -53,7 +53,6 @@
     private val authenticationInteractor: AuthenticationInteractor,
     private val sceneInteractor: SceneInteractor,
     featureFlags: FeatureFlags,
-    @Assisted private val containerName: String,
 ) {
 
     /** The user-facing message to show in the bouncer. */
@@ -118,23 +117,19 @@
     /**
      * Either shows the bouncer or unlocks the device, if the bouncer doesn't need to be shown.
      *
-     * @param containerName The name of the scene container to show the bouncer in.
      * @param message An optional message to show to the user in the bouncer.
      */
     fun showOrUnlockDevice(
-        containerName: String,
         message: String? = null,
     ) {
         applicationScope.launch {
             if (authenticationInteractor.isAuthenticationRequired()) {
                 repository.setMessage(message ?: promptMessage(getAuthenticationMethod()))
                 sceneInteractor.setCurrentScene(
-                    containerName = containerName,
                     scene = SceneModel(SceneKey.Bouncer),
                 )
             } else {
                 sceneInteractor.setCurrentScene(
-                    containerName = containerName,
                     scene = SceneModel(SceneKey.Gone),
                 )
             }
@@ -180,7 +175,6 @@
 
         if (isAuthenticated) {
             sceneInteractor.setCurrentScene(
-                containerName = containerName,
                 scene = SceneModel(SceneKey.Gone),
             )
         } else {
@@ -228,11 +222,4 @@
             else -> ""
         }
     }
-
-    @AssistedFactory
-    interface Factory {
-        fun create(
-            containerName: String,
-        ): BouncerInteractor
-    }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/BouncerViewModel.kt b/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/BouncerViewModel.kt
index a4ef5ce..68e1a29 100644
--- a/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/BouncerViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/BouncerViewModel.kt
@@ -22,13 +22,12 @@
 import com.android.systemui.R
 import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
 import com.android.systemui.bouncer.domain.interactor.BouncerInteractor
+import com.android.systemui.dagger.SysUISingleton
 import com.android.systemui.dagger.qualifiers.Application
 import com.android.systemui.flags.FeatureFlags
 import com.android.systemui.flags.Flags
 import com.android.systemui.util.kotlin.pairwise
-import dagger.assisted.Assisted
-import dagger.assisted.AssistedFactory
-import dagger.assisted.AssistedInject
+import javax.inject.Inject
 import kotlin.math.ceil
 import kotlinx.coroutines.CoroutineScope
 import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -45,17 +44,15 @@
 import kotlinx.coroutines.launch
 
 /** Holds UI state and handles user input on bouncer UIs. */
+@SysUISingleton
 class BouncerViewModel
-@AssistedInject
+@Inject
 constructor(
     @Application private val applicationContext: Context,
     @Application private val applicationScope: CoroutineScope,
-    interactorFactory: BouncerInteractor.Factory,
+    private val interactor: BouncerInteractor,
     featureFlags: FeatureFlags,
-    @Assisted containerName: String,
 ) {
-    private val interactor: BouncerInteractor = interactorFactory.create(containerName)
-
     private val isInputEnabled: StateFlow<Boolean> =
         interactor.isThrottled
             .map { !it }
@@ -222,11 +219,4 @@
          */
         val isUpdateAnimated: Boolean,
     )
-
-    @AssistedFactory
-    interface Factory {
-        fun create(
-            containerName: String,
-        ): BouncerViewModel
-    }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/controls/management/ControlsListingControllerImpl.kt b/packages/SystemUI/src/com/android/systemui/controls/management/ControlsListingControllerImpl.kt
index 1eba667..83bec66 100644
--- a/packages/SystemUI/src/com/android/systemui/controls/management/ControlsListingControllerImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/controls/management/ControlsListingControllerImpl.kt
@@ -124,8 +124,7 @@
     }
 
     private fun updateServices(newServices: List<ControlsServiceInfo>) {
-        if (featureFlags.isEnabled(Flags.USE_APP_PANELS) &&
-                activityTaskManagerProxy.supportsMultiWindow(context)) {
+        if (activityTaskManagerProxy.supportsMultiWindow(context)) {
             val allowAllApps = featureFlags.isEnabled(Flags.APP_PANELS_ALL_APPS_ALLOWED)
             newServices.forEach {
                 it.resolvePanelActivity(allowAllApps) }
diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlActionCoordinatorImpl.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlActionCoordinatorImpl.kt
index 3713811..a7e9efd8 100644
--- a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlActionCoordinatorImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlActionCoordinatorImpl.kt
@@ -34,12 +34,9 @@
 import com.android.internal.annotations.VisibleForTesting
 import com.android.systemui.broadcast.BroadcastSender
 import com.android.systemui.controls.ControlsMetricsLogger
-import com.android.systemui.controls.settings.ControlsSettingsDialogManager
 import com.android.systemui.controls.settings.ControlsSettingsRepository
 import com.android.systemui.dagger.SysUISingleton
 import com.android.systemui.dagger.qualifiers.Main
-import com.android.systemui.flags.FeatureFlags
-import com.android.systemui.flags.Flags
 import com.android.systemui.plugins.ActivityStarter
 import com.android.systemui.statusbar.VibratorHelper
 import com.android.systemui.statusbar.policy.KeyguardStateController
@@ -60,8 +57,6 @@
         private val controlsMetricsLogger: ControlsMetricsLogger,
         private val vibrator: VibratorHelper,
         private val controlsSettingsRepository: ControlsSettingsRepository,
-        private val controlsSettingsDialogManager: ControlsSettingsDialogManager,
-        private val featureFlags: FeatureFlags,
 ) : ControlActionCoordinator {
     private var dialog: Dialog? = null
     private var pendingAction: Action? = null
@@ -77,9 +72,6 @@
     }
 
     override fun closeDialogs() {
-        if (!featureFlags.isEnabled(Flags.USE_APP_PANELS)) {
-            controlsSettingsDialogManager.closeDialog()
-        }
         val isActivityFinishing =
             (activityContext as? Activity)?.let { it.isFinishing || it.isDestroyed }
         if (isActivityFinishing == true) {
@@ -169,7 +161,6 @@
     override fun runPendingAction(controlId: String) {
         if (isLocked) return
         if (pendingAction?.controlId == controlId) {
-            showSettingsDialogIfNeeded(pendingAction!!)
             pendingAction?.invoke()
             pendingAction = null
         }
@@ -208,7 +199,6 @@
                 true
             }, { pendingAction = null }, true /* afterKeyguardGone */)
         } else {
-            showSettingsDialogIfNeeded(action)
             action.invoke()
         }
     }
@@ -243,15 +233,6 @@
         }
     }
 
-    private fun showSettingsDialogIfNeeded(action: Action) {
-        if (action.authIsRequired) {
-            return
-        }
-        if (!featureFlags.isEnabled(Flags.USE_APP_PANELS)) {
-            controlsSettingsDialogManager.maybeShowDialog(activityContext) {}
-        }
-    }
-
     @VisibleForTesting
     fun createAction(
         controlId: String,
diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsActivity.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsActivity.kt
index 557dcf4..8341964 100644
--- a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsActivity.kt
+++ b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsActivity.kt
@@ -36,7 +36,6 @@
 import com.android.systemui.controls.management.ControlsAnimations
 import com.android.systemui.controls.settings.ControlsSettingsDialogManager
 import com.android.systemui.flags.FeatureFlags
-import com.android.systemui.flags.Flags
 import com.android.systemui.statusbar.policy.KeyguardStateController
 import javax.inject.Inject
 
@@ -66,9 +65,7 @@
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
         lastConfiguration.setTo(resources.configuration)
-        if (featureFlags.isEnabled(Flags.USE_APP_PANELS)) {
-            window.addPrivateFlags(WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY)
-        }
+        window.addPrivateFlags(WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY)
 
         setContentView(R.layout.controls_fullscreen)
 
@@ -77,7 +74,7 @@
                 requireViewById(R.id.control_detail_root),
                 window,
                 intent,
-                !featureFlags.isEnabled(Flags.USE_APP_PANELS)
+                false
             )
         )
 
@@ -114,7 +111,7 @@
 
         parent = requireViewById(R.id.control_detail_root)
         parent.alpha = 0f
-        if (featureFlags.isEnabled(Flags.USE_APP_PANELS) && !keyguardStateController.isUnlocked) {
+        if (!keyguardStateController.isUnlocked) {
             controlsSettingsDialogManager.maybeShowDialog(this) {
                 uiController.show(parent, { finishOrReturnToDream() }, this)
             }
diff --git a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java
index 553405f..5577cbc 100644
--- a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java
+++ b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java
@@ -17,6 +17,7 @@
 package com.android.systemui.dreams;
 
 import static com.android.systemui.dreams.dagger.DreamModule.DREAM_OVERLAY_WINDOW_TITLE;
+import static com.android.systemui.dreams.dagger.DreamModule.DREAM_TOUCH_INSET_MANAGER;
 
 import android.content.ComponentName;
 import android.content.Context;
@@ -161,7 +162,7 @@
             DreamOverlayStateController stateController,
             KeyguardUpdateMonitor keyguardUpdateMonitor,
             UiEventLogger uiEventLogger,
-            TouchInsetManager touchInsetManager,
+            @Named(DREAM_TOUCH_INSET_MANAGER) TouchInsetManager touchInsetManager,
             @Nullable @Named(LowLightDreamModule.LOW_LIGHT_DREAM_COMPONENT)
                     ComponentName lowLightDreamComponent,
             DreamOverlayCallbackController dreamOverlayCallbackController,
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 c61b4775..4bafe32 100644
--- a/packages/SystemUI/src/com/android/systemui/dreams/dagger/DreamModule.java
+++ b/packages/SystemUI/src/com/android/systemui/dreams/dagger/DreamModule.java
@@ -31,11 +31,13 @@
 import com.android.systemui.dreams.DreamOverlayService;
 import com.android.systemui.dreams.complication.dagger.ComplicationComponent;
 import com.android.systemui.dreams.touch.scrim.dagger.ScrimModule;
+import com.android.systemui.touch.TouchInsetManager;
 
 import dagger.Module;
 import dagger.Provides;
 
 import java.util.Optional;
+import java.util.concurrent.Executor;
 
 import javax.inject.Named;
 
@@ -55,7 +57,7 @@
     String DREAM_ONLY_ENABLED_FOR_DOCK_USER = "dream_only_enabled_for_dock_user";
     String DREAM_OVERLAY_SERVICE_COMPONENT = "dream_overlay_service_component";
     String DREAM_OVERLAY_ENABLED = "dream_overlay_enabled";
-
+    String DREAM_TOUCH_INSET_MANAGER = "dream_touch_inset_manager";
     String DREAM_SUPPORTED = "dream_supported";
     String DREAM_OVERLAY_WINDOW_TITLE = "dream_overlay_window_title";
 
@@ -69,6 +71,15 @@
     }
 
     /**
+     * Provides a touch inset manager for dreams.
+     */
+    @Provides
+    @Named(DREAM_TOUCH_INSET_MANAGER)
+    static TouchInsetManager providesTouchInsetManager(@Main Executor executor) {
+        return new TouchInsetManager(executor);
+    }
+
+    /**
      * Provides whether dream overlay is enabled.
      */
     @Provides
diff --git a/packages/SystemUI/src/com/android/systemui/flags/Flags.kt b/packages/SystemUI/src/com/android/systemui/flags/Flags.kt
index f3339c0..40a90fb 100644
--- a/packages/SystemUI/src/com/android/systemui/flags/Flags.kt
+++ b/packages/SystemUI/src/com/android/systemui/flags/Flags.kt
@@ -62,11 +62,12 @@
     val INSTANT_VOICE_REPLY = unreleasedFlag(111, "instant_voice_reply")
 
     /**
-     * This flag is server-controlled and should stay as [unreleasedFlag] since we never want to
-     * enable it on release builds.
+     * This flag controls whether we register a listener for StatsD notification memory reports.
+     * For statsd to actually call the listener however, a server-side toggle needs to be
+     * enabled as well.
      */
     val NOTIFICATION_MEMORY_LOGGING_ENABLED =
-        unreleasedFlag(119, "notification_memory_logging_enabled")
+            releasedFlag(119, "notification_memory_logging_enabled")
 
     // TODO(b/260335638): Tracking Bug
     @JvmField
@@ -239,7 +240,7 @@
 
     /** Whether to delay showing bouncer UI when face auth or active unlock are enrolled. */
     // TODO(b/279794160): Tracking bug.
-    @JvmField val DELAY_BOUNCER = unreleasedFlag(235, "delay_bouncer", teamfood = true)
+    @JvmField val DELAY_BOUNCER = releasedFlag(235, "delay_bouncer")
 
     /** Keyguard Migration */
 
@@ -382,6 +383,9 @@
     // 804 - monochromatic themes
     @JvmField val MONOCHROMATIC_THEME = releasedFlag(804, "monochromatic")
 
+    // TODO(b/293380347): Tracking Bug
+    @JvmField val COLOR_FIDELITY = unreleasedFlag(805, "color_fidelity")
+
     // 900 - media
     // TODO(b/254512697): Tracking Bug
     val MEDIA_TAP_TO_TRANSFER = releasedFlag(900, "media_tap_to_transfer")
@@ -613,8 +617,6 @@
     @JvmField val NOTE_TASKS = releasedFlag(1900, "keycode_flag")
 
     // 2000 - device controls
-    @Keep @JvmField val USE_APP_PANELS = releasedFlag(2000, "use_app_panels")
-
     @JvmField val APP_PANELS_ALL_APPS_ALLOWED = releasedFlag(2001, "app_panels_all_apps_allowed")
 
     @JvmField
@@ -731,4 +733,12 @@
     // TODO(b/290213663): Tracking Bug
     @JvmField
     val ONE_WAY_HAPTICS_API_MIGRATION = unreleasedFlag(3100, "oneway_haptics_api_migration")
+
+    /** Enable the Compose implementation of the PeopleSpaceActivity. */
+    @JvmField
+    val COMPOSE_PEOPLE_SPACE = unreleasedFlag(293570761, "compose_people_space")
+
+    /** Enable the Compose implementation of the Quick Settings footer actions. */
+    @JvmField
+    val COMPOSE_QS_FOOTER_ACTIONS = unreleasedFlag(293569320, "compose_qs_footer_actions")
 }
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/DeviceEntryFaceAuthRepository.kt b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/DeviceEntryFaceAuthRepository.kt
index 6fd3e21..30f8f3e 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/DeviceEntryFaceAuthRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/DeviceEntryFaceAuthRepository.kt
@@ -110,6 +110,18 @@
     fun lockoutFaceAuth()
 
     /**
+     * Cancel current face authentication and prevent it from running until [resumeFaceAuth] is
+     * invoked.
+     */
+    fun pauseFaceAuth()
+
+    /**
+     * Allow face auth paused using [pauseFaceAuth] to run again. The next invocation to
+     * [authenticate] will run as long as other gating conditions don't stop it from running.
+     */
+    fun resumeFaceAuth()
+
+    /**
      * Trigger face authentication.
      *
      * [uiEvent] provided should be logged whenever face authentication runs. Invocation should be
@@ -186,6 +198,15 @@
     override val isAuthRunning: StateFlow<Boolean>
         get() = _isAuthRunning
 
+    private val faceAuthPaused = MutableStateFlow(false)
+    override fun pauseFaceAuth() {
+        faceAuthPaused.value = true
+    }
+
+    override fun resumeFaceAuth() {
+        faceAuthPaused.value = false
+    }
+
     private val keyguardSessionId: InstanceId?
         get() = sessionTracker.getSessionId(StatusBarManager.SESSION_KEYGUARD)
 
@@ -329,11 +350,7 @@
                     "isFaceAuthenticationEnabled",
                     tableLogBuffer
                 ),
-                logAndObserve(
-                    userRepository.userSwitchingInProgress.isFalse(),
-                    "userSwitchingNotInProgress",
-                    tableLogBuffer
-                ),
+                logAndObserve(faceAuthPaused.isFalse(), "faceAuthIsNotPaused", tableLogBuffer),
                 logAndObserve(
                     keyguardRepository.isKeyguardGoingAway.isFalse(),
                     "keyguardNotGoingAway",
@@ -454,7 +471,6 @@
         }
 
     private fun handleFaceCancellationError() {
-        cancelNotReceivedHandlerJob?.cancel()
         applicationScope.launch {
             faceAuthRequestedWhileCancellation?.let {
                 faceAuthLogger.launchingQueuedFaceAuthRequest(it)
@@ -483,6 +499,7 @@
     }
 
     private fun onFaceAuthRequestCompleted() {
+        cancelNotReceivedHandlerJob?.cancel()
         cancellationInProgress = false
         _isAuthRunning.value = false
         authCancellationSignal = null
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/NoopDeviceEntryFaceAuthRepository.kt b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/NoopDeviceEntryFaceAuthRepository.kt
index 5ef9a9e..e4e6a6d 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/NoopDeviceEntryFaceAuthRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/NoopDeviceEntryFaceAuthRepository.kt
@@ -56,6 +56,9 @@
         get() = emptyFlow()
 
     override fun lockoutFaceAuth() = Unit
+    override fun pauseFaceAuth() = Unit
+
+    override fun resumeFaceAuth() = Unit
 
     /**
      * Trigger face authentication.
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/LockscreenSceneInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/LockscreenSceneInteractor.kt
index 1c200b0..278c68d 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/LockscreenSceneInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/LockscreenSceneInteractor.kt
@@ -19,10 +19,9 @@
 import com.android.systemui.authentication.domain.interactor.AuthenticationInteractor
 import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
 import com.android.systemui.bouncer.domain.interactor.BouncerInteractor
+import com.android.systemui.dagger.SysUISingleton
 import com.android.systemui.dagger.qualifiers.Application
-import dagger.assisted.Assisted
-import dagger.assisted.AssistedFactory
-import dagger.assisted.AssistedInject
+import javax.inject.Inject
 import kotlinx.coroutines.CoroutineScope
 import kotlinx.coroutines.flow.SharingStarted
 import kotlinx.coroutines.flow.StateFlow
@@ -30,17 +29,14 @@
 import kotlinx.coroutines.flow.stateIn
 
 /** Hosts business and application state accessing logic for the lockscreen scene. */
+@SysUISingleton
 class LockscreenSceneInteractor
-@AssistedInject
+@Inject
 constructor(
     @Application applicationScope: CoroutineScope,
     private val authenticationInteractor: AuthenticationInteractor,
-    bouncerInteractorFactory: BouncerInteractor.Factory,
-    @Assisted private val containerName: String,
+    private val bouncerInteractor: BouncerInteractor,
 ) {
-    private val bouncerInteractor: BouncerInteractor =
-        bouncerInteractorFactory.create(containerName)
-
     /** Whether the device is currently locked. */
     val isDeviceLocked: StateFlow<Boolean> =
         authenticationInteractor.isUnlocked
@@ -67,13 +63,6 @@
 
     /** Attempts to dismiss the lockscreen. This will cause the bouncer to show, if needed. */
     fun dismissLockscreen() {
-        bouncerInteractor.showOrUnlockDevice(containerName = containerName)
-    }
-
-    @AssistedFactory
-    interface Factory {
-        fun create(
-            containerName: String,
-        ): LockscreenSceneInteractor
+        bouncerInteractor.showOrUnlockDevice()
     }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/SystemUIKeyguardFaceAuthInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/SystemUIKeyguardFaceAuthInteractor.kt
index 8f4776f..2a3f852 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/SystemUIKeyguardFaceAuthInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/SystemUIKeyguardFaceAuthInteractor.kt
@@ -35,6 +35,7 @@
 import com.android.systemui.keyguard.shared.model.FaceAuthenticationStatus
 import com.android.systemui.keyguard.shared.model.TransitionState
 import com.android.systemui.log.FaceAuthenticationLogger
+import com.android.systemui.user.data.repository.UserRepository
 import com.android.systemui.util.kotlin.pairwise
 import javax.inject.Inject
 import kotlinx.coroutines.CoroutineDispatcher
@@ -49,6 +50,7 @@
 import kotlinx.coroutines.flow.merge
 import kotlinx.coroutines.flow.onEach
 import kotlinx.coroutines.launch
+import kotlinx.coroutines.withContext
 
 /**
  * Encapsulates business logic related face authentication being triggered for device entry from
@@ -69,6 +71,7 @@
     private val faceAuthenticationLogger: FaceAuthenticationLogger,
     private val keyguardUpdateMonitor: KeyguardUpdateMonitor,
     private val deviceEntryFingerprintAuthRepository: DeviceEntryFingerprintAuthRepository,
+    private val userRepository: UserRepository,
 ) : CoreStartable, KeyguardFaceAuthInteractor {
 
     private val listeners: MutableList<FaceAuthenticationListener> = mutableListOf()
@@ -128,6 +131,23 @@
                 }
             }
             .launchIn(applicationScope)
+
+        // User switching should stop face auth and then when it is complete we should trigger face
+        // auth so that the switched user can unlock the device with face auth.
+        userRepository.userSwitchingInProgress
+            .pairwise(false)
+            .onEach { (wasSwitching, isSwitching) ->
+                if (!wasSwitching && isSwitching) {
+                    repository.pauseFaceAuth()
+                } else if (wasSwitching && !isSwitching) {
+                    repository.resumeFaceAuth()
+                    runFaceAuth(
+                        FaceAuthUiEvent.FACE_AUTH_UPDATED_USER_SWITCHING,
+                        fallbackToDetect = true
+                    )
+                }
+            }
+            .launchIn(applicationScope)
     }
 
     override fun onSwipeUpOnBouncer() {
@@ -199,8 +219,10 @@
             } else {
                 faceAuthenticationStatusOverride.value = null
                 applicationScope.launch {
-                    faceAuthenticationLogger.authRequested(uiEvent)
-                    repository.authenticate(uiEvent, fallbackToDetection = fallbackToDetect)
+                    withContext(mainDispatcher) {
+                        faceAuthenticationLogger.authRequested(uiEvent)
+                        repository.authenticate(uiEvent, fallbackToDetection = fallbackToDetect)
+                    }
                 }
             }
         } else {
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneViewModel.kt
index f212a55..abd178c 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneViewModel.kt
@@ -19,12 +19,11 @@
 import com.android.systemui.R
 import com.android.systemui.common.shared.model.ContentDescription
 import com.android.systemui.common.shared.model.Icon
+import com.android.systemui.dagger.SysUISingleton
 import com.android.systemui.dagger.qualifiers.Application
 import com.android.systemui.keyguard.domain.interactor.LockscreenSceneInteractor
 import com.android.systemui.scene.shared.model.SceneKey
-import dagger.assisted.Assisted
-import dagger.assisted.AssistedFactory
-import dagger.assisted.AssistedInject
+import javax.inject.Inject
 import kotlinx.coroutines.CoroutineScope
 import kotlinx.coroutines.flow.SharingStarted
 import kotlinx.coroutines.flow.StateFlow
@@ -32,15 +31,13 @@
 import kotlinx.coroutines.flow.stateIn
 
 /** Models UI state and handles user input for the lockscreen scene. */
+@SysUISingleton
 class LockscreenSceneViewModel
-@AssistedInject
+@Inject
 constructor(
     @Application applicationScope: CoroutineScope,
-    interactorFactory: LockscreenSceneInteractor.Factory,
-    @Assisted containerName: String,
+    private val interactor: LockscreenSceneInteractor,
 ) {
-    private val interactor: LockscreenSceneInteractor = interactorFactory.create(containerName)
-
     /** The icon for the "lock" button on the lockscreen. */
     val lockButtonIcon: StateFlow<Icon> =
         interactor.isDeviceLocked
@@ -98,11 +95,4 @@
                 )
         )
     }
-
-    @AssistedFactory
-    interface Factory {
-        fun create(
-            containerName: String,
-        ): LockscreenSceneViewModel
-    }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaProjectionAppSelectorActivity.kt b/packages/SystemUI/src/com/android/systemui/media/MediaProjectionAppSelectorActivity.kt
index 42164c7..fdb3ddd 100644
--- a/packages/SystemUI/src/com/android/systemui/media/MediaProjectionAppSelectorActivity.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/MediaProjectionAppSelectorActivity.kt
@@ -30,16 +30,11 @@
 import android.os.ResultReceiver
 import android.os.UserHandle
 import android.view.ViewGroup
-import androidx.lifecycle.Lifecycle
-import androidx.lifecycle.LifecycleOwner
-import androidx.lifecycle.LifecycleRegistry
+import com.android.intentresolver.AbstractMultiProfilePagerAdapter.EmptyStateProvider
+import com.android.intentresolver.AbstractMultiProfilePagerAdapter.MyUserIdProvider
+import com.android.intentresolver.ChooserActivity
+import com.android.intentresolver.chooser.TargetInfo
 import com.android.internal.annotations.VisibleForTesting
-import com.android.internal.app.AbstractMultiProfilePagerAdapter.EmptyStateProvider
-import com.android.internal.app.AbstractMultiProfilePagerAdapter.MyUserIdProvider
-import com.android.internal.app.ChooserActivity
-import com.android.internal.app.ResolverListController
-import com.android.internal.app.chooser.NotSelectableTargetInfo
-import com.android.internal.app.chooser.TargetInfo
 import com.android.systemui.R
 import com.android.systemui.mediaprojection.appselector.MediaProjectionAppSelectorComponent
 import com.android.systemui.mediaprojection.appselector.MediaProjectionAppSelectorController
@@ -56,12 +51,8 @@
     private val activityLauncher: AsyncActivityLauncher,
     /** This is used to override the dependency in a screenshot test */
     @VisibleForTesting
-    private val listControllerFactory: ((userHandle: UserHandle) -> ResolverListController)?
-) :
-    ChooserActivity(),
-    MediaProjectionAppSelectorView,
-    MediaProjectionAppSelectorResultHandler,
-    LifecycleOwner {
+    private val listControllerFactory: ((userHandle: UserHandle) -> ChooserListController)?
+) : ChooserActivity(), MediaProjectionAppSelectorView, MediaProjectionAppSelectorResultHandler {
 
     @Inject
     constructor(
@@ -69,8 +60,6 @@
         activityLauncher: AsyncActivityLauncher
     ) : this(componentFactory, activityLauncher, listControllerFactory = null)
 
-    private val lifecycleRegistry = LifecycleRegistry(this)
-    override val lifecycle = lifecycleRegistry
     private lateinit var configurationController: ConfigurationController
     private lateinit var controller: MediaProjectionAppSelectorController
     private lateinit var recentsViewController: MediaProjectionRecentsViewController
@@ -84,7 +73,6 @@
     override fun getLayoutResource() = R.layout.media_projection_app_selector
 
     public override fun onCreate(bundle: Bundle?) {
-        lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_CREATE)
         component = componentFactory.create(view = this, resultHandler = this)
         component.lifecycleObservers.forEach { lifecycle.addObserver(it) }
 
@@ -107,26 +95,6 @@
         controller.init()
     }
 
-    override fun onStart() {
-        super.onStart()
-        lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_START)
-    }
-
-    override fun onResume() {
-        super.onResume()
-        lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_RESUME)
-    }
-
-    override fun onPause() {
-        lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_PAUSE)
-        super.onPause()
-    }
-
-    override fun onStop() {
-        lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_STOP)
-        super.onStop()
-    }
-
     override fun onConfigurationChanged(newConfig: Configuration) {
         super.onConfigurationChanged(newConfig)
         configurationController.onConfigurationChanged(newConfig)
@@ -137,13 +105,13 @@
     override fun createBlockerEmptyStateProvider(): EmptyStateProvider =
         component.emptyStateProvider
 
-    override fun createListController(userHandle: UserHandle): ResolverListController =
+    override fun createListController(userHandle: UserHandle): ChooserListController =
         listControllerFactory?.invoke(userHandle) ?: super.createListController(userHandle)
 
     override fun startSelected(which: Int, always: Boolean, filtered: Boolean) {
         val currentListAdapter = mChooserMultiProfilePagerAdapter.activeListAdapter
         val targetInfo = currentListAdapter.targetInfoForPosition(which, filtered) ?: return
-        if (targetInfo is NotSelectableTargetInfo) return
+        if (targetInfo.isNotSelectableTargetInfo) return
 
         val intent = createIntent(targetInfo)
 
@@ -183,7 +151,6 @@
     }
 
     override fun onDestroy() {
-        lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_DESTROY)
         component.lifecycleObservers.forEach { lifecycle.removeObserver(it) }
         // onDestroy is also called when an app is selected, in that case we only want to send
         // RECORD_CONTENT_TASK but not RECORD_CANCEL
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/pipeline/LocalMediaManagerFactory.kt b/packages/SystemUI/src/com/android/systemui/media/controls/pipeline/LocalMediaManagerFactory.kt
index f908481..785a1e8 100644
--- a/packages/SystemUI/src/com/android/systemui/media/controls/pipeline/LocalMediaManagerFactory.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/controls/pipeline/LocalMediaManagerFactory.kt
@@ -18,8 +18,8 @@
 
 import android.content.Context
 import com.android.settingslib.bluetooth.LocalBluetoothManager
+import com.android.settingslib.media.InfoMediaManager
 import com.android.settingslib.media.LocalMediaManager
-import com.android.settingslib.media.ManagerInfoMediaManager
 import javax.inject.Inject
 
 /** Factory to create [LocalMediaManager] objects. */
@@ -31,8 +31,7 @@
 ) {
     /** Creates a [LocalMediaManager] for the given package. */
     fun create(packageName: String): LocalMediaManager {
-        return ManagerInfoMediaManager(context, packageName, null, localBluetoothManager).run {
-            LocalMediaManager(context, localBluetoothManager, this, packageName)
-        }
+        return InfoMediaManager.createInstance(context, packageName, null, localBluetoothManager)
+            .run { LocalMediaManager(context, localBluetoothManager, this, packageName) }
     }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputController.java b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputController.java
index 83631b0..be42569 100644
--- a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputController.java
+++ b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputController.java
@@ -76,7 +76,6 @@
 import com.android.settingslib.bluetooth.LocalBluetoothManager;
 import com.android.settingslib.media.InfoMediaManager;
 import com.android.settingslib.media.LocalMediaManager;
-import com.android.settingslib.media.ManagerInfoMediaManager;
 import com.android.settingslib.media.MediaDevice;
 import com.android.settingslib.utils.ThreadUtils;
 import com.android.systemui.R;
@@ -194,7 +193,7 @@
         mKeyGuardManager = keyGuardManager;
         mFeatureFlags = featureFlags;
         mUserTracker = userTracker;
-        InfoMediaManager imm = new ManagerInfoMediaManager(mContext, packageName, null, lbm);
+        InfoMediaManager imm = InfoMediaManager.createInstance(mContext, packageName, null, lbm);
         mLocalMediaManager = new LocalMediaManager(mContext, lbm, imm, packageName);
         mMetricLogger = new MediaOutputMetricLogger(mContext, mPackageName);
         mDialogLaunchAnimator = dialogLaunchAnimator;
diff --git a/packages/SystemUI/src/com/android/systemui/mediaprojection/appselector/MediaProjectionBlockerEmptyStateProvider.kt b/packages/SystemUI/src/com/android/systemui/mediaprojection/appselector/MediaProjectionBlockerEmptyStateProvider.kt
index 829b0dd..fd14e2b 100644
--- a/packages/SystemUI/src/com/android/systemui/mediaprojection/appselector/MediaProjectionBlockerEmptyStateProvider.kt
+++ b/packages/SystemUI/src/com/android/systemui/mediaprojection/appselector/MediaProjectionBlockerEmptyStateProvider.kt
@@ -17,10 +17,10 @@
 
 import android.content.Context
 import android.os.UserHandle
+import com.android.intentresolver.AbstractMultiProfilePagerAdapter.EmptyState
+import com.android.intentresolver.AbstractMultiProfilePagerAdapter.EmptyStateProvider
+import com.android.intentresolver.ResolverListAdapter
 import com.android.internal.R as AndroidR
-import com.android.internal.app.AbstractMultiProfilePagerAdapter.EmptyState
-import com.android.internal.app.AbstractMultiProfilePagerAdapter.EmptyStateProvider
-import com.android.internal.app.ResolverListAdapter
 import com.android.systemui.R
 import com.android.systemui.mediaprojection.devicepolicy.PersonalProfile
 import com.android.systemui.mediaprojection.devicepolicy.ScreenCaptureDevicePolicyResolver
diff --git a/packages/SystemUI/src/com/android/systemui/people/PeopleSpaceActivity.java b/packages/SystemUI/src/com/android/systemui/people/PeopleSpaceActivity.java
index 7f0f894..d1d3e3d 100644
--- a/packages/SystemUI/src/com/android/systemui/people/PeopleSpaceActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/people/PeopleSpaceActivity.java
@@ -28,6 +28,8 @@
 import androidx.lifecycle.ViewModelProvider;
 
 import com.android.systemui.compose.ComposeFacade;
+import com.android.systemui.flags.FeatureFlags;
+import com.android.systemui.flags.Flags;
 import com.android.systemui.people.ui.view.PeopleViewBinder;
 import com.android.systemui.people.ui.viewmodel.PeopleViewModel;
 
@@ -43,11 +45,14 @@
     private static final boolean DEBUG = PeopleSpaceUtils.DEBUG;
 
     private final PeopleViewModel.Factory mViewModelFactory;
+    private final FeatureFlags mFeatureFlags;
 
     @Inject
-    public PeopleSpaceActivity(PeopleViewModel.Factory viewModelFactory) {
+    public PeopleSpaceActivity(PeopleViewModel.Factory viewModelFactory,
+            FeatureFlags featureFlags) {
         super();
         mViewModelFactory = viewModelFactory;
+        mFeatureFlags = featureFlags;
     }
 
     @Override
@@ -67,7 +72,8 @@
             return null;
         };
 
-        if (ComposeFacade.INSTANCE.isComposeAvailable()) {
+        if (mFeatureFlags.isEnabled(Flags.COMPOSE_PEOPLE_SPACE)
+                && ComposeFacade.INSTANCE.isComposeAvailable()) {
             Log.d(TAG, "Using the Compose implementation of the PeopleSpaceActivity");
             ComposeFacade.INSTANCE.setPeopleSpaceActivityContent(this, viewModel, onResult);
         } else {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java b/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java
index a2b2a89..d801faa 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java
@@ -52,6 +52,7 @@
 import com.android.systemui.compose.ComposeFacade;
 import com.android.systemui.dump.DumpManager;
 import com.android.systemui.flags.FeatureFlags;
+import com.android.systemui.flags.Flags;
 import com.android.systemui.media.controls.ui.MediaHost;
 import com.android.systemui.plugins.qs.QS;
 import com.android.systemui.plugins.qs.QSContainerController;
@@ -285,7 +286,8 @@
     private void bindFooterActionsView(View root) {
         LinearLayout footerActionsView = root.findViewById(R.id.qs_footer_actions);
 
-        if (!ComposeFacade.INSTANCE.isComposeAvailable()) {
+        if (!mFeatureFlags.isEnabled(Flags.COMPOSE_QS_FOOTER_ACTIONS)
+                || !ComposeFacade.INSTANCE.isComposeAvailable()) {
             Log.d(TAG, "Binding the View implementation of the QS footer actions");
             mFooterActionsViewBinder.bind(footerActionsView, mQSFooterActionsViewModel,
                     mListeningAndVisibilityLifecycleOwner);
diff --git a/packages/SystemUI/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsSceneViewModel.kt b/packages/SystemUI/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsSceneViewModel.kt
index 36dec1d..5e6a44b 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsSceneViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsSceneViewModel.kt
@@ -16,30 +16,19 @@
 
 package com.android.systemui.qs.ui.viewmodel
 
+import com.android.systemui.dagger.SysUISingleton
 import com.android.systemui.keyguard.domain.interactor.LockscreenSceneInteractor
-import dagger.assisted.Assisted
-import dagger.assisted.AssistedFactory
-import dagger.assisted.AssistedInject
+import javax.inject.Inject
 
 /** Models UI state and handles user input for the quick settings scene. */
+@SysUISingleton
 class QuickSettingsSceneViewModel
-@AssistedInject
+@Inject
 constructor(
-    lockscreenSceneInteractorFactory: LockscreenSceneInteractor.Factory,
-    @Assisted containerName: String,
+    private val lockscreenSceneInteractor: LockscreenSceneInteractor,
 ) {
-    private val lockscreenSceneInteractor: LockscreenSceneInteractor =
-        lockscreenSceneInteractorFactory.create(containerName)
-
     /** Notifies that some content in quick settings was clicked. */
     fun onContentClicked() {
         lockscreenSceneInteractor.dismissLockscreen()
     }
-
-    @AssistedFactory
-    interface Factory {
-        fun create(
-            containerName: String,
-        ): QuickSettingsSceneViewModel
-    }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java
index bf40a2d..03bd11b 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java
@@ -97,7 +97,6 @@
 import com.android.systemui.navigationbar.buttons.KeyButtonView;
 import com.android.systemui.recents.OverviewProxyService.OverviewProxyListener;
 import com.android.systemui.scene.domain.interactor.SceneInteractor;
-import com.android.systemui.scene.shared.model.SceneContainerNames;
 import com.android.systemui.settings.DisplayTracker;
 import com.android.systemui.settings.UserTracker;
 import com.android.systemui.shade.ShadeViewController;
@@ -221,8 +220,7 @@
                             // If scene framework is enabled, set the scene container window to
                             // visible and let the touch "slip" into that window.
                             if (mFeatureFlags.isEnabled(Flags.SCENE_CONTAINER)) {
-                                mSceneInteractor.get().setVisible(
-                                        SceneContainerNames.SYSTEM_UI_DEFAULT, true);
+                                mSceneInteractor.get().setVisible(true);
                             } else {
                                 centralSurfaces.onInputFocusTransfer(
                                         mInputFocusTransferStarted, false /* cancel */,
diff --git a/packages/SystemUI/src/com/android/systemui/scene/SceneContainerFrameworkModule.kt b/packages/SystemUI/src/com/android/systemui/scene/SceneContainerFrameworkModule.kt
index 0a9839e..398e64b 100644
--- a/packages/SystemUI/src/com/android/systemui/scene/SceneContainerFrameworkModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/scene/SceneContainerFrameworkModule.kt
@@ -16,16 +16,16 @@
 
 package com.android.systemui.scene
 
+import com.android.systemui.scene.domain.startable.SceneContainerStartableModule
 import com.android.systemui.scene.shared.model.SceneContainerConfigModule
 import com.android.systemui.scene.ui.composable.SceneModule
-import com.android.systemui.scene.ui.viewmodel.SceneContainerViewModelModule
 import dagger.Module
 
 @Module(
     includes =
         [
             SceneContainerConfigModule::class,
-            SceneContainerViewModelModule::class,
+            SceneContainerStartableModule::class,
             SceneModule::class,
         ],
 )
diff --git a/packages/SystemUI/src/com/android/systemui/scene/data/repository/SceneContainerRepository.kt b/packages/SystemUI/src/com/android/systemui/scene/data/repository/SceneContainerRepository.kt
index 0a86d35..1fca488 100644
--- a/packages/SystemUI/src/com/android/systemui/scene/data/repository/SceneContainerRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/scene/data/repository/SceneContainerRepository.kt
@@ -29,26 +29,20 @@
 class SceneContainerRepository
 @Inject
 constructor(
-    private val containerConfigByName: Map<String, SceneContainerConfig>,
+    private val config: SceneContainerConfig,
 ) {
 
-    private val containerVisibilityByName: Map<String, MutableStateFlow<Boolean>> =
-        containerConfigByName
-            .map { (containerName, _) -> containerName to MutableStateFlow(true) }
-            .toMap()
-    private val currentSceneByContainerName: Map<String, MutableStateFlow<SceneModel>> =
-        containerConfigByName
-            .map { (containerName, config) ->
-                containerName to MutableStateFlow(SceneModel(config.initialSceneKey))
-            }
-            .toMap()
-    private val sceneTransitionProgressByContainerName: Map<String, MutableStateFlow<Float>> =
-        containerConfigByName
-            .map { (containerName, _) -> containerName to MutableStateFlow(1f) }
-            .toMap()
-    private val sceneTransitionByContainerName:
-        Map<String, MutableStateFlow<SceneTransitionModel?>> =
-        containerConfigByName.keys.associateWith { MutableStateFlow(null) }
+    private val _isVisible = MutableStateFlow(true)
+    val isVisible: StateFlow<Boolean> = _isVisible.asStateFlow()
+
+    private val _currentScene = MutableStateFlow(SceneModel(config.initialSceneKey))
+    val currentScene: StateFlow<SceneModel> = _currentScene.asStateFlow()
+
+    private val _transitionProgress = MutableStateFlow(1f)
+    val transitionProgress: StateFlow<Float> = _transitionProgress.asStateFlow()
+
+    private val _transitions = MutableStateFlow<SceneTransitionModel?>(null)
+    val transitions: StateFlow<SceneTransitionModel?> = _transitions.asStateFlow()
 
     /**
      * Returns the keys to all scenes in the container with the given name.
@@ -56,100 +50,50 @@
      * The scenes will be sorted in z-order such that the last one is the one that should be
      * rendered on top of all previous ones.
      */
-    fun allSceneKeys(containerName: String): List<SceneKey> {
-        return containerConfigByName[containerName]?.sceneKeys
-            ?: error(noSuchContainerErrorMessage(containerName))
+    fun allSceneKeys(): List<SceneKey> {
+        return config.sceneKeys
     }
 
     /** Sets the current scene in the container with the given name. */
-    fun setCurrentScene(containerName: String, scene: SceneModel) {
-        check(allSceneKeys(containerName).contains(scene.key)) {
+    fun setCurrentScene(scene: SceneModel) {
+        check(allSceneKeys().contains(scene.key)) {
             """
-                Cannot set current scene key to "${scene.key}". The container "$containerName" does
-                not contain a scene with that key.
+                Cannot set current scene key to "${scene.key}". The configuration does not contain a
+                scene with that key.
             """
                 .trimIndent()
         }
 
-        currentSceneByContainerName.setValue(containerName, scene)
+        _currentScene.value = scene
     }
 
     /** Sets the scene transition in the container with the given name. */
-    fun setSceneTransition(containerName: String, from: SceneKey, to: SceneKey) {
-        check(allSceneKeys(containerName).contains(from)) {
+    fun setSceneTransition(from: SceneKey, to: SceneKey) {
+        check(allSceneKeys().contains(from)) {
             """
-                Cannot set current scene key to "$from". The container "$containerName" does
-                not contain a scene with that key.
+                Cannot set current scene key to "$from". The configuration does not contain a scene
+                with that key.
             """
                 .trimIndent()
         }
-        check(allSceneKeys(containerName).contains(to)) {
+        check(allSceneKeys().contains(to)) {
             """
-                Cannot set current scene key to "$to". The container "$containerName" does
-                not contain a scene with that key.
+                Cannot set current scene key to "$to". The configuration does not contain a scene
+                with that key.
             """
                 .trimIndent()
         }
 
-        sceneTransitionByContainerName.setValue(
-            containerName,
-            SceneTransitionModel(from = from, to = to)
-        )
-    }
-
-    /** The current scene in the container with the given name. */
-    fun currentScene(containerName: String): StateFlow<SceneModel> {
-        return currentSceneByContainerName.mutableOrError(containerName).asStateFlow()
-    }
-
-    /**
-     * Scene transitions as pairs of keys. A new value is emitted exactly once, each time a scene
-     * transition occurs. The flow begins with a `null` value at first, because the initial scene is
-     * not something that we transition to from another scene.
-     */
-    fun sceneTransitions(containerName: String): StateFlow<SceneTransitionModel?> {
-        return sceneTransitionByContainerName.mutableOrError(containerName).asStateFlow()
+        _transitions.value = SceneTransitionModel(from = from, to = to)
     }
 
     /** Sets whether the container with the given name is visible. */
-    fun setVisible(containerName: String, isVisible: Boolean) {
-        containerVisibilityByName.setValue(containerName, isVisible)
-    }
-
-    /** Whether the container with the given name should be visible. */
-    fun isVisible(containerName: String): StateFlow<Boolean> {
-        return containerVisibilityByName.mutableOrError(containerName).asStateFlow()
+    fun setVisible(isVisible: Boolean) {
+        _isVisible.value = isVisible
     }
 
     /** Sets scene transition progress to the current scene in the container with the given name. */
-    fun setSceneTransitionProgress(containerName: String, progress: Float) {
-        sceneTransitionProgressByContainerName.setValue(containerName, progress)
-    }
-
-    /** Progress of the transition into the current scene in the container with the given name. */
-    fun sceneTransitionProgress(containerName: String): StateFlow<Float> {
-        return sceneTransitionProgressByContainerName.mutableOrError(containerName).asStateFlow()
-    }
-
-    private fun <T> Map<String, MutableStateFlow<T>>.mutableOrError(
-        containerName: String,
-    ): MutableStateFlow<T> {
-        return this[containerName] ?: error(noSuchContainerErrorMessage(containerName))
-    }
-
-    private fun <T> Map<String, MutableStateFlow<T>>.setValue(
-        containerName: String,
-        value: T,
-    ) {
-        val mutable = mutableOrError(containerName)
-        mutable.value = value
-    }
-
-    private fun noSuchContainerErrorMessage(containerName: String): String {
-        return """
-            No container named "$containerName". Existing containers:
-            ${containerConfigByName.values.joinToString(", ") { it.name }}
-        """
-            .trimIndent()
+    fun setSceneTransitionProgress(progress: Float) {
+        _transitionProgress.value = progress
     }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/scene/domain/interactor/SceneInteractor.kt b/packages/SystemUI/src/com/android/systemui/scene/domain/interactor/SceneInteractor.kt
index f03f040..39daad3 100644
--- a/packages/SystemUI/src/com/android/systemui/scene/domain/interactor/SceneInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/scene/domain/interactor/SceneInteractor.kt
@@ -30,12 +30,8 @@
 /**
  * Generic business logic and app state accessors for the scene framework.
  *
- * Note that scene container specific business logic does not belong in this class. Instead, it
- * should be hoisted to a class that is specific to that scene container, for an example, please see
- * [SystemUiDefaultSceneContainerStartable].
- *
- * Also note that this class should not depend on state or logic of other modules or features.
- * Instead, other feature modules should depend on and call into this class when their parts of the
+ * Note that this class should not depend on state or logic of other modules or features. Instead,
+ * other feature modules should depend on and call into this class when their parts of the
  * application state change.
  */
 @SysUISingleton
@@ -51,50 +47,42 @@
      * The scenes will be sorted in z-order such that the last one is the one that should be
      * rendered on top of all previous ones.
      */
-    fun allSceneKeys(containerName: String): List<SceneKey> {
-        return repository.allSceneKeys(containerName)
+    fun allSceneKeys(): List<SceneKey> {
+        return repository.allSceneKeys()
     }
 
     /** Sets the scene in the container with the given name. */
-    fun setCurrentScene(containerName: String, scene: SceneModel) {
-        val currentSceneKey = repository.currentScene(containerName).value.key
-        repository.setCurrentScene(containerName, scene)
-        repository.setSceneTransition(containerName, from = currentSceneKey, to = scene.key)
+    fun setCurrentScene(scene: SceneModel) {
+        val currentSceneKey = repository.currentScene.value.key
+        repository.setCurrentScene(scene)
+        repository.setSceneTransition(from = currentSceneKey, to = scene.key)
     }
 
     /** The current scene in the container with the given name. */
-    fun currentScene(containerName: String): StateFlow<SceneModel> {
-        return repository.currentScene(containerName)
-    }
+    val currentScene: StateFlow<SceneModel> = repository.currentScene
 
     /** Sets the visibility of the container with the given name. */
-    fun setVisible(containerName: String, isVisible: Boolean) {
-        return repository.setVisible(containerName, isVisible)
+    fun setVisible(isVisible: Boolean) {
+        return repository.setVisible(isVisible)
     }
 
     /** Whether the container with the given name is visible. */
-    fun isVisible(containerName: String): StateFlow<Boolean> {
-        return repository.isVisible(containerName)
-    }
+    val isVisible: StateFlow<Boolean> = repository.isVisible
 
     /** Sets scene transition progress to the current scene in the container with the given name. */
-    fun setSceneTransitionProgress(containerName: String, progress: Float) {
-        repository.setSceneTransitionProgress(containerName, progress)
+    fun setSceneTransitionProgress(progress: Float) {
+        repository.setSceneTransitionProgress(progress)
     }
 
     /** Progress of the transition into the current scene in the container with the given name. */
-    fun sceneTransitionProgress(containerName: String): StateFlow<Float> {
-        return repository.sceneTransitionProgress(containerName)
-    }
+    val transitionProgress: StateFlow<Float> = repository.transitionProgress
 
     /**
      * Scene transitions as pairs of keys. A new value is emitted exactly once, each time a scene
      * transition occurs. The flow begins with a `null` value at first, because the initial scene is
      * not something that we transition to from another scene.
      */
-    fun sceneTransitions(containerName: String): StateFlow<SceneTransitionModel?> {
-        return repository.sceneTransitions(containerName)
-    }
+    val transitions: StateFlow<SceneTransitionModel?> = repository.transitions
 
     private val _remoteUserInput: MutableStateFlow<RemoteUserInput?> = MutableStateFlow(null)
 
diff --git a/packages/SystemUI/src/com/android/systemui/scene/domain/startable/SystemUiDefaultSceneContainerStartable.kt b/packages/SystemUI/src/com/android/systemui/scene/domain/startable/SceneContainerStartable.kt
similarity index 89%
rename from packages/SystemUI/src/com/android/systemui/scene/domain/startable/SystemUiDefaultSceneContainerStartable.kt
rename to packages/SystemUI/src/com/android/systemui/scene/domain/startable/SceneContainerStartable.kt
index 92384d6..1c87eb2 100644
--- a/packages/SystemUI/src/com/android/systemui/scene/domain/startable/SystemUiDefaultSceneContainerStartable.kt
+++ b/packages/SystemUI/src/com/android/systemui/scene/domain/startable/SceneContainerStartable.kt
@@ -28,7 +28,6 @@
 import com.android.systemui.model.SysUiState
 import com.android.systemui.model.updateFlags
 import com.android.systemui.scene.domain.interactor.SceneInteractor
-import com.android.systemui.scene.shared.model.SceneContainerNames
 import com.android.systemui.scene.shared.model.SceneKey
 import com.android.systemui.scene.shared.model.SceneModel
 import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_BOUNCER_SHOWING
@@ -44,12 +43,11 @@
 import kotlinx.coroutines.launch
 
 /**
- * Hooks up business logic that manipulates the state of the [SceneInteractor] for the default
- * system UI scene container (the one named [SceneContainerNames.SYSTEM_UI_DEFAULT]) based on state
- * from other systems.
+ * Hooks up business logic that manipulates the state of the [SceneInteractor] for the system UI
+ * scene container based on state from other systems.
  */
 @SysUISingleton
-class SystemUiDefaultSceneContainerStartable
+class SceneContainerStartable
 @Inject
 constructor(
     @Application private val applicationScope: CoroutineScope,
@@ -72,13 +70,10 @@
     /** Updates the visibility of the scene container based on the current scene. */
     private fun hydrateVisibility() {
         applicationScope.launch {
-            sceneInteractor
-                .currentScene(CONTAINER_NAME)
+            sceneInteractor.currentScene
                 .map { it.key }
                 .distinctUntilChanged()
-                .collect { sceneKey ->
-                    sceneInteractor.setVisible(CONTAINER_NAME, sceneKey != SceneKey.Gone)
-                }
+                .collect { sceneKey -> sceneInteractor.setVisible(sceneKey != SceneKey.Gone) }
         }
     }
 
@@ -87,7 +82,7 @@
         applicationScope.launch {
             authenticationInteractor.isUnlocked
                 .map { isUnlocked ->
-                    val currentSceneKey = sceneInteractor.currentScene(CONTAINER_NAME).value.key
+                    val currentSceneKey = sceneInteractor.currentScene.value.key
                     val isBypassEnabled = authenticationInteractor.isBypassEnabled()
                     when {
                         isUnlocked ->
@@ -135,8 +130,7 @@
     /** Keeps [SysUiState] up-to-date */
     private fun hydrateSystemUiState() {
         applicationScope.launch {
-            sceneInteractor
-                .currentScene(SceneContainerNames.SYSTEM_UI_DEFAULT)
+            sceneInteractor.currentScene
                 .map { it.key }
                 .distinctUntilChanged()
                 .collect { sceneKey ->
@@ -155,12 +149,7 @@
 
     private fun switchToScene(targetSceneKey: SceneKey) {
         sceneInteractor.setCurrentScene(
-            containerName = CONTAINER_NAME,
             scene = SceneModel(targetSceneKey),
         )
     }
-
-    companion object {
-        private const val CONTAINER_NAME = SceneContainerNames.SYSTEM_UI_DEFAULT
-    }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/scene/domain/startable/SceneContainerStartableModule.kt b/packages/SystemUI/src/com/android/systemui/scene/domain/startable/SceneContainerStartableModule.kt
index b3de2d1..8da1803 100644
--- a/packages/SystemUI/src/com/android/systemui/scene/domain/startable/SceneContainerStartableModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/scene/domain/startable/SceneContainerStartableModule.kt
@@ -27,6 +27,6 @@
 
     @Binds
     @IntoMap
-    @ClassKey(SystemUiDefaultSceneContainerStartable::class)
-    fun bind(impl: SystemUiDefaultSceneContainerStartable): CoreStartable
+    @ClassKey(SceneContainerStartable::class)
+    fun bind(impl: SceneContainerStartable): CoreStartable
 }
diff --git a/packages/SystemUI/src/com/android/systemui/scene/shared/model/Scene.kt b/packages/SystemUI/src/com/android/systemui/scene/shared/model/Scene.kt
index 354de8a..31597c1 100644
--- a/packages/SystemUI/src/com/android/systemui/scene/shared/model/Scene.kt
+++ b/packages/SystemUI/src/com/android/systemui/scene/shared/model/Scene.kt
@@ -27,8 +27,6 @@
  * takes care of rendering the current scene and allowing scenes to be switched from one to another
  * based on either user action (for example, swiping down while on the lock screen scene may switch
  * to the shade scene).
- *
- * The framework also supports multiple containers, each one with its own configuration.
  */
 interface Scene {
 
@@ -59,7 +57,7 @@
      * The API is designed such that it's possible to emit ever-changing values for each
      * [UserAction] to enable, disable, or change the destination scene of a given user action.
      */
-    fun destinationScenes(containerName: String): StateFlow<Map<UserAction, SceneModel>> =
+    fun destinationScenes(): StateFlow<Map<UserAction, SceneModel>> =
         MutableStateFlow(emptyMap<UserAction, SceneModel>()).asStateFlow()
 }
 
diff --git a/packages/SystemUI/src/com/android/systemui/scene/shared/model/SceneContainerConfig.kt b/packages/SystemUI/src/com/android/systemui/scene/shared/model/SceneContainerConfig.kt
index 0327edb..8204edc 100644
--- a/packages/SystemUI/src/com/android/systemui/scene/shared/model/SceneContainerConfig.kt
+++ b/packages/SystemUI/src/com/android/systemui/scene/shared/model/SceneContainerConfig.kt
@@ -16,10 +16,8 @@
 
 package com.android.systemui.scene.shared.model
 
-/** Models the configuration of a single scene container. */
+/** Models the configuration of the scene container. */
 data class SceneContainerConfig(
-    /** Container name. Must be unique across all containers in System UI. */
-    val name: String,
 
     /**
      * The keys to all scenes in the container, sorted by z-order such that the last one renders on
diff --git a/packages/SystemUI/src/com/android/systemui/scene/shared/model/SceneContainerConfigModule.kt b/packages/SystemUI/src/com/android/systemui/scene/shared/model/SceneContainerConfigModule.kt
index 7562a5a..f74005b 100644
--- a/packages/SystemUI/src/com/android/systemui/scene/shared/model/SceneContainerConfigModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/scene/shared/model/SceneContainerConfigModule.kt
@@ -16,44 +16,27 @@
 
 package com.android.systemui.scene.shared.model
 
-import com.android.systemui.dagger.SysUISingleton
 import dagger.Module
 import dagger.Provides
-import javax.inject.Named
 
 @Module
 object SceneContainerConfigModule {
 
     @Provides
-    fun containerConfigs(): Map<String, SceneContainerConfig> {
-        return mapOf(
-            SceneContainerNames.SYSTEM_UI_DEFAULT to
-                SceneContainerConfig(
-                    name = SceneContainerNames.SYSTEM_UI_DEFAULT,
-                    // Note that this list is in z-order. The first one is the bottom-most and the
-                    // last
-                    // one is top-most.
-                    sceneKeys =
-                        listOf(
-                            SceneKey.Gone,
-                            SceneKey.Lockscreen,
-                            SceneKey.Bouncer,
-                            SceneKey.Shade,
-                            SceneKey.QuickSettings,
-                        ),
-                    initialSceneKey = SceneKey.Lockscreen,
+    fun containerConfig(): SceneContainerConfig {
+        return SceneContainerConfig(
+            // Note that this list is in z-order. The first one is the bottom-most and the
+            // last
+            // one is top-most.
+            sceneKeys =
+                listOf(
+                    SceneKey.Gone,
+                    SceneKey.Lockscreen,
+                    SceneKey.Bouncer,
+                    SceneKey.Shade,
+                    SceneKey.QuickSettings,
                 ),
+            initialSceneKey = SceneKey.Lockscreen,
         )
     }
-
-    @Provides
-    @SysUISingleton
-    @Named(SceneContainerNames.SYSTEM_UI_DEFAULT)
-    fun provideDefaultSceneContainerConfig(
-        configs: Map<String, SceneContainerConfig>,
-    ): SceneContainerConfig {
-        return checkNotNull(configs[SceneContainerNames.SYSTEM_UI_DEFAULT]) {
-            "No SceneContainerConfig named \"${SceneContainerNames.SYSTEM_UI_DEFAULT}\"."
-        }
-    }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModel.kt b/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModel.kt
index 005f48d9..f44748a 100644
--- a/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModel.kt
@@ -17,16 +17,20 @@
 package com.android.systemui.scene.ui.viewmodel
 
 import android.view.MotionEvent
+import com.android.systemui.dagger.SysUISingleton
 import com.android.systemui.scene.domain.interactor.SceneInteractor
 import com.android.systemui.scene.shared.model.RemoteUserInput
 import com.android.systemui.scene.shared.model.SceneKey
 import com.android.systemui.scene.shared.model.SceneModel
+import javax.inject.Inject
 import kotlinx.coroutines.flow.StateFlow
 
-/** Models UI state for a single scene container. */
-class SceneContainerViewModel(
+/** Models UI state for the scene container. */
+@SysUISingleton
+class SceneContainerViewModel
+@Inject
+constructor(
     private val interactor: SceneInteractor,
-    val containerName: String,
 ) {
     /** A flow of motion events originating from outside of the scene framework. */
     val remoteUserInput: StateFlow<RemoteUserInput?> = interactor.remoteUserInput
@@ -37,22 +41,22 @@
      * The scenes will be sorted in z-order such that the last one is the one that should be
      * rendered on top of all previous ones.
      */
-    val allSceneKeys: List<SceneKey> = interactor.allSceneKeys(containerName)
+    val allSceneKeys: List<SceneKey> = interactor.allSceneKeys()
 
     /** The current scene. */
-    val currentScene: StateFlow<SceneModel> = interactor.currentScene(containerName)
+    val currentScene: StateFlow<SceneModel> = interactor.currentScene
 
     /** Whether the container is visible. */
-    val isVisible: StateFlow<Boolean> = interactor.isVisible(containerName)
+    val isVisible: StateFlow<Boolean> = interactor.isVisible
 
     /** Requests a transition to the scene with the given key. */
     fun setCurrentScene(scene: SceneModel) {
-        interactor.setCurrentScene(containerName, scene)
+        interactor.setCurrentScene(scene)
     }
 
     /** Notifies of the progress of a scene transition. */
     fun setSceneTransitionProgress(progress: Float) {
-        interactor.setSceneTransitionProgress(containerName, progress)
+        interactor.setSceneTransitionProgress(progress)
     }
 
     /** Handles a [MotionEvent] representing remote user input. */
diff --git a/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModelModule.kt b/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModelModule.kt
deleted file mode 100644
index 100f427..0000000
--- a/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModelModule.kt
+++ /dev/null
@@ -1,40 +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.scene.ui.viewmodel
-
-import com.android.systemui.dagger.SysUISingleton
-import com.android.systemui.scene.domain.interactor.SceneInteractor
-import com.android.systemui.scene.shared.model.SceneContainerNames
-import dagger.Module
-import dagger.Provides
-import javax.inject.Named
-
-@Module
-object SceneContainerViewModelModule {
-
-    @Provides
-    @SysUISingleton
-    @Named(SceneContainerNames.SYSTEM_UI_DEFAULT)
-    fun defaultSceneContainerViewModel(
-        interactor: SceneInteractor,
-    ): SceneContainerViewModel {
-        return SceneContainerViewModel(
-            interactor = interactor,
-            containerName = SceneContainerNames.SYSTEM_UI_DEFAULT,
-        )
-    }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeViewProviderModule.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeViewProviderModule.kt
index e02c427..2955118 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/ShadeViewProviderModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeViewProviderModule.kt
@@ -36,7 +36,6 @@
 import com.android.systemui.privacy.OngoingPrivacyChip
 import com.android.systemui.scene.shared.model.Scene
 import com.android.systemui.scene.shared.model.SceneContainerConfig
-import com.android.systemui.scene.shared.model.SceneContainerNames
 import com.android.systemui.scene.ui.view.SceneWindowRootView
 import com.android.systemui.scene.ui.view.WindowRootView
 import com.android.systemui.scene.ui.viewmodel.SceneContainerViewModel
@@ -73,11 +72,8 @@
         fun providesWindowRootView(
             layoutInflater: LayoutInflater,
             featureFlags: FeatureFlags,
-            @Named(SceneContainerNames.SYSTEM_UI_DEFAULT)
             viewModelProvider: Provider<SceneContainerViewModel>,
-            @Named(SceneContainerNames.SYSTEM_UI_DEFAULT)
             containerConfigProvider: Provider<SceneContainerConfig>,
-            @Named(SceneContainerNames.SYSTEM_UI_DEFAULT)
             scenesProvider: Provider<Set<@JvmSuppressWildcards Scene>>,
             layoutInsetController: NotificationInsetsController,
         ): WindowRootView {
diff --git a/packages/SystemUI/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModel.kt b/packages/SystemUI/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModel.kt
index 8a96a47..0b3ed56 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModel.kt
@@ -16,12 +16,11 @@
 
 package com.android.systemui.shade.ui.viewmodel
 
+import com.android.systemui.dagger.SysUISingleton
 import com.android.systemui.dagger.qualifiers.Application
 import com.android.systemui.keyguard.domain.interactor.LockscreenSceneInteractor
 import com.android.systemui.scene.shared.model.SceneKey
-import dagger.assisted.Assisted
-import dagger.assisted.AssistedFactory
-import dagger.assisted.AssistedInject
+import javax.inject.Inject
 import kotlinx.coroutines.CoroutineScope
 import kotlinx.coroutines.flow.SharingStarted
 import kotlinx.coroutines.flow.StateFlow
@@ -29,32 +28,29 @@
 import kotlinx.coroutines.flow.stateIn
 
 /** Models UI state and handles user input for the shade scene. */
+@SysUISingleton
 class ShadeSceneViewModel
-@AssistedInject
+@Inject
 constructor(
     @Application private val applicationScope: CoroutineScope,
-    lockscreenSceneInteractorFactory: LockscreenSceneInteractor.Factory,
-    @Assisted private val containerName: String,
+    private val lockscreenSceneInteractor: LockscreenSceneInteractor,
 ) {
-    private val lockScreenInteractor: LockscreenSceneInteractor =
-        lockscreenSceneInteractorFactory.create(containerName)
-
     /** The key of the scene we should switch to when swiping up. */
     val upDestinationSceneKey: StateFlow<SceneKey> =
-        lockScreenInteractor.isDeviceLocked
+        lockscreenSceneInteractor.isDeviceLocked
             .map { isLocked -> upDestinationSceneKey(isLocked = isLocked) }
             .stateIn(
                 scope = applicationScope,
                 started = SharingStarted.WhileSubscribed(),
                 initialValue =
                     upDestinationSceneKey(
-                        isLocked = lockScreenInteractor.isDeviceLocked.value,
+                        isLocked = lockscreenSceneInteractor.isDeviceLocked.value,
                     ),
             )
 
     /** Notifies that some content in the shade was clicked. */
     fun onContentClicked() {
-        lockScreenInteractor.dismissLockscreen()
+        lockscreenSceneInteractor.dismissLockscreen()
     }
 
     private fun upDestinationSceneKey(
@@ -62,11 +58,4 @@
     ): SceneKey {
         return if (isLocked) SceneKey.Lockscreen else SceneKey.Gone
     }
-
-    @AssistedFactory
-    interface Factory {
-        fun create(
-            containerName: String,
-        ): ShadeSceneViewModel
-    }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/dagger/NotificationMemoryModule.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/dagger/NotificationMemoryModule.kt
new file mode 100644
index 0000000..92e9765
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/dagger/NotificationMemoryModule.kt
@@ -0,0 +1,33 @@
+/*
+ * 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.statusbar.notification.dagger
+
+import com.android.systemui.CoreStartable
+import com.android.systemui.statusbar.notification.logging.NotificationMemoryMonitor
+import dagger.Binds
+import dagger.Module
+import dagger.multibindings.ClassKey
+import dagger.multibindings.IntoMap
+
+@Module
+interface NotificationMemoryModule {
+
+    /** Binds memory monitor into startable map. */
+    @Binds
+    @IntoMap
+    @ClassKey(NotificationMemoryMonitor::class)
+    fun bindsNotificationMemoryMonitorStartable(monitor: NotificationMemoryMonitor): CoreStartable
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/init/NotificationsControllerImpl.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/init/NotificationsControllerImpl.kt
index f7bd177..106d11f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/init/NotificationsControllerImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/init/NotificationsControllerImpl.kt
@@ -39,7 +39,6 @@
 import com.android.systemui.statusbar.notification.collection.render.NotifStackController
 import com.android.systemui.statusbar.notification.interruption.HeadsUpViewBinder
 import com.android.systemui.statusbar.notification.logging.NotificationLogger
-import com.android.systemui.statusbar.notification.logging.NotificationMemoryMonitor
 import com.android.systemui.statusbar.notification.row.NotifBindPipelineInitializer
 import com.android.systemui.statusbar.notification.stack.NotificationListContainer
 import com.android.wm.shell.bubbles.Bubbles
@@ -72,7 +71,6 @@
     private val peopleSpaceWidgetManager: PeopleSpaceWidgetManager,
     private val bubblesOptional: Optional<Bubbles>,
     private val fgsNotifListener: ForegroundServiceNotificationListener,
-    private val memoryMonitor: Lazy<NotificationMemoryMonitor>,
     private val featureFlags: FeatureFlags
 ) : NotificationsController {
 
@@ -108,7 +106,6 @@
         notificationLogger.setUpWithContainer(listContainer)
         peopleSpaceWidgetManager.attach(notificationListener)
         fgsNotifListener.init()
-        memoryMonitor.get().init()
     }
 
     // TODO: Convert all functions below this line into listeners instead of public methods
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationMemoryMonitor.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationMemoryMonitor.kt
index f38c1e5..0fdf681 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationMemoryMonitor.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationMemoryMonitor.kt
@@ -18,6 +18,7 @@
 package com.android.systemui.statusbar.notification.logging
 
 import android.util.Log
+import com.android.systemui.CoreStartable
 import com.android.systemui.dagger.SysUISingleton
 import com.android.systemui.flags.FeatureFlags
 import com.android.systemui.flags.Flags
@@ -32,13 +33,13 @@
     private val featureFlags: FeatureFlags,
     private val notificationMemoryDumper: NotificationMemoryDumper,
     private val notificationMemoryLogger: Lazy<NotificationMemoryLogger>,
-) {
+) : CoreStartable {
 
     companion object {
         private const val TAG = "NotificationMemory"
     }
 
-    fun init() {
+    override fun start() {
         Log.d(TAG, "NotificationMemoryMonitor initialized.")
         notificationMemoryDumper.init()
         if (featureFlags.isEnabled(Flags.NOTIFICATION_MEMORY_LOGGING_ENABLED)) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java
index 36a8e98..5e7e4be 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java
@@ -426,16 +426,21 @@
         updateAppearAnimationAlpha();
         updateAppearRect();
         mAppearAnimator.addListener(new AnimatorListenerAdapter() {
-            private boolean mWasCancelled;
+            private boolean mRunWithoutInterruptions;
 
             @Override
             public void onAnimationEnd(Animator animation) {
                 if (onFinishedRunnable != null) {
                     onFinishedRunnable.run();
                 }
-                if (!mWasCancelled) {
+                if (mRunWithoutInterruptions) {
                     enableAppearDrawing(false);
-                    onAppearAnimationFinished(isAppearing);
+                }
+
+                // We need to reset the View state, even if the animation was cancelled
+                onAppearAnimationFinished(isAppearing);
+
+                if (mRunWithoutInterruptions) {
                     InteractionJankMonitor.getInstance().end(getCujType(isAppearing));
                 } else {
                     InteractionJankMonitor.getInstance().cancel(getCujType(isAppearing));
@@ -444,7 +449,7 @@
 
             @Override
             public void onAnimationStart(Animator animation) {
-                mWasCancelled = false;
+                mRunWithoutInterruptions = true;
                 Configuration.Builder builder = Configuration.Builder
                         .withView(getCujType(isAppearing), ActivatableNotificationView.this);
                 InteractionJankMonitor.getInstance().begin(builder);
@@ -452,7 +457,7 @@
 
             @Override
             public void onAnimationCancel(Animator animation) {
-                mWasCancelled = true;
+                mRunWithoutInterruptions = false;
             }
         });
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewController.kt
index 8c3050d..1227287 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewController.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewController.kt
@@ -30,7 +30,6 @@
 import com.android.systemui.flags.Flags
 import com.android.systemui.scene.domain.interactor.SceneInteractor
 import com.android.systemui.scene.shared.model.RemoteUserInput
-import com.android.systemui.scene.shared.model.SceneContainerNames
 import com.android.systemui.shade.ShadeController
 import com.android.systemui.shade.ShadeLogger
 import com.android.systemui.shade.ShadeViewController
@@ -183,7 +182,7 @@
                 sceneInteractor.get()
                     .onRemoteUserInput(RemoteUserInput.translateMotionEvent(event))
                 // TODO(b/291965119): remove once view is expanded to cover the status bar
-                sceneInteractor.get().setVisible(SceneContainerNames.SYSTEM_UI_DEFAULT, true)
+                sceneInteractor.get().setVisible(true)
                 return false
             }
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarTouchableRegionManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarTouchableRegionManager.java
index 68a6b3d..fa9b9d2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarTouchableRegionManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarTouchableRegionManager.java
@@ -37,7 +37,6 @@
 import com.android.systemui.flags.FeatureFlags;
 import com.android.systemui.flags.Flags;
 import com.android.systemui.scene.domain.interactor.SceneInteractor;
-import com.android.systemui.scene.shared.model.SceneContainerNames;
 import com.android.systemui.shade.ShadeExpansionStateManager;
 import com.android.systemui.statusbar.NotificationShadeWindowController;
 import com.android.systemui.statusbar.policy.ConfigurationController;
@@ -126,7 +125,7 @@
 
         if (featureFlags.isEnabled(Flags.SCENE_CONTAINER)) {
             javaAdapter.get().alwaysCollectFlow(
-                    sceneInteractor.get().isVisible(SceneContainerNames.SYSTEM_UI_DEFAULT),
+                    sceneInteractor.get().isVisible(),
                     this::onShadeExpansionFullyChanged);
         }
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/window/StatusBarWindowView.java b/packages/SystemUI/src/com/android/systemui/statusbar/window/StatusBarWindowView.java
index 06cc96e..d696979 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/window/StatusBarWindowView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/window/StatusBarWindowView.java
@@ -46,6 +46,7 @@
 
     public StatusBarWindowView(Context context, AttributeSet attrs) {
         super(context, attrs);
+        setClipChildren(false);
     }
 
     @Override
diff --git a/packages/SystemUI/src/com/android/systemui/theme/DynamicColors.kt b/packages/SystemUI/src/com/android/systemui/theme/DynamicColors.kt
index eef66b6..a983d2f 100644
--- a/packages/SystemUI/src/com/android/systemui/theme/DynamicColors.kt
+++ b/packages/SystemUI/src/com/android/systemui/theme/DynamicColors.kt
@@ -22,83 +22,86 @@
 
 class DynamicColors {
     companion object {
-        private val MDC = MaterialDynamicColors()
-        @JvmField
-        val ALL_DYNAMIC_COLORS_MAPPED: List<Pair<String, DynamicColor>> =
-            arrayListOf(
-                Pair.create("primary_container", MDC.primaryContainer()),
-                Pair.create("on_primary_container", MDC.onPrimaryContainer()),
-                Pair.create("primary", MDC.primary()),
-                Pair.create("on_primary", MDC.onPrimary()),
-                Pair.create("secondary_container", MDC.secondaryContainer()),
-                Pair.create("on_secondary_container", MDC.onSecondaryContainer()),
-                Pair.create("secondary", MDC.secondary()),
-                Pair.create("on_secondary", MDC.onSecondary()),
-                Pair.create("tertiary_container", MDC.tertiaryContainer()),
-                Pair.create("on_tertiary_container", MDC.onTertiaryContainer()),
-                Pair.create("tertiary", MDC.tertiary()),
-                Pair.create("on_tertiary", MDC.onTertiary()),
-                Pair.create("background", MDC.background()),
-                Pair.create("on_background", MDC.onBackground()),
-                Pair.create("surface", MDC.surface()),
-                Pair.create("on_surface", MDC.onSurface()),
-                Pair.create("surface_container_low", MDC.surfaceContainerLow()),
-                Pair.create("surface_container_lowest", MDC.surfaceContainerLowest()),
-                Pair.create("surface_container", MDC.surfaceContainer()),
-                Pair.create("surface_container_high", MDC.surfaceContainerHigh()),
-                Pair.create("surface_container_highest", MDC.surfaceContainerHighest()),
-                Pair.create("surface_bright", MDC.surfaceBright()),
-                Pair.create("surface_dim", MDC.surfaceDim()),
-                Pair.create("surface_variant", MDC.surfaceVariant()),
-                Pair.create("on_surface_variant", MDC.onSurfaceVariant()),
-                Pair.create("outline", MDC.outline()),
-                Pair.create("outline_variant", MDC.outlineVariant()),
-                Pair.create("error", MDC.error()),
-                Pair.create("on_error", MDC.onError()),
-                Pair.create("error_container", MDC.errorContainer()),
-                Pair.create("on_error_container", MDC.onErrorContainer()),
-                Pair.create("control_activated", MDC.controlActivated()),
-                Pair.create("control_normal", MDC.controlNormal()),
-                Pair.create("control_highlight", MDC.controlHighlight()),
-                Pair.create("text_primary_inverse", MDC.textPrimaryInverse()),
+        @JvmStatic
+        fun allDynamicColorsMapped(isExtendedFidelity: Boolean): List<Pair<String, DynamicColor>> {
+            val mdc = MaterialDynamicColors(isExtendedFidelity)
+            return arrayListOf(
+                Pair.create("primary_container", mdc.primaryContainer()),
+                Pair.create("on_primary_container", mdc.onPrimaryContainer()),
+                Pair.create("primary", mdc.primary()),
+                Pair.create("on_primary", mdc.onPrimary()),
+                Pair.create("secondary_container", mdc.secondaryContainer()),
+                Pair.create("on_secondary_container", mdc.onSecondaryContainer()),
+                Pair.create("secondary", mdc.secondary()),
+                Pair.create("on_secondary", mdc.onSecondary()),
+                Pair.create("tertiary_container", mdc.tertiaryContainer()),
+                Pair.create("on_tertiary_container", mdc.onTertiaryContainer()),
+                Pair.create("tertiary", mdc.tertiary()),
+                Pair.create("on_tertiary", mdc.onTertiary()),
+                Pair.create("background", mdc.background()),
+                Pair.create("on_background", mdc.onBackground()),
+                Pair.create("surface", mdc.surface()),
+                Pair.create("on_surface", mdc.onSurface()),
+                Pair.create("surface_container_low", mdc.surfaceContainerLow()),
+                Pair.create("surface_container_lowest", mdc.surfaceContainerLowest()),
+                Pair.create("surface_container", mdc.surfaceContainer()),
+                Pair.create("surface_container_high", mdc.surfaceContainerHigh()),
+                Pair.create("surface_container_highest", mdc.surfaceContainerHighest()),
+                Pair.create("surface_bright", mdc.surfaceBright()),
+                Pair.create("surface_dim", mdc.surfaceDim()),
+                Pair.create("surface_variant", mdc.surfaceVariant()),
+                Pair.create("on_surface_variant", mdc.onSurfaceVariant()),
+                Pair.create("outline", mdc.outline()),
+                Pair.create("outline_variant", mdc.outlineVariant()),
+                Pair.create("error", mdc.error()),
+                Pair.create("on_error", mdc.onError()),
+                Pair.create("error_container", mdc.errorContainer()),
+                Pair.create("on_error_container", mdc.onErrorContainer()),
+                Pair.create("control_activated", mdc.controlActivated()),
+                Pair.create("control_normal", mdc.controlNormal()),
+                Pair.create("control_highlight", mdc.controlHighlight()),
+                Pair.create("text_primary_inverse", mdc.textPrimaryInverse()),
                 Pair.create(
                     "text_secondary_and_tertiary_inverse",
-                    MDC.textSecondaryAndTertiaryInverse()
+                    mdc.textSecondaryAndTertiaryInverse()
                 ),
                 Pair.create(
                     "text_primary_inverse_disable_only",
-                    MDC.textPrimaryInverseDisableOnly()
+                    mdc.textPrimaryInverseDisableOnly()
                 ),
                 Pair.create(
                     "text_secondary_and_tertiary_inverse_disabled",
-                    MDC.textSecondaryAndTertiaryInverseDisabled()
+                    mdc.textSecondaryAndTertiaryInverseDisabled()
                 ),
-                Pair.create("text_hint_inverse", MDC.textHintInverse()),
-                Pair.create("palette_key_color_primary", MDC.primaryPaletteKeyColor()),
-                Pair.create("palette_key_color_secondary", MDC.secondaryPaletteKeyColor()),
-                Pair.create("palette_key_color_tertiary", MDC.tertiaryPaletteKeyColor()),
-                Pair.create("palette_key_color_neutral", MDC.neutralPaletteKeyColor()),
+                Pair.create("text_hint_inverse", mdc.textHintInverse()),
+                Pair.create("palette_key_color_primary", mdc.primaryPaletteKeyColor()),
+                Pair.create("palette_key_color_secondary", mdc.secondaryPaletteKeyColor()),
+                Pair.create("palette_key_color_tertiary", mdc.tertiaryPaletteKeyColor()),
+                Pair.create("palette_key_color_neutral", mdc.neutralPaletteKeyColor()),
                 Pair.create(
                     "palette_key_color_neutral_variant",
-                    MDC.neutralVariantPaletteKeyColor()
+                    mdc.neutralVariantPaletteKeyColor()
                 ),
             )
+        }
 
-        @JvmField
-        val FIXED_COLORS_MAPPED: List<Pair<String, DynamicColor>> =
-            arrayListOf(
-                Pair.create("primary_fixed", MDC.primaryFixed()),
-                Pair.create("primary_fixed_dim", MDC.primaryFixedDim()),
-                Pair.create("on_primary_fixed", MDC.onPrimaryFixed()),
-                Pair.create("on_primary_fixed_variant", MDC.onPrimaryFixedVariant()),
-                Pair.create("secondary_fixed", MDC.secondaryFixed()),
-                Pair.create("secondary_fixed_dim", MDC.secondaryFixedDim()),
-                Pair.create("on_secondary_fixed", MDC.onSecondaryFixed()),
-                Pair.create("on_secondary_fixed_variant", MDC.onSecondaryFixedVariant()),
-                Pair.create("tertiary_fixed", MDC.tertiaryFixed()),
-                Pair.create("tertiary_fixed_dim", MDC.tertiaryFixedDim()),
-                Pair.create("on_tertiary_fixed", MDC.onTertiaryFixed()),
-                Pair.create("on_tertiary_fixed_variant", MDC.onTertiaryFixedVariant()),
+        @JvmStatic
+        fun getFixedColorsMapped(isExtendedFidelity: Boolean): List<Pair<String, DynamicColor>> {
+            val mdc = MaterialDynamicColors(isExtendedFidelity)
+            return arrayListOf(
+                Pair.create("primary_fixed", mdc.primaryFixed()),
+                Pair.create("primary_fixed_dim", mdc.primaryFixedDim()),
+                Pair.create("on_primary_fixed", mdc.onPrimaryFixed()),
+                Pair.create("on_primary_fixed_variant", mdc.onPrimaryFixedVariant()),
+                Pair.create("secondary_fixed", mdc.secondaryFixed()),
+                Pair.create("secondary_fixed_dim", mdc.secondaryFixedDim()),
+                Pair.create("on_secondary_fixed", mdc.onSecondaryFixed()),
+                Pair.create("on_secondary_fixed_variant", mdc.onSecondaryFixedVariant()),
+                Pair.create("tertiary_fixed", mdc.tertiaryFixed()),
+                Pair.create("tertiary_fixed_dim", mdc.tertiaryFixedDim()),
+                Pair.create("on_tertiary_fixed", mdc.onTertiaryFixed()),
+                Pair.create("on_tertiary_fixed_variant", mdc.onTertiaryFixedVariant()),
             )
+        }
     }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java b/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java
index 06f68c6..5a9f5d5 100644
--- a/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java
+++ b/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java
@@ -130,6 +130,7 @@
     private final boolean mIsMonochromaticEnabled;
     private final Context mContext;
     private final boolean mIsMonetEnabled;
+    private final boolean mIsFidelityEnabled;
     private final UserTracker mUserTracker;
     private final DeviceProvisionedController mDeviceProvisionedController;
     private final Resources mResources;
@@ -398,6 +399,7 @@
         mContext = context;
         mIsMonochromaticEnabled = featureFlags.isEnabled(Flags.MONOCHROMATIC_THEME);
         mIsMonetEnabled = featureFlags.isEnabled(Flags.MONET);
+        mIsFidelityEnabled = featureFlags.isEnabled(Flags.COLOR_FIDELITY);
         mDeviceProvisionedController = deviceProvisionedController;
         mBroadcastDispatcher = broadcastDispatcher;
         mUserManager = userManager;
@@ -632,7 +634,7 @@
     private void assignDynamicPaletteToOverlay(FabricatedOverlay overlay, boolean isDark) {
         String suffix = isDark ? "dark" : "light";
         DynamicScheme scheme = isDark ? mDynamicSchemeDark : mDynamicSchemeLight;
-        DynamicColors.ALL_DYNAMIC_COLORS_MAPPED.forEach(p -> {
+        DynamicColors.allDynamicColorsMapped(mIsFidelityEnabled).forEach(p -> {
             String resourceName = "android:color/system_" + p.first + "_" + suffix;
             int colorValue = p.second.getArgb(scheme);
             overlay.setResourceValue(resourceName, TYPE_INT_COLOR_ARGB8, colorValue,
@@ -641,7 +643,7 @@
     }
 
     private void assignFixedColorsToOverlay(FabricatedOverlay overlay) {
-        DynamicColors.FIXED_COLORS_MAPPED.forEach(p -> {
+        DynamicColors.getFixedColorsMapped(mIsFidelityEnabled).forEach(p -> {
             String resourceName = "android:color/system_" + p.first;
             int colorValue = p.second.getArgb(mDynamicSchemeLight);
             overlay.setResourceValue(resourceName, TYPE_INT_COLOR_ARGB8, colorValue,
@@ -660,7 +662,7 @@
             Resources res = userHandle.isSystem()
                     ? mResources : mContext.createContextAsUser(userHandle, 0).getResources();
             Resources.Theme theme = mContext.getTheme();
-            MaterialDynamicColors dynamicColors = new MaterialDynamicColors();
+            MaterialDynamicColors dynamicColors = new MaterialDynamicColors(mIsFidelityEnabled);
             if (!(res.getColor(android.R.color.system_accent1_500, theme)
                     == mColorScheme.getAccent1().getS500()
                     && res.getColor(android.R.color.system_accent2_500, theme)
@@ -819,6 +821,7 @@
         pw.println("mNeutralOverlay=" + mNeutralOverlay);
         pw.println("mDynamicOverlay=" + mDynamicOverlay);
         pw.println("mIsMonetEnabled=" + mIsMonetEnabled);
+        pw.println("mIsFidelityEnabled=" + mIsFidelityEnabled);
         pw.println("mColorScheme=" + mColorScheme);
         pw.println("mNeedsOverlayCreation=" + mNeedsOverlayCreation);
         pw.println("mAcceptColorEvents=" + mAcceptColorEvents);
diff --git a/packages/SystemUI/src/com/android/systemui/touch/TouchInsetManager.java b/packages/SystemUI/src/com/android/systemui/touch/TouchInsetManager.java
index 757b4e5..13c1019 100644
--- a/packages/SystemUI/src/com/android/systemui/touch/TouchInsetManager.java
+++ b/packages/SystemUI/src/com/android/systemui/touch/TouchInsetManager.java
@@ -25,16 +25,12 @@
 
 import androidx.concurrent.futures.CallbackToFutureAdapter;
 
-import com.android.systemui.dagger.qualifiers.Main;
-
 import com.google.common.util.concurrent.ListenableFuture;
 
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.concurrent.Executor;
 
-import javax.inject.Inject;
-
 /**
  * {@link TouchInsetManager} handles setting the touchable inset regions for a given View. This
  * is useful for passing through touch events for all but select areas.
@@ -153,8 +149,7 @@
      * Default constructor.
      * @param executor An {@link Executor} to marshal all operations on.
      */
-    @Inject
-    public TouchInsetManager(@Main Executor executor) {
+    public TouchInsetManager(Executor executor) {
         mExecutor = executor;
     }
 
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.kt b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.kt
index 3abae6b..e447c29 100644
--- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.kt
@@ -733,29 +733,20 @@
             // is
             // not enough to trigger a dismissal of the keyguard.
             underTest.onViewAttached()
-            sceneInteractor.setCurrentScene(
-                SceneTestUtils.CONTAINER_1,
-                SceneModel(SceneKey.Bouncer, null)
-            )
+            sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer, null))
             runCurrent()
             verify(viewMediatorCallback, never()).keyguardDone(anyBoolean(), anyInt())
 
             // While listening, going from the bouncer scene to the gone scene, does dismiss the
             // keyguard.
-            sceneInteractor.setCurrentScene(
-                SceneTestUtils.CONTAINER_1,
-                SceneModel(SceneKey.Gone, null)
-            )
+            sceneInteractor.setCurrentScene(SceneModel(SceneKey.Gone, null))
             runCurrent()
             verify(viewMediatorCallback).keyguardDone(anyBoolean(), anyInt())
 
             // While listening, moving back to the bouncer scene does not dismiss the keyguard
             // again.
             clearInvocations(viewMediatorCallback)
-            sceneInteractor.setCurrentScene(
-                SceneTestUtils.CONTAINER_1,
-                SceneModel(SceneKey.Bouncer, null)
-            )
+            sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer, null))
             runCurrent()
             verify(viewMediatorCallback, never()).keyguardDone(anyBoolean(), anyInt())
 
@@ -763,18 +754,12 @@
             // scene
             // does not dismiss the keyguard while we're not listening.
             underTest.onViewDetached()
-            sceneInteractor.setCurrentScene(
-                SceneTestUtils.CONTAINER_1,
-                SceneModel(SceneKey.Gone, null)
-            )
+            sceneInteractor.setCurrentScene(SceneModel(SceneKey.Gone, null))
             runCurrent()
             verify(viewMediatorCallback, never()).keyguardDone(anyBoolean(), anyInt())
 
             // While not listening, moving back to the bouncer does not dismiss the keyguard.
-            sceneInteractor.setCurrentScene(
-                SceneTestUtils.CONTAINER_1,
-                SceneModel(SceneKey.Bouncer, null)
-            )
+            sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer, null))
             runCurrent()
             verify(viewMediatorCallback, never()).keyguardDone(anyBoolean(), anyInt())
 
@@ -782,10 +767,7 @@
             // gone
             // scene now does dismiss the keyguard again.
             underTest.onViewAttached()
-            sceneInteractor.setCurrentScene(
-                SceneTestUtils.CONTAINER_1,
-                SceneModel(SceneKey.Gone, null)
-            )
+            sceneInteractor.setCurrentScene(SceneModel(SceneKey.Gone, null))
             runCurrent()
             verify(viewMediatorCallback).keyguardDone(anyBoolean(), anyInt())
         }
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityViewFlipperControllerTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityViewFlipperControllerTest.java
index cd18754..64e1458 100644
--- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityViewFlipperControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityViewFlipperControllerTest.java
@@ -138,6 +138,11 @@
 
     @Test
     public void asynchronouslyInflateView_setNeedsInput() {
+        when(mKeyguardSecurityViewControllerFactory.create(
+               any(), any(SecurityMode.class),
+                any(KeyguardSecurityCallback.class)))
+                .thenReturn(mKeyguardInputViewController);
+
         ArgumentCaptor<AsyncLayoutInflater.OnInflateFinishedListener> argumentCaptor =
                 ArgumentCaptor.forClass(AsyncLayoutInflater.OnInflateFinishedListener.class);
         mKeyguardSecurityViewFlipperController.asynchronouslyInflateView(SecurityMode.PIN,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/ExpandHelperTest.java b/packages/SystemUI/tests/src/com/android/systemui/ExpandHelperTest.java
index 5867a40c..44a2b68 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/ExpandHelperTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/ExpandHelperTest.java
@@ -20,12 +20,13 @@
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
-import android.animation.ObjectAnimator;
 import android.content.Context;
 import android.testing.AndroidTestingRunner;
 import android.testing.TestableLooper;
 import android.testing.TestableLooper.RunWithLooper;
 
+import androidx.core.animation.AnimatorTestRule;
+import androidx.core.animation.ObjectAnimator;
 import androidx.test.annotation.UiThreadTest;
 import androidx.test.filters.SmallTest;
 
@@ -37,6 +38,7 @@
 import com.android.systemui.statusbar.notification.row.NotificationTestHelper;
 
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
@@ -45,6 +47,9 @@
 @RunWithLooper
 public class ExpandHelperTest extends SysuiTestCase {
 
+    @Rule
+    public final AnimatorTestRule mAnimatorTestRule = new AnimatorTestRule();
+
     private final FakeFeatureFlags mFeatureFlags = new FakeFeatureFlags();
     private ExpandableNotificationRow mRow;
     private ExpandHelper mExpandHelper;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bouncer/domain/interactor/BouncerInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/bouncer/domain/interactor/BouncerInteractorTest.kt
index 6babf04..14fc931 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bouncer/domain/interactor/BouncerInteractorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/bouncer/domain/interactor/BouncerInteractorTest.kt
@@ -69,13 +69,12 @@
     @Test
     fun pinAuthMethod() =
         testScope.runTest {
-            val currentScene by
-                collectLastValue(sceneInteractor.currentScene(SceneTestUtils.CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             val message by collectLastValue(underTest.message)
 
             utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
             utils.authenticationRepository.setUnlocked(false)
-            underTest.showOrUnlockDevice(SceneTestUtils.CONTAINER_1)
+            underTest.showOrUnlockDevice()
             assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
             assertThat(message).isEqualTo(MESSAGE_ENTER_YOUR_PIN)
 
@@ -101,14 +100,13 @@
     @Test
     fun pinAuthMethod_tryAutoConfirm_withAutoConfirmPin() =
         testScope.runTest {
-            val currentScene by
-                collectLastValue(sceneInteractor.currentScene(SceneTestUtils.CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             val message by collectLastValue(underTest.message)
 
             utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
             utils.authenticationRepository.setAutoConfirmEnabled(true)
             utils.authenticationRepository.setUnlocked(false)
-            underTest.showOrUnlockDevice(SceneTestUtils.CONTAINER_1)
+            underTest.showOrUnlockDevice()
             assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
             assertThat(message).isEqualTo(MESSAGE_ENTER_YOUR_PIN)
             underTest.clearMessage()
@@ -138,13 +136,12 @@
     @Test
     fun pinAuthMethod_tryAutoConfirm_withoutAutoConfirmPin() =
         testScope.runTest {
-            val currentScene by
-                collectLastValue(sceneInteractor.currentScene(SceneTestUtils.CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             val message by collectLastValue(underTest.message)
 
             utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
             utils.authenticationRepository.setUnlocked(false)
-            underTest.showOrUnlockDevice(SceneTestUtils.CONTAINER_1)
+            underTest.showOrUnlockDevice()
             assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
             underTest.clearMessage()
 
@@ -168,14 +165,13 @@
     @Test
     fun passwordAuthMethod() =
         testScope.runTest {
-            val currentScene by
-                collectLastValue(sceneInteractor.currentScene(SceneTestUtils.CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             val message by collectLastValue(underTest.message)
             utils.authenticationRepository.setAuthenticationMethod(
                 AuthenticationMethodModel.Password
             )
             utils.authenticationRepository.setUnlocked(false)
-            underTest.showOrUnlockDevice(SceneTestUtils.CONTAINER_1)
+            underTest.showOrUnlockDevice()
             assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
             assertThat(message).isEqualTo(MESSAGE_ENTER_YOUR_PASSWORD)
 
@@ -201,14 +197,13 @@
     @Test
     fun patternAuthMethod() =
         testScope.runTest {
-            val currentScene by
-                collectLastValue(sceneInteractor.currentScene(SceneTestUtils.CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             val message by collectLastValue(underTest.message)
             utils.authenticationRepository.setAuthenticationMethod(
                 AuthenticationMethodModel.Pattern
             )
             utils.authenticationRepository.setUnlocked(false)
-            underTest.showOrUnlockDevice(SceneTestUtils.CONTAINER_1)
+            underTest.showOrUnlockDevice()
             assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
             assertThat(message).isEqualTo(MESSAGE_ENTER_YOUR_PATTERN)
 
@@ -239,13 +234,12 @@
     @Test
     fun showOrUnlockDevice_notLocked_switchesToGoneScene() =
         testScope.runTest {
-            val currentScene by
-                collectLastValue(sceneInteractor.currentScene(SceneTestUtils.CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
             utils.authenticationRepository.setUnlocked(true)
             runCurrent()
 
-            underTest.showOrUnlockDevice(SceneTestUtils.CONTAINER_1)
+            underTest.showOrUnlockDevice()
 
             assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Gone))
         }
@@ -253,12 +247,11 @@
     @Test
     fun showOrUnlockDevice_authMethodNotSecure_switchesToGoneScene() =
         testScope.runTest {
-            val currentScene by
-                collectLastValue(sceneInteractor.currentScene(SceneTestUtils.CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Swipe)
             utils.authenticationRepository.setUnlocked(false)
 
-            underTest.showOrUnlockDevice(SceneTestUtils.CONTAINER_1)
+            underTest.showOrUnlockDevice()
 
             assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Gone))
         }
@@ -266,8 +259,7 @@
     @Test
     fun showOrUnlockDevice_customMessageShown() =
         testScope.runTest {
-            val currentScene by
-                collectLastValue(sceneInteractor.currentScene(SceneTestUtils.CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             val message by collectLastValue(underTest.message)
             utils.authenticationRepository.setAuthenticationMethod(
                 AuthenticationMethodModel.Password
@@ -275,7 +267,7 @@
             utils.authenticationRepository.setUnlocked(false)
 
             val customMessage = "Hello there!"
-            underTest.showOrUnlockDevice(SceneTestUtils.CONTAINER_1, customMessage)
+            underTest.showOrUnlockDevice(customMessage)
 
             assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
             assertThat(message).isEqualTo(customMessage)
@@ -287,11 +279,10 @@
             val isThrottled by collectLastValue(underTest.isThrottled)
             val throttling by collectLastValue(underTest.throttling)
             val message by collectLastValue(underTest.message)
-            val currentScene by
-                collectLastValue(sceneInteractor.currentScene(SceneTestUtils.CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
             runCurrent()
-            underTest.showOrUnlockDevice(SceneTestUtils.CONTAINER_1)
+            underTest.showOrUnlockDevice()
             runCurrent()
             assertThat(currentScene?.key).isEqualTo(SceneKey.Bouncer)
             assertThat(isThrottled).isFalse()
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bouncer/ui/viewmodel/PasswordBouncerViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/bouncer/ui/viewmodel/PasswordBouncerViewModelTest.kt
index b1533fe..1f089ca 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bouncer/ui/viewmodel/PasswordBouncerViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/bouncer/ui/viewmodel/PasswordBouncerViewModelTest.kt
@@ -72,18 +72,14 @@
     @Test
     fun onShown() =
         testScope.runTest {
-            val currentScene by
-                collectLastValue(sceneInteractor.currentScene(SceneTestUtils.CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             val message by collectLastValue(bouncerViewModel.message)
             val password by collectLastValue(underTest.password)
             utils.authenticationRepository.setAuthenticationMethod(
                 AuthenticationMethodModel.Password
             )
             utils.authenticationRepository.setUnlocked(false)
-            sceneInteractor.setCurrentScene(
-                SceneTestUtils.CONTAINER_1,
-                SceneModel(SceneKey.Bouncer)
-            )
+            sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
             assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
 
             underTest.onShown()
@@ -96,18 +92,14 @@
     @Test
     fun onPasswordInputChanged() =
         testScope.runTest {
-            val currentScene by
-                collectLastValue(sceneInteractor.currentScene(SceneTestUtils.CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             val message by collectLastValue(bouncerViewModel.message)
             val password by collectLastValue(underTest.password)
             utils.authenticationRepository.setAuthenticationMethod(
                 AuthenticationMethodModel.Password
             )
             utils.authenticationRepository.setUnlocked(false)
-            sceneInteractor.setCurrentScene(
-                SceneTestUtils.CONTAINER_1,
-                SceneModel(SceneKey.Bouncer)
-            )
+            sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
             assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
             underTest.onShown()
             runCurrent()
@@ -122,16 +114,12 @@
     @Test
     fun onAuthenticateKeyPressed_whenCorrect() =
         testScope.runTest {
-            val currentScene by
-                collectLastValue(sceneInteractor.currentScene(SceneTestUtils.CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             utils.authenticationRepository.setAuthenticationMethod(
                 AuthenticationMethodModel.Password
             )
             utils.authenticationRepository.setUnlocked(false)
-            sceneInteractor.setCurrentScene(
-                SceneTestUtils.CONTAINER_1,
-                SceneModel(SceneKey.Bouncer)
-            )
+            sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
             assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
             underTest.onShown()
             underTest.onPasswordInputChanged("password")
@@ -144,18 +132,14 @@
     @Test
     fun onAuthenticateKeyPressed_whenWrong() =
         testScope.runTest {
-            val currentScene by
-                collectLastValue(sceneInteractor.currentScene(SceneTestUtils.CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             val message by collectLastValue(bouncerViewModel.message)
             val password by collectLastValue(underTest.password)
             utils.authenticationRepository.setAuthenticationMethod(
                 AuthenticationMethodModel.Password
             )
             utils.authenticationRepository.setUnlocked(false)
-            sceneInteractor.setCurrentScene(
-                SceneTestUtils.CONTAINER_1,
-                SceneModel(SceneKey.Bouncer)
-            )
+            sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
             assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
             underTest.onShown()
             underTest.onPasswordInputChanged("wrong")
@@ -170,18 +154,14 @@
     @Test
     fun onAuthenticateKeyPressed_correctAfterWrong() =
         testScope.runTest {
-            val currentScene by
-                collectLastValue(sceneInteractor.currentScene(SceneTestUtils.CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             val message by collectLastValue(bouncerViewModel.message)
             val password by collectLastValue(underTest.password)
             utils.authenticationRepository.setAuthenticationMethod(
                 AuthenticationMethodModel.Password
             )
             utils.authenticationRepository.setUnlocked(false)
-            sceneInteractor.setCurrentScene(
-                SceneTestUtils.CONTAINER_1,
-                SceneModel(SceneKey.Bouncer)
-            )
+            sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
             assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
             underTest.onShown()
             underTest.onPasswordInputChanged("wrong")
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bouncer/ui/viewmodel/PatternBouncerViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/bouncer/ui/viewmodel/PatternBouncerViewModelTest.kt
index f69cbb8..af54989 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bouncer/ui/viewmodel/PatternBouncerViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/bouncer/ui/viewmodel/PatternBouncerViewModelTest.kt
@@ -75,8 +75,7 @@
     @Test
     fun onShown() =
         testScope.runTest {
-            val currentScene by
-                collectLastValue(sceneInteractor.currentScene(SceneTestUtils.CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             val message by collectLastValue(bouncerViewModel.message)
             val selectedDots by collectLastValue(underTest.selectedDots)
             val currentDot by collectLastValue(underTest.currentDot)
@@ -84,10 +83,7 @@
                 AuthenticationMethodModel.Pattern
             )
             utils.authenticationRepository.setUnlocked(false)
-            sceneInteractor.setCurrentScene(
-                SceneTestUtils.CONTAINER_1,
-                SceneModel(SceneKey.Bouncer)
-            )
+            sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
             assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
 
             underTest.onShown()
@@ -101,8 +97,7 @@
     @Test
     fun onDragStart() =
         testScope.runTest {
-            val currentScene by
-                collectLastValue(sceneInteractor.currentScene(SceneTestUtils.CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             val message by collectLastValue(bouncerViewModel.message)
             val selectedDots by collectLastValue(underTest.selectedDots)
             val currentDot by collectLastValue(underTest.currentDot)
@@ -110,10 +105,7 @@
                 AuthenticationMethodModel.Pattern
             )
             utils.authenticationRepository.setUnlocked(false)
-            sceneInteractor.setCurrentScene(
-                SceneTestUtils.CONTAINER_1,
-                SceneModel(SceneKey.Bouncer)
-            )
+            sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
             assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
             underTest.onShown()
             runCurrent()
@@ -129,18 +121,14 @@
     @Test
     fun onDragEnd_whenCorrect() =
         testScope.runTest {
-            val currentScene by
-                collectLastValue(sceneInteractor.currentScene(SceneTestUtils.CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             val selectedDots by collectLastValue(underTest.selectedDots)
             val currentDot by collectLastValue(underTest.currentDot)
             utils.authenticationRepository.setAuthenticationMethod(
                 AuthenticationMethodModel.Pattern
             )
             utils.authenticationRepository.setUnlocked(false)
-            sceneInteractor.setCurrentScene(
-                SceneTestUtils.CONTAINER_1,
-                SceneModel(SceneKey.Bouncer)
-            )
+            sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
             assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
             underTest.onShown()
             underTest.onDragStart()
@@ -180,8 +168,7 @@
     @Test
     fun onDragEnd_whenWrong() =
         testScope.runTest {
-            val currentScene by
-                collectLastValue(sceneInteractor.currentScene(SceneTestUtils.CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             val message by collectLastValue(bouncerViewModel.message)
             val selectedDots by collectLastValue(underTest.selectedDots)
             val currentDot by collectLastValue(underTest.currentDot)
@@ -189,10 +176,7 @@
                 AuthenticationMethodModel.Pattern
             )
             utils.authenticationRepository.setUnlocked(false)
-            sceneInteractor.setCurrentScene(
-                SceneTestUtils.CONTAINER_1,
-                SceneModel(SceneKey.Bouncer)
-            )
+            sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
             assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
             underTest.onShown()
             underTest.onDragStart()
@@ -216,8 +200,7 @@
     @Test
     fun onDragEnd_correctAfterWrong() =
         testScope.runTest {
-            val currentScene by
-                collectLastValue(sceneInteractor.currentScene(SceneTestUtils.CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             val message by collectLastValue(bouncerViewModel.message)
             val selectedDots by collectLastValue(underTest.selectedDots)
             val currentDot by collectLastValue(underTest.currentDot)
@@ -225,10 +208,7 @@
                 AuthenticationMethodModel.Pattern
             )
             utils.authenticationRepository.setUnlocked(false)
-            sceneInteractor.setCurrentScene(
-                SceneTestUtils.CONTAINER_1,
-                SceneModel(SceneKey.Bouncer)
-            )
+            sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
             assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
             underTest.onShown()
             underTest.onDragStart()
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bouncer/ui/viewmodel/PinBouncerViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/bouncer/ui/viewmodel/PinBouncerViewModelTest.kt
index 8edc6cf..c12ed03 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bouncer/ui/viewmodel/PinBouncerViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/bouncer/ui/viewmodel/PinBouncerViewModelTest.kt
@@ -75,15 +75,11 @@
     @Test
     fun onShown() =
         testScope.runTest {
-            val currentScene by
-                collectLastValue(sceneInteractor.currentScene(SceneTestUtils.CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             val message by collectLastValue(bouncerViewModel.message)
             val pin by collectLastValue(underTest.pinInput.map { it.getPin() })
             utils.authenticationRepository.setUnlocked(false)
-            sceneInteractor.setCurrentScene(
-                SceneTestUtils.CONTAINER_1,
-                SceneModel(SceneKey.Bouncer)
-            )
+            sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
             assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
 
             underTest.onShown()
@@ -96,16 +92,12 @@
     @Test
     fun onPinButtonClicked() =
         testScope.runTest {
-            val currentScene by
-                collectLastValue(sceneInteractor.currentScene(SceneTestUtils.CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             val message by collectLastValue(bouncerViewModel.message)
             val pin by collectLastValue(underTest.pinInput.map { it.getPin() })
             utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
             utils.authenticationRepository.setUnlocked(false)
-            sceneInteractor.setCurrentScene(
-                SceneTestUtils.CONTAINER_1,
-                SceneModel(SceneKey.Bouncer)
-            )
+            sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
             assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
             underTest.onShown()
             runCurrent()
@@ -120,16 +112,12 @@
     @Test
     fun onBackspaceButtonClicked() =
         testScope.runTest {
-            val currentScene by
-                collectLastValue(sceneInteractor.currentScene(SceneTestUtils.CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             val message by collectLastValue(bouncerViewModel.message)
             val pin by collectLastValue(underTest.pinInput.map { it.getPin() })
             utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
             utils.authenticationRepository.setUnlocked(false)
-            sceneInteractor.setCurrentScene(
-                SceneTestUtils.CONTAINER_1,
-                SceneModel(SceneKey.Bouncer)
-            )
+            sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
             assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
             underTest.onShown()
             runCurrent()
@@ -146,15 +134,11 @@
     @Test
     fun onPinEdit() =
         testScope.runTest {
-            val currentScene by
-                collectLastValue(sceneInteractor.currentScene(SceneTestUtils.CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             val pin by collectLastValue(underTest.pinInput.map { it.getPin() })
             utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
             utils.authenticationRepository.setUnlocked(false)
-            sceneInteractor.setCurrentScene(
-                SceneTestUtils.CONTAINER_1,
-                SceneModel(SceneKey.Bouncer)
-            )
+            sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
             assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
             underTest.onShown()
 
@@ -172,16 +156,12 @@
     @Test
     fun onBackspaceButtonLongPressed() =
         testScope.runTest {
-            val currentScene by
-                collectLastValue(sceneInteractor.currentScene(SceneTestUtils.CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             val message by collectLastValue(bouncerViewModel.message)
             val pin by collectLastValue(underTest.pinInput.map { it.getPin() })
             utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
             utils.authenticationRepository.setUnlocked(false)
-            sceneInteractor.setCurrentScene(
-                SceneTestUtils.CONTAINER_1,
-                SceneModel(SceneKey.Bouncer)
-            )
+            sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
             assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
             underTest.onShown()
             runCurrent()
@@ -200,14 +180,10 @@
     @Test
     fun onAuthenticateButtonClicked_whenCorrect() =
         testScope.runTest {
-            val currentScene by
-                collectLastValue(sceneInteractor.currentScene(SceneTestUtils.CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
             utils.authenticationRepository.setUnlocked(false)
-            sceneInteractor.setCurrentScene(
-                SceneTestUtils.CONTAINER_1,
-                SceneModel(SceneKey.Bouncer)
-            )
+            sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
             assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
             underTest.onShown()
             FakeAuthenticationRepository.DEFAULT_PIN.forEach { digit ->
@@ -222,16 +198,12 @@
     @Test
     fun onAuthenticateButtonClicked_whenWrong() =
         testScope.runTest {
-            val currentScene by
-                collectLastValue(sceneInteractor.currentScene(SceneTestUtils.CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             val message by collectLastValue(bouncerViewModel.message)
             val pin by collectLastValue(underTest.pinInput.map { it.getPin() })
             utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
             utils.authenticationRepository.setUnlocked(false)
-            sceneInteractor.setCurrentScene(
-                SceneTestUtils.CONTAINER_1,
-                SceneModel(SceneKey.Bouncer)
-            )
+            sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
             assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
             underTest.onShown()
             underTest.onPinButtonClicked(1)
@@ -250,16 +222,12 @@
     @Test
     fun onAuthenticateButtonClicked_correctAfterWrong() =
         testScope.runTest {
-            val currentScene by
-                collectLastValue(sceneInteractor.currentScene(SceneTestUtils.CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             val message by collectLastValue(bouncerViewModel.message)
             val pin by collectLastValue(underTest.pinInput.map { it.getPin() })
             utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
             utils.authenticationRepository.setUnlocked(false)
-            sceneInteractor.setCurrentScene(
-                SceneTestUtils.CONTAINER_1,
-                SceneModel(SceneKey.Bouncer)
-            )
+            sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
             assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
             underTest.onShown()
             underTest.onPinButtonClicked(1)
@@ -286,15 +254,11 @@
     @Test
     fun onAutoConfirm_whenCorrect() =
         testScope.runTest {
-            val currentScene by
-                collectLastValue(sceneInteractor.currentScene(SceneTestUtils.CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
             utils.authenticationRepository.setUnlocked(false)
             utils.authenticationRepository.setAutoConfirmEnabled(true)
-            sceneInteractor.setCurrentScene(
-                SceneTestUtils.CONTAINER_1,
-                SceneModel(SceneKey.Bouncer)
-            )
+            sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
             assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
             underTest.onShown()
             FakeAuthenticationRepository.DEFAULT_PIN.forEach { digit ->
@@ -307,17 +271,13 @@
     @Test
     fun onAutoConfirm_whenWrong() =
         testScope.runTest {
-            val currentScene by
-                collectLastValue(sceneInteractor.currentScene(SceneTestUtils.CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             val message by collectLastValue(bouncerViewModel.message)
             val pin by collectLastValue(underTest.pinInput.map { it.getPin() })
             utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
             utils.authenticationRepository.setUnlocked(false)
             utils.authenticationRepository.setAutoConfirmEnabled(true)
-            sceneInteractor.setCurrentScene(
-                SceneTestUtils.CONTAINER_1,
-                SceneModel(SceneKey.Bouncer)
-            )
+            sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
             assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
             underTest.onShown()
             FakeAuthenticationRepository.DEFAULT_PIN.dropLast(1).forEach { digit ->
diff --git a/packages/SystemUI/tests/src/com/android/systemui/controls/controller/ControlActionCoordinatorImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/controls/controller/ControlActionCoordinatorImplTest.kt
index 38372a3..692d794 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/controls/controller/ControlActionCoordinatorImplTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/controls/controller/ControlActionCoordinatorImplTest.kt
@@ -24,7 +24,6 @@
 import com.android.systemui.controls.settings.ControlsSettingsDialogManager
 import com.android.systemui.controls.settings.FakeControlsSettingsRepository
 import com.android.systemui.flags.FeatureFlags
-import com.android.systemui.flags.Flags
 import com.android.systemui.plugins.ActivityStarter
 import com.android.systemui.statusbar.VibratorHelper
 import com.android.systemui.statusbar.policy.KeyguardStateController
@@ -36,7 +35,6 @@
 import org.mockito.Answers
 import org.mockito.Mock
 import org.mockito.Mockito
-import org.mockito.Mockito.`when`
 import org.mockito.Mockito.anyBoolean
 import org.mockito.Mockito.doNothing
 import org.mockito.Mockito.doReturn
@@ -44,6 +42,7 @@
 import org.mockito.Mockito.reset
 import org.mockito.Mockito.spy
 import org.mockito.Mockito.verify
+import org.mockito.Mockito.`when`
 import org.mockito.MockitoAnnotations
 import java.util.Optional
 
@@ -102,14 +101,11 @@
                 metricsLogger,
                 vibratorHelper,
                 controlsSettingsRepository,
-                controlsSettingsDialogManager,
-                featureFlags
         ))
         coordinator.activityContext = mContext
 
         `when`(cvh.cws.ci.controlId).thenReturn(ID)
         `when`(cvh.cws.control?.isAuthRequired()).thenReturn(true)
-        `when`(featureFlags.isEnabled(Flags.USE_APP_PANELS)).thenReturn(false)
 
         action = spy(coordinator.Action(ID, {}, false, true))
         doReturn(action).`when`(coordinator).createAction(any(), any(), anyBoolean(), anyBoolean())
@@ -155,13 +151,11 @@
         coordinator.toggle(cvh, "", true)
 
         verify(coordinator).bouncerOrRun(action)
-        verify(controlsSettingsDialogManager).maybeShowDialog(any(), any())
         verify(action).invoke()
     }
 
     @Test
     fun testToggleWhenLockedDoesNotTriggerDialog_featureFlagEnabled() {
-        `when`(featureFlags.isEnabled(Flags.USE_APP_PANELS)).thenReturn(true)
         action = spy(coordinator.Action(ID, {}, false, false))
         doReturn(action).`when`(coordinator).createAction(any(), any(), anyBoolean(), anyBoolean())
 
diff --git a/packages/SystemUI/tests/src/com/android/systemui/controls/management/ControlsListingControllerImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/controls/management/ControlsListingControllerImplTest.kt
index ee213f7..b1061ba 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/controls/management/ControlsListingControllerImplTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/controls/management/ControlsListingControllerImplTest.kt
@@ -37,7 +37,6 @@
 import com.android.systemui.dump.DumpManager
 import com.android.systemui.flags.FeatureFlags
 import com.android.systemui.flags.Flags.APP_PANELS_ALL_APPS_ALLOWED
-import com.android.systemui.flags.Flags.USE_APP_PANELS
 import com.android.systemui.settings.UserTracker
 import com.android.systemui.util.ActivityTaskManagerProxy
 import com.android.systemui.util.concurrency.FakeExecutor
@@ -124,8 +123,6 @@
                         arrayOf(componentName.packageName)
                 )
 
-        // Return true by default, we'll test the false path
-        `when`(featureFlags.isEnabled(USE_APP_PANELS)).thenReturn(true)
         // Return false by default, we'll test the true path
         `when`(featureFlags.isEnabled(APP_PANELS_ALL_APPS_ALLOWED)).thenReturn(false)
 
@@ -445,34 +442,6 @@
     }
 
     @Test
-    fun testActivityDefaultEnabled_flagDisabled_nullPanel() {
-        `when`(featureFlags.isEnabled(USE_APP_PANELS)).thenReturn(false)
-        val serviceInfo = ServiceInfo(
-                componentName,
-                activityName,
-        )
-
-        `when`(packageManager.getComponentEnabledSetting(eq(activityName)))
-                .thenReturn(PackageManager.COMPONENT_ENABLED_STATE_DEFAULT)
-
-        setUpQueryResult(listOf(
-                ActivityInfo(
-                        activityName,
-                        enabled = true,
-                        exported = true,
-                        permission = Manifest.permission.BIND_CONTROLS
-                )
-        ))
-
-        val list = listOf(serviceInfo)
-        serviceListingCallbackCaptor.value.onServicesReloaded(list)
-
-        executor.runAllReady()
-
-        assertNull(controller.getCurrentServices()[0].panelActivity)
-    }
-
-    @Test
     fun testActivityDifferentPackage_nullPanel() {
         val serviceInfo = ServiceInfo(
                 componentName,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/DeviceEntryFaceAuthRepositoryTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/DeviceEntryFaceAuthRepositoryTest.kt
index 01a6c64..85ee0e4 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/DeviceEntryFaceAuthRepositoryTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/DeviceEntryFaceAuthRepositoryTest.kt
@@ -541,10 +541,8 @@
         }
 
     @Test
-    fun authenticateDoesNotRunIfUserIsCurrentlySwitching() =
-        testScope.runTest {
-            testGatingCheckForFaceAuth { fakeUserRepository.setUserSwitching(true) }
-        }
+    fun authenticateDoesNotRunIfFaceAuthIsCurrentlyPaused() =
+        testScope.runTest { testGatingCheckForFaceAuth { underTest.pauseFaceAuth() } }
 
     @Test
     fun authenticateDoesNotRunIfKeyguardIsNotShowing() =
@@ -840,7 +838,7 @@
 
     @Test
     fun detectDoesNotRunWhenUserSwitchingInProgress() =
-        testScope.runTest { testGatingCheckForDetect { fakeUserRepository.setUserSwitching(true) } }
+        testScope.runTest { testGatingCheckForDetect { underTest.pauseFaceAuth() } }
 
     @Test
     fun detectDoesNotRunWhenKeyguardGoingAway() =
@@ -1130,7 +1128,7 @@
             .addLockoutResetCallback(faceLockoutResetCallback.capture())
         biometricSettingsRepository.setFaceEnrolled(true)
         biometricSettingsRepository.setIsFaceAuthEnabled(true)
-        fakeUserRepository.setUserSwitching(false)
+        underTest.resumeFaceAuth()
         trustRepository.setCurrentUserTrusted(false)
         keyguardRepository.setKeyguardGoingAway(false)
         keyguardRepository.setWakefulnessModel(
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardFaceAuthInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardFaceAuthInteractorTest.kt
index 8636dd8..93f208e 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardFaceAuthInteractorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardFaceAuthInteractorTest.kt
@@ -48,6 +48,7 @@
 import com.android.systemui.log.FaceAuthenticationLogger
 import com.android.systemui.plugins.statusbar.StatusBarStateController
 import com.android.systemui.statusbar.policy.KeyguardStateController
+import com.android.systemui.user.data.repository.FakeUserRepository
 import com.android.systemui.util.time.FakeSystemClock
 import com.google.common.truth.Truth.assertThat
 import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -74,6 +75,7 @@
     private lateinit var keyguardTransitionRepository: FakeKeyguardTransitionRepository
     private lateinit var keyguardTransitionInteractor: KeyguardTransitionInteractor
     private lateinit var faceAuthRepository: FakeDeviceEntryFaceAuthRepository
+    private lateinit var fakeUserRepository: FakeUserRepository
     private lateinit var fakeDeviceEntryFingerprintAuthRepository:
         FakeDeviceEntryFingerprintAuthRepository
 
@@ -98,6 +100,7 @@
                 .keyguardTransitionInteractor
 
         fakeDeviceEntryFingerprintAuthRepository = FakeDeviceEntryFingerprintAuthRepository()
+        fakeUserRepository = FakeUserRepository()
         underTest =
             SystemUIKeyguardFaceAuthInteractor(
                 mContext,
@@ -131,7 +134,8 @@
                 featureFlags,
                 FaceAuthenticationLogger(logcatLogBuffer("faceAuthBuffer")),
                 keyguardUpdateMonitor,
-                fakeDeviceEntryFingerprintAuthRepository
+                fakeDeviceEntryFingerprintAuthRepository,
+                fakeUserRepository,
             )
     }
 
@@ -212,6 +216,38 @@
         }
 
     @Test
+    fun faceAuthIsPausedWhenUserSwitchingIsInProgress() =
+        testScope.runTest {
+            underTest.start()
+
+            fakeUserRepository.setUserSwitching(false)
+            runCurrent()
+            fakeUserRepository.setUserSwitching(true)
+            runCurrent()
+
+            assertThat(faceAuthRepository.isFaceAuthPaused()).isTrue()
+        }
+
+    @Test
+    fun faceAuthIsUnpausedWhenUserSwitchingIsInComplete() =
+        testScope.runTest {
+            underTest.start()
+
+            // previously running
+            fakeUserRepository.setUserSwitching(true)
+            runCurrent()
+            fakeUserRepository.setUserSwitching(false)
+            runCurrent()
+
+            assertThat(faceAuthRepository.isFaceAuthPaused()).isFalse()
+
+            runCurrent()
+            assertThat(faceAuthRepository.runningAuthRequest.value!!.first)
+                .isEqualTo(FaceAuthUiEvent.FACE_AUTH_UPDATED_USER_SWITCHING)
+            assertThat(faceAuthRepository.runningAuthRequest.value!!.second).isEqualTo(true)
+        }
+
+    @Test
     fun faceAuthIsRequestedWhenPrimaryBouncerIsVisible() =
         testScope.runTest {
             underTest.start()
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/LockscreenSceneInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/LockscreenSceneInteractorTest.kt
index ca6a5b6..d825c2a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/LockscreenSceneInteractorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/LockscreenSceneInteractorTest.kt
@@ -21,7 +21,6 @@
 import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
 import com.android.systemui.coroutines.collectLastValue
 import com.android.systemui.scene.SceneTestUtils
-import com.android.systemui.scene.SceneTestUtils.Companion.CONTAINER_1
 import com.android.systemui.scene.shared.model.SceneKey
 import com.android.systemui.scene.shared.model.SceneModel
 import com.google.common.truth.Truth.assertThat
@@ -91,7 +90,7 @@
     @Test
     fun dismissLockScreen_deviceLockedWithSecureAuthMethod_switchesToBouncer() =
         testScope.runTest {
-            val currentScene by collectLastValue(sceneInteractor.currentScene(CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             utils.authenticationRepository.setUnlocked(false)
             utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
             assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Lockscreen))
@@ -104,7 +103,7 @@
     @Test
     fun dismissLockScreen_deviceUnlocked_switchesToGone() =
         testScope.runTest {
-            val currentScene by collectLastValue(sceneInteractor.currentScene(CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             utils.authenticationRepository.setUnlocked(true)
             utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
             assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Lockscreen))
@@ -117,7 +116,7 @@
     @Test
     fun dismissLockScreen_deviceLockedWithInsecureAuthMethod_switchesToGone() =
         testScope.runTest {
-            val currentScene by collectLastValue(sceneInteractor.currentScene(CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             utils.authenticationRepository.setUnlocked(false)
             utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Swipe)
             assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Lockscreen))
@@ -131,11 +130,11 @@
     fun switchFromLockScreenToGone_authMethodNotSwipe_doesNotUnlockDevice() =
         testScope.runTest {
             val isUnlocked by collectLastValue(authenticationInteractor.isUnlocked)
-            sceneInteractor.setCurrentScene(CONTAINER_1, SceneModel(SceneKey.Lockscreen))
+            sceneInteractor.setCurrentScene(SceneModel(SceneKey.Lockscreen))
             utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
             assertThat(isUnlocked).isFalse()
 
-            sceneInteractor.setCurrentScene(CONTAINER_1, SceneModel(SceneKey.Gone))
+            sceneInteractor.setCurrentScene(SceneModel(SceneKey.Gone))
 
             assertThat(isUnlocked).isFalse()
         }
@@ -145,13 +144,13 @@
         testScope.runTest {
             val isUnlocked by collectLastValue(authenticationInteractor.isUnlocked)
             runCurrent()
-            sceneInteractor.setCurrentScene(CONTAINER_1, SceneModel(SceneKey.Shade))
+            sceneInteractor.setCurrentScene(SceneModel(SceneKey.Shade))
             runCurrent()
             utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Swipe)
             runCurrent()
             assertThat(isUnlocked).isFalse()
 
-            sceneInteractor.setCurrentScene(CONTAINER_1, SceneModel(SceneKey.Gone))
+            sceneInteractor.setCurrentScene(SceneModel(SceneKey.Gone))
 
             assertThat(isUnlocked).isFalse()
         }
@@ -159,10 +158,10 @@
     @Test
     fun authMethodChangedToNone_notOnLockScreenScene_doesNotDismissLockScreen() =
         testScope.runTest {
-            val currentScene by collectLastValue(sceneInteractor.currentScene(CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Swipe)
             runCurrent()
-            sceneInteractor.setCurrentScene(CONTAINER_1, SceneModel(SceneKey.QuickSettings))
+            sceneInteractor.setCurrentScene(SceneModel(SceneKey.QuickSettings))
             runCurrent()
             assertThat(currentScene).isEqualTo(SceneModel(SceneKey.QuickSettings))
 
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneViewModelTest.kt
index ba8e0f2..63ee240 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneViewModelTest.kt
@@ -22,9 +22,7 @@
 import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
 import com.android.systemui.common.shared.model.Icon
 import com.android.systemui.coroutines.collectLastValue
-import com.android.systemui.keyguard.domain.interactor.LockscreenSceneInteractor
 import com.android.systemui.scene.SceneTestUtils
-import com.android.systemui.scene.SceneTestUtils.Companion.CONTAINER_1
 import com.android.systemui.scene.shared.model.SceneKey
 import com.android.systemui.scene.shared.model.SceneModel
 import com.google.common.truth.Truth.assertThat
@@ -51,20 +49,15 @@
     private val underTest =
         LockscreenSceneViewModel(
             applicationScope = testScope.backgroundScope,
-            interactorFactory =
-                object : LockscreenSceneInteractor.Factory {
-                    override fun create(containerName: String): LockscreenSceneInteractor {
-                        return utils.lockScreenSceneInteractor(
+            interactor =
+                utils.lockScreenSceneInteractor(
+                    authenticationInteractor = authenticationInteractor,
+                    bouncerInteractor =
+                        utils.bouncerInteractor(
                             authenticationInteractor = authenticationInteractor,
-                            bouncerInteractor =
-                                utils.bouncerInteractor(
-                                    authenticationInteractor = authenticationInteractor,
-                                    sceneInteractor = sceneInteractor,
-                                ),
-                        )
-                    }
-                },
-            containerName = CONTAINER_1
+                            sceneInteractor = sceneInteractor,
+                        ),
+                ),
         )
 
     @Test
@@ -116,7 +109,7 @@
     @Test
     fun onLockButtonClicked_deviceLockedSecurely_switchesToBouncer() =
         testScope.runTest {
-            val currentScene by collectLastValue(sceneInteractor.currentScene(CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
             utils.authenticationRepository.setUnlocked(false)
             runCurrent()
@@ -129,7 +122,7 @@
     @Test
     fun onContentClicked_deviceUnlocked_switchesToGone() =
         testScope.runTest {
-            val currentScene by collectLastValue(sceneInteractor.currentScene(CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
             utils.authenticationRepository.setUnlocked(true)
             runCurrent()
@@ -142,7 +135,7 @@
     @Test
     fun onContentClicked_deviceLockedSecurely_switchesToBouncer() =
         testScope.runTest {
-            val currentScene by collectLastValue(sceneInteractor.currentScene(CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
             utils.authenticationRepository.setUnlocked(false)
             runCurrent()
@@ -155,7 +148,7 @@
     @Test
     fun onLockButtonClicked_deviceUnlocked_switchesToGone() =
         testScope.runTest {
-            val currentScene by collectLastValue(sceneInteractor.currentScene(CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
             utils.authenticationRepository.setUnlocked(true)
             runCurrent()
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsSceneViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsSceneViewModelTest.kt
index ed7a59e..ee42a70 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsSceneViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsSceneViewModelTest.kt
@@ -20,9 +20,7 @@
 import com.android.systemui.SysuiTestCase
 import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
 import com.android.systemui.coroutines.collectLastValue
-import com.android.systemui.keyguard.domain.interactor.LockscreenSceneInteractor
 import com.android.systemui.scene.SceneTestUtils
-import com.android.systemui.scene.SceneTestUtils.Companion.CONTAINER_1
 import com.android.systemui.scene.shared.model.SceneKey
 import com.android.systemui.scene.shared.model.SceneModel
 import com.google.common.truth.Truth.assertThat
@@ -48,26 +46,21 @@
 
     private val underTest =
         QuickSettingsSceneViewModel(
-            lockscreenSceneInteractorFactory =
-                object : LockscreenSceneInteractor.Factory {
-                    override fun create(containerName: String): LockscreenSceneInteractor {
-                        return utils.lockScreenSceneInteractor(
+            lockscreenSceneInteractor =
+                utils.lockScreenSceneInteractor(
+                    authenticationInteractor = authenticationInteractor,
+                    bouncerInteractor =
+                        utils.bouncerInteractor(
                             authenticationInteractor = authenticationInteractor,
-                            bouncerInteractor =
-                                utils.bouncerInteractor(
-                                    authenticationInteractor = authenticationInteractor,
-                                    sceneInteractor = sceneInteractor,
-                                ),
-                        )
-                    }
-                },
-            containerName = CONTAINER_1
+                            sceneInteractor = sceneInteractor,
+                        ),
+                ),
         )
 
     @Test
     fun onContentClicked_deviceUnlocked_switchesToGone() =
         testScope.runTest {
-            val currentScene by collectLastValue(sceneInteractor.currentScene(CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
             utils.authenticationRepository.setUnlocked(true)
             runCurrent()
@@ -80,7 +73,7 @@
     @Test
     fun onContentClicked_deviceLockedSecurely_switchesToBouncer() =
         testScope.runTest {
-            val currentScene by collectLastValue(sceneInteractor.currentScene(CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
             utils.authenticationRepository.setUnlocked(false)
             runCurrent()
diff --git a/packages/SystemUI/tests/src/com/android/systemui/scene/data/repository/SceneContainerRepositoryTest.kt b/packages/SystemUI/tests/src/com/android/systemui/scene/data/repository/SceneContainerRepositoryTest.kt
index 9ce378d..826a6cc 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/scene/data/repository/SceneContainerRepositoryTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/scene/data/repository/SceneContainerRepositoryTest.kt
@@ -41,7 +41,7 @@
     @Test
     fun allSceneKeys() {
         val underTest = utils.fakeSceneContainerRepository()
-        assertThat(underTest.allSceneKeys(SceneTestUtils.CONTAINER_1))
+        assertThat(underTest.allSceneKeys())
             .isEqualTo(
                 listOf(
                     SceneKey.QuickSettings,
@@ -53,115 +53,58 @@
             )
     }
 
-    @Test(expected = IllegalStateException::class)
-    fun allSceneKeys_noSuchContainer_throws() {
-        val underTest = utils.fakeSceneContainerRepository()
-        underTest.allSceneKeys("nonExistingContainer")
-    }
-
     @Test
     fun currentScene() = runTest {
         val underTest = utils.fakeSceneContainerRepository()
-        val currentScene by collectLastValue(underTest.currentScene(SceneTestUtils.CONTAINER_1))
+        val currentScene by collectLastValue(underTest.currentScene)
         assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Lockscreen))
 
-        underTest.setCurrentScene(SceneTestUtils.CONTAINER_1, SceneModel(SceneKey.Shade))
+        underTest.setCurrentScene(SceneModel(SceneKey.Shade))
         assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Shade))
     }
 
     @Test(expected = IllegalStateException::class)
-    fun currentScene_noSuchContainer_throws() {
-        val underTest = utils.fakeSceneContainerRepository()
-        underTest.currentScene("nonExistingContainer")
-    }
-
-    @Test(expected = IllegalStateException::class)
-    fun setCurrentScene_noSuchContainer_throws() {
-        val underTest = utils.fakeSceneContainerRepository()
-        underTest.setCurrentScene("nonExistingContainer", SceneModel(SceneKey.Shade))
-    }
-
-    @Test(expected = IllegalStateException::class)
     fun setCurrentScene_noSuchSceneInContainer_throws() {
         val underTest =
             utils.fakeSceneContainerRepository(
-                setOf(
-                    utils.fakeSceneContainerConfig(SceneTestUtils.CONTAINER_1),
-                    utils.fakeSceneContainerConfig(
-                        SceneTestUtils.CONTAINER_2,
-                        listOf(SceneKey.QuickSettings, SceneKey.Lockscreen)
-                    ),
-                )
+                utils.fakeSceneContainerConfig(listOf(SceneKey.QuickSettings, SceneKey.Lockscreen)),
             )
-        underTest.setCurrentScene(SceneTestUtils.CONTAINER_2, SceneModel(SceneKey.Shade))
+        underTest.setCurrentScene(SceneModel(SceneKey.Shade))
     }
 
     @Test
     fun isVisible() = runTest {
         val underTest = utils.fakeSceneContainerRepository()
-        val isVisible by collectLastValue(underTest.isVisible(SceneTestUtils.CONTAINER_1))
+        val isVisible by collectLastValue(underTest.isVisible)
         assertThat(isVisible).isTrue()
 
-        underTest.setVisible(SceneTestUtils.CONTAINER_1, false)
+        underTest.setVisible(false)
         assertThat(isVisible).isFalse()
 
-        underTest.setVisible(SceneTestUtils.CONTAINER_1, true)
+        underTest.setVisible(true)
         assertThat(isVisible).isTrue()
     }
 
-    @Test(expected = IllegalStateException::class)
-    fun isVisible_noSuchContainer_throws() {
-        val underTest = utils.fakeSceneContainerRepository()
-        underTest.isVisible("nonExistingContainer")
-    }
-
-    @Test(expected = IllegalStateException::class)
-    fun setVisible_noSuchContainer_throws() {
-        val underTest = utils.fakeSceneContainerRepository()
-        underTest.setVisible("nonExistingContainer", false)
-    }
-
     @Test
-    fun sceneTransitionProgress() = runTest {
+    fun transitionProgress() = runTest {
         val underTest = utils.fakeSceneContainerRepository()
-        val sceneTransitionProgress by
-            collectLastValue(underTest.sceneTransitionProgress(SceneTestUtils.CONTAINER_1))
+        val sceneTransitionProgress by collectLastValue(underTest.transitionProgress)
         assertThat(sceneTransitionProgress).isEqualTo(1f)
 
-        underTest.setSceneTransitionProgress(SceneTestUtils.CONTAINER_1, 0.1f)
+        underTest.setSceneTransitionProgress(0.1f)
         assertThat(sceneTransitionProgress).isEqualTo(0.1f)
 
-        underTest.setSceneTransitionProgress(SceneTestUtils.CONTAINER_1, 0.9f)
+        underTest.setSceneTransitionProgress(0.9f)
         assertThat(sceneTransitionProgress).isEqualTo(0.9f)
     }
 
-    @Test(expected = IllegalStateException::class)
-    fun sceneTransitionProgress_noSuchContainer_throws() {
-        val underTest = utils.fakeSceneContainerRepository()
-        underTest.sceneTransitionProgress("nonExistingContainer")
-    }
-
     @Test
     fun setSceneTransition() = runTest {
-        val underTest =
-            utils.fakeSceneContainerRepository(
-                setOf(
-                    utils.fakeSceneContainerConfig(SceneTestUtils.CONTAINER_1),
-                    utils.fakeSceneContainerConfig(
-                        SceneTestUtils.CONTAINER_2,
-                        listOf(SceneKey.QuickSettings, SceneKey.Lockscreen)
-                    ),
-                )
-            )
-        val sceneTransition by
-            collectLastValue(underTest.sceneTransitions(SceneTestUtils.CONTAINER_2))
+        val underTest = utils.fakeSceneContainerRepository()
+        val sceneTransition by collectLastValue(underTest.transitions)
         assertThat(sceneTransition).isNull()
 
-        underTest.setSceneTransition(
-            SceneTestUtils.CONTAINER_2,
-            SceneKey.Lockscreen,
-            SceneKey.QuickSettings
-        )
+        underTest.setSceneTransition(SceneKey.Lockscreen, SceneKey.QuickSettings)
         assertThat(sceneTransition)
             .isEqualTo(
                 SceneTransitionModel(from = SceneKey.Lockscreen, to = SceneKey.QuickSettings)
@@ -169,46 +112,20 @@
     }
 
     @Test(expected = IllegalStateException::class)
-    fun setSceneTransition_noSuchContainer_throws() {
-        val underTest = utils.fakeSceneContainerRepository()
-        underTest.setSceneTransition("nonExistingContainer", SceneKey.Lockscreen, SceneKey.Shade)
-    }
-
-    @Test(expected = IllegalStateException::class)
     fun setSceneTransition_noFromSceneInContainer_throws() {
         val underTest =
             utils.fakeSceneContainerRepository(
-                setOf(
-                    utils.fakeSceneContainerConfig(SceneTestUtils.CONTAINER_1),
-                    utils.fakeSceneContainerConfig(
-                        SceneTestUtils.CONTAINER_2,
-                        listOf(SceneKey.QuickSettings, SceneKey.Lockscreen)
-                    ),
-                )
+                utils.fakeSceneContainerConfig(listOf(SceneKey.QuickSettings, SceneKey.Lockscreen)),
             )
-        underTest.setSceneTransition(
-            SceneTestUtils.CONTAINER_2,
-            SceneKey.Shade,
-            SceneKey.Lockscreen
-        )
+        underTest.setSceneTransition(SceneKey.Shade, SceneKey.Lockscreen)
     }
 
     @Test(expected = IllegalStateException::class)
     fun setSceneTransition_noToSceneInContainer_throws() {
         val underTest =
             utils.fakeSceneContainerRepository(
-                setOf(
-                    utils.fakeSceneContainerConfig(SceneTestUtils.CONTAINER_1),
-                    utils.fakeSceneContainerConfig(
-                        SceneTestUtils.CONTAINER_2,
-                        listOf(SceneKey.QuickSettings, SceneKey.Lockscreen)
-                    ),
-                )
+                utils.fakeSceneContainerConfig(listOf(SceneKey.QuickSettings, SceneKey.Lockscreen)),
             )
-        underTest.setSceneTransition(
-            SceneTestUtils.CONTAINER_2,
-            SceneKey.Shade,
-            SceneKey.Lockscreen
-        )
+        underTest.setSceneTransition(SceneKey.Shade, SceneKey.Lockscreen)
     }
 }
diff --git a/packages/SystemUI/tests/src/com/android/systemui/scene/domain/interactor/SceneInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/scene/domain/interactor/SceneInteractorTest.kt
index d2bbfa8..13a602d 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/scene/domain/interactor/SceneInteractorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/scene/domain/interactor/SceneInteractorTest.kt
@@ -41,48 +41,46 @@
 
     @Test
     fun allSceneKeys() {
-        assertThat(underTest.allSceneKeys(SceneTestUtils.CONTAINER_1))
-            .isEqualTo(utils.fakeSceneKeys())
+        assertThat(underTest.allSceneKeys()).isEqualTo(utils.fakeSceneKeys())
     }
 
     @Test
     fun currentScene() = runTest {
-        val currentScene by collectLastValue(underTest.currentScene(SceneTestUtils.CONTAINER_1))
+        val currentScene by collectLastValue(underTest.currentScene)
         assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Lockscreen))
 
-        underTest.setCurrentScene(SceneTestUtils.CONTAINER_1, SceneModel(SceneKey.Shade))
+        underTest.setCurrentScene(SceneModel(SceneKey.Shade))
         assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Shade))
     }
 
     @Test
     fun sceneTransitionProgress() = runTest {
-        val progress by
-            collectLastValue(underTest.sceneTransitionProgress(SceneTestUtils.CONTAINER_1))
+        val progress by collectLastValue(underTest.transitionProgress)
         assertThat(progress).isEqualTo(1f)
 
-        underTest.setSceneTransitionProgress(SceneTestUtils.CONTAINER_1, 0.55f)
+        underTest.setSceneTransitionProgress(0.55f)
         assertThat(progress).isEqualTo(0.55f)
     }
 
     @Test
     fun isVisible() = runTest {
-        val isVisible by collectLastValue(underTest.isVisible(SceneTestUtils.CONTAINER_1))
+        val isVisible by collectLastValue(underTest.isVisible)
         assertThat(isVisible).isTrue()
 
-        underTest.setVisible(SceneTestUtils.CONTAINER_1, false)
+        underTest.setVisible(false)
         assertThat(isVisible).isFalse()
 
-        underTest.setVisible(SceneTestUtils.CONTAINER_1, true)
+        underTest.setVisible(true)
         assertThat(isVisible).isTrue()
     }
 
     @Test
     fun sceneTransitions() = runTest {
-        val transitions by collectLastValue(underTest.sceneTransitions(SceneTestUtils.CONTAINER_1))
+        val transitions by collectLastValue(underTest.transitions)
         assertThat(transitions).isNull()
 
-        val initialSceneKey = underTest.currentScene(SceneTestUtils.CONTAINER_1).value.key
-        underTest.setCurrentScene(SceneTestUtils.CONTAINER_1, SceneModel(SceneKey.Shade))
+        val initialSceneKey = underTest.currentScene.value.key
+        underTest.setCurrentScene(SceneModel(SceneKey.Shade))
         assertThat(transitions)
             .isEqualTo(
                 SceneTransitionModel(
@@ -91,7 +89,7 @@
                 )
             )
 
-        underTest.setCurrentScene(SceneTestUtils.CONTAINER_1, SceneModel(SceneKey.QuickSettings))
+        underTest.setCurrentScene(SceneModel(SceneKey.QuickSettings))
         assertThat(transitions)
             .isEqualTo(
                 SceneTransitionModel(
diff --git a/packages/SystemUI/tests/src/com/android/systemui/scene/domain/startable/SystemUiDefaultSceneContainerStartableTest.kt b/packages/SystemUI/tests/src/com/android/systemui/scene/domain/startable/SceneContainerStartableTest.kt
similarity index 72%
rename from packages/SystemUI/tests/src/com/android/systemui/scene/domain/startable/SystemUiDefaultSceneContainerStartableTest.kt
rename to packages/SystemUI/tests/src/com/android/systemui/scene/domain/startable/SceneContainerStartableTest.kt
index 6f6c5a5..b6bd31f 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/scene/domain/startable/SystemUiDefaultSceneContainerStartableTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/scene/domain/startable/SceneContainerStartableTest.kt
@@ -28,7 +28,6 @@
 import com.android.systemui.keyguard.shared.model.WakefulnessState
 import com.android.systemui.model.SysUiState
 import com.android.systemui.scene.SceneTestUtils
-import com.android.systemui.scene.shared.model.SceneContainerNames
 import com.android.systemui.scene.shared.model.SceneKey
 import com.android.systemui.scene.shared.model.SceneModel
 import com.android.systemui.util.mockito.mock
@@ -47,7 +46,7 @@
 
 @SmallTest
 @RunWith(JUnit4::class)
-class SystemUiDefaultSceneContainerStartableTest : SysuiTestCase() {
+class SceneContainerStartableTest : SysuiTestCase() {
 
     private val utils = SceneTestUtils(this)
     private val testScope = utils.testScope
@@ -66,7 +65,7 @@
     private val sysUiState: SysUiState = mock()
 
     private val underTest =
-        SystemUiDefaultSceneContainerStartable(
+        SceneContainerStartable(
             applicationScope = testScope.backgroundScope,
             sceneInteractor = sceneInteractor,
             authenticationInteractor = authenticationInteractor,
@@ -84,14 +83,8 @@
     @Test
     fun hydrateVisibility_featureEnabled() =
         testScope.runTest {
-            val currentSceneKey by
-                collectLastValue(
-                    sceneInteractor.currentScene(SceneContainerNames.SYSTEM_UI_DEFAULT).map {
-                        it.key
-                    }
-                )
-            val isVisible by
-                collectLastValue(sceneInteractor.isVisible(SceneContainerNames.SYSTEM_UI_DEFAULT))
+            val currentSceneKey by collectLastValue(sceneInteractor.currentScene.map { it.key })
+            val isVisible by collectLastValue(sceneInteractor.isVisible)
             prepareState(
                 isFeatureEnabled = true,
                 isDeviceUnlocked = true,
@@ -104,24 +97,15 @@
 
             assertThat(isVisible).isFalse()
 
-            sceneInteractor.setCurrentScene(
-                SceneContainerNames.SYSTEM_UI_DEFAULT,
-                SceneModel(SceneKey.Shade)
-            )
+            sceneInteractor.setCurrentScene(SceneModel(SceneKey.Shade))
             assertThat(isVisible).isTrue()
         }
 
     @Test
     fun hydrateVisibility_featureDisabled() =
         testScope.runTest {
-            val currentSceneKey by
-                collectLastValue(
-                    sceneInteractor.currentScene(SceneContainerNames.SYSTEM_UI_DEFAULT).map {
-                        it.key
-                    }
-                )
-            val isVisible by
-                collectLastValue(sceneInteractor.isVisible(SceneContainerNames.SYSTEM_UI_DEFAULT))
+            val currentSceneKey by collectLastValue(sceneInteractor.currentScene.map { it.key })
+            val isVisible by collectLastValue(sceneInteractor.isVisible)
             prepareState(
                 isFeatureEnabled = false,
                 isDeviceUnlocked = true,
@@ -133,28 +117,17 @@
             underTest.start()
             assertThat(isVisible).isTrue()
 
-            sceneInteractor.setCurrentScene(
-                SceneContainerNames.SYSTEM_UI_DEFAULT,
-                SceneModel(SceneKey.Gone)
-            )
+            sceneInteractor.setCurrentScene(SceneModel(SceneKey.Gone))
             assertThat(isVisible).isTrue()
 
-            sceneInteractor.setCurrentScene(
-                SceneContainerNames.SYSTEM_UI_DEFAULT,
-                SceneModel(SceneKey.Shade)
-            )
+            sceneInteractor.setCurrentScene(SceneModel(SceneKey.Shade))
             assertThat(isVisible).isTrue()
         }
 
     @Test
     fun switchToLockscreenWhenDeviceLocks_featureEnabled() =
         testScope.runTest {
-            val currentSceneKey by
-                collectLastValue(
-                    sceneInteractor.currentScene(SceneContainerNames.SYSTEM_UI_DEFAULT).map {
-                        it.key
-                    }
-                )
+            val currentSceneKey by collectLastValue(sceneInteractor.currentScene.map { it.key })
             prepareState(
                 isFeatureEnabled = true,
                 isDeviceUnlocked = true,
@@ -171,12 +144,7 @@
     @Test
     fun switchToLockscreenWhenDeviceLocks_featureDisabled() =
         testScope.runTest {
-            val currentSceneKey by
-                collectLastValue(
-                    sceneInteractor.currentScene(SceneContainerNames.SYSTEM_UI_DEFAULT).map {
-                        it.key
-                    }
-                )
+            val currentSceneKey by collectLastValue(sceneInteractor.currentScene.map { it.key })
             prepareState(
                 isFeatureEnabled = false,
                 isDeviceUnlocked = false,
@@ -193,12 +161,7 @@
     @Test
     fun switchFromBouncerToGoneWhenDeviceUnlocked_featureEnabled() =
         testScope.runTest {
-            val currentSceneKey by
-                collectLastValue(
-                    sceneInteractor.currentScene(SceneContainerNames.SYSTEM_UI_DEFAULT).map {
-                        it.key
-                    }
-                )
+            val currentSceneKey by collectLastValue(sceneInteractor.currentScene.map { it.key })
             prepareState(
                 isFeatureEnabled = true,
                 isDeviceUnlocked = false,
@@ -215,12 +178,7 @@
     @Test
     fun switchFromBouncerToGoneWhenDeviceUnlocked_featureDisabled() =
         testScope.runTest {
-            val currentSceneKey by
-                collectLastValue(
-                    sceneInteractor.currentScene(SceneContainerNames.SYSTEM_UI_DEFAULT).map {
-                        it.key
-                    }
-                )
+            val currentSceneKey by collectLastValue(sceneInteractor.currentScene.map { it.key })
             prepareState(
                 isFeatureEnabled = false,
                 isDeviceUnlocked = false,
@@ -237,12 +195,7 @@
     @Test
     fun switchFromLockscreenToGoneWhenDeviceUnlocksWithBypassOn_featureOn_bypassOn() =
         testScope.runTest {
-            val currentSceneKey by
-                collectLastValue(
-                    sceneInteractor.currentScene(SceneContainerNames.SYSTEM_UI_DEFAULT).map {
-                        it.key
-                    }
-                )
+            val currentSceneKey by collectLastValue(sceneInteractor.currentScene.map { it.key })
             prepareState(
                 isFeatureEnabled = true,
                 isBypassEnabled = true,
@@ -259,12 +212,7 @@
     @Test
     fun switchFromLockscreenToGoneWhenDeviceUnlocksWithBypassOn_featureOn_bypassOff() =
         testScope.runTest {
-            val currentSceneKey by
-                collectLastValue(
-                    sceneInteractor.currentScene(SceneContainerNames.SYSTEM_UI_DEFAULT).map {
-                        it.key
-                    }
-                )
+            val currentSceneKey by collectLastValue(sceneInteractor.currentScene.map { it.key })
             prepareState(
                 isFeatureEnabled = true,
                 isBypassEnabled = false,
@@ -281,12 +229,7 @@
     @Test
     fun switchFromLockscreenToGoneWhenDeviceUnlocksWithBypassOn_featureOff_bypassOn() =
         testScope.runTest {
-            val currentSceneKey by
-                collectLastValue(
-                    sceneInteractor.currentScene(SceneContainerNames.SYSTEM_UI_DEFAULT).map {
-                        it.key
-                    }
-                )
+            val currentSceneKey by collectLastValue(sceneInteractor.currentScene.map { it.key })
             prepareState(
                 isFeatureEnabled = false,
                 isBypassEnabled = true,
@@ -303,12 +246,7 @@
     @Test
     fun switchToGoneWhenDeviceSleepsUnlocked_featureEnabled() =
         testScope.runTest {
-            val currentSceneKey by
-                collectLastValue(
-                    sceneInteractor.currentScene(SceneContainerNames.SYSTEM_UI_DEFAULT).map {
-                        it.key
-                    }
-                )
+            val currentSceneKey by collectLastValue(sceneInteractor.currentScene.map { it.key })
             prepareState(
                 isFeatureEnabled = true,
                 isDeviceUnlocked = true,
@@ -325,12 +263,7 @@
     @Test
     fun switchToGoneWhenDeviceSleepsUnlocked_featureDisabled() =
         testScope.runTest {
-            val currentSceneKey by
-                collectLastValue(
-                    sceneInteractor.currentScene(SceneContainerNames.SYSTEM_UI_DEFAULT).map {
-                        it.key
-                    }
-                )
+            val currentSceneKey by collectLastValue(sceneInteractor.currentScene.map { it.key })
             prepareState(
                 isFeatureEnabled = false,
                 isDeviceUnlocked = true,
@@ -347,12 +280,7 @@
     @Test
     fun switchToLockscreenWhenDeviceSleepsLocked_featureEnabled() =
         testScope.runTest {
-            val currentSceneKey by
-                collectLastValue(
-                    sceneInteractor.currentScene(SceneContainerNames.SYSTEM_UI_DEFAULT).map {
-                        it.key
-                    }
-                )
+            val currentSceneKey by collectLastValue(sceneInteractor.currentScene.map { it.key })
             prepareState(
                 isFeatureEnabled = true,
                 isDeviceUnlocked = false,
@@ -369,12 +297,7 @@
     @Test
     fun switchToLockscreenWhenDeviceSleepsLocked_featureDisabled() =
         testScope.runTest {
-            val currentSceneKey by
-                collectLastValue(
-                    sceneInteractor.currentScene(SceneContainerNames.SYSTEM_UI_DEFAULT).map {
-                        it.key
-                    }
-                )
+            val currentSceneKey by collectLastValue(sceneInteractor.currentScene.map { it.key })
             prepareState(
                 isFeatureEnabled = false,
                 isDeviceUnlocked = false,
@@ -403,10 +326,7 @@
                     SceneKey.QuickSettings,
                 )
                 .forEachIndexed { index, sceneKey ->
-                    sceneInteractor.setCurrentScene(
-                        SceneContainerNames.SYSTEM_UI_DEFAULT,
-                        SceneModel(sceneKey),
-                    )
+                    sceneInteractor.setCurrentScene(SceneModel(sceneKey))
                     runCurrent()
 
                     verify(sysUiState, times(index + 1)).commitUpdate(Display.DEFAULT_DISPLAY)
@@ -422,9 +342,7 @@
         featureFlags.set(Flags.SCENE_CONTAINER, isFeatureEnabled)
         authenticationRepository.setUnlocked(isDeviceUnlocked)
         keyguardRepository.setBypassEnabled(isBypassEnabled)
-        initialSceneKey?.let {
-            sceneInteractor.setCurrentScene(SceneContainerNames.SYSTEM_UI_DEFAULT, SceneModel(it))
-        }
+        initialSceneKey?.let { sceneInteractor.setCurrentScene(SceneModel(it)) }
     }
 
     companion object {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModelTest.kt
index 63ea918c..0ab98ad 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModelTest.kt
@@ -45,7 +45,6 @@
     private val underTest =
         SceneContainerViewModel(
             interactor = interactor,
-            containerName = SceneTestUtils.CONTAINER_1,
         )
 
     @Test
@@ -53,10 +52,10 @@
         val isVisible by collectLastValue(underTest.isVisible)
         assertThat(isVisible).isTrue()
 
-        interactor.setVisible(SceneTestUtils.CONTAINER_1, false)
+        interactor.setVisible(false)
         assertThat(isVisible).isFalse()
 
-        interactor.setVisible(SceneTestUtils.CONTAINER_1, true)
+        interactor.setVisible(true)
         assertThat(isVisible).isTrue()
     }
 
diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModelTest.kt
index 6e9fba6..8739b28 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModelTest.kt
@@ -20,7 +20,6 @@
 import com.android.systemui.SysuiTestCase
 import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
 import com.android.systemui.coroutines.collectLastValue
-import com.android.systemui.keyguard.domain.interactor.LockscreenSceneInteractor
 import com.android.systemui.scene.SceneTestUtils
 import com.android.systemui.scene.shared.model.SceneKey
 import com.android.systemui.scene.shared.model.SceneModel
@@ -48,20 +47,15 @@
     private val underTest =
         ShadeSceneViewModel(
             applicationScope = testScope.backgroundScope,
-            lockscreenSceneInteractorFactory =
-                object : LockscreenSceneInteractor.Factory {
-                    override fun create(containerName: String): LockscreenSceneInteractor {
-                        return utils.lockScreenSceneInteractor(
+            lockscreenSceneInteractor =
+                utils.lockScreenSceneInteractor(
+                    authenticationInteractor = authenticationInteractor,
+                    bouncerInteractor =
+                        utils.bouncerInteractor(
                             authenticationInteractor = authenticationInteractor,
-                            bouncerInteractor =
-                                utils.bouncerInteractor(
-                                    authenticationInteractor = authenticationInteractor,
-                                    sceneInteractor = sceneInteractor,
-                                ),
-                        )
-                    }
-                },
-            containerName = SceneTestUtils.CONTAINER_1
+                            sceneInteractor = sceneInteractor,
+                        ),
+                ),
         )
 
     @Test
@@ -87,8 +81,7 @@
     @Test
     fun onContentClicked_deviceUnlocked_switchesToGone() =
         testScope.runTest {
-            val currentScene by
-                collectLastValue(sceneInteractor.currentScene(SceneTestUtils.CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
             utils.authenticationRepository.setUnlocked(true)
             runCurrent()
@@ -101,8 +94,7 @@
     @Test
     fun onContentClicked_deviceLockedSecurely_switchesToBouncer() =
         testScope.runTest {
-            val currentScene by
-                collectLastValue(sceneInteractor.currentScene(SceneTestUtils.CONTAINER_1))
+            val currentScene by collectLastValue(sceneInteractor.currentScene)
             utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
             utils.authenticationRepository.setUnlocked(false)
             runCurrent()
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/events/SystemEventChipAnimationControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/events/SystemEventChipAnimationControllerTest.kt
index 0b2da8b..0cfca61 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/events/SystemEventChipAnimationControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/events/SystemEventChipAnimationControllerTest.kt
@@ -24,6 +24,7 @@
 import android.view.Gravity
 import android.view.View
 import android.widget.FrameLayout
+import androidx.core.animation.AnimatorTestRule
 import androidx.test.filters.SmallTest
 import com.android.systemui.SysuiTestCase
 import com.android.systemui.flags.FakeFeatureFlags
@@ -38,6 +39,7 @@
 import org.junit.Assert.assertFalse
 import org.junit.Assert.assertTrue
 import org.junit.Before
+import org.junit.Rule
 import org.junit.Test
 import org.junit.runner.RunWith
 import org.mockito.Mock
@@ -50,6 +52,7 @@
 class SystemEventChipAnimationControllerTest : SysuiTestCase() {
     private lateinit var controller: SystemEventChipAnimationController
 
+    @get:Rule val animatorTestRule = AnimatorTestRule()
     @Mock private lateinit var sbWindowController: StatusBarWindowController
     @Mock private lateinit var insetsProvider: StatusBarContentInsetsProvider
 
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java
index 1dc8453..ac8b42a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java
@@ -789,6 +789,50 @@
         assertThat(row.isExpanded()).isTrue();
     }
 
+    @Test
+    public void onDisappearAnimationFinished_shouldSetFalse_headsUpAnimatingAway()
+            throws Exception {
+        final ExpandableNotificationRow row = mNotificationTestHelper.createRow();
+
+        // Initial state: suppose heads up animation in progress
+        row.setHeadsUpAnimatingAway(true);
+        assertThat(row.isHeadsUpAnimatingAway()).isTrue();
+
+        // on disappear animation ends
+        row.onAppearAnimationFinished(/* wasAppearing = */ false);
+        assertThat(row.isHeadsUpAnimatingAway()).isFalse();
+    }
+
+    @Test
+    public void onHUNAppear_cancelAppearDrawing_shouldResetAnimationState() throws Exception {
+        final ExpandableNotificationRow row = mNotificationTestHelper.createRow();
+
+        row.performAddAnimation(/* delay */ 0, /* duration */ 1000, /* isHeadsUpAppear */ true);
+
+        waitForIdleSync();
+        assertThat(row.isDrawingAppearAnimation()).isTrue();
+
+        row.cancelAppearDrawing();
+
+        waitForIdleSync();
+        assertThat(row.isDrawingAppearAnimation()).isFalse();
+    }
+
+    @Test
+    public void onHUNDisappear_cancelAppearDrawing_shouldResetAnimationState() throws Exception {
+        final ExpandableNotificationRow row = mNotificationTestHelper.createRow();
+
+        row.performAddAnimation(/* delay */ 0, /* duration */ 1000, /* isHeadsUpAppear */ false);
+
+        waitForIdleSync();
+        assertThat(row.isDrawingAppearAnimation()).isTrue();
+
+        row.cancelAppearDrawing();
+
+        waitForIdleSync();
+        assertThat(row.isDrawingAppearAnimation()).isFalse();
+    }
+
     private void setDrawableIconsInImageView(CachingIconView icon, Drawable iconDrawable,
             Drawable rightIconDrawable) {
         ImageView iconView = mock(ImageView.class);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/surfaceeffects/shaders/SolidColorShaderTest.kt b/packages/SystemUI/tests/src/com/android/systemui/surfaceeffects/shaders/SolidColorShaderTest.kt
new file mode 100644
index 0000000..f1fadf6
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/surfaceeffects/shaders/SolidColorShaderTest.kt
@@ -0,0 +1,33 @@
+/*
+ * 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.surfaceeffects.shaders
+
+import android.graphics.Color
+import android.testing.AndroidTestingRunner
+import androidx.test.filters.SmallTest
+import com.android.systemui.SysuiTestCase
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@SmallTest
+@RunWith(AndroidTestingRunner::class)
+class SolidColorShaderTest : SysuiTestCase() {
+
+    @Test
+    fun compilesShader() {
+        SolidColorShader(Color.RED)
+    }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/surfaceeffects/shaders/SparkleShaderTest.kt b/packages/SystemUI/tests/src/com/android/systemui/surfaceeffects/shaders/SparkleShaderTest.kt
new file mode 100644
index 0000000..64ea6a6
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/surfaceeffects/shaders/SparkleShaderTest.kt
@@ -0,0 +1,44 @@
+/*
+ * 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.surfaceeffects.shaders
+
+import android.graphics.Color
+import android.testing.AndroidTestingRunner
+import androidx.test.filters.SmallTest
+import com.android.systemui.SysuiTestCase
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@SmallTest
+@RunWith(AndroidTestingRunner::class)
+class SparkleShaderTest : SysuiTestCase() {
+
+    private lateinit var sparkleShader: SparkleShader
+
+    @Test
+    fun compilesSparkleShader() {
+        sparkleShader =
+            SparkleShader().apply {
+                setPixelateAmount(
+                    context.resources.displayMetrics.density *
+                        SparkleShader.DEFAULT_SPARKLE_PIXELATE_AMOUNT
+                )
+                setColor(Color.RED)
+                setTime(0.01f)
+                setLumaMatteColor(Color.WHITE)
+            }
+    }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java
index 09ac0e3..c454b45 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java
@@ -959,8 +959,8 @@
         // All dynamic colors were added twice: light and dark them
         // All fixed colors were added once
         verify(dynamic, times(
-                DynamicColors.ALL_DYNAMIC_COLORS_MAPPED.size() * 2
-                        + DynamicColors.FIXED_COLORS_MAPPED.size())
+                DynamicColors.allDynamicColorsMapped(false).size() * 2
+                        + DynamicColors.getFixedColorsMapped(false).size())
         ).setResourceValue(any(String.class), eq(TYPE_INT_COLOR_ARGB8), anyInt(), eq(null));
     }
 }
diff --git a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java
index 2f228a8..e10a80c 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java
@@ -158,7 +158,6 @@
 
 import org.junit.After;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
@@ -174,7 +173,6 @@
 import java.util.List;
 import java.util.Optional;
 
-@Ignore("b/292153259")
 @SmallTest
 @RunWith(AndroidTestingRunner.class)
 @TestableLooper.RunWithLooper(setAsMainLooper = true)
@@ -280,8 +278,6 @@
     @Mock
     private TaskStackListenerImpl mTaskStackListener;
     @Mock
-    private ShellTaskOrganizer mShellTaskOrganizer;
-    @Mock
     private KeyguardStateController mKeyguardStateController;
     @Mock
     private ScreenOffAnimationController mScreenOffAnimationController;
@@ -298,6 +294,7 @@
     @Mock
     private Icon mAppBubbleIcon;
 
+    private ShellTaskOrganizer mShellTaskOrganizer;
     private TaskViewTransitions mTaskViewTransitions;
 
     private TestableBubblePositioner mPositioner;
@@ -379,7 +376,13 @@
                         mock(UiEventLogger.class),
                         mock(UserTracker.class)
                 );
-        when(mShellTaskOrganizer.getExecutor()).thenReturn(syncExecutor);
+
+        mShellTaskOrganizer = new ShellTaskOrganizer(mock(ShellInit.class),
+                mock(ShellCommandHandler.class),
+                null,
+                Optional.empty(),
+                Optional.empty(),
+                syncExecutor);
         mBubbleProperties = new FakeBubbleProperties();
         mBubbleController = new TestableBubbleController(
                 mContext,
diff --git a/packages/SystemUI/tests/utils/src/androidx/core/animation/AndroidXAnimatorIsolationRule.kt b/packages/SystemUI/tests/utils/src/androidx/core/animation/AndroidXAnimatorIsolationRule.kt
new file mode 100644
index 0000000..026372f
--- /dev/null
+++ b/packages/SystemUI/tests/utils/src/androidx/core/animation/AndroidXAnimatorIsolationRule.kt
@@ -0,0 +1,55 @@
+/*
+ * 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 androidx.core.animation
+
+import org.junit.rules.TestRule
+import org.junit.runner.Description
+import org.junit.runners.model.Statement
+
+class AndroidXAnimatorIsolationRule : TestRule {
+
+    private class TestAnimationHandler : AnimationHandler(null) {
+        override fun addAnimationFrameCallback(callback: AnimationFrameCallback?) = doFail()
+        override fun removeCallback(callback: AnimationFrameCallback?) = doFail()
+        override fun onAnimationFrame(frameTime: Long) = doFail()
+        override fun setFrameDelay(frameDelay: Long) = doFail()
+        override fun getFrameDelay(): Long = doFail()
+    }
+
+    override fun apply(base: Statement, description: Description): Statement {
+        return object : Statement() {
+            @Throws(Throwable::class)
+            override fun evaluate() {
+                AnimationHandler.setTestHandler(testHandler)
+                try {
+                    base.evaluate()
+                } finally {
+                    AnimationHandler.setTestHandler(null)
+                }
+            }
+        }
+    }
+
+    companion object {
+        private val testHandler = TestAnimationHandler()
+        private fun doFail(): Nothing =
+            error(
+                "Test's animations are not isolated! " +
+                    "Did you forget to add an AnimatorTestRule to your test class?"
+            )
+    }
+}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/SysuiTestCase.java b/packages/SystemUI/tests/utils/src/com/android/systemui/SysuiTestCase.java
index de177168..28b7d41 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/SysuiTestCase.java
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/SysuiTestCase.java
@@ -33,6 +33,7 @@
 import android.testing.TestableLooper;
 import android.util.Log;
 
+import androidx.core.animation.AndroidXAnimatorIsolationRule;
 import androidx.test.InstrumentationRegistry;
 import androidx.test.uiautomator.UiDevice;
 
@@ -52,6 +53,7 @@
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.Before;
+import org.junit.ClassRule;
 import org.junit.Rule;
 import org.mockito.Mockito;
 
@@ -69,6 +71,12 @@
     private static final String TAG = "SysuiTestCase";
 
     private Handler mHandler;
+
+    // set the lowest order so it's the outermost rule
+    @ClassRule(order = Integer.MIN_VALUE)
+    public static AndroidXAnimatorIsolationRule mAndroidXAnimatorIsolationRule =
+            new AndroidXAnimatorIsolationRule();
+
     @Rule
     public SysuiTestableContext mContext = new SysuiTestableContext(
             InstrumentationRegistry.getContext(), getLeakCheck());
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeDeviceEntryFaceAuthRepository.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeDeviceEntryFaceAuthRepository.kt
index f4c2db1..1e1dc4f 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeDeviceEntryFaceAuthRepository.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeDeviceEntryFaceAuthRepository.kt
@@ -61,6 +61,19 @@
         _wasDisabled = true
     }
 
+    private val faceAuthPaused = MutableStateFlow(false)
+    override fun pauseFaceAuth() {
+        faceAuthPaused.value = true
+    }
+
+    override fun resumeFaceAuth() {
+        faceAuthPaused.value = false
+    }
+
+    fun isFaceAuthPaused(): Boolean {
+        return faceAuthPaused.value
+    }
+
     override suspend fun authenticate(uiEvent: FaceAuthUiEvent, fallbackToDetection: Boolean) {
         _runningAuthRequest.value = uiEvent to fallbackToDetection
         _isAuthRunning.value = true
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/scene/SceneTestUtils.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/scene/SceneTestUtils.kt
index f39982f..26a75d0 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/scene/SceneTestUtils.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/scene/SceneTestUtils.kt
@@ -41,7 +41,6 @@
 import com.android.systemui.scene.shared.model.RemoteUserInput
 import com.android.systemui.scene.shared.model.RemoteUserInputAction
 import com.android.systemui.scene.shared.model.SceneContainerConfig
-import com.android.systemui.scene.shared.model.SceneContainerNames
 import com.android.systemui.scene.shared.model.SceneKey
 import com.android.systemui.user.data.repository.FakeUserRepository
 import com.android.systemui.user.data.repository.UserRepository
@@ -96,13 +95,9 @@
     private val context = test.context
 
     fun fakeSceneContainerRepository(
-        containerConfigurations: Set<SceneContainerConfig> =
-            setOf(
-                fakeSceneContainerConfig(CONTAINER_1),
-                fakeSceneContainerConfig(CONTAINER_2),
-            )
+        containerConfig: SceneContainerConfig = fakeSceneContainerConfig(),
     ): SceneContainerRepository {
-        return SceneContainerRepository(containerConfigurations.associateBy { it.name })
+        return SceneContainerRepository(containerConfig)
     }
 
     fun fakeSceneKeys(): List<SceneKey> {
@@ -116,11 +111,9 @@
     }
 
     fun fakeSceneContainerConfig(
-        name: String,
         sceneKeys: List<SceneKey> = fakeSceneKeys(),
     ): SceneContainerConfig {
         return SceneContainerConfig(
-            name = name,
             sceneKeys = sceneKeys,
             initialSceneKey = SceneKey.Lockscreen,
         )
@@ -174,7 +167,6 @@
             authenticationInteractor = authenticationInteractor,
             sceneInteractor = sceneInteractor,
             featureFlags = featureFlags,
-            containerName = CONTAINER_1,
         )
     }
 
@@ -184,14 +176,8 @@
         return BouncerViewModel(
             applicationContext = context,
             applicationScope = applicationScope(),
-            interactorFactory =
-                object : BouncerInteractor.Factory {
-                    override fun create(containerName: String): BouncerInteractor {
-                        return bouncerInteractor
-                    }
-                },
+            interactor = bouncerInteractor,
             featureFlags = featureFlags,
-            containerName = CONTAINER_1,
         )
     }
 
@@ -202,13 +188,7 @@
         return LockscreenSceneInteractor(
             applicationScope = applicationScope(),
             authenticationInteractor = authenticationInteractor,
-            bouncerInteractorFactory =
-                object : BouncerInteractor.Factory {
-                    override fun create(containerName: String): BouncerInteractor {
-                        return bouncerInteractor
-                    }
-                },
-            containerName = CONTAINER_1,
+            bouncerInteractor = bouncerInteractor,
         )
     }
 
@@ -217,9 +197,6 @@
     }
 
     companion object {
-        const val CONTAINER_1 = SceneContainerNames.SYSTEM_UI_DEFAULT
-        const val CONTAINER_2 = "container2"
-
         val REMOTE_INPUT_DOWN_GESTURE =
             listOf(
                 RemoteUserInput(10f, 10f, RemoteUserInputAction.DOWN),
diff --git a/services/accessibility/java/com/android/server/accessibility/gestures/TouchExplorer.java b/services/accessibility/java/com/android/server/accessibility/gestures/TouchExplorer.java
index 777c7c8..9b9593b 100644
--- a/services/accessibility/java/com/android/server/accessibility/gestures/TouchExplorer.java
+++ b/services/accessibility/java/com/android/server/accessibility/gestures/TouchExplorer.java
@@ -1344,6 +1344,8 @@
                 Slog.e(LOG_TAG, "Unable to find a valid pointer for touch exploration.");
                 return;
             }
+            // Send hover exit if we haven't closed a previous touch exploration event stream.
+            sendHoverExitAndTouchExplorationGestureEndIfNeeded(pointerId);
             final int pointerIdBits = (1 << pointerId);
             final int policyFlags = mState.getLastReceivedPolicyFlags();
             mSendHoverEnterAndMoveDelayed.setPointerIdBits(pointerIdBits);
diff --git a/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java b/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java
index be52b1c..82d4d60 100644
--- a/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java
+++ b/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java
@@ -21,6 +21,7 @@
 import static android.Manifest.permission.DELIVER_COMPANION_MESSAGES;
 import static android.Manifest.permission.MANAGE_COMPANION_DEVICES;
 import static android.Manifest.permission.REQUEST_OBSERVE_COMPANION_DEVICE_PRESENCE;
+import static android.Manifest.permission.USE_COMPANION_TRANSPORTS;
 import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE;
 import static android.companion.AssociationRequest.DEVICE_PROFILE_AUTOMOTIVE_PROJECTION;
 import static android.content.pm.PackageManager.CERT_INPUT_SHA256;
@@ -640,29 +641,44 @@
         }
 
         @Override
+        @EnforcePermission(USE_COMPANION_TRANSPORTS)
         public void addOnTransportsChangedListener(IOnTransportsChangedListener listener) {
+            addOnTransportsChangedListener_enforcePermission();
+
             mTransportManager.addListener(listener);
         }
 
         @Override
+        @EnforcePermission(USE_COMPANION_TRANSPORTS)
         public void removeOnTransportsChangedListener(IOnTransportsChangedListener listener) {
+            removeOnTransportsChangedListener_enforcePermission();
+
             mTransportManager.removeListener(listener);
         }
 
         @Override
+        @EnforcePermission(USE_COMPANION_TRANSPORTS)
         public void sendMessage(int messageType, byte[] data, int[] associationIds) {
+            sendMessage_enforcePermission();
+
             mTransportManager.sendMessage(messageType, data, associationIds);
         }
 
         @Override
+        @EnforcePermission(USE_COMPANION_TRANSPORTS)
         public void addOnMessageReceivedListener(int messageType,
                 IOnMessageReceivedListener listener) {
+            addOnMessageReceivedListener_enforcePermission();
+
             mTransportManager.addListener(messageType, listener);
         }
 
         @Override
+        @EnforcePermission(USE_COMPANION_TRANSPORTS)
         public void removeOnMessageReceivedListener(int messageType,
                 IOnMessageReceivedListener listener) {
+            removeOnMessageReceivedListener_enforcePermission();
+
             mTransportManager.removeListener(messageType, listener);
         }
 
diff --git a/services/companion/java/com/android/server/companion/CompanionDeviceShellCommand.java b/services/companion/java/com/android/server/companion/CompanionDeviceShellCommand.java
index c79466f..94cede8 100644
--- a/services/companion/java/com/android/server/companion/CompanionDeviceShellCommand.java
+++ b/services/companion/java/com/android/server/companion/CompanionDeviceShellCommand.java
@@ -16,6 +16,8 @@
 
 package com.android.server.companion;
 
+import static android.companion.CompanionDeviceManager.MESSAGE_REQUEST_CONTEXT_SYNC;
+
 import android.companion.AssociationInfo;
 import android.companion.ContextSyncMessage;
 import android.companion.Telecom;
@@ -30,7 +32,6 @@
 import com.android.server.companion.datatransfer.contextsync.CrossDeviceSyncController;
 import com.android.server.companion.presence.CompanionDevicePresenceMonitor;
 import com.android.server.companion.transport.CompanionTransportManager;
-import com.android.server.companion.transport.Transport;
 
 import java.io.PrintWriter;
 import java.util.List;
@@ -135,7 +136,7 @@
                 case "send-context-sync-empty-message": {
                     associationId = getNextIntArgRequired();
                     mTransportManager.createEmulatedTransport(associationId)
-                            .processMessage(Transport.MESSAGE_REQUEST_CONTEXT_SYNC,
+                            .processMessage(MESSAGE_REQUEST_CONTEXT_SYNC,
                                     /* sequence= */ 0,
                                     CrossDeviceSyncController.createEmptyMessage());
                     break;
@@ -147,7 +148,7 @@
                     String address = getNextArgRequired();
                     String facilitator = getNextArgRequired();
                     mTransportManager.createEmulatedTransport(associationId)
-                            .processMessage(Transport.MESSAGE_REQUEST_CONTEXT_SYNC,
+                            .processMessage(MESSAGE_REQUEST_CONTEXT_SYNC,
                                     /* sequence= */ 0,
                                     CrossDeviceSyncController.createCallCreateMessage(callId,
                                             address, facilitator));
@@ -159,7 +160,7 @@
                     String callId = getNextArgRequired();
                     int control = getNextIntArgRequired();
                     mTransportManager.createEmulatedTransport(associationId)
-                            .processMessage(Transport.MESSAGE_REQUEST_CONTEXT_SYNC,
+                            .processMessage(MESSAGE_REQUEST_CONTEXT_SYNC,
                                     /* sequence= */ 0,
                                     CrossDeviceSyncController.createCallControlMessage(callId,
                                             control));
@@ -184,7 +185,7 @@
                     }
                     pos.end(telecomToken);
                     mTransportManager.createEmulatedTransport(associationId)
-                            .processMessage(Transport.MESSAGE_REQUEST_CONTEXT_SYNC,
+                            .processMessage(MESSAGE_REQUEST_CONTEXT_SYNC,
                                     /* sequence= */ 0, pos.getBytes());
                     break;
                 }
@@ -246,7 +247,7 @@
                     pos.end(callsToken);
                     pos.end(telecomToken);
                     mTransportManager.createEmulatedTransport(associationId)
-                            .processMessage(Transport.MESSAGE_REQUEST_CONTEXT_SYNC,
+                            .processMessage(MESSAGE_REQUEST_CONTEXT_SYNC,
                                     /* sequence= */ 0, pos.getBytes());
                     break;
                 }
diff --git a/services/companion/java/com/android/server/companion/datatransfer/SystemDataTransferProcessor.java b/services/companion/java/com/android/server/companion/datatransfer/SystemDataTransferProcessor.java
index 7af4957..13f41ed 100644
--- a/services/companion/java/com/android/server/companion/datatransfer/SystemDataTransferProcessor.java
+++ b/services/companion/java/com/android/server/companion/datatransfer/SystemDataTransferProcessor.java
@@ -19,10 +19,10 @@
 import static android.app.PendingIntent.FLAG_CANCEL_CURRENT;
 import static android.app.PendingIntent.FLAG_IMMUTABLE;
 import static android.app.PendingIntent.FLAG_ONE_SHOT;
+import static android.companion.CompanionDeviceManager.MESSAGE_REQUEST_PERMISSION_RESTORE;
 import static android.content.ComponentName.createRelative;
 
 import static com.android.server.companion.Utils.prepareForIpc;
-import static com.android.server.companion.transport.Transport.MESSAGE_REQUEST_PERMISSION_RESTORE;
 
 import android.annotation.NonNull;
 import android.annotation.Nullable;
diff --git a/services/companion/java/com/android/server/companion/datatransfer/contextsync/CrossDeviceSyncController.java b/services/companion/java/com/android/server/companion/datatransfer/contextsync/CrossDeviceSyncController.java
index 9bd5af9..ad1eff8 100644
--- a/services/companion/java/com/android/server/companion/datatransfer/contextsync/CrossDeviceSyncController.java
+++ b/services/companion/java/com/android/server/companion/datatransfer/contextsync/CrossDeviceSyncController.java
@@ -16,7 +16,7 @@
 
 package com.android.server.companion.datatransfer.contextsync;
 
-import static com.android.server.companion.transport.Transport.MESSAGE_REQUEST_CONTEXT_SYNC;
+import static android.companion.CompanionDeviceManager.MESSAGE_REQUEST_CONTEXT_SYNC;
 
 import android.app.admin.DevicePolicyManager;
 import android.companion.AssociationInfo;
diff --git a/services/companion/java/com/android/server/companion/transport/CompanionTransportManager.java b/services/companion/java/com/android/server/companion/transport/CompanionTransportManager.java
index 41867f9..f648f09 100644
--- a/services/companion/java/com/android/server/companion/transport/CompanionTransportManager.java
+++ b/services/companion/java/com/android/server/companion/transport/CompanionTransportManager.java
@@ -16,7 +16,7 @@
 
 package com.android.server.companion.transport;
 
-import static com.android.server.companion.transport.Transport.MESSAGE_REQUEST_PERMISSION_RESTORE;
+import static android.companion.CompanionDeviceManager.MESSAGE_REQUEST_PERMISSION_RESTORE;
 
 import android.annotation.NonNull;
 import android.annotation.SuppressLint;
diff --git a/services/companion/java/com/android/server/companion/transport/Transport.java b/services/companion/java/com/android/server/companion/transport/Transport.java
index 5af3b98..32d4061 100644
--- a/services/companion/java/com/android/server/companion/transport/Transport.java
+++ b/services/companion/java/com/android/server/companion/transport/Transport.java
@@ -16,6 +16,11 @@
 
 package com.android.server.companion.transport;
 
+import static android.companion.CompanionDeviceManager.MESSAGE_REQUEST_CONTEXT_SYNC;
+import static android.companion.CompanionDeviceManager.MESSAGE_REQUEST_PERMISSION_RESTORE;
+import static android.companion.CompanionDeviceManager.MESSAGE_REQUEST_PING;
+import static android.companion.CompanionDeviceManager.MESSAGE_REQUEST_REMOTE_AUTHENTICATION;
+
 import android.annotation.NonNull;
 import android.companion.IOnMessageReceivedListener;
 import android.content.Context;
@@ -45,10 +50,6 @@
     protected static final String TAG = "CDM_CompanionTransport";
     protected static final boolean DEBUG = Build.IS_DEBUGGABLE;
 
-    static final int MESSAGE_REQUEST_PING = 0x63807378; // ?PIN
-    public static final int MESSAGE_REQUEST_CONTEXT_SYNC = 0x63678883; // ?CXS
-    public static final int MESSAGE_REQUEST_PERMISSION_RESTORE = 0x63826983; // ?RES
-
     static final int MESSAGE_RESPONSE_SUCCESS = 0x33838567; // !SUC
     static final int MESSAGE_RESPONSE_FAILURE = 0x33706573; // !FAI
 
@@ -181,7 +182,8 @@
                 sendMessage(MESSAGE_RESPONSE_SUCCESS, sequence, data);
                 break;
             }
-            case MESSAGE_REQUEST_CONTEXT_SYNC: {
+            case MESSAGE_REQUEST_CONTEXT_SYNC:
+            case MESSAGE_REQUEST_REMOTE_AUTHENTICATION: {
                 callback(message, data);
                 sendMessage(MESSAGE_RESPONSE_SUCCESS, sequence, EmptyArray.BYTE);
                 break;
diff --git a/services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java b/services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java
index 09f373f..35c6120 100644
--- a/services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java
+++ b/services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java
@@ -466,8 +466,9 @@
                 // TODO(271471342): Implement
             }
 
-            public byte[] getUuid() {
-                return UUID;
+            public byte[] getUuid() throws RemoteException {
+                //TODO(b/247124878): return the UUID defined in this file when the API is put in use
+                throw new RemoteException("This API is not implemented yet.");
             }
 
             @Override
diff --git a/services/core/java/com/android/server/tv/TvInputManagerService.java b/services/core/java/com/android/server/tv/TvInputManagerService.java
index 19ee554..f36ecf7 100644
--- a/services/core/java/com/android/server/tv/TvInputManagerService.java
+++ b/services/core/java/com/android/server/tv/TvInputManagerService.java
@@ -155,6 +155,12 @@
     // ID of the current user.
     @GuardedBy("mLock")
     private int mCurrentUserId = UserHandle.USER_SYSTEM;
+    @GuardedBy("mLock")
+    // ID of the current input displayed on the screen.
+    private String mCurrentInputId = null;
+    @GuardedBy("mLock")
+    // SessionState of the currently active TIS session.
+    private SessionState mCurrentSessionState = null;
     // IDs of the running profiles. Their parent user ID should be mCurrentUserId.
     @GuardedBy("mLock")
     private final Set<Integer> mRunningProfiles = new HashSet<>();
@@ -884,6 +890,10 @@
                 sessionState.session = null;
             }
         }
+        logExternalInputEvent(FrameworkStatsLog.EXTERNAL_TV_INPUT_EVENT__EVENT_TYPE__RELEASED,
+                mCurrentInputId, sessionState);
+        mCurrentInputId = null;
+        mCurrentSessionState = null;
         removeSessionStateLocked(sessionToken, userId);
         return sessionState;
     }
@@ -1065,6 +1075,7 @@
             Slog.e(TAG, "failed to set input info - unknown input id " + inputId);
             return;
         }
+        boolean currentCecTvInputInfoUpdated = isCurrentCecTvInputInfoUpdate(userState, inputInfo);
         inputState.info = inputInfo;
         inputState.uid = getInputUid(inputInfo);
         ServiceState serviceState = userState.serviceStateMap.get(inputInfo.getComponent());
@@ -1073,6 +1084,12 @@
             mTvInputHardwareManager.updateInputInfo(inputInfo);
         }
 
+        if (currentCecTvInputInfoUpdated) {
+            logExternalInputEvent(
+                    FrameworkStatsLog.EXTERNAL_TV_INPUT_EVENT__EVENT_TYPE__DEVICE_INFO_UPDATED,
+                    mCurrentInputId, mCurrentSessionState);
+        }
+
         int n = userState.mCallbacks.beginBroadcast();
         for (int i = 0; i < n; ++i) {
             try {
@@ -1085,6 +1102,29 @@
     }
 
     @GuardedBy("mLock")
+    private boolean isCurrentCecTvInputInfoUpdate(UserState userState, TvInputInfo newInputInfo) {
+        if (newInputInfo == null || newInputInfo.getId() == null
+                || !newInputInfo.getId().equals(mCurrentInputId)) {
+            return false;
+        }
+        if (newInputInfo.getHdmiDeviceInfo() == null
+                || !newInputInfo.getHdmiDeviceInfo().isCecDevice()) {
+            return false;
+        }
+        TvInputState inputState = userState.inputMap.get(mCurrentInputId);
+        if (inputState == null || inputState.info == null) {
+            return false;
+        }
+        if (inputState.info.getHdmiDeviceInfo() == null
+                || !inputState.info.getHdmiDeviceInfo().isCecDevice()) {
+            return false;
+        }
+        int newVendorId = newInputInfo.getHdmiDeviceInfo().getVendorId(),
+            currentVendorId = inputState.info.getHdmiDeviceInfo().getVendorId();
+        return newVendorId != currentVendorId;
+    }
+
+    @GuardedBy("mLock")
     private void setStateLocked(String inputId, int state, int userId) {
         UserState userState = getOrCreateUserStateLocked(userId);
         TvInputState inputState = userState.inputMap.get(inputId);
@@ -1101,6 +1141,24 @@
             return;
         }
         if (oldState != state) {
+            if (inputId.equals(mCurrentInputId)) {
+                logExternalInputEvent(
+                        FrameworkStatsLog
+                                .EXTERNAL_TV_INPUT_EVENT__EVENT_TYPE__CONNECTION_STATE_CHANGED,
+                        mCurrentInputId, mCurrentSessionState);
+            } else if (mCurrentInputId != null) {
+                TvInputInfo currentInputInfo = userState.inputMap.get(mCurrentInputId).info;
+                if (currentInputInfo != null && currentInputInfo.getHdmiDeviceInfo() != null
+                        && inputId.equals(currentInputInfo.getParentId())) {
+                    logExternalInputEvent(
+                            FrameworkStatsLog
+                                    .EXTERNAL_TV_INPUT_EVENT__EVENT_TYPE__CONNECTION_STATE_CHANGED,
+                            inputId, mCurrentSessionState);
+                    if (state == INPUT_STATE_CONNECTED_STANDBY) {
+                        mCurrentInputId = currentInputInfo.getParentId();
+                    }
+                }
+            }
             notifyInputStateChangedLocked(userState, inputId, state, null);
         }
     }
@@ -1764,10 +1822,18 @@
                         UserState userState = getOrCreateUserStateLocked(resolvedUserId);
                         SessionState sessionState = getSessionStateLocked(sessionToken, callingUid,
                                 userState);
+                        if (mCurrentInputId == null
+                                || !mCurrentInputId.equals(sessionState.inputId)) {
+                            mCurrentInputId = sessionState.inputId;
+                            logExternalInputEvent(
+                                    FrameworkStatsLog.EXTERNAL_TV_INPUT_EVENT__EVENT_TYPE__TUNED,
+                                    sessionState.inputId, sessionState);
+                        }
                         if (!sessionState.isCurrent
                                 || !Objects.equals(sessionState.currentChannel, channelUri)) {
                             sessionState.isCurrent = true;
                             sessionState.currentChannel = channelUri;
+                            mCurrentSessionState = sessionState;
                             notifyCurrentChannelInfosUpdatedLocked(userState);
                         }
                         if (TvContract.isChannelUriForPassthroughInput(channelUri)) {
@@ -2990,6 +3056,30 @@
                 hdmiPort);
     }
 
+    private void logExternalInputEvent(int eventType, String inputId, SessionState sessionState) {
+        UserState userState = getOrCreateUserStateLocked(sessionState.userId);
+        TvInputState tvInputState = userState.inputMap.get(inputId);
+        TvInputInfo tvInputInfo = tvInputState.info;
+        int inputState = tvInputState.state;
+        int inputType = tvInputInfo.getType();
+        // For non-CEC input, the value of vendorId is 0.
+        int vendorId = 0;
+        // For non-HDMI input, the value of hdmiPort is 0.
+        int hdmiPort = 0;
+        String tifSessionId = sessionState.sessionId;
+
+        if (tvInputInfo.getType() == TvInputInfo.TYPE_HDMI) {
+            HdmiDeviceInfo hdmiDeviceInfo = tvInputInfo.getHdmiDeviceInfo();
+            if (hdmiDeviceInfo != null) {
+                vendorId = hdmiDeviceInfo.getVendorId();
+                hdmiPort = hdmiDeviceInfo.getPortId();
+            }
+        }
+
+        FrameworkStatsLog.write(FrameworkStatsLog.EXTERNAL_TV_INPUT_EVENT, eventType, inputState,
+                inputType, vendorId, hdmiPort, tifSessionId);
+    }
+
     private static final class UserState {
         // A mapping from the TV input id to its TvInputState.
         private Map<String, TvInputState> inputMap = new HashMap<>();
@@ -3353,6 +3443,16 @@
                 synchronized (mLock) {
                     mTvInputHardwareManager.addHdmiInput(id, inputInfo);
                     addHardwareInputLocked(inputInfo);
+                    // catch the use case when a CEC device is unplugged from
+                    // an HDMI port, then plugged in to the same HDMI port.
+                    if (mCurrentInputId != null && mCurrentSessionState != null
+                            && mCurrentInputId.equals(inputInfo.getParentId())
+                            && inputInfo.getId().equals(mCurrentSessionState.inputId)) {
+                        logExternalInputEvent(
+                                FrameworkStatsLog.EXTERNAL_TV_INPUT_EVENT__EVENT_TYPE__TUNED,
+                                inputInfo.getId(), mCurrentSessionState);
+                        mCurrentInputId = inputInfo.getId();
+                    }
                 }
             } finally {
                 Binder.restoreCallingIdentity(identity);
@@ -3455,6 +3555,8 @@
                         UserState userState = getOrCreateUserStateLocked(mSessionState.userId);
                         mSessionState.isCurrent = true;
                         mSessionState.currentChannel = channelUri;
+                        mCurrentSessionState = mSessionState;
+                        mCurrentInputId = mSessionState.inputId;
                         notifyCurrentChannelInfosUpdatedLocked(userState);
                     }
                 } catch (RemoteException e) {
diff --git a/services/core/java/com/android/server/vibrator/ClippingAmplitudeAndFrequencyAdapter.java b/services/core/java/com/android/server/vibrator/ClippingAmplitudeAndFrequencyAdapter.java
index 48d477c..111e075a 100644
--- a/services/core/java/com/android/server/vibrator/ClippingAmplitudeAndFrequencyAdapter.java
+++ b/services/core/java/com/android/server/vibrator/ClippingAmplitudeAndFrequencyAdapter.java
@@ -30,7 +30,7 @@
  * each frequency.
  *
  * <p>The {@link VibratorInfo.FrequencyProfile} is only applicable to PWLE compositions. This
- * adapter is only applied to {@link RampSegment} and leaves all other segments unchanged.
+ * adapter is only applied to {@link RampSegment} and all other segments will remain unchanged.
  */
 final class ClippingAmplitudeAndFrequencyAdapter implements VibrationSegmentsAdapter {
 
@@ -41,13 +41,13 @@
         for (int i = 0; i < segmentCount; i++) {
             VibrationEffectSegment segment = segments.get(i);
             if (segment instanceof RampSegment) {
-                segments.set(i, apply((RampSegment) segment, info));
+                segments.set(i, adaptToVibrator(info, (RampSegment) segment));
             }
         }
         return repeatIndex;
     }
 
-    private RampSegment apply(RampSegment segment, VibratorInfo info) {
+    private RampSegment adaptToVibrator(VibratorInfo info, RampSegment segment) {
         float clampedStartFrequency = clampFrequency(info, segment.getStartFrequencyHz());
         float clampedEndFrequency = clampFrequency(info, segment.getEndFrequencyHz());
         return new RampSegment(
diff --git a/services/core/java/com/android/server/vibrator/DeviceAdapter.java b/services/core/java/com/android/server/vibrator/DeviceAdapter.java
index 41649fa..98309cd 100644
--- a/services/core/java/com/android/server/vibrator/DeviceAdapter.java
+++ b/services/core/java/com/android/server/vibrator/DeviceAdapter.java
@@ -53,9 +53,14 @@
         mSegmentAdapters = Arrays.asList(
                 // TODO(b/167947076): add filter that removes unsupported primitives
                 // TODO(b/167947076): add filter that replaces unsupported prebaked with fallback
+                // Convert segments based on device capabilities
                 new RampToStepAdapter(settings.getRampStepDuration()),
                 new StepToRampAdapter(),
+                // Add extra ramp down segments as needed
                 new RampDownAdapter(settings.getRampDownDuration(), settings.getRampStepDuration()),
+                // Split segments based on their duration and device supported limits
+                new SplitSegmentsAdapter(),
+                // Clip amplitudes and frequencies of final segments based on device bandwidth curve
                 new ClippingAmplitudeAndFrequencyAdapter()
         );
         mAvailableVibrators = vibrators;
diff --git a/services/core/java/com/android/server/vibrator/RampToStepAdapter.java b/services/core/java/com/android/server/vibrator/RampToStepAdapter.java
index 9e248cd..fc19e27 100644
--- a/services/core/java/com/android/server/vibrator/RampToStepAdapter.java
+++ b/services/core/java/com/android/server/vibrator/RampToStepAdapter.java
@@ -28,9 +28,11 @@
 import java.util.List;
 
 /**
- * Adapter that converts ramp segments that to a sequence of fixed step segments.
+ * Adapter that converts ramp segments to a sequence of fixed step segments.
  *
- * <p>This leaves the list unchanged if the device has compose PWLE capability.
+ * <p>This change preserves the frequency parameters by interpolating the ramp values.
+ *
+ * <p>The segments will not be changed if the device has {@link IVibrator#CAP_COMPOSE_PWLE_EFFECTS}.
  */
 final class RampToStepAdapter implements VibrationSegmentsAdapter {
 
@@ -53,7 +55,7 @@
             if (!(segment instanceof RampSegment)) {
                 continue;
             }
-            List<StepSegment> steps = apply(info, (RampSegment) segment);
+            List<StepSegment> steps = convertRampToSteps(info, (RampSegment) segment);
             segments.remove(i);
             segments.addAll(i, steps);
             int addedSegments = steps.size() - 1;
@@ -66,7 +68,7 @@
         return repeatIndex;
     }
 
-    private List<StepSegment> apply(VibratorInfo info, RampSegment ramp) {
+    private List<StepSegment> convertRampToSteps(VibratorInfo info, RampSegment ramp) {
         if (Float.compare(ramp.getStartAmplitude(), ramp.getEndAmplitude()) == 0) {
             // Amplitude is the same, so return a single step to simulate this ramp.
             return Arrays.asList(
diff --git a/services/core/java/com/android/server/vibrator/SplitSegmentsAdapter.java b/services/core/java/com/android/server/vibrator/SplitSegmentsAdapter.java
new file mode 100644
index 0000000..347db35
--- /dev/null
+++ b/services/core/java/com/android/server/vibrator/SplitSegmentsAdapter.java
@@ -0,0 +1,115 @@
+/*
+ * 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.server.vibrator;
+
+import android.hardware.vibrator.IVibrator;
+import android.os.VibratorInfo;
+import android.os.vibrator.RampSegment;
+import android.os.vibrator.VibrationEffectSegment;
+import android.util.MathUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Adapter that splits segments with longer duration than the device capabilities.
+ *
+ * <p>This transformation replaces large {@link RampSegment} entries by a sequence of smaller
+ * ramp segments that starts and ends at the same amplitudes/frequencies, interpolating the
+ * intermediate values.
+ *
+ * <p>The segments will not be changed if the device doesn't have
+ * {@link IVibrator#CAP_COMPOSE_PWLE_EFFECTS}.
+ */
+final class SplitSegmentsAdapter implements VibrationSegmentsAdapter {
+
+    @Override
+    public int adaptToVibrator(VibratorInfo info, List<VibrationEffectSegment> segments,
+            int repeatIndex) {
+        if (!info.hasCapability(IVibrator.CAP_COMPOSE_PWLE_EFFECTS)) {
+            // The vibrator does not have PWLE capability, so keep the segments unchanged.
+            return repeatIndex;
+        }
+        int maxRampDuration = info.getPwlePrimitiveDurationMax();
+        if (maxRampDuration <= 0) {
+            // No limit set to PWLE primitive duration.
+            return repeatIndex;
+        }
+
+        int segmentCount = segments.size();
+        for (int i = 0; i < segmentCount; i++) {
+            if (!(segments.get(i) instanceof RampSegment)) {
+                continue;
+            }
+            RampSegment ramp = (RampSegment) segments.get(i);
+            int splits = ((int) ramp.getDuration() + maxRampDuration - 1) / maxRampDuration;
+            if (splits <= 1) {
+                continue;
+            }
+            segments.remove(i);
+            segments.addAll(i, splitRampSegment(info, ramp, splits));
+            int addedSegments = splits - 1;
+            if (repeatIndex > i) {
+                repeatIndex += addedSegments;
+            }
+            i += addedSegments;
+            segmentCount += addedSegments;
+        }
+
+        return repeatIndex;
+    }
+
+    private static List<RampSegment> splitRampSegment(VibratorInfo info, RampSegment ramp,
+            int splits) {
+        List<RampSegment> ramps = new ArrayList<>(splits);
+        // Fill zero frequency values with the device resonant frequency before interpolating.
+        float startFrequencyHz = fillEmptyFrequency(info, ramp.getStartFrequencyHz());
+        float endFrequencyHz = fillEmptyFrequency(info, ramp.getEndFrequencyHz());
+        long splitDuration = ramp.getDuration() / splits;
+        float previousAmplitude = ramp.getStartAmplitude();
+        float previousFrequencyHz = startFrequencyHz;
+        long accumulatedDuration = 0;
+
+        for (int i = 1; i < splits; i++) {
+            accumulatedDuration += splitDuration;
+            float durationRatio = (float) accumulatedDuration / ramp.getDuration();
+            float interpolatedFrequency =
+                    MathUtils.lerp(startFrequencyHz, endFrequencyHz, durationRatio);
+            float interpolatedAmplitude =
+                    MathUtils.lerp(ramp.getStartAmplitude(), ramp.getEndAmplitude(), durationRatio);
+            RampSegment rampSplit = new RampSegment(
+                    previousAmplitude, interpolatedAmplitude,
+                    previousFrequencyHz, interpolatedFrequency,
+                    (int) splitDuration);
+            ramps.add(rampSplit);
+            previousAmplitude = rampSplit.getEndAmplitude();
+            previousFrequencyHz = rampSplit.getEndFrequencyHz();
+        }
+
+        ramps.add(new RampSegment(previousAmplitude, ramp.getEndAmplitude(), previousFrequencyHz,
+                endFrequencyHz, (int) (ramp.getDuration() - accumulatedDuration)));
+
+        return ramps;
+    }
+
+    private static float fillEmptyFrequency(VibratorInfo info, float frequencyHz) {
+        if (Float.isNaN(info.getResonantFrequencyHz())) {
+            return frequencyHz;
+        }
+        return frequencyHz == 0 ? info.getResonantFrequencyHz() : frequencyHz;
+    }
+}
diff --git a/services/core/java/com/android/server/vibrator/StepToRampAdapter.java b/services/core/java/com/android/server/vibrator/StepToRampAdapter.java
index d86ee78..6616f10 100644
--- a/services/core/java/com/android/server/vibrator/StepToRampAdapter.java
+++ b/services/core/java/com/android/server/vibrator/StepToRampAdapter.java
@@ -21,17 +21,17 @@
 import android.os.vibrator.RampSegment;
 import android.os.vibrator.StepSegment;
 import android.os.vibrator.VibrationEffectSegment;
-import android.util.MathUtils;
 
-import java.util.ArrayList;
 import java.util.List;
 
 /**
  * Adapter that converts step segments that should be handled as PWLEs to ramp segments.
  *
- * <p>Each replaced {@link StepSegment} will be represented by a {@link RampSegment} with same
- * start and end amplitudes/frequencies, which can then be converted to PWLE compositions. This
- * adapter leaves the segments unchanged if the device doesn't have the PWLE composition capability.
+ * <p>Each replaced step will be represented by a ramp with same start and end
+ * amplitudes/frequencies, which can then be converted to PWLE compositions.
+ *
+ * <p>The segments will not be changed if the device doesn't have
+ * {@link IVibrator#CAP_COMPOSE_PWLE_EFFECTS}.
  */
 final class StepToRampAdapter implements VibrationSegmentsAdapter {
 
@@ -42,12 +42,6 @@
             // The vibrator does not have PWLE capability, so keep the segments unchanged.
             return repeatIndex;
         }
-        convertStepsToRamps(info, segments);
-        repeatIndex = splitLongRampSegments(info, segments, repeatIndex);
-        return repeatIndex;
-    }
-
-    private void convertStepsToRamps(VibratorInfo info, List<VibrationEffectSegment> segments) {
         int segmentCount = segments.size();
         // Convert steps that require frequency control to ramps.
         for (int i = 0; i < segmentCount; i++) {
@@ -68,40 +62,6 @@
                 }
             }
         }
-    }
-
-    /**
-     * Split {@link RampSegment} entries that have duration longer than {@link
-     * VibratorInfo#getPwlePrimitiveDurationMax()}.
-     */
-    private int splitLongRampSegments(VibratorInfo info, List<VibrationEffectSegment> segments,
-            int repeatIndex) {
-        int maxDuration = info.getPwlePrimitiveDurationMax();
-        if (maxDuration <= 0) {
-            // No limit set to PWLE primitive duration.
-            return repeatIndex;
-        }
-
-        int segmentCount = segments.size();
-        for (int i = 0; i < segmentCount; i++) {
-            if (!(segments.get(i) instanceof RampSegment)) {
-                continue;
-            }
-            RampSegment ramp = (RampSegment) segments.get(i);
-            int splits = ((int) ramp.getDuration() + maxDuration - 1) / maxDuration;
-            if (splits <= 1) {
-                continue;
-            }
-            segments.remove(i);
-            segments.addAll(i, splitRampSegment(info, ramp, splits));
-            int addedSegments = splits - 1;
-            if (repeatIndex > i) {
-                repeatIndex += addedSegments;
-            }
-            i += addedSegments;
-            segmentCount += addedSegments;
-        }
-
         return repeatIndex;
     }
 
@@ -111,38 +71,6 @@
                 frequencyHz, frequencyHz, (int) segment.getDuration());
     }
 
-    private static List<RampSegment> splitRampSegment(VibratorInfo info, RampSegment ramp,
-            int splits) {
-        List<RampSegment> ramps = new ArrayList<>(splits);
-        float startFrequencyHz = fillEmptyFrequency(info, ramp.getStartFrequencyHz());
-        float endFrequencyHz = fillEmptyFrequency(info, ramp.getEndFrequencyHz());
-        long splitDuration = ramp.getDuration() / splits;
-        float previousAmplitude = ramp.getStartAmplitude();
-        float previousFrequency = startFrequencyHz;
-        long accumulatedDuration = 0;
-
-        for (int i = 1; i < splits; i++) {
-            accumulatedDuration += splitDuration;
-            float durationRatio = (float) accumulatedDuration / ramp.getDuration();
-            float interpolatedFrequency =
-                    MathUtils.lerp(startFrequencyHz, endFrequencyHz, durationRatio);
-            float interpolatedAmplitude =
-                    MathUtils.lerp(ramp.getStartAmplitude(), ramp.getEndAmplitude(), durationRatio);
-            RampSegment rampSplit = new RampSegment(
-                    previousAmplitude, interpolatedAmplitude,
-                    previousFrequency, interpolatedFrequency,
-                    (int) splitDuration);
-            ramps.add(rampSplit);
-            previousAmplitude = rampSplit.getEndAmplitude();
-            previousFrequency = rampSplit.getEndFrequencyHz();
-        }
-
-        ramps.add(new RampSegment(previousAmplitude, ramp.getEndAmplitude(), previousFrequency,
-                endFrequencyHz, (int) (ramp.getDuration() - accumulatedDuration)));
-
-        return ramps;
-    }
-
     private static boolean isStep(VibrationEffectSegment segment) {
         return segment instanceof StepSegment;
     }
diff --git a/services/core/java/com/android/server/vibrator/Vibration.java b/services/core/java/com/android/server/vibrator/Vibration.java
index 4f7f13e..fed6e7e 100644
--- a/services/core/java/com/android/server/vibrator/Vibration.java
+++ b/services/core/java/com/android/server/vibrator/Vibration.java
@@ -18,6 +18,7 @@
 
 import android.annotation.NonNull;
 import android.annotation.Nullable;
+import android.media.AudioAttributes;
 import android.os.CombinedVibration;
 import android.os.IBinder;
 import android.os.VibrationAttributes;
@@ -27,8 +28,10 @@
 import android.os.vibrator.RampSegment;
 import android.os.vibrator.StepSegment;
 import android.os.vibrator.VibrationEffectSegment;
+import android.util.IndentingPrintWriter;
 import android.util.proto.ProtoOutputStream;
 
+import java.io.PrintWriter;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Locale;
@@ -39,7 +42,9 @@
  * The base class for all vibrations.
  */
 abstract class Vibration {
-    private static final SimpleDateFormat DEBUG_DATE_FORMAT =
+    private static final SimpleDateFormat DEBUG_TIME_FORMAT =
+            new SimpleDateFormat("HH:mm:ss.SSS");
+    private static final SimpleDateFormat DEBUG_DATE_TIME_FORMAT =
             new SimpleDateFormat("MM-dd HH:mm:ss.SSS");
     // Used to generate globally unique vibration ids.
     private static final AtomicInteger sNextVibrationId = new AtomicInteger(1); // 0 = no callback
@@ -146,10 +151,10 @@
         @Override
         public String toString() {
             return "CallerInfo{"
-                    + " attrs=" + attrs
-                    + ", uid=" + uid
-                    + ", displayId=" + displayId
+                    + " uid=" + uid
                     + ", opPkg=" + opPkg
+                    + ", displayId=" + displayId
+                    + ", attrs=" + attrs
                     + ", reason=" + reason
                     + '}';
         }
@@ -203,14 +208,17 @@
      * potentially expensive or resource-linked objects, such as {@link IBinder}.
      */
     static final class DebugInfo {
-        private final long mCreateTime;
+        final long mCreateTime;
+        final CallerInfo mCallerInfo;
+        @Nullable
+        final CombinedVibration mPlayedEffect;
+
         private final long mStartTime;
         private final long mEndTime;
         private final long mDurationMs;
-        @Nullable private final CombinedVibration mOriginalEffect;
-        @Nullable private final CombinedVibration mPlayedEffect;
+        @Nullable
+        private final CombinedVibration mOriginalEffect;
         private final float mScale;
-        private final CallerInfo mCallerInfo;
         private final Status mStatus;
 
         DebugInfo(Status status, VibrationStats stats, @Nullable CombinedVibration playedEffect,
@@ -230,10 +238,10 @@
 
         @Override
         public String toString() {
-            return "createTime: " + DEBUG_DATE_FORMAT.format(new Date(mCreateTime))
-                    + ", startTime: " + DEBUG_DATE_FORMAT.format(new Date(mStartTime))
+            return "createTime: " + DEBUG_DATE_TIME_FORMAT.format(new Date(mCreateTime))
+                    + ", startTime: " + DEBUG_DATE_TIME_FORMAT.format(new Date(mStartTime))
                     + ", endTime: "
-                    + (mEndTime == 0 ? null : DEBUG_DATE_FORMAT.format(new Date(mEndTime)))
+                    + (mEndTime == 0 ? null : DEBUG_DATE_TIME_FORMAT.format(new Date(mEndTime)))
                     + ", durationMs: " + mDurationMs
                     + ", status: " + mStatus.name().toLowerCase(Locale.ROOT)
                     + ", playedEffect: " + mPlayedEffect
@@ -242,8 +250,56 @@
                     + ", callerInfo: " + mCallerInfo;
         }
 
+        /**
+         * Write this info in a compact way into given {@link PrintWriter}.
+         *
+         * <p>This is used by dumpsys to log multiple vibration records in single lines that are
+         * easy to skim through by the sorted created time.
+         */
+        void dumpCompact(IndentingPrintWriter pw) {
+            boolean isExternalVibration = mPlayedEffect == null;
+            String timingsStr = String.format(Locale.ROOT,
+                    "%s | %8s | %20s | duration: %5dms | start: %12s | end: %10s",
+                    DEBUG_DATE_TIME_FORMAT.format(new Date(mCreateTime)),
+                    isExternalVibration ? "external" : "effect",
+                    mStatus.name().toLowerCase(Locale.ROOT),
+                    mDurationMs,
+                    mStartTime == 0 ? "" : DEBUG_TIME_FORMAT.format(new Date(mStartTime)),
+                    mEndTime == 0 ? "" : DEBUG_TIME_FORMAT.format(new Date(mEndTime)));
+            String callerInfoStr = String.format(Locale.ROOT,
+                    " | %s (uid=%d, displayId=%d) | usage: %s (audio=%s) | flags: %s | reason: %s",
+                    mCallerInfo.opPkg, mCallerInfo.uid, mCallerInfo.displayId,
+                    mCallerInfo.attrs.usageToString(),
+                    AudioAttributes.usageToString(mCallerInfo.attrs.getAudioUsage()),
+                    Long.toBinaryString(mCallerInfo.attrs.getFlags()),
+                    mCallerInfo.reason);
+            String effectStr = String.format(Locale.ROOT,
+                    " | played: %s | original: %s | scale: %.2f",
+                    mPlayedEffect == null ? null : mPlayedEffect.toDebugString(),
+                    mOriginalEffect == null ? null : mOriginalEffect.toDebugString(),
+                    mScale);
+            pw.println(timingsStr + callerInfoStr + effectStr);
+        }
+
+        /** Write this info into given {@link PrintWriter}. */
+        void dump(IndentingPrintWriter pw) {
+            pw.println("Vibration:");
+            pw.increaseIndent();
+            pw.println("status = " + mStatus.name().toLowerCase(Locale.ROOT));
+            pw.println("durationMs = " + mDurationMs);
+            pw.println("createTime = " + DEBUG_DATE_TIME_FORMAT.format(new Date(mCreateTime)));
+            pw.println("startTime = " + DEBUG_DATE_TIME_FORMAT.format(new Date(mStartTime)));
+            pw.println("endTime = "
+                    + (mEndTime == 0 ? null : DEBUG_DATE_TIME_FORMAT.format(new Date(mEndTime))));
+            pw.println("playedEffect = " + mPlayedEffect);
+            pw.println("originalEffect = " + mOriginalEffect);
+            pw.println("scale = " + String.format(Locale.ROOT, "%.2f", mScale));
+            pw.println("callerInfo = " + mCallerInfo);
+            pw.decreaseIndent();
+        }
+
         /** Write this info into given {@code fieldId} on {@link ProtoOutputStream}. */
-        public void dumpProto(ProtoOutputStream proto, long fieldId) {
+        void dump(ProtoOutputStream proto, long fieldId) {
             final long token = proto.start(fieldId);
             proto.write(VibrationProto.START_TIME, mStartTime);
             proto.write(VibrationProto.END_TIME, mEndTime);
diff --git a/services/core/java/com/android/server/vibrator/VibrationSettings.java b/services/core/java/com/android/server/vibrator/VibrationSettings.java
index dbd6bf4..db8a9ae 100644
--- a/services/core/java/com/android/server/vibrator/VibrationSettings.java
+++ b/services/core/java/com/android/server/vibrator/VibrationSettings.java
@@ -54,6 +54,7 @@
 import android.os.Vibrator.VibrationIntensity;
 import android.os.vibrator.VibrationConfig;
 import android.provider.Settings;
+import android.util.IndentingPrintWriter;
 import android.util.Slog;
 import android.util.SparseArray;
 import android.util.SparseIntArray;
@@ -65,6 +66,7 @@
 import com.android.server.LocalServices;
 import com.android.server.companion.virtual.VirtualDeviceManagerInternal;
 
+import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashSet;
@@ -601,8 +603,32 @@
         }
     }
 
+    /** Write current settings into given {@link PrintWriter}. */
+    void dump(IndentingPrintWriter pw) {
+        pw.println("VibrationSettings:");
+        pw.increaseIndent();
+        pw.println("vibrateOn = " + mVibrateOn);
+        pw.println("vibrateInputDevices = " + mVibrateInputDevices);
+        pw.println("batterySaverMode = " + mBatterySaverMode);
+        pw.println("VibrationIntensities:");
+
+        pw.increaseIndent();
+        for (int i = 0; i < mCurrentVibrationIntensities.size(); i++) {
+            int usage = mCurrentVibrationIntensities.keyAt(i);
+            int intensity = mCurrentVibrationIntensities.valueAt(i);
+            pw.println(VibrationAttributes.usageToString(usage) + " = "
+                    + intensityToString(intensity)
+                    + ", default: " + intensityToString(getDefaultIntensity(usage)));
+        }
+        pw.decreaseIndent();
+
+        mVibrationConfig.dumpWithoutDefaultSettings(pw);
+        pw.println("processStateCache = " + mUidObserver.mProcStatesCache);
+        pw.decreaseIndent();
+    }
+
     /** Write current settings into given {@link ProtoOutputStream}. */
-    public void dumpProto(ProtoOutputStream proto) {
+    void dump(ProtoOutputStream proto) {
         synchronized (mLock) {
             proto.write(VibratorManagerServiceDumpProto.VIBRATE_ON, mVibrateOn);
             proto.write(VibratorManagerServiceDumpProto.LOW_POWER_MODE, mBatterySaverMode);
diff --git a/services/core/java/com/android/server/vibrator/VibratorController.java b/services/core/java/com/android/server/vibrator/VibratorController.java
index 47b3e1a..f5d4d1e 100644
--- a/services/core/java/com/android/server/vibrator/VibratorController.java
+++ b/services/core/java/com/android/server/vibrator/VibratorController.java
@@ -17,6 +17,7 @@
 package com.android.server.vibrator;
 
 import android.annotation.Nullable;
+import android.annotation.Nullable;
 import android.hardware.vibrator.IVibrator;
 import android.os.Binder;
 import android.os.IVibratorStateListener;
@@ -26,6 +27,7 @@
 import android.os.vibrator.PrebakedSegment;
 import android.os.vibrator.PrimitiveSegment;
 import android.os.vibrator.RampSegment;
+import android.util.IndentingPrintWriter;
 import android.util.Slog;
 
 import com.android.internal.annotations.GuardedBy;
@@ -351,6 +353,19 @@
                 + '}';
     }
 
+    void dump(IndentingPrintWriter pw) {
+        pw.println("VibratorController:");
+        pw.increaseIndent();
+        pw.println("isVibrating = " + mIsVibrating);
+        pw.println("isUnderExternalControl = " + mIsUnderExternalControl);
+        pw.println("currentAmplitude = " + mCurrentAmplitude);
+        pw.println("vibratorInfoLoadSuccessful = " + mVibratorInfoLoadSuccessful);
+        pw.println("vibratorStateListenerCount = "
+                + mVibratorStateListeners.getRegisteredCallbackCount());
+        mVibratorInfo.dump(pw);
+        pw.decreaseIndent();
+    }
+
     @GuardedBy("mLock")
     private void notifyListenerOnVibrating(boolean isVibrating) {
         if (mIsVibrating != isVibrating) {
diff --git a/services/core/java/com/android/server/vibrator/VibratorManagerService.java b/services/core/java/com/android/server/vibrator/VibratorManagerService.java
index 6fdb1db..270f7f0c 100644
--- a/services/core/java/com/android/server/vibrator/VibratorManagerService.java
+++ b/services/core/java/com/android/server/vibrator/VibratorManagerService.java
@@ -56,6 +56,7 @@
 import android.os.vibrator.VibrationEffectSegment;
 import android.os.vibrator.persistence.VibrationXmlParser;
 import android.text.TextUtils;
+import android.util.IndentingPrintWriter;
 import android.util.Slog;
 import android.util.SparseArray;
 import android.util.proto.ProtoOutputStream;
@@ -80,6 +81,7 @@
 import java.util.Arrays;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Objects;
 import java.util.function.Consumer;
 import java.util.function.Function;
 
@@ -204,9 +206,15 @@
         mNativeWrapper = injector.getNativeWrapper();
         mNativeWrapper.init(listener);
 
-        int dumpLimit = mContext.getResources().getInteger(
-                com.android.internal.R.integer.config_previousVibrationsDumpLimit);
-        mVibratorManagerRecords = new VibratorManagerRecords(dumpLimit);
+        int recentDumpSizeLimit = mContext.getResources().getInteger(
+                com.android.internal.R.integer.config_recentVibrationsDumpSizeLimit);
+        int dumpSizeLimit = mContext.getResources().getInteger(
+                com.android.internal.R.integer.config_previousVibrationsDumpSizeLimit);
+        int dumpAggregationTimeLimit = mContext.getResources().getInteger(
+                com.android.internal.R.integer
+                        .config_previousVibrationsDumpAggregationTimeMillisLimit);
+        mVibratorManagerRecords = new VibratorManagerRecords(
+                recentDumpSizeLimit, dumpSizeLimit, dumpAggregationTimeLimit);
 
         mBatteryStatsService = injector.getBatteryStatsService();
         mFrameworkStatsLogger = injector.getFrameworkStatsLogger(mHandler);
@@ -544,49 +552,74 @@
         }
     }
 
-    private void dumpText(PrintWriter pw) {
+    private void dumpText(PrintWriter w) {
         if (DEBUG) {
             Slog.d(TAG, "Dumping vibrator manager service to text...");
         }
+        IndentingPrintWriter pw = new IndentingPrintWriter(w, /* singleIndent= */ "  ");
         synchronized (mLock) {
             pw.println("Vibrator Manager Service:");
-            pw.println("  mVibrationSettings:");
-            pw.println("    " + mVibrationSettings);
+            pw.increaseIndent();
+
+            mVibrationSettings.dump(pw);
             pw.println();
-            pw.println("  mVibratorControllers:");
+
+            pw.println("VibratorControllers:");
+            pw.increaseIndent();
             for (int i = 0; i < mVibrators.size(); i++) {
-                pw.println("    " + mVibrators.valueAt(i));
+                mVibrators.valueAt(i).dump(pw);
             }
+            pw.decreaseIndent();
             pw.println();
-            pw.println("  mCurrentVibration:");
-            pw.println("    " + (mCurrentVibration == null
-                    ? null : mCurrentVibration.getVibration().getDebugInfo()));
+
+            pw.println("CurrentVibration:");
+            pw.increaseIndent();
+            if (mCurrentVibration != null) {
+                mCurrentVibration.getVibration().getDebugInfo().dump(pw);
+            } else {
+                pw.println("null");
+            }
+            pw.decreaseIndent();
             pw.println();
-            pw.println("  mNextVibration:");
-            pw.println("    " + (mNextVibration == null
-                    ? null : mNextVibration.getVibration().getDebugInfo()));
+
+            pw.println("NextVibration:");
+            pw.increaseIndent();
+            if (mNextVibration != null) {
+                mNextVibration.getVibration().getDebugInfo().dump(pw);
+            } else {
+                pw.println("null");
+            }
+            pw.decreaseIndent();
             pw.println();
-            pw.println("  mCurrentExternalVibration:");
-            pw.println("    " + (mCurrentExternalVibration == null
-                    ? null : mCurrentExternalVibration.getDebugInfo()));
-            pw.println();
+
+            pw.println("CurrentExternalVibration:");
+            pw.increaseIndent();
+            if (mCurrentExternalVibration != null) {
+                mCurrentExternalVibration.getDebugInfo().dump(pw);
+            } else {
+                pw.println("null");
+            }
+            pw.decreaseIndent();
         }
-        mVibratorManagerRecords.dumpText(pw);
+
+        pw.println();
+        pw.println();
+        mVibratorManagerRecords.dump(pw);
     }
 
-    synchronized void dumpProto(FileDescriptor fd) {
+    private void dumpProto(FileDescriptor fd) {
         final ProtoOutputStream proto = new ProtoOutputStream(fd);
         if (DEBUG) {
             Slog.d(TAG, "Dumping vibrator manager service to proto...");
         }
         synchronized (mLock) {
-            mVibrationSettings.dumpProto(proto);
+            mVibrationSettings.dump(proto);
             if (mCurrentVibration != null) {
-                mCurrentVibration.getVibration().getDebugInfo().dumpProto(proto,
+                mCurrentVibration.getVibration().getDebugInfo().dump(proto,
                         VibratorManagerServiceDumpProto.CURRENT_VIBRATION);
             }
             if (mCurrentExternalVibration != null) {
-                mCurrentExternalVibration.getDebugInfo().dumpProto(proto,
+                mCurrentExternalVibration.getDebugInfo().dump(proto,
                         VibratorManagerServiceDumpProto.CURRENT_EXTERNAL_VIBRATION);
             }
 
@@ -601,7 +634,7 @@
             proto.write(VibratorManagerServiceDumpProto.VIBRATOR_UNDER_EXTERNAL_CONTROL,
                     isUnderExternalControl);
         }
-        mVibratorManagerRecords.dumpProto(proto);
+        mVibratorManagerRecords.dump(proto);
         proto.flush();
     }
 
@@ -1581,64 +1614,105 @@
 
     /** Keep records of vibrations played and provide debug information for this service. */
     private static final class VibratorManagerRecords {
-        private final SparseArray<LinkedList<Vibration.DebugInfo>> mPreviousVibrations =
-                new SparseArray<>();
-        private final LinkedList<Vibration.DebugInfo> mPreviousExternalVibrations =
-                new LinkedList<>();
-        private final int mPreviousVibrationsLimit;
+        private final VibrationRecords mAggregatedVibrationHistory;
+        private final VibrationRecords mRecentVibrations;
 
-        VibratorManagerRecords(int limit) {
-            mPreviousVibrationsLimit = limit;
+        VibratorManagerRecords(int recentVibrationSizeLimit, int aggregationSizeLimit,
+                int aggregationTimeLimit) {
+            mAggregatedVibrationHistory =
+                    new VibrationRecords(aggregationSizeLimit, aggregationTimeLimit);
+            mRecentVibrations = new VibrationRecords(
+                    recentVibrationSizeLimit, /* aggregationTimeLimit= */ 0);
         }
 
         synchronized void record(HalVibration vib) {
-            int usage = vib.callerInfo.attrs.getUsage();
-            if (!mPreviousVibrations.contains(usage)) {
-                mPreviousVibrations.put(usage, new LinkedList<>());
-            }
-            record(mPreviousVibrations.get(usage), vib.getDebugInfo());
+            record(vib.getDebugInfo());
         }
 
         synchronized void record(ExternalVibrationHolder vib) {
-            record(mPreviousExternalVibrations, vib.getDebugInfo());
+            record(vib.getDebugInfo());
         }
 
-        synchronized void record(LinkedList<Vibration.DebugInfo> records,
-                Vibration.DebugInfo info) {
-            if (records.size() > mPreviousVibrationsLimit) {
-                records.removeFirst();
+        private synchronized void record(Vibration.DebugInfo info) {
+            AggregatedVibrationRecord removedRecord = mRecentVibrations.record(info);
+            if (removedRecord != null) {
+                mAggregatedVibrationHistory.record(removedRecord.mLatestVibration);
             }
-            records.addLast(info);
         }
 
-        synchronized void dumpText(PrintWriter pw) {
-            for (int i = 0; i < mPreviousVibrations.size(); i++) {
-                pw.println();
-                pw.print("  Previous vibrations for usage ");
-                pw.print(VibrationAttributes.usageToString(mPreviousVibrations.keyAt(i)));
-                pw.println(":");
-                for (Vibration.DebugInfo info : mPreviousVibrations.valueAt(i)) {
-                    pw.println("    " + info);
+        synchronized void dump(IndentingPrintWriter pw) {
+            pw.println("Recent vibrations:");
+            pw.increaseIndent();
+            mRecentVibrations.dump(pw);
+            pw.decreaseIndent();
+            pw.println();
+            pw.println();
+
+            pw.println("Aggregated vibration history:");
+            pw.increaseIndent();
+            mAggregatedVibrationHistory.dump(pw);
+            pw.decreaseIndent();
+        }
+
+        synchronized void dump(ProtoOutputStream proto) {
+            mRecentVibrations.dump(proto);
+        }
+    }
+
+    /** Keep records of vibrations played and provide debug information for this service. */
+    private static final class VibrationRecords {
+        private final SparseArray<LinkedList<AggregatedVibrationRecord>> mVibrations =
+                new SparseArray<>();
+        private final int mSizeLimit;
+        private final int mAggregationTimeLimit;
+
+        VibrationRecords(int sizeLimit, int aggregationTimeLimit) {
+            mSizeLimit = sizeLimit;
+            mAggregationTimeLimit = aggregationTimeLimit;
+        }
+
+        synchronized AggregatedVibrationRecord record(Vibration.DebugInfo info) {
+            int usage = info.mCallerInfo.attrs.getUsage();
+            if (!mVibrations.contains(usage)) {
+                mVibrations.put(usage, new LinkedList<>());
+            }
+            LinkedList<AggregatedVibrationRecord> records = mVibrations.get(usage);
+            if (mAggregationTimeLimit > 0 && !records.isEmpty()) {
+                AggregatedVibrationRecord lastRecord = records.getLast();
+                if (lastRecord.mayAggregate(info, mAggregationTimeLimit)) {
+                    lastRecord.record(info);
+                    return null;
                 }
             }
+            AggregatedVibrationRecord removedRecord = null;
+            if (records.size() > mSizeLimit) {
+                removedRecord = records.removeFirst();
+            }
+            records.addLast(new AggregatedVibrationRecord(info));
+            return removedRecord;
+        }
 
-            pw.println();
-            pw.println("  Previous external vibrations:");
-            for (Vibration.DebugInfo info : mPreviousExternalVibrations) {
-                pw.println("    " + info);
+        synchronized void dump(IndentingPrintWriter pw) {
+            for (int i = 0; i < mVibrations.size(); i++) {
+                pw.println(VibrationAttributes.usageToString(mVibrations.keyAt(i)) + ":");
+                pw.increaseIndent();
+                for (AggregatedVibrationRecord info : mVibrations.valueAt(i)) {
+                    info.dump(pw);
+                }
+                pw.decreaseIndent();
+                pw.println();
             }
         }
 
-        synchronized void dumpProto(ProtoOutputStream proto) {
-            for (int i = 0; i < mPreviousVibrations.size(); i++) {
+        synchronized void dump(ProtoOutputStream proto) {
+            for (int i = 0; i < mVibrations.size(); i++) {
                 long fieldId;
-                switch (mPreviousVibrations.keyAt(i)) {
+                switch (mVibrations.keyAt(i)) {
                     case VibrationAttributes.USAGE_RINGTONE:
                         fieldId = VibratorManagerServiceDumpProto.PREVIOUS_RING_VIBRATIONS;
                         break;
                     case VibrationAttributes.USAGE_NOTIFICATION:
-                        fieldId = VibratorManagerServiceDumpProto
-                                .PREVIOUS_NOTIFICATION_VIBRATIONS;
+                        fieldId = VibratorManagerServiceDumpProto.PREVIOUS_NOTIFICATION_VIBRATIONS;
                         break;
                     case VibrationAttributes.USAGE_ALARM:
                         fieldId = VibratorManagerServiceDumpProto.PREVIOUS_ALARM_VIBRATIONS;
@@ -1646,18 +1720,70 @@
                     default:
                         fieldId = VibratorManagerServiceDumpProto.PREVIOUS_VIBRATIONS;
                 }
-                for (Vibration.DebugInfo info : mPreviousVibrations.valueAt(i)) {
-                    info.dumpProto(proto, fieldId);
+                for (AggregatedVibrationRecord info : mVibrations.valueAt(i)) {
+                    if (info.mLatestVibration.mPlayedEffect == null) {
+                        // External vibrations are reported separately in the dump proto
+                        info.dump(proto,
+                                VibratorManagerServiceDumpProto.PREVIOUS_EXTERNAL_VIBRATIONS);
+                    } else {
+                        info.dump(proto, fieldId);
+                    }
                 }
             }
+        }
 
-            for (Vibration.DebugInfo info : mPreviousExternalVibrations) {
-                info.dumpProto(proto,
-                        VibratorManagerServiceDumpProto.PREVIOUS_EXTERNAL_VIBRATIONS);
+        synchronized void dumpOnSingleField(ProtoOutputStream proto, long fieldId) {
+            for (int i = 0; i < mVibrations.size(); i++) {
+                for (AggregatedVibrationRecord info : mVibrations.valueAt(i)) {
+                    info.dump(proto, fieldId);
+                }
             }
         }
     }
 
+    /**
+     * Record that keeps the last {@link Vibration.DebugInfo} played, aggregating close vibrations
+     * from the same uid that have the same {@link VibrationAttributes} and {@link VibrationEffect}.
+     */
+    private static final class AggregatedVibrationRecord {
+        private final Vibration.DebugInfo mFirstVibration;
+        private Vibration.DebugInfo mLatestVibration;
+        private int mVibrationCount;
+
+        AggregatedVibrationRecord(Vibration.DebugInfo info) {
+            mLatestVibration = mFirstVibration = info;
+            mVibrationCount = 1;
+        }
+
+        synchronized boolean mayAggregate(Vibration.DebugInfo info, long timeLimit) {
+            return Objects.equals(mLatestVibration.mCallerInfo.uid, info.mCallerInfo.uid)
+                    && Objects.equals(mLatestVibration.mCallerInfo.attrs, info.mCallerInfo.attrs)
+                    && Objects.equals(mLatestVibration.mPlayedEffect, info.mPlayedEffect)
+                    && Math.abs(mLatestVibration.mCreateTime - info.mCreateTime) < timeLimit;
+        }
+
+        synchronized void record(Vibration.DebugInfo vib) {
+            mLatestVibration = vib;
+            mVibrationCount++;
+        }
+
+        synchronized void dump(IndentingPrintWriter pw) {
+            mFirstVibration.dumpCompact(pw);
+            if (mVibrationCount == 1) {
+                return;
+            }
+            if (mVibrationCount > 2) {
+                pw.println(
+                        "-> Skipping " + (mVibrationCount - 2) + " aggregated vibrations, latest:");
+            }
+            mLatestVibration.dumpCompact(pw);
+        }
+
+        synchronized void dump(ProtoOutputStream proto, long fieldId) {
+            mLatestVibration.dump(proto, fieldId);
+        }
+    }
+
     /** Clears mNextVibration if set, ending it cleanly */
     @GuardedBy("mLock")
     private void clearNextVibrationLocked(Vibration.EndInfo vibrationEndInfo) {
@@ -1676,7 +1802,7 @@
     /**
      * Ends the external vibration, and clears related service state.
      *
-     * @param vibrationEndInfo the status and related info to end the associated Vibration with
+     * @param vibrationEndInfo        the status and related info to end the associated Vibration
      * @param continueExternalControl indicates whether external control will continue. If not, the
      *                                HAL will have external control turned off.
      */
diff --git a/services/core/java/com/android/server/wm/WindowContextListenerController.java b/services/core/java/com/android/server/wm/WindowContextListenerController.java
index 26aab07..726ae5c 100644
--- a/services/core/java/com/android/server/wm/WindowContextListenerController.java
+++ b/services/core/java/com/android/server/wm/WindowContextListenerController.java
@@ -76,7 +76,7 @@
             @NonNull IBinder clientToken, @NonNull WindowContainer<?> container,
             @WindowType int type, @Nullable Bundle options) {
         registerWindowContainerListener(wpc, clientToken, container, type, options,
-                true /* shouDispatchConfigWhenRegistering */);
+                true /* shouldDispatchConfigWhenRegistering */);
     }
 
     /**
@@ -91,19 +91,19 @@
      * @param container the {@link WindowContainer} which the listener is going to listen to.
      * @param type the window type
      * @param options a bundle used to pass window-related options.
-     * @param shouDispatchConfigWhenRegistering {@code true} to indicate the current
+     * @param shouldDispatchConfigWhenRegistering {@code true} to indicate the current
      *                {@code container}'s config will dispatch to the client side when
      *                registering the {@link WindowContextListenerImpl}
      */
     void registerWindowContainerListener(@NonNull WindowProcessController wpc,
             @NonNull IBinder clientToken, @NonNull WindowContainer<?> container,
             @WindowType int type, @Nullable Bundle options,
-            boolean shouDispatchConfigWhenRegistering) {
+            boolean shouldDispatchConfigWhenRegistering) {
         WindowContextListenerImpl listener = mListeners.get(clientToken);
         if (listener == null) {
             listener = new WindowContextListenerImpl(wpc, clientToken, container, type,
                     options);
-            listener.register(shouDispatchConfigWhenRegistering);
+            listener.register(shouldDispatchConfigWhenRegistering);
         } else {
             updateContainerForWindowContextListener(clientToken, container);
         }
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 210378f..261d6bc 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -305,6 +305,7 @@
 import android.window.ScreenCapture;
 import android.window.TaskSnapshot;
 import android.window.WindowContainerToken;
+import android.window.WindowContextInfo;
 
 import com.android.internal.R;
 import com.android.internal.annotations.VisibleForTesting;
@@ -2737,7 +2738,7 @@
 
     @Nullable
     @Override
-    public Configuration attachWindowContextToDisplayArea(@NonNull IApplicationThread appThread,
+    public WindowContextInfo attachWindowContextToDisplayArea(@NonNull IApplicationThread appThread,
             @NonNull IBinder clientToken, @LayoutParams.WindowType int type, int displayId,
             @Nullable Bundle options) {
         Objects.requireNonNull(appThread);
@@ -2766,8 +2767,8 @@
                 final DisplayArea<?> da = dc.findAreaForWindowType(type, options,
                         callerCanManageAppTokens, false /* roundedCornerOverlay */);
                 mWindowContextListenerController.registerWindowContainerListener(wpc, clientToken,
-                        da, type, options, false /* shouDispatchConfigWhenRegistering */);
-                return da.getConfiguration();
+                        da, type, options, false /* shouldDispatchConfigWhenRegistering */);
+                return new WindowContextInfo(da.getConfiguration(), displayId);
             }
         } finally {
             Binder.restoreCallingIdentity(origId);
@@ -2776,8 +2777,8 @@
 
     @Nullable
     @Override
-    public Configuration attachWindowContextToDisplayContent(@NonNull IApplicationThread appThread,
-            @NonNull IBinder clientToken, int displayId) {
+    public WindowContextInfo attachWindowContextToDisplayContent(
+            @NonNull IApplicationThread appThread, @NonNull IBinder clientToken, int displayId) {
         Objects.requireNonNull(appThread);
         Objects.requireNonNull(clientToken);
         final int callingPid = Binder.getCallingPid();
@@ -2809,16 +2810,17 @@
 
                 mWindowContextListenerController.registerWindowContainerListener(wpc, clientToken,
                         dc, INVALID_WINDOW_TYPE, null /* options */,
-                        false /* shouDispatchConfigWhenRegistering */);
-                return dc.getConfiguration();
+                        false /* shouldDispatchConfigWhenRegistering */);
+                return new WindowContextInfo(dc.getConfiguration(), displayId);
             }
         } finally {
             Binder.restoreCallingIdentity(origId);
         }
     }
 
+    @Nullable
     @Override
-    public void attachWindowContextToWindowToken(@NonNull IApplicationThread appThread,
+    public WindowContextInfo attachWindowContextToWindowToken(@NonNull IApplicationThread appThread,
             @NonNull IBinder clientToken, @NonNull IBinder token) {
         Objects.requireNonNull(appThread);
         Objects.requireNonNull(clientToken);
@@ -2834,13 +2836,13 @@
                 if (wpc == null) {
                     ProtoLog.w(WM_ERROR, "attachWindowContextToWindowToken: calling from"
                             + " non-existing process pid=%d uid=%d", callingPid, callingUid);
-                    return;
+                    return null;
                 }
                 final WindowToken windowToken = mRoot.getWindowToken(token);
                 if (windowToken == null) {
                     ProtoLog.w(WM_ERROR, "Then token:%s is invalid. It might be "
                             + "removed", token);
-                    return;
+                    return null;
                 }
                 final int type = mWindowContextListenerController.getWindowType(clientToken);
                 if (type == INVALID_WINDOW_TYPE) {
@@ -2854,10 +2856,13 @@
                 }
                 if (!mWindowContextListenerController.assertCallerCanModifyListener(clientToken,
                         callerCanManageAppTokens, callingUid)) {
-                    return;
+                    return null;
                 }
                 mWindowContextListenerController.registerWindowContainerListener(wpc, clientToken,
-                        windowToken, windowToken.windowType, windowToken.mOptions);
+                        windowToken, windowToken.windowType, windowToken.mOptions,
+                                               false /* shouldDispatchConfigWhenRegistering */);
+                return new WindowContextInfo(windowToken.getConfiguration(),
+                        windowToken.getDisplayContent().getDisplayId());
             }
         } finally {
             Binder.restoreCallingIdentity(origId);
diff --git a/services/tests/dreamservicetests/Android.bp b/services/tests/dreamservicetests/Android.bp
index b698a60..8ef443e 100644
--- a/services/tests/dreamservicetests/Android.bp
+++ b/services/tests/dreamservicetests/Android.bp
@@ -16,6 +16,7 @@
         "frameworks-base-testutils",
         "mockito-target-minus-junit4",
         "services.core",
+        "mockingservicestests-utils-mockito",
     ],
 
     platform_apis: true,
diff --git a/services/tests/mockingservicestests/src/com/android/server/dreams/DreamManagerServiceMockingTest.java b/services/tests/dreamservicetests/src/com/android/server/dreams/DreamManagerServiceMockingTest.java
similarity index 97%
rename from services/tests/mockingservicestests/src/com/android/server/dreams/DreamManagerServiceMockingTest.java
rename to services/tests/dreamservicetests/src/com/android/server/dreams/DreamManagerServiceMockingTest.java
index c02cbd1..32d4e75 100644
--- a/services/tests/mockingservicestests/src/com/android/server/dreams/DreamManagerServiceMockingTest.java
+++ b/services/tests/dreamservicetests/src/com/android/server/dreams/DreamManagerServiceMockingTest.java
@@ -36,6 +36,7 @@
 import android.provider.Settings;
 
 import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.FlakyTest;
 
 import com.android.server.LocalServices;
 import com.android.server.SystemService;
@@ -102,6 +103,7 @@
     }
 
     @Test
+    @FlakyTest(bugId = 293443309)
     public void testSettingsQueryUserChange() {
         final DreamManagerService service = createService();
 
diff --git a/services/tests/servicestests/src/com/android/server/job/BiasSchedulingTest.java b/services/tests/servicestests/src/com/android/server/job/BiasSchedulingTest.java
index 5e7dc33..1726ec1 100644
--- a/services/tests/servicestests/src/com/android/server/job/BiasSchedulingTest.java
+++ b/services/tests/servicestests/src/com/android/server/job/BiasSchedulingTest.java
@@ -24,6 +24,8 @@
 import android.os.DeviceIdleManager;
 import android.test.AndroidTestCase;
 
+import androidx.test.filters.FlakyTest;
+
 import com.android.server.job.MockBiasJobService.TestEnvironment;
 import com.android.server.job.MockBiasJobService.TestEnvironment.Event;
 
@@ -58,6 +60,7 @@
         super.tearDown();
     }
 
+    @FlakyTest(bugId = 293589359)
     public void testLowerBiasJobPreempted() throws Exception {
         for (int i = 0; i < JobConcurrencyManager.MAX_CONCURRENCY_LIMIT; ++i) {
             JobInfo job = new JobInfo.Builder(100 + i, sJobServiceComponent)
diff --git a/services/tests/servicestests/src/com/android/server/media/projection/MediaProjectionManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/media/projection/MediaProjectionManagerServiceTest.java
index bb8b986..ddd1221 100644
--- a/services/tests/servicestests/src/com/android/server/media/projection/MediaProjectionManagerServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/media/projection/MediaProjectionManagerServiceTest.java
@@ -62,6 +62,7 @@
 import android.view.ContentRecordingSession;
 
 import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.FlakyTest;
 import androidx.test.filters.SmallTest;
 import androidx.test.platform.app.InstrumentationRegistry;
 
@@ -688,6 +689,7 @@
         assertThat(mService.isCurrentProjection(projection)).isTrue();
     }
 
+    @FlakyTest(bugId = 288342281)
     @Test
     public void setContentRecordingSession_successful_notifiesListeners()
             throws Exception {
diff --git a/services/tests/vibrator/src/com/android/server/vibrator/RampToStepAdapterTest.java b/services/tests/vibrator/src/com/android/server/vibrator/RampToStepAdapterTest.java
index 8bb21b3..867c061 100644
--- a/services/tests/vibrator/src/com/android/server/vibrator/RampToStepAdapterTest.java
+++ b/services/tests/vibrator/src/com/android/server/vibrator/RampToStepAdapterTest.java
@@ -66,6 +66,9 @@
         assertEquals(-1, mAdapter.adaptToVibrator(EMPTY_VIBRATOR_INFO, segments, -1));
         assertEquals(1, mAdapter.adaptToVibrator(EMPTY_VIBRATOR_INFO, segments, 1));
 
+        assertEquals(-1, mAdapter.adaptToVibrator(PWLE_VIBRATOR_INFO, segments, -1));
+        assertEquals(1, mAdapter.adaptToVibrator(PWLE_VIBRATOR_INFO, segments, 1));
+
         assertEquals(originalSegments, segments);
     }
 
diff --git a/services/tests/vibrator/src/com/android/server/vibrator/SplitSegmentsAdapterTest.java b/services/tests/vibrator/src/com/android/server/vibrator/SplitSegmentsAdapterTest.java
new file mode 100644
index 0000000..6630cca
--- /dev/null
+++ b/services/tests/vibrator/src/com/android/server/vibrator/SplitSegmentsAdapterTest.java
@@ -0,0 +1,144 @@
+/*
+ * 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.server.vibrator;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.hardware.vibrator.IVibrator;
+import android.os.VibrationEffect;
+import android.os.VibratorInfo;
+import android.os.vibrator.PrebakedSegment;
+import android.os.vibrator.PrimitiveSegment;
+import android.os.vibrator.RampSegment;
+import android.os.vibrator.StepSegment;
+import android.os.vibrator.VibrationEffectSegment;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.IntStream;
+
+public class SplitSegmentsAdapterTest {
+    private static final int PWLE_COMPOSITION_PRIMITIVE_DURATION_MAX = 10;
+
+    private static final float[] TEST_AMPLITUDE_MAP = new float[]{
+            /* 50Hz= */ 0.1f, 0.2f, 0.4f, 0.8f, /* 150Hz= */ 1f, 0.9f, /* 200Hz= */ 0.8f};
+
+    private static final VibratorInfo.FrequencyProfile TEST_FREQUENCY_PROFILE =
+            new VibratorInfo.FrequencyProfile(
+                    /* resonantFrequencyHz= */ 150f, /* minFrequencyHz= */ 50f,
+                    /* frequencyResolutionHz= */ 25f, TEST_AMPLITUDE_MAP);
+
+    private static final VibratorInfo EMPTY_VIBRATOR_INFO = createVibratorInfo();
+    private static final VibratorInfo PWLE_VIBRATOR_INFO = createVibratorInfo(
+            IVibrator.CAP_COMPOSE_PWLE_EFFECTS);
+
+    private SplitSegmentsAdapter mAdapter;
+
+    @Before
+    public void setUp() throws Exception {
+        mAdapter = new SplitSegmentsAdapter();
+    }
+
+    @Test
+    public void testStepAndPrebakedAndPrimitiveSegments_returnsOriginalSegments() {
+        List<VibrationEffectSegment> segments = new ArrayList<>(Arrays.asList(
+                new StepSegment(/* amplitude= */ 1, /* frequencyHz= */ 40f, /* duration= */ 100),
+                new PrebakedSegment(
+                        VibrationEffect.EFFECT_CLICK, false, VibrationEffect.EFFECT_STRENGTH_LIGHT),
+                new PrimitiveSegment(VibrationEffect.Composition.PRIMITIVE_TICK, 1, 10)));
+        List<VibrationEffectSegment> originalSegments = new ArrayList<>(segments);
+
+        assertThat(mAdapter.adaptToVibrator(EMPTY_VIBRATOR_INFO, segments, /*repeatIndex= */ -1))
+                .isEqualTo(-1);
+        assertThat(mAdapter.adaptToVibrator(EMPTY_VIBRATOR_INFO, segments, /*repeatIndex= */ 1))
+                .isEqualTo(1);
+
+        assertThat(mAdapter.adaptToVibrator(PWLE_VIBRATOR_INFO, segments, /*repeatIndex= */ -1))
+                .isEqualTo(-1);
+        assertThat(mAdapter.adaptToVibrator(PWLE_VIBRATOR_INFO, segments, /*repeatIndex= */ 1))
+                .isEqualTo(1);
+
+        assertThat(segments).isEqualTo(originalSegments);
+    }
+
+    @Test
+    public void testRampSegments_noPwleCapabilities_returnsOriginalSegments() {
+        List<VibrationEffectSegment> segments = new ArrayList<>(Arrays.asList(
+                new RampSegment(/* startAmplitude= */ 0.5f, /* endAmplitude*/ 0.5f,
+                        /* startFrequencyHz= */ 10, /* endFrequencyHz= */ 10, /* duration= */ 10),
+                new RampSegment(/* startAmplitude= */ 0.2f, /* endAmplitude*/ 0.8f,
+                        /* startFrequencyHz= */ 60, /* endFrequencyHz= */ 90, /* duration= */ 10)));
+        List<VibrationEffectSegment> originalSegments = new ArrayList<>(segments);
+
+        assertThat(mAdapter.adaptToVibrator(EMPTY_VIBRATOR_INFO, segments, /*repeatIndex= */ -1))
+                .isEqualTo(-1);
+        assertThat(mAdapter.adaptToVibrator(EMPTY_VIBRATOR_INFO, segments, /*repeatIndex= */ 1))
+                .isEqualTo(1);
+
+        assertThat(segments).isEqualTo(originalSegments);
+    }
+
+    @Test
+    public void testRampSegments_withPwleDurationLimit_splitsLongRampsAndPreserveOtherSegments() {
+        List<VibrationEffectSegment> segments = new ArrayList<>(Arrays.asList(
+                new StepSegment(/* amplitude= */ 1, /* frequencyHz= */ 40f, /* duration= */ 100),
+                new RampSegment(/* startAmplitude= */ 0.5f, /* endAmplitude*/ 0.5f,
+                        /* startFrequencyHz= */ 10, /* endFrequencyHz= */ 10, /* duration= */ 10),
+                new RampSegment(/* startAmplitude= */ 0, /* endAmplitude= */ 1,
+                        /* startFrequencyHz= */ 0, /* endFrequencyHz= */ 50, /* duration= */ 25),
+                new StepSegment(/* amplitude= */ 1, /* frequencyHz= */ 40f, /* duration= */ 100),
+                new RampSegment(/* startAmplitude= */ 1, /* endAmplitude*/ 1,
+                        /* startFrequencyHz= */ 10, /* endFrequencyHz= */ 20, /* duration= */ 5)));
+        List<VibrationEffectSegment> expectedSegments = Arrays.asList(
+                new StepSegment(/* amplitude= */ 1, /* frequencyHz= */ 40f, /* duration= */ 100),
+                new RampSegment(/* startAmplitude= */ 0.5f, /* endAmplitude*/ 0.5f,
+                        /* startFrequencyHz= */ 10, /* endFrequencyHz= */ 10, /* duration= */ 10),
+                new RampSegment(/* startAmplitude= */ 0, /* endAmplitude= */ 0.32f,
+                        /* startFrequencyHz= */ 150, /* endFrequencyHz= */ 118f, /* duration= */ 8),
+                new RampSegment(/* startAmplitude= */ 0.32f, /* endAmplitude= */ 0.64f,
+                        /* startFrequencyHz= */ 118f, /* endFrequencyHz= */ 86f,
+                        /* duration= */ 8),
+                new RampSegment(/* startAmplitude= */ 0.64f, /* endAmplitude= */ 1,
+                        /* startFrequencyHz= */ 86f, /* endFrequencyHz= */ 50f, /* duration= */ 9),
+                new StepSegment(/* amplitude= */ 1, /* frequencyHz= */ 40f, /* duration= */ 100),
+                new RampSegment(/* startAmplitude= */ 1, /* endAmplitude*/ 1,
+                        /* startFrequencyHz= */ 10, /* endFrequencyHz= */ 20, /* duration= */ 5));
+
+        VibratorInfo vibratorInfo = new VibratorInfo.Builder(0)
+                .setCapabilities(IVibrator.CAP_COMPOSE_PWLE_EFFECTS)
+                .setPwlePrimitiveDurationMax(10)
+                .setFrequencyProfile(TEST_FREQUENCY_PROFILE)
+                .build();
+
+        // Update repeat index to skip the ramp splits.
+        assertThat(mAdapter.adaptToVibrator(vibratorInfo, segments, /*repeatIndex= */ 3))
+                .isEqualTo(5);
+        assertThat(segments).isEqualTo(expectedSegments);
+    }
+
+    private static VibratorInfo createVibratorInfo(int... capabilities) {
+        return new VibratorInfo.Builder(0)
+                .setCapabilities(IntStream.of(capabilities).reduce((a, b) -> a | b).orElse(0))
+                .setFrequencyProfile(TEST_FREQUENCY_PROFILE)
+                .setPwlePrimitiveDurationMax(PWLE_COMPOSITION_PRIMITIVE_DURATION_MAX)
+                .build();
+    }
+}
diff --git a/services/tests/vibrator/src/com/android/server/vibrator/StepToRampAdapterTest.java b/services/tests/vibrator/src/com/android/server/vibrator/StepToRampAdapterTest.java
index 58deeec..82deff0 100644
--- a/services/tests/vibrator/src/com/android/server/vibrator/StepToRampAdapterTest.java
+++ b/services/tests/vibrator/src/com/android/server/vibrator/StepToRampAdapterTest.java
@@ -66,43 +66,13 @@
         assertEquals(-1, mAdapter.adaptToVibrator(EMPTY_VIBRATOR_INFO, segments, -1));
         assertEquals(1, mAdapter.adaptToVibrator(EMPTY_VIBRATOR_INFO, segments, 1));
 
+        assertEquals(-1, mAdapter.adaptToVibrator(PWLE_VIBRATOR_INFO, segments, -1));
+        assertEquals(1, mAdapter.adaptToVibrator(PWLE_VIBRATOR_INFO, segments, 1));
+
         assertEquals(originalSegments, segments);
     }
 
     @Test
-    public void testRampSegments_withPwleDurationLimit_splitsLongRamps() {
-        List<VibrationEffectSegment> segments = new ArrayList<>(Arrays.asList(
-                new RampSegment(/* startAmplitude= */ 0.5f, /* endAmplitude*/ 0.5f,
-                        /* startFrequencyHz= */ 10, /* endFrequencyHz= */ 10, /* duration= */ 10),
-                new RampSegment(/* startAmplitude= */ 0, /* endAmplitude= */ 1,
-                        /* startFrequencyHz= */ 0, /* endFrequencyHz= */ 50, /* duration= */ 25),
-                new RampSegment(/* startAmplitude= */ 1, /* endAmplitude*/ 1,
-                        /* startFrequencyHz= */ 10, /* endFrequencyHz= */ 20, /* duration= */ 5)));
-        List<VibrationEffectSegment> expectedSegments = Arrays.asList(
-                new RampSegment(/* startAmplitude= */ 0.5f, /* endAmplitude*/ 0.5f,
-                        /* startFrequencyHz= */ 10, /* endFrequencyHz= */ 10, /* duration= */ 10),
-                new RampSegment(/* startAmplitude= */ 0, /* endAmplitude= */ 0.32f,
-                        /* startFrequencyHz= */ 150, /* endFrequencyHz= */ 118f, /* duration= */ 8),
-                new RampSegment(/* startAmplitude= */ 0.32f, /* endAmplitude= */ 0.64f,
-                        /* startFrequencyHz= */ 118f, /* endFrequencyHz= */ 86f,
-                        /* duration= */ 8),
-                new RampSegment(/* startAmplitude= */ 0.64f, /* endAmplitude= */ 1,
-                        /* startFrequencyHz= */ 86f, /* endFrequencyHz= */ 50f, /* duration= */ 9),
-                new RampSegment(/* startAmplitude= */ 1, /* endAmplitude*/ 1,
-                        /* startFrequencyHz= */ 10, /* endFrequencyHz= */ 20, /* duration= */ 5));
-
-        VibratorInfo vibratorInfo = new VibratorInfo.Builder(0)
-                .setCapabilities(IVibrator.CAP_COMPOSE_PWLE_EFFECTS)
-                .setPwlePrimitiveDurationMax(10)
-                .setFrequencyProfile(TEST_FREQUENCY_PROFILE)
-                .build();
-
-        // Update repeat index to skip the ramp splits.
-        assertEquals(4, mAdapter.adaptToVibrator(vibratorInfo, segments, 2));
-        assertEquals(expectedSegments, segments);
-    }
-
-    @Test
     public void testStepAndRampSegments_withoutPwleCapability_keepsListUnchanged() {
         List<VibrationEffectSegment> segments = new ArrayList<>(Arrays.asList(
                 new StepSegment(/* amplitude= */ 0, /* frequencyHz= */ 1, /* duration= */ 10),
diff --git a/services/tests/vibrator/src/com/android/server/vibrator/VibrationThreadTest.java b/services/tests/vibrator/src/com/android/server/vibrator/VibrationThreadTest.java
index e739033..54995fb 100644
--- a/services/tests/vibrator/src/com/android/server/vibrator/VibrationThreadTest.java
+++ b/services/tests/vibrator/src/com/android/server/vibrator/VibrationThreadTest.java
@@ -1005,6 +1005,7 @@
                 mVibratorProviders.get(3).getEffectSegments(vibrationId));
     }
 
+    @FlakyTest
     @Test
     public void vibrate_multipleSyncedCallbackTriggered_finishSteps() throws Exception {
         int[] vibratorIds = new int[]{1, 2};
diff --git a/services/tests/wmtests/AndroidManifest.xml b/services/tests/wmtests/AndroidManifest.xml
index 9067593..42e3383 100644
--- a/services/tests/wmtests/AndroidManifest.xml
+++ b/services/tests/wmtests/AndroidManifest.xml
@@ -65,6 +65,7 @@
         <activity android:name="com.android.server.wm.TaskStackChangedListenerTest$ActivityInVirtualDisplay"
                   android:resizeableActivity="true" />
         <activity android:name="com.android.server.wm.TaskStackChangedListenerTest$LandscapeActivity"
+                  android:configChanges="screenLayout|screenSize|smallestScreenSize|orientation"
                   android:screenOrientation="sensorLandscape"
                   android:showWhenLocked="true"
                   android:turnScreenOn="true" />
diff --git a/services/tests/wmtests/OWNERS b/services/tests/wmtests/OWNERS
index cece37f..78b867f 100644
--- a/services/tests/wmtests/OWNERS
+++ b/services/tests/wmtests/OWNERS
@@ -3,3 +3,5 @@
 
 # Voice Interaction
 per-file *Assist* = file:/core/java/android/service/voice/OWNERS
+
+natanieljr@google.com
\ No newline at end of file
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityLeakTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityLeakTests.java
index bd6ac58..71d40de 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityLeakTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityLeakTests.java
@@ -34,6 +34,8 @@
 import android.os.strictmode.InstanceCountViolation;
 import android.util.Log;
 
+import com.android.server.wm.utils.CommonUtils;
+
 import org.junit.After;
 import org.junit.Test;
 
@@ -63,6 +65,10 @@
                 activity.finish();
             }
         }
+        if (!mStartedActivityList.isEmpty()) {
+            CommonUtils.waitUntilActivityRemoved(
+                    mStartedActivityList.get(mStartedActivityList.size() - 1));
+        }
         mStartedActivityList.clear();
     }
 
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityOptionsTest.java b/services/tests/wmtests/src/com/android/server/wm/ActivityOptionsTest.java
index f6f3f03..93adddb 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityOptionsTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityOptionsTest.java
@@ -54,6 +54,8 @@
 
 import androidx.test.filters.MediumTest;
 
+import com.android.server.wm.utils.CommonUtils;
+
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 
@@ -172,6 +174,7 @@
             instrumentation.removeMonitor(monitor);
             if (mainActivity != null) {
                 mainActivity.finish();
+                CommonUtils.waitUntilActivityRemoved(mainActivity);
             }
         }
     }
diff --git a/services/tests/wmtests/src/com/android/server/wm/AssistDataRequesterTest.java b/services/tests/wmtests/src/com/android/server/wm/AssistDataRequesterTest.java
index 7b4392b..1c6408b 100644
--- a/services/tests/wmtests/src/com/android/server/wm/AssistDataRequesterTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/AssistDataRequesterTest.java
@@ -50,6 +50,7 @@
 import android.util.Log;
 import android.view.IWindowManager;
 
+import androidx.test.filters.FlakyTest;
 import androidx.test.filters.MediumTest;
 
 import com.android.server.am.AssistDataRequester;
@@ -153,6 +154,7 @@
                 .noteOpNoThrow(eq(OP_ASSIST_SCREENSHOT), anyInt(), anyString(), any(), any());
     }
 
+    @FlakyTest(bugId = 280107567)
     @Test
     public void testRequestData() throws Exception {
         setupMocks(CURRENT_ACTIVITY_ASSIST_ALLOWED, CALLER_ASSIST_STRUCTURE_ALLOWED,
@@ -260,6 +262,7 @@
         assertReceivedDataCount(0, 1, 0, 1);
     }
 
+    @FlakyTest(bugId = 280107567)
     @Test
     public void testNoFetchScreenshots_expectNoScreenshotCallbacks() throws Exception {
         setupMocks(CURRENT_ACTIVITY_ASSIST_ALLOWED, CALLER_ASSIST_STRUCTURE_ALLOWED,
@@ -271,6 +274,7 @@
         assertReceivedDataCount(5, 5, 0, 0);
     }
 
+    @FlakyTest(bugId = 280107567)
     @Test
     public void testDisallowAssistScreenshot_expectNullScreenshotCallback() throws Exception {
         setupMocks(CURRENT_ACTIVITY_ASSIST_ALLOWED, CALLER_ASSIST_STRUCTURE_ALLOWED,
diff --git a/services/tests/wmtests/src/com/android/server/wm/InputMethodDialogWindowContextTest.java b/services/tests/wmtests/src/com/android/server/wm/InputMethodDialogWindowContextTest.java
index 1180ebd..c3db241 100644
--- a/services/tests/wmtests/src/com/android/server/wm/InputMethodDialogWindowContextTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/InputMethodDialogWindowContextTest.java
@@ -47,6 +47,7 @@
 import android.view.IWindowManager;
 import android.view.WindowManager;
 import android.view.WindowManagerGlobal;
+import android.window.WindowContextInfo;
 import android.window.WindowTokenClient;
 
 import com.android.server.inputmethod.InputMethodDialogWindowContext;
@@ -99,7 +100,7 @@
             final WindowProcessController wpc = mAtm.getProcessController(appThread);
             mWm.mWindowContextListenerController.registerWindowContainerListener(wpc, clientToken,
                     dc.getImeContainer(), TYPE_INPUT_METHOD_DIALOG, null /* options */);
-            return dc.getImeContainer().getConfiguration();
+            return new WindowContextInfo(dc.getImeContainer().getConfiguration(), displayId);
         }).when(mIWindowManager).attachWindowContextToDisplayArea(any(), any(),
                 eq(TYPE_INPUT_METHOD_DIALOG), anyInt(), any());
         mDisplayManagerGlobal = DisplayManagerGlobal.getInstance();
diff --git a/services/tests/wmtests/src/com/android/server/wm/ScreenshotTests.java b/services/tests/wmtests/src/com/android/server/wm/ScreenshotTests.java
index fb95748..0fcae92 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ScreenshotTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ScreenshotTests.java
@@ -56,6 +56,9 @@
 import androidx.test.filters.SmallTest;
 import androidx.test.rule.ActivityTestRule;
 
+import com.android.server.wm.utils.CommonUtils;
+
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -90,6 +93,11 @@
         mInstrumentation.waitForIdleSync();
     }
 
+    @After
+    public void tearDown() {
+        CommonUtils.waitUntilActivityRemoved(mActivity);
+    }
+
     @Test
     public void testScreenshotSecureLayers() throws InterruptedException {
         SurfaceControl secureSC = new SurfaceControl.Builder()
diff --git a/services/tests/wmtests/src/com/android/server/wm/SurfaceControlViewHostTests.java b/services/tests/wmtests/src/com/android/server/wm/SurfaceControlViewHostTests.java
index 1a4b94b..ce1a46b 100644
--- a/services/tests/wmtests/src/com/android/server/wm/SurfaceControlViewHostTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/SurfaceControlViewHostTests.java
@@ -52,6 +52,8 @@
 import androidx.test.platform.app.InstrumentationRegistry;
 import androidx.test.rule.ActivityTestRule;
 
+import com.android.server.wm.utils.CommonUtils;
+
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -87,6 +89,7 @@
     @After
     public void tearDown() {
         mInstrumentation.getUiAutomation().dropShellPermissionIdentity();
+        CommonUtils.waitUntilActivityRemoved(mActivity);
     }
 
     @Test
diff --git a/services/tests/wmtests/src/com/android/server/wm/SurfaceSyncGroupTests.java b/services/tests/wmtests/src/com/android/server/wm/SurfaceSyncGroupTests.java
index abaa776..77290e3 100644
--- a/services/tests/wmtests/src/com/android/server/wm/SurfaceSyncGroupTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/SurfaceSyncGroupTests.java
@@ -47,6 +47,9 @@
 import androidx.test.InstrumentationRegistry;
 import androidx.test.rule.ActivityTestRule;
 
+import com.android.server.wm.utils.CommonUtils;
+
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -79,6 +82,12 @@
         mHandler = mHandlerThread.getThreadHandler();
     }
 
+    @After
+    public void tearDown() {
+        mHandlerThread.quitSafely();
+        CommonUtils.waitUntilActivityRemoved(mActivity);
+    }
+
     @Test
     public void testOverlappingSyncsEnsureOrder_WhenTimeout() throws InterruptedException {
         WindowManager.LayoutParams params = new WindowManager.LayoutParams();
diff --git a/services/tests/wmtests/src/com/android/server/wm/SurfaceViewSyncContinuousTest.java b/services/tests/wmtests/src/com/android/server/wm/SurfaceViewSyncContinuousTest.java
index f958e6f..c59a04b 100644
--- a/services/tests/wmtests/src/com/android/server/wm/SurfaceViewSyncContinuousTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/SurfaceViewSyncContinuousTest.java
@@ -25,6 +25,9 @@
 
 import androidx.test.rule.ActivityTestRule;
 
+import com.android.server.wm.utils.CommonUtils;
+
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -54,6 +57,11 @@
         }
     }
 
+    @After
+    public void tearDown() {
+        CommonUtils.waitUntilActivityRemoved(mCapturedActivity);
+    }
+
     @Test
     public void testSurfaceViewSyncDuringResize() throws Throwable {
         mCapturedActivity.verifyTest(new SurfaceViewSyncValidatorTestCase(), mName);
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskStackChangedListenerTest.java b/services/tests/wmtests/src/com/android/server/wm/TaskStackChangedListenerTest.java
index e16208b..16c38ac 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskStackChangedListenerTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskStackChangedListenerTest.java
@@ -60,6 +60,7 @@
 import org.junit.Before;
 import org.junit.Test;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.concurrent.ArrayBlockingQueue;
 import java.util.concurrent.CountDownLatch;
@@ -76,6 +77,7 @@
     private ITaskStackListener mTaskStackListener;
     private VirtualDisplay mVirtualDisplay;
     private ImageReader mImageReader;
+    private final ArrayList<Activity> mStartedActivities = new ArrayList<>();
 
     private static final int WAIT_TIMEOUT_MS = 5000;
     private static final Object sLock = new Object();
@@ -94,6 +96,19 @@
             mVirtualDisplay.release();
             mImageReader.close();
         }
+        // Finish from bottom to top.
+        final int size = mStartedActivities.size();
+        for (int i = 0; i < size; i++) {
+            final Activity activity = mStartedActivities.get(i);
+            if (!activity.isFinishing()) {
+                activity.finish();
+            }
+        }
+        // Wait for the last launched activity to be removed.
+        if (size > 0) {
+            CommonUtils.waitUntilActivityRemoved(mStartedActivities.get(size - 1));
+        }
+        mStartedActivities.clear();
     }
 
     private VirtualDisplay createVirtualDisplay() {
@@ -381,6 +396,7 @@
             throw new RuntimeException("Timed out waiting for Activity");
         }
         activity.waitForResumeStateChange(true);
+        mStartedActivities.add(activity);
         return activity;
     }
 
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowManagerServiceTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowManagerServiceTests.java
index 325176f..55fda05 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowManagerServiceTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowManagerServiceTests.java
@@ -468,7 +468,7 @@
         mWm.attachWindowContextToWindowToken(mAppThread, new Binder(), windowToken.token);
 
         verify(mWm.mWindowContextListenerController, never()).registerWindowContainerListener(
-                any(), any(), any(), anyInt(), any());
+                any(), any(), any(), anyInt(), any(), anyBoolean());
     }
 
     @Test
@@ -484,9 +484,9 @@
         final IBinder clientToken = new Binder();
         mWm.attachWindowContextToWindowToken(mAppThread, clientToken, windowToken.token);
         final WindowProcessController wpc = mAtm.getProcessController(mAppThread);
-        verify(mWm.mWindowContextListenerController).registerWindowContainerListener(eq(wpc),
-                eq(clientToken), eq(windowToken), eq(TYPE_INPUT_METHOD),
-                eq(windowToken.mOptions));
+        verify(mWm.mWindowContextListenerController).registerWindowContainerListener(wpc,
+                clientToken, windowToken, TYPE_INPUT_METHOD, windowToken.mOptions,
+                false /* shouldDispatchConfigWhenRegistering */);
     }
 
     @Test
@@ -514,7 +514,7 @@
                 new InsetsSourceControl.Array(), new Rect(), new float[1]);
 
         verify(mWm.mWindowContextListenerController, never()).registerWindowContainerListener(any(),
-                any(), any(), anyInt(), any());
+                any(), any(), anyInt(), any(), anyBoolean());
     }
 
     @Test
diff --git a/services/tests/wmtests/src/com/android/server/wm/utils/CommonUtils.java b/services/tests/wmtests/src/com/android/server/wm/utils/CommonUtils.java
index 34f9c75..ed23296 100644
--- a/services/tests/wmtests/src/com/android/server/wm/utils/CommonUtils.java
+++ b/services/tests/wmtests/src/com/android/server/wm/utils/CommonUtils.java
@@ -18,14 +18,23 @@
 
 import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
 
+import android.app.Activity;
 import android.app.KeyguardManager;
 import android.app.UiAutomation;
+import android.os.SystemClock;
+import android.util.Log;
 import android.view.KeyEvent;
 
 import androidx.test.uiautomator.UiDevice;
 
+import java.io.IOException;
+
 /** Provides common utility functions. */
 public class CommonUtils {
+    private static final String TAG = "CommonUtils";
+    private static final long REMOVAL_TIMEOUT_MS = 3000;
+    private static final long TIMEOUT_INTERVAL_MS = 200;
+
     public static UiAutomation getUiAutomation() {
         return getInstrumentation().getUiAutomation();
     }
@@ -50,4 +59,26 @@
         device.pressKeyCode(KeyEvent.KEYCODE_WAKEUP);
         device.pressKeyCode(KeyEvent.KEYCODE_MENU);
     }
+
+    public static void waitUntilActivityRemoved(Activity activity) {
+        if (!activity.isFinishing()) {
+            activity.finish();
+        }
+        final UiDevice uiDevice = UiDevice.getInstance(getInstrumentation());
+        final String classPattern = activity.getComponentName().flattenToShortString();
+        final long startTime = SystemClock.uptimeMillis();
+        while (SystemClock.uptimeMillis() - startTime <= REMOVAL_TIMEOUT_MS) {
+            SystemClock.sleep(TIMEOUT_INTERVAL_MS);
+            final String windowTokenDump;
+            try {
+                windowTokenDump = uiDevice.executeShellCommand("dumpsys window tokens");
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }
+            if (!windowTokenDump.contains(classPattern)) {
+                return;
+            }
+        }
+        Log.i(TAG, "Removal timeout of " + classPattern);
+    }
 }
diff --git a/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerService.java b/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerService.java
index 997015f..b3db2de 100644
--- a/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerService.java
+++ b/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerService.java
@@ -365,7 +365,7 @@
             // Validate package name
             try {
                 int uid = mPackageManager.getPackageUid(mOriginatorIdentity.packageName,
-                        PackageManager.PackageInfoFlags.of(0));
+                        PackageManager.PackageInfoFlags.of(PackageManager.MATCH_ANY_USER));
                 if (!UserHandle.isSameApp(uid, mOriginatorIdentity.uid)) {
                     throw new SecurityException("Uid " + mOriginatorIdentity.uid +
                             " attempted to spoof package name " +
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockscreenViaIntentTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockscreenViaIntentTest.kt
index 063e2c3..e0fb751 100644
--- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockscreenViaIntentTest.kt
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockscreenViaIntentTest.kt
@@ -93,7 +93,7 @@
      * Checks that the [ComponentNameMatcher.NAV_BAR] starts the transition invisible, then becomes
      * visible during the unlocking animation and remains visible at the end of the transition
      */
-    @Presubmit
+    @FlakyTest(bugId = 293581770)
     @Test
     fun navBarWindowsVisibilityChanges() {
         Assume.assumeFalse(flicker.scenario.isTablet)