Merge "Add rear display dialog methods to CommandQueue and StatusBarService" into tm-qpr-dev
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationAdapter.java b/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationAdapter.java
index 215308d..00b9fced 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationAdapter.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationAdapter.java
@@ -30,6 +30,8 @@
 
 import androidx.annotation.NonNull;
 
+import com.android.wm.shell.transition.Transitions;
+
 /**
  * Wrapper to handle the ActivityEmbedding animation update in one
  * {@link SurfaceControl.Transaction}.
@@ -50,6 +52,16 @@
     /** Area in absolute coordinate that the animation surface shouldn't go beyond. */
     @NonNull
     private final Rect mWholeAnimationBounds = new Rect();
+    /**
+     * Area in absolute coordinate that should represent all the content to show for this window.
+     * This should be the end bounds for opening window, and start bounds for closing window in case
+     * the window is resizing during the open/close transition.
+     */
+    @NonNull
+    private final Rect mContentBounds = new Rect();
+    /** Offset relative to the window parent surface for {@link #mContentBounds}. */
+    @NonNull
+    private final Point mContentRelOffset = new Point();
 
     @NonNull
     final Transformation mTransformation = new Transformation();
@@ -80,6 +92,21 @@
         mChange = change;
         mLeash = leash;
         mWholeAnimationBounds.set(wholeAnimationBounds);
+        if (Transitions.isClosingType(change.getMode())) {
+            // When it is closing, we want to show the content at the start position in case the
+            // window is resizing as well. For example, when the activities is changing from split
+            // to stack, the bottom TaskFragment will be resized to fullscreen when hiding.
+            final Rect startBounds = change.getStartAbsBounds();
+            final Rect endBounds = change.getEndAbsBounds();
+            mContentBounds.set(startBounds);
+            mContentRelOffset.set(change.getEndRelOffset());
+            mContentRelOffset.offset(
+                    startBounds.left - endBounds.left,
+                    startBounds.top - endBounds.top);
+        } else {
+            mContentBounds.set(change.getEndAbsBounds());
+            mContentRelOffset.set(change.getEndRelOffset());
+        }
     }
 
     /**
@@ -110,8 +137,7 @@
     /** To be overridden by subclasses to adjust the animation surface change. */
     void onAnimationUpdateInner(@NonNull SurfaceControl.Transaction t) {
         // Update the surface position and alpha.
-        final Point offset = mChange.getEndRelOffset();
-        mTransformation.getMatrix().postTranslate(offset.x, offset.y);
+        mTransformation.getMatrix().postTranslate(mContentRelOffset.x, mContentRelOffset.y);
         t.setMatrix(mLeash, mTransformation.getMatrix(), mMatrix);
         t.setAlpha(mLeash, mTransformation.getAlpha());
 
@@ -119,8 +145,8 @@
         // positionX/Y are in local coordinate, so minus the local offset to get the slide amount.
         final int positionX = Math.round(mMatrix[MTRANS_X]);
         final int positionY = Math.round(mMatrix[MTRANS_Y]);
-        final Rect cropRect = new Rect(mChange.getEndAbsBounds());
-        cropRect.offset(positionX - offset.x, positionY - offset.y);
+        final Rect cropRect = new Rect(mContentBounds);
+        cropRect.offset(positionX - mContentRelOffset.x, positionY - mContentRelOffset.y);
 
         // Store the current offset of the surface top left from (0,0) in absolute coordinate.
         final int offsetX = cropRect.left;
@@ -133,7 +159,7 @@
         } else if (mAnimation.hasExtension()) {
             // Allow the surface to be shown in its original bounds in case we want to use edge
             // extensions.
-            cropRect.union(mChange.getEndAbsBounds());
+            cropRect.union(mContentBounds);
         }
 
         // cropRect is in absolute coordinate, so we need to translate it to surface top left.
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationRunner.java b/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationRunner.java
index 921861a..c0a6456 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationRunner.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationRunner.java
@@ -304,6 +304,7 @@
         // This is because the TaskFragment surface/change won't contain the Activity's before its
         // reparent.
         Animation changeAnimation = null;
+        Rect parentBounds = new Rect();
         for (TransitionInfo.Change change : info.getChanges()) {
             if (change.getMode() != TRANSIT_CHANGE
                     || change.getStartAbsBounds().equals(change.getEndAbsBounds())) {
@@ -326,10 +327,15 @@
                 }
             }
 
+            // The TaskFragment may be enter/exit split, so we take the union of both as the parent
+            // size.
+            parentBounds.union(boundsAnimationChange.getStartAbsBounds());
+            parentBounds.union(boundsAnimationChange.getEndAbsBounds());
+
             // There are two animations in the array. The first one is for the start leash
             // (snapshot), and the second one is for the end leash (TaskFragment).
             final Animation[] animations = mAnimationSpec.createChangeBoundsChangeAnimations(change,
-                    boundsAnimationChange.getEndAbsBounds());
+                    parentBounds);
             // Keep track as we might need to add background color for the animation.
             // Although there may be multiple change animation, record one of them is sufficient
             // because the background color will be added to the root leash for the whole animation.
@@ -352,6 +358,11 @@
                     animations[1], boundsAnimationChange));
         }
 
+        if (parentBounds.isEmpty()) {
+            throw new IllegalStateException(
+                    "There should be at least one changing window to play the change animation");
+        }
+
         // If there is no corresponding open/close window with the change, we should show background
         // color to cover the empty part of the screen.
         boolean shouldShouldBackgroundColor = true;
@@ -368,10 +379,10 @@
                 // No-op if it will be covered by the changing parent window.
                 animation = ActivityEmbeddingAnimationSpec.createNoopAnimation(change);
             } else if (Transitions.isClosingType(change.getMode())) {
-                animation = mAnimationSpec.createChangeBoundsCloseAnimation(change);
+                animation = mAnimationSpec.createChangeBoundsCloseAnimation(change, parentBounds);
                 shouldShouldBackgroundColor = false;
             } else {
-                animation = mAnimationSpec.createChangeBoundsOpenAnimation(change);
+                animation = mAnimationSpec.createChangeBoundsOpenAnimation(change, parentBounds);
                 shouldShouldBackgroundColor = false;
             }
             adapters.add(new ActivityEmbeddingAnimationAdapter(animation, change));
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationSpec.java b/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationSpec.java
index 2bb7369..65a7d09 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationSpec.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationSpec.java
@@ -21,7 +21,6 @@
 import static com.android.wm.shell.transition.TransitionAnimationHelper.loadAttributeAnimation;
 
 import android.content.Context;
-import android.graphics.Point;
 import android.graphics.Rect;
 import android.view.animation.AlphaAnimation;
 import android.view.animation.Animation;
@@ -80,15 +79,25 @@
 
     /** Animation for window that is opening in a change transition. */
     @NonNull
-    Animation createChangeBoundsOpenAnimation(@NonNull TransitionInfo.Change change) {
+    Animation createChangeBoundsOpenAnimation(@NonNull TransitionInfo.Change change,
+            @NonNull Rect parentBounds) {
+        // Use end bounds for opening.
         final Rect bounds = change.getEndAbsBounds();
-        final Point offset = change.getEndRelOffset();
-        // The window will be animated in from left or right depends on its position.
-        final int startLeft = offset.x == 0 ? -bounds.width() : bounds.width();
+        final int startLeft;
+        final int startTop;
+        if (parentBounds.top == bounds.top && parentBounds.bottom == bounds.bottom) {
+            // The window will be animated in from left or right depends on its position.
+            startTop = 0;
+            startLeft = parentBounds.left == bounds.left ? -bounds.width() : bounds.width();
+        } else {
+            // The window will be animated in from top or bottom depends on its position.
+            startTop = parentBounds.top == bounds.top ? -bounds.height() : bounds.height();
+            startLeft = 0;
+        }
 
         // The position should be 0-based as we will post translate in
         // ActivityEmbeddingAnimationAdapter#onAnimationUpdate
-        final Animation animation = new TranslateAnimation(startLeft, 0, 0, 0);
+        final Animation animation = new TranslateAnimation(startLeft, 0, startTop, 0);
         animation.setInterpolator(mFastOutExtraSlowInInterpolator);
         animation.setDuration(CHANGE_ANIMATION_DURATION);
         animation.initialize(bounds.width(), bounds.height(), bounds.width(), bounds.height());
@@ -98,15 +107,25 @@
 
     /** Animation for window that is closing in a change transition. */
     @NonNull
-    Animation createChangeBoundsCloseAnimation(@NonNull TransitionInfo.Change change) {
-        final Rect bounds = change.getEndAbsBounds();
-        final Point offset = change.getEndRelOffset();
-        // The window will be animated out to left or right depends on its position.
-        final int endLeft = offset.x == 0 ? -bounds.width() : bounds.width();
+    Animation createChangeBoundsCloseAnimation(@NonNull TransitionInfo.Change change,
+            @NonNull Rect parentBounds) {
+        // Use start bounds for closing.
+        final Rect bounds = change.getStartAbsBounds();
+        final int endTop;
+        final int endLeft;
+        if (parentBounds.top == bounds.top && parentBounds.bottom == bounds.bottom) {
+            // The window will be animated out to left or right depends on its position.
+            endTop = 0;
+            endLeft = parentBounds.left == bounds.left ? -bounds.width() : bounds.width();
+        } else {
+            // The window will be animated out to top or bottom depends on its position.
+            endTop = parentBounds.top == bounds.top ? -bounds.height() : bounds.height();
+            endLeft = 0;
+        }
 
         // The position should be 0-based as we will post translate in
         // ActivityEmbeddingAnimationAdapter#onAnimationUpdate
-        final Animation animation = new TranslateAnimation(0, endLeft, 0, 0);
+        final Animation animation = new TranslateAnimation(0, endLeft, 0, endTop);
         animation.setInterpolator(mFastOutExtraSlowInInterpolator);
         animation.setDuration(CHANGE_ANIMATION_DURATION);
         animation.initialize(bounds.width(), bounds.height(), bounds.width(), bounds.height());
diff --git a/packages/SystemUI/docs/device-entry/quickaffordance.md b/packages/SystemUI/docs/device-entry/quickaffordance.md
index 95b986f..01d4f00 100644
--- a/packages/SystemUI/docs/device-entry/quickaffordance.md
+++ b/packages/SystemUI/docs/device-entry/quickaffordance.md
@@ -1,25 +1,73 @@
 # Keyguard Quick Affordances
-These are interactive UI elements that appear at the bottom of the lockscreen when the device is
-locked. They allow the user to perform quick actions without unlocking their device. For example:
+Quick Affordances are interactive UI elements that appear on the lock screen when the device is
+locked. They allow the user to perform quick actions without necessarily unlocking their device. For example:
 opening an screen that lets them control the smart devices in their home, access their touch-to-pay
-credit card, etc.
+credit card, turn on the flashlight, etc.
 
-## Adding a new Quick Affordance
-### Step 1: create a new quick affordance config
-* Create a new class under the [systemui/keyguard/domain/quickaffordance](../../src/com/android/systemui/keyguard/domain/quickaffordance) directory
-* Please make sure that the class is injected through the Dagger dependency injection system by using the `@Inject` annotation on its main constructor and the `@SysUISingleton` annotation at class level, to make sure only one instance of the class is ever instantiated
-* Have the class implement the [KeyguardQuickAffordanceConfig](../../src/com/android/systemui/keyguard/data/quickaffordance/KeyguardQuickAffordanceConfig.kt) interface, notes:
-  * The `state` Flow property must emit `State.Hidden` when the feature is not enabled!
-  * It is safe to assume that `onQuickAffordanceClicked` will not be invoked if-and-only-if the previous rule is followed
-  * When implementing `onQuickAffordanceClicked`, the implementation can do something or it can ask the framework to start an activity using an `Intent` provided by the implementation
-* Please include a unit test for your new implementation under [the correct directory](../../tests/src/com/android/systemui/keyguard/domain/quickaffordance)
+## Creating a new Quick Affordance
+All Quick Affordances are defined in System UI code.
 
-### Step 2: choose a position and priority
-* Add the new class as a dependency in the constructor of [KeyguardQuickAffordanceRegistry](../../src/com/android/systemui/keyguard/domain/quickaffordance/KeyguardQuickAffordanceRegistry.kt)
-* Place the new class in one of the available positions in the `configsByPosition` property, note:
-  * In each position, there is a list. The order matters. The order of that list is the priority order in which the framework considers each config. The first config whose state property returns `State.Visible` determines the button that is shown for that position
-  * Please only add to one position. The framework treats each position individually and there is no good way to prevent the same config from making its button appear in more than one position at the same time
+To implement a new Quick Affordance, a developer may add a new implementation of `KeyguardQuickAffordanceConfig` in the `packages/SystemUI/src/com/android/systemui/keyguard/data/quickaffordance` package/directory and add it to the set defined in `KeyguardDataQuickAffordanceModule`.
 
-### Step 3: manually verify the new quick affordance
-* Build and launch SysUI on a device
-* Verify that the quick affordance button for the new implementation is correctly visible and clicking it does the right thing
+Tests belong in the `packages/SystemUI/tests/src/com/android/systemui/keyguard/data/quickaffordance` package. This should be enough for the system to pick up the new config and make it available for selection by the user.
+
+## Slots
+"Slots" is what we call the position of Quick Affordances on the lock screen. Each slot has a unique ID and a capacity denoting how many Quick Affordances can be "placed" in that slot.
+
+By default, AOSP ships with a "bottom right" and a "bottom left" slot, each with a slot capacity of `1`, allowing only one Quick Affordance on each side of the lock screen.
+
+### Customizing Slots
+OEMs may choose to override the IDs and number of slots and/or override the default capacities. This can be achieved by overridding the `config_keyguardQuickAffordanceSlots` resource in `packages/SystemUI/res/values/config.xml`.
+
+### Default Quick Affordances
+OEMs may also choose to predefine default Quick Affordances for each slot. To achieve this, a developer may override the `config_keyguardQuickAffordanceDefaults` resource in `packages/SystemUI/res/values/config.xml`. Note that defaults only work until the user of the device selects a different quick affordance for that slot, even if they select the "None" option.
+
+## Selections
+"Selections" are many-to-many relationships between slots and quick affordances. We add a selection when the user selects a quick affordance for a specific slot. We remove a selection when the user un-selects a quick affordance in a slot or when the user selects an additional quick affordance for a slot that is already at capacity. The definition of each slot tells us the maximum number of quick affordances that may be selected for each slot.
+
+## Building a Quick affordance Picker Experience
+This section describes how to implement a potential picker, selector, or configuration experience for quick affordances.
+
+### Accessing Quick Affordance Data
+Quick Affordances structured data are exposed to other applications through the `KeyguardQuickAffordanceProvider` content provider which is owned by the System UI process.
+
+To access this content provider, applications must have the `android.permission.ACCESS_KEYGUARD_QUICK_AFFORDANCES` permission which is a signature and privileged permission, limiting access to system apps or apps signed by the same signature as System UI. The `KeyguardQuickAffordanceProviderContract` file defines the content provider schema for consumers.
+
+Generally speaking, there are three important tables served by the content provider: `slots`, `affordances`, and `selections`. There is also a `flags` table, but that's not important and may be ignored.
+
+The `slots`, `affordances`, and `selections` tables may be queried using their `Uri` resulting with a `Cursor` where each row represents a slot, affordance, or selection, respectively. Note that the affordance list does not include the "None" option.
+
+### Modifying Quick Affordance Data
+The `selections` table accepts `insert` or `delete` operations to either add or remove a quick affordance on a slot.
+* To add a selection of a quick affordance on a slot, execute the `insert` operation on the `selections` table `Uri` and include the `slot_id` of the slot and `affordance_id` of the affordance, both in the `ContentValues`
+* To remove a selection of a specific quick affordance from a slot, execute the `delete` operation on the `selections` table `Uri` and include the `slot_id` of the slot and the `affordance_id` of the affordance to remove as the first and second selection arguments, respectively
+* To remove all selections of any currently-selected quick affordance from a specific slot, repeat the above, but omit the `affordance_id`
+
+### The Picker Experience
+A picker experience may:
+* Show the list of available slots based on the result of the `slots` table query
+* Show the list of available quick affordances on the device (regardless of selection) based on the result of the `affordances` table query
+* Show the quick affordances already selected for each slot based on the result of the `selections` table query
+* Select one quick affordance per slot at a time
+* Unselect an already-selected quick affordance from a slot
+* Unselect all already-selected quick affordances from a slot
+
+## Debugging
+To see the current state of the system, you can run `dumpsys`:
+
+```
+$ adb shell dumpsys activity service com.android.systemui/.SystemUIService KeyguardQuickAffordances
+```
+
+The output will spell out the current slot configuration, selections, and collection of available affordances, for example:
+```
+    KeyguardQuickAffordances:
+    ----------------------------------------------------------------------------
+    Slots & selections:
+        bottom_start: home (capacity = 1)
+        bottom_end is empty (capacity = 1)
+    Available affordances on device:
+        home ("Home")
+        wallet ("Wallet")
+        qr_code_scanner ("QR code scanner")
+```
diff --git a/packages/SystemUI/res/drawable/ic_ring_volume.xml b/packages/SystemUI/res/drawable/ic_ring_volume.xml
deleted file mode 100644
index 343fe5d..0000000
--- a/packages/SystemUI/res/drawable/ic_ring_volume.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<!--
-    Copyright (C) 2022 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.
--->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="24dp"
-    android:height="24dp"
-    android:viewportWidth="24"
-    android:viewportHeight="24"
-    android:tint="?android:attr/colorControlNormal">
-  <path
-      android:pathData="M11,7V2H13V7ZM17.6,9.85 L16.2,8.4 19.75,4.85 21.15,6.3ZM6.4,9.85 L2.85,6.3 4.25,4.85 7.8,8.4ZM12,12Q14.95,12 17.812,13.188Q20.675,14.375 22.9,16.75Q23.2,17.05 23.2,17.45Q23.2,17.85 22.9,18.15L20.6,20.4Q20.325,20.675 19.963,20.7Q19.6,20.725 19.3,20.5L16.4,18.3Q16.2,18.15 16.1,17.95Q16,17.75 16,17.5V14.65Q15.05,14.35 14.05,14.175Q13.05,14 12,14Q10.95,14 9.95,14.175Q8.95,14.35 8,14.65V17.5Q8,17.75 7.9,17.95Q7.8,18.15 7.6,18.3L4.7,20.5Q4.4,20.725 4.038,20.7Q3.675,20.675 3.4,20.4L1.1,18.15Q0.8,17.85 0.8,17.45Q0.8,17.05 1.1,16.75Q3.3,14.375 6.175,13.188Q9.05,12 12,12ZM6,15.35Q5.275,15.725 4.6,16.212Q3.925,16.7 3.2,17.3L4.2,18.3L6,16.9ZM18,15.4V16.9L19.8,18.3L20.8,17.35Q20.075,16.7 19.4,16.225Q18.725,15.75 18,15.4ZM6,15.35Q6,15.35 6,15.35Q6,15.35 6,15.35ZM18,15.4Q18,15.4 18,15.4Q18,15.4 18,15.4Z"
-      android:fillColor="?android:attr/colorPrimary"/>
-
-</vector>
\ No newline at end of file
diff --git a/packages/SystemUI/res/drawable/ic_ring_volume_off.xml b/packages/SystemUI/res/drawable/ic_ring_volume_off.xml
deleted file mode 100644
index 74f30d1..0000000
--- a/packages/SystemUI/res/drawable/ic_ring_volume_off.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<!--
-    Copyright (C) 2022 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.
--->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="24dp"
-    android:height="24dp"
-    android:viewportWidth="24"
-    android:viewportHeight="24"
-    android:tint="?android:attr/colorControlNormal">
-<path
-      android:pathData="M0.8,4.2l8.1,8.1c-2.2,0.5 -5.2,1.6 -7.8,4.4c-0.4,0.4 -0.4,1 0,1.4l2.3,2.3c0.3,0.3 0.9,0.4 1.3,0.1l2.9,-2.2C7.8,18.1 8,17.8 8,17.5v-2.9c0.9,-0.3 1.7,-0.5 2.7,-0.6l8.5,8.5l1.4,-1.4L2.2,2.8L0.8,4.2z"
-    android:fillColor="?android:attr/colorPrimary"/>
-  <path
-      android:pathData="M11,2h2v5h-2z"
-      android:fillColor="?android:attr/colorPrimary"/>
-  <path
-      android:pathData="M21.2,6.3l-1.4,-1.4l-3.6,3.6l1.4,1.4C17.6,9.8 21,6.3 21.2,6.3z"
-      android:fillColor="?android:attr/colorPrimary"/>
-  <path
-      android:pathData="M22.9,16.7c-2.8,-3 -6.2,-4.1 -8.4,-4.5l7.2,7.2l1.3,-1.3C23.3,17.7 23.3,17.1 22.9,16.7z"
-      android:fillColor="?android:attr/colorPrimary"/>
-</vector>
diff --git a/packages/SystemUI/res/drawable/ic_speaker_mute.xml b/packages/SystemUI/res/drawable/ic_speaker_mute.xml
deleted file mode 100644
index 4e402cf..0000000
--- a/packages/SystemUI/res/drawable/ic_speaker_mute.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<!--
-  ~ Copyright (C) 2022 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.
-  -->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="24dp"
-    android:height="24dp"
-    android:viewportWidth="24"
-    android:viewportHeight="24"
-    android:tint="?android:attr/textColorPrimary"
-    android:autoMirrored="true">
-    <path android:fillColor="#FFFFFFFF"
-        android:pathData="M19.8,22.6 L16.775,19.575Q16.15,19.975 15.45,20.263Q14.75,20.55 14,20.725V18.675Q14.35,18.55 14.688,18.425Q15.025,18.3 15.325,18.125L12,14.8V20L7,15H3V9H6.2L1.4,4.2L2.8,2.8L21.2,21.2ZM19.6,16.8 L18.15,15.35Q18.575,14.575 18.788,13.725Q19,12.875 19,11.975Q19,9.625 17.625,7.775Q16.25,5.925 14,5.275V3.225Q17.1,3.925 19.05,6.362Q21,8.8 21,11.975Q21,13.3 20.638,14.525Q20.275,15.75 19.6,16.8ZM16.25,13.45 L14,11.2V7.95Q15.175,8.5 15.838,9.6Q16.5,10.7 16.5,12Q16.5,12.375 16.438,12.738Q16.375,13.1 16.25,13.45ZM12,9.2 L9.4,6.6 12,4ZM10,15.15V12.8L8.2,11H5V13H7.85ZM9.1,11.9Z"/>
-</vector>
\ No newline at end of file
diff --git a/packages/SystemUI/res/drawable/ic_speaker_on.xml b/packages/SystemUI/res/drawable/ic_speaker_on.xml
deleted file mode 100644
index 2a90e05..0000000
--- a/packages/SystemUI/res/drawable/ic_speaker_on.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<!--
-  ~ Copyright (C) 2022 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.
-  -->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="24dp"
-    android:height="24dp"
-    android:viewportWidth="24"
-    android:viewportHeight="24"
-    android:tint="?android:attr/textColorPrimary"
-    android:autoMirrored="true">
-    <path android:fillColor="#FFFFFFFF"
-        android:pathData="M14,20.725V18.675Q16.25,18.025 17.625,16.175Q19,14.325 19,11.975Q19,9.625 17.625,7.775Q16.25,5.925 14,5.275V3.225Q17.1,3.925 19.05,6.362Q21,8.8 21,11.975Q21,15.15 19.05,17.587Q17.1,20.025 14,20.725ZM3,15V9H7L12,4V20L7,15ZM14,16V7.95Q15.175,8.5 15.838,9.6Q16.5,10.7 16.5,12Q16.5,13.275 15.838,14.362Q15.175,15.45 14,16ZM10,8.85 L7.85,11H5V13H7.85L10,15.15ZM7.5,12Z"/>
-</vector>
\ No newline at end of file
diff --git a/packages/SystemUI/res/layout-sw600dp/global_actions_controls_list_view.xml b/packages/SystemUI/res/layout-sw600dp/global_actions_controls_list_view.xml
deleted file mode 100644
index ef49b9c..0000000
--- a/packages/SystemUI/res/layout-sw600dp/global_actions_controls_list_view.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<!--
-  ~ Copyright (C) 2020 The Android Open Source Project
-  ~
-  ~ Licensed under the Apache License, Version 2.0 (the "License");
-  ~ you may not use this file except in compliance with the License.
-  ~ You may obtain a copy of the License at
-  ~
-  ~      http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
-
-<com.android.systemui.globalactions.MinHeightScrollView
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:orientation="vertical"
-    android:scrollbars="none">
-  <LinearLayout
-      android:id="@+id/global_actions_controls_list"
-      android:layout_width="match_parent"
-      android:layout_height="wrap_content"
-      android:orientation="vertical"
-      android:layout_marginLeft="@dimen/global_actions_side_margin"
-      android:layout_marginRight="@dimen/global_actions_side_margin" />
-</com.android.systemui.globalactions.MinHeightScrollView>
\ No newline at end of file
diff --git a/packages/SystemUI/res/layout/controls_fullscreen.xml b/packages/SystemUI/res/layout/controls_fullscreen.xml
index 11a5665..e08e63b 100644
--- a/packages/SystemUI/res/layout/controls_fullscreen.xml
+++ b/packages/SystemUI/res/layout/controls_fullscreen.xml
@@ -15,28 +15,19 @@
      limitations under the License.
 -->
 
-<LinearLayout
+<FrameLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/control_detail_root"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical">
 
-  <com.android.systemui.globalactions.MinHeightScrollView
-      android:layout_width="match_parent"
-      android:layout_height="0dp"
-      android:layout_weight="1"
-      android:orientation="vertical"
-      android:scrollbars="none">
 
     <LinearLayout
         android:id="@+id/global_actions_controls"
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:clipChildren="false"
+        android:layout_height="match_parent"
         android:orientation="vertical"
-        android:clipToPadding="false"
         android:paddingHorizontal="@dimen/controls_padding_horizontal" />
 
-  </com.android.systemui.globalactions.MinHeightScrollView>
-</LinearLayout>
+</FrameLayout>
diff --git a/packages/SystemUI/res/layout/controls_with_favorites.xml b/packages/SystemUI/res/layout/controls_with_favorites.xml
index 9d01148..9efad22 100644
--- a/packages/SystemUI/res/layout/controls_with_favorites.xml
+++ b/packages/SystemUI/res/layout/controls_with_favorites.xml
@@ -18,7 +18,7 @@
 
   <LinearLayout
       android:layout_width="match_parent"
-      android:layout_height="match_parent"
+      android:layout_height="wrap_content"
       android:orientation="horizontal"
       android:layout_marginTop="@dimen/controls_top_margin"
       android:layout_marginBottom="@dimen/controls_header_bottom_margin">
@@ -71,5 +71,27 @@
         android:background="?android:attr/selectableItemBackgroundBorderless" />
   </LinearLayout>
 
-  <include layout="@layout/global_actions_controls_list_view" />
+  <ScrollView
+        android:id="@+id/controls_scroll_view"
+        android:layout_width="match_parent"
+        android:layout_height="0dp"
+        android:layout_weight="1"
+        android:orientation="vertical"
+        android:clipChildren="true"
+        android:scrollbars="none">
+    <include layout="@layout/global_actions_controls_list_view" />
+
+  </ScrollView>
+
+  <FrameLayout
+      android:id="@+id/controls_panel"
+      android:layout_width="match_parent"
+      android:layout_height="0dp"
+      android:layout_weight="1"
+      android:layout_marginLeft="@dimen/global_actions_side_margin"
+      android:layout_marginRight="@dimen/global_actions_side_margin"
+      android:background="#ff0000"
+      android:padding="@dimen/global_actions_side_margin"
+      android:visibility="gone"
+      />
 </merge>
diff --git a/packages/SystemUI/res/values-sw600dp-land/dimens.xml b/packages/SystemUI/res/values-sw600dp-land/dimens.xml
index b24ce12..6c7cab5 100644
--- a/packages/SystemUI/res/values-sw600dp-land/dimens.xml
+++ b/packages/SystemUI/res/values-sw600dp-land/dimens.xml
@@ -24,6 +24,7 @@
     <!-- margin from keyguard status bar to clock. For split shade it should be
          keyguard_split_shade_top_margin - status_bar_header_height_keyguard = 8dp -->
     <dimen name="keyguard_clock_top_margin">8dp</dimen>
+    <dimen name="keyguard_smartspace_top_offset">0dp</dimen>
 
     <!-- QS-->
     <dimen name="qs_panel_padding_top">16dp</dimen>
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 5086cd7..3e7b0f1 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -1321,6 +1321,9 @@
     <!-- QR Code Scanner label, title [CHAR LIMIT=32] -->
     <string name="qr_code_scanner_title">QR code scanner</string>
 
+    <!-- QR Code Scanner Secondary label when GMS Core is Updating -->
+    <string name="qr_code_scanner_updating_secondary_label">Updating</string>
+
     <!-- Name of the work status bar icon. -->
     <string name="status_bar_work">Work profile</string>
 
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardConstants.java b/packages/SystemUI/src/com/android/keyguard/KeyguardConstants.java
index b2658c9..a5b62b6 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardConstants.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardConstants.java
@@ -29,5 +29,4 @@
      */
     public static final boolean DEBUG = Log.isLoggable("Keyguard", Log.DEBUG);
     public static final boolean DEBUG_SIM_STATES = true;
-    public static final boolean DEBUG_BIOMETRIC_WAKELOCK = true;
 }
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
index 88477aaa..331497e 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
@@ -845,6 +845,7 @@
                     + " triggered while waiting for cancellation, removing watchdog");
             mHandler.removeCallbacks(mFpCancelNotReceived);
         }
+        mLogger.d("handleFingerprintAuthFailed");
         for (int i = 0; i < mCallbacks.size(); i++) {
             KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
             if (cb != null) {
@@ -974,6 +975,7 @@
             stopListeningForFace(FACE_AUTH_STOPPED_FP_LOCKED_OUT);
         }
 
+        mLogger.logFingerprintError(msgId, errString);
         for (int i = 0; i < mCallbacks.size(); i++) {
             KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
             if (cb != null) {
@@ -3900,6 +3902,8 @@
             pw.println("    listening: actual=" + mFaceRunningState
                     + " expected=(" + (shouldListenForFace() ? 1 : 0));
             pw.println("    strongAuthFlags=" + Integer.toHexString(strongAuthFlags));
+            pw.println("    isNonStrongBiometricAllowedAfterIdleTimeout="
+                    + mStrongAuthTracker.isNonStrongBiometricAllowedAfterIdleTimeout(userId));
             pw.println("    trustManaged=" + getUserTrustIsManaged(userId));
             pw.println("    mFaceLockedOutPermanent=" + mFaceLockedOutPermanent);
             pw.println("    enabledByUser=" + mBiometricEnabledForUser.get(userId));
diff --git a/packages/SystemUI/src/com/android/keyguard/logging/BiometricMessageDeferralLogger.kt b/packages/SystemUI/src/com/android/keyguard/logging/BiometricMessageDeferralLogger.kt
index 6264ce7..2bb75aa 100644
--- a/packages/SystemUI/src/com/android/keyguard/logging/BiometricMessageDeferralLogger.kt
+++ b/packages/SystemUI/src/com/android/keyguard/logging/BiometricMessageDeferralLogger.kt
@@ -17,7 +17,7 @@
 package com.android.keyguard.logging
 
 import com.android.systemui.dagger.SysUISingleton
-import com.android.systemui.log.dagger.BiometricMessagesLog
+import com.android.systemui.log.dagger.BiometricLog
 import com.android.systemui.plugins.log.LogBuffer
 import com.android.systemui.plugins.log.LogLevel.DEBUG
 import javax.inject.Inject
@@ -26,7 +26,7 @@
 @SysUISingleton
 class FaceMessageDeferralLogger
 @Inject
-constructor(@BiometricMessagesLog private val logBuffer: LogBuffer) :
+constructor(@BiometricLog private val logBuffer: LogBuffer) :
     BiometricMessageDeferralLogger(logBuffer, "FaceMessageDeferralLogger")
 
 open class BiometricMessageDeferralLogger(
diff --git a/packages/SystemUI/src/com/android/keyguard/logging/BiometricUnlockLogger.kt b/packages/SystemUI/src/com/android/keyguard/logging/BiometricUnlockLogger.kt
new file mode 100644
index 0000000..bc0bd8c
--- /dev/null
+++ b/packages/SystemUI/src/com/android/keyguard/logging/BiometricUnlockLogger.kt
@@ -0,0 +1,174 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.keyguard.logging
+
+import com.android.systemui.dagger.SysUISingleton
+import com.android.systemui.log.dagger.BiometricLog
+import com.android.systemui.plugins.log.LogBuffer
+import com.android.systemui.plugins.log.LogLevel
+import com.android.systemui.plugins.log.LogLevel.DEBUG
+import com.android.systemui.plugins.log.LogLevel.INFO
+import com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_DISMISS_BOUNCER
+import com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_NONE
+import com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_ONLY_WAKE
+import com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_SHOW_BOUNCER
+import com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_UNLOCK_COLLAPSING
+import com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_WAKE_AND_UNLOCK
+import com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_WAKE_AND_UNLOCK_FROM_DREAM
+import com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_WAKE_AND_UNLOCK_PULSING
+import com.google.errorprone.annotations.CompileTimeConstant
+import javax.inject.Inject
+
+private const val TAG = "BiometricUnlockLogger"
+
+/** Helper class for logging for [com.android.systemui.statusbar.phone.BiometricUnlockController] */
+@SysUISingleton
+class BiometricUnlockLogger @Inject constructor(@BiometricLog private val logBuffer: LogBuffer) {
+    fun i(@CompileTimeConstant msg: String) = log(msg, INFO)
+    fun d(@CompileTimeConstant msg: String) = log(msg, DEBUG)
+    fun log(@CompileTimeConstant msg: String, level: LogLevel) = logBuffer.log(TAG, level, msg)
+
+    fun logStartWakeAndUnlock(mode: Int) {
+        logBuffer.log(
+            TAG,
+            DEBUG,
+            { int1 = mode },
+            { "startWakeAndUnlock(${wakeAndUnlockModeToString(int1)})" }
+        )
+    }
+
+    fun logUdfpsAttemptThresholdMet(consecutiveFailedAttempts: Int) {
+        logBuffer.log(
+            TAG,
+            DEBUG,
+            { int1 = consecutiveFailedAttempts },
+            { "udfpsAttemptThresholdMet consecutiveFailedAttempts=$int1" }
+        )
+    }
+
+    fun logCalculateModeForFingerprintUnlockingAllowed(
+        deviceInteractive: Boolean,
+        keyguardShowing: Boolean,
+        deviceDreaming: Boolean
+    ) {
+        logBuffer.log(
+            TAG,
+            DEBUG,
+            {
+                bool1 = deviceInteractive
+                bool2 = keyguardShowing
+                bool3 = deviceDreaming
+            },
+            {
+                "calculateModeForFingerprint unlockingAllowed=true" +
+                    " deviceInteractive=$bool1 isKeyguardShowing=$bool2" +
+                    " deviceDreaming=$bool3"
+            }
+        )
+    }
+
+    fun logCalculateModeForFingerprintUnlockingNotAllowed(
+        strongBiometric: Boolean,
+        strongAuthFlags: Int,
+        nonStrongBiometricAllowed: Boolean,
+        deviceInteractive: Boolean,
+        keyguardShowing: Boolean
+    ) {
+        logBuffer.log(
+            TAG,
+            DEBUG,
+            {
+                int1 = strongAuthFlags
+                bool1 = strongBiometric
+                bool2 = nonStrongBiometricAllowed
+                bool3 = deviceInteractive
+                bool4 = keyguardShowing
+            },
+            {
+                "calculateModeForFingerprint unlockingAllowed=false" +
+                    " strongBiometric=$bool1 strongAuthFlags=$int1" +
+                    " nonStrongBiometricAllowed=$bool2" +
+                    " deviceInteractive=$bool3 isKeyguardShowing=$bool4"
+            }
+        )
+    }
+
+    fun logCalculateModeForPassiveAuthUnlockingAllowed(
+        deviceInteractive: Boolean,
+        keyguardShowing: Boolean,
+        deviceDreaming: Boolean,
+        bypass: Boolean
+    ) {
+        logBuffer.log(
+            TAG,
+            DEBUG,
+            {
+                bool1 = deviceInteractive
+                bool2 = keyguardShowing
+                bool3 = deviceDreaming
+                bool4 = bypass
+            },
+            {
+                "calculateModeForPassiveAuth unlockingAllowed=true" +
+                    " deviceInteractive=$bool1 isKeyguardShowing=$bool2" +
+                    " deviceDreaming=$bool3 bypass=$bool4"
+            }
+        )
+    }
+
+    fun logCalculateModeForPassiveAuthUnlockingNotAllowed(
+        strongBiometric: Boolean,
+        strongAuthFlags: Int,
+        nonStrongBiometricAllowed: Boolean,
+        deviceInteractive: Boolean,
+        keyguardShowing: Boolean,
+        bypass: Boolean
+    ) {
+        logBuffer.log(
+            TAG,
+            DEBUG,
+            {
+                int1 = if (strongBiometric) 1 else 0
+                int2 = strongAuthFlags
+                bool1 = nonStrongBiometricAllowed
+                bool2 = deviceInteractive
+                bool3 = keyguardShowing
+                bool4 = bypass
+            },
+            {
+                "calculateModeForPassiveAuth unlockingAllowed=false" +
+                    " strongBiometric=${int1 == 1}" +
+                    " strongAuthFlags=$int2 nonStrongBiometricAllowed=$bool1" +
+                    " deviceInteractive=$bool2 isKeyguardShowing=$bool3 bypass=$bool4"
+            }
+        )
+    }
+}
+
+private fun wakeAndUnlockModeToString(mode: Int): String {
+    return when (mode) {
+        MODE_NONE -> "MODE_NONE"
+        MODE_WAKE_AND_UNLOCK -> "MODE_WAKE_AND_UNLOCK"
+        MODE_WAKE_AND_UNLOCK_PULSING -> "MODE_WAKE_AND_UNLOCK_PULSING"
+        MODE_SHOW_BOUNCER -> "MODE_SHOW_BOUNCER"
+        MODE_ONLY_WAKE -> "MODE_ONLY_WAKE"
+        MODE_UNLOCK_COLLAPSING -> "MODE_UNLOCK_COLLAPSING"
+        MODE_WAKE_AND_UNLOCK_FROM_DREAM -> "MODE_WAKE_AND_UNLOCK_FROM_DREAM"
+        MODE_DISMISS_BOUNCER -> "MODE_DISMISS_BOUNCER"
+        else -> "UNKNOWN{$mode}"
+    }
+}
diff --git a/packages/SystemUI/src/com/android/keyguard/logging/KeyguardUpdateMonitorLogger.kt b/packages/SystemUI/src/com/android/keyguard/logging/KeyguardUpdateMonitorLogger.kt
index 6763700..1f6441a 100644
--- a/packages/SystemUI/src/com/android/keyguard/logging/KeyguardUpdateMonitorLogger.kt
+++ b/packages/SystemUI/src/com/android/keyguard/logging/KeyguardUpdateMonitorLogger.kt
@@ -161,6 +161,13 @@
         }, {"Fingerprint auth successful: userId: $int1, isStrongBiometric: $bool1"})
     }
 
+    fun logFingerprintError(msgId: Int, originalErrMsg: String) {
+        logBuffer.log(TAG, DEBUG, {
+            str1 = originalErrMsg
+            int1 = msgId
+        }, { "Fingerprint error received: $str1 msgId= $int1" })
+    }
+
     fun logInvalidSubId(subId: Int) {
         logBuffer.log(TAG, INFO,
                 { int1 = subId },
diff --git a/packages/SystemUI/src/com/android/systemui/controls/controller/ControlsController.kt b/packages/SystemUI/src/com/android/systemui/controls/controller/ControlsController.kt
index 31fadb1..2f49c3f 100644
--- a/packages/SystemUI/src/com/android/systemui/controls/controller/ControlsController.kt
+++ b/packages/SystemUI/src/com/android/systemui/controls/controller/ControlsController.kt
@@ -24,6 +24,7 @@
 import com.android.systemui.util.UserAwareController
 import com.android.systemui.controls.management.ControlsFavoritingActivity
 import com.android.systemui.controls.ui.ControlsUiController
+import com.android.systemui.controls.ui.SelectedItem
 import java.util.function.Consumer
 
 /**
@@ -184,8 +185,8 @@
      */
     fun countFavoritesForComponent(componentName: ComponentName): Int
 
-    /** See [ControlsUiController.getPreferredStructure]. */
-    fun getPreferredStructure(): StructureInfo
+    /** See [ControlsUiController.getPreferredSelectedItem]. */
+    fun getPreferredSelection(): SelectedItem
 
     /**
      * Interface for structure to pass data to [ControlsFavoritingActivity].
diff --git a/packages/SystemUI/src/com/android/systemui/controls/controller/ControlsControllerImpl.kt b/packages/SystemUI/src/com/android/systemui/controls/controller/ControlsControllerImpl.kt
index 50ce9d4..bdfe1fb 100644
--- a/packages/SystemUI/src/com/android/systemui/controls/controller/ControlsControllerImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/controls/controller/ControlsControllerImpl.kt
@@ -38,6 +38,7 @@
 import com.android.systemui.controls.ControlsServiceInfo
 import com.android.systemui.controls.management.ControlsListingController
 import com.android.systemui.controls.ui.ControlsUiController
+import com.android.systemui.controls.ui.SelectedItem
 import com.android.systemui.dagger.SysUISingleton
 import com.android.systemui.dagger.qualifiers.Background
 import com.android.systemui.dump.DumpManager
@@ -556,8 +557,8 @@
         )
     }
 
-    override fun getPreferredStructure(): StructureInfo {
-        return uiController.getPreferredStructure(getFavorites())
+    override fun getPreferredSelection(): SelectedItem {
+        return uiController.getPreferredSelectedItem(getFavorites())
     }
 
     override fun dump(pw: PrintWriter, args: Array<out String>) {
diff --git a/packages/SystemUI/src/com/android/systemui/controls/controller/StructureInfo.kt b/packages/SystemUI/src/com/android/systemui/controls/controller/StructureInfo.kt
index 34bfa13..c8090bf 100644
--- a/packages/SystemUI/src/com/android/systemui/controls/controller/StructureInfo.kt
+++ b/packages/SystemUI/src/com/android/systemui/controls/controller/StructureInfo.kt
@@ -31,4 +31,9 @@
     val componentName: ComponentName,
     val structure: CharSequence,
     val controls: List<ControlInfo>
-)
+) {
+    companion object {
+        val EMPTY_COMPONENT = ComponentName("", "")
+        val EMPTY_STRUCTURE = StructureInfo(EMPTY_COMPONENT, "", mutableListOf())
+    }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/controls/management/AppAdapter.kt b/packages/SystemUI/src/com/android/systemui/controls/management/AppAdapter.kt
index 2389ad1..753d5ad 100644
--- a/packages/SystemUI/src/com/android/systemui/controls/management/AppAdapter.kt
+++ b/packages/SystemUI/src/com/android/systemui/controls/management/AppAdapter.kt
@@ -64,7 +64,8 @@
                 val localeComparator = compareBy<ControlsServiceInfo, CharSequence>(collator) {
                     it.loadLabel() ?: ""
                 }
-                listOfServices = serviceInfos.sortedWith(localeComparator)
+                listOfServices = serviceInfos.filter { it.panelActivity == null }
+                        .sortedWith(localeComparator)
                 uiExecutor.execute(::notifyDataSetChanged)
             }
         }
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 d3b5d0e..bd704c1 100644
--- a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsActivity.kt
+++ b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsActivity.kt
@@ -27,10 +27,13 @@
 import android.view.ViewGroup
 import android.view.WindowInsets
 import android.view.WindowInsets.Type
+import android.view.WindowManager
 import androidx.activity.ComponentActivity
 import com.android.systemui.R
 import com.android.systemui.broadcast.BroadcastDispatcher
 import com.android.systemui.controls.management.ControlsAnimations
+import com.android.systemui.flags.FeatureFlags
+import com.android.systemui.flags.Flags
 import javax.inject.Inject
 
 /**
@@ -44,6 +47,7 @@
     private val uiController: ControlsUiController,
     private val broadcastDispatcher: BroadcastDispatcher,
     private val dreamManager: IDreamManager,
+    private val featureFlags: FeatureFlags
 ) : ComponentActivity() {
 
     private lateinit var parent: ViewGroup
@@ -52,6 +56,9 @@
 
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
+        if (featureFlags.isEnabled(Flags.USE_APP_PANELS)) {
+            window.addPrivateFlags(WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY)
+        }
 
         setContentView(R.layout.controls_fullscreen)
 
diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiController.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiController.kt
index c1cfbcb..f5c5905 100644
--- a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiController.kt
+++ b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiController.kt
@@ -35,7 +35,7 @@
 
     /**
      * Returns the preferred activity to start, depending on if the user has favorited any
-     * controls.
+     * controls or whether there are any app providing panels.
      */
     fun resolveActivity(): Class<*>
 
@@ -53,9 +53,43 @@
     )
 
     /**
-     * Returns the structure that is currently preferred by the user.
+     * Returns the element that is currently preferred by the user.
      *
-     * This structure will be the one that appears when the user first opens the controls activity.
+     * This element will be the one that appears when the user first opens the controls activity.
      */
-    fun getPreferredStructure(structures: List<StructureInfo>): StructureInfo
+    fun getPreferredSelectedItem(structures: List<StructureInfo>): SelectedItem
 }
+
+sealed class SelectedItem {
+
+    abstract val name: CharSequence
+    abstract val hasControls: Boolean
+    abstract val componentName: ComponentName
+
+    /**
+     * Represents the currently selected item for a structure.
+     */
+    data class StructureItem(val structure: StructureInfo) : SelectedItem() {
+        override val name: CharSequence = structure.structure
+        override val hasControls: Boolean = structure.controls.isNotEmpty()
+        override val componentName: ComponentName = structure.componentName
+    }
+
+    /**
+     * Represents the currently selected item for a service that provides a panel activity.
+     *
+     * The [componentName] is that of the service, as that is the expected identifier that should
+     * not change (to always provide proper migration).
+     */
+    data class PanelItem(
+            val appName: CharSequence,
+            override val componentName:
+            ComponentName
+    ) : SelectedItem() {
+        override val name: CharSequence = appName
+        override val hasControls: Boolean = true
+    }
+    companion object {
+        val EMPTY_SELECTION: SelectedItem = StructureItem(StructureInfo.EMPTY_STRUCTURE)
+    }
+}
\ No newline at end of file
diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiControllerImpl.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiControllerImpl.kt
index 6cb0e8b..4c8e1ac 100644
--- a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiControllerImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiControllerImpl.kt
@@ -21,6 +21,7 @@
 import android.animation.ObjectAnimator
 import android.app.Activity
 import android.app.ActivityOptions
+import android.app.PendingIntent
 import android.content.ComponentName
 import android.content.Context
 import android.content.Intent
@@ -36,18 +37,22 @@
 import android.view.animation.DecelerateInterpolator
 import android.widget.AdapterView
 import android.widget.ArrayAdapter
+import android.widget.FrameLayout
 import android.widget.ImageView
 import android.widget.LinearLayout
 import android.widget.ListPopupWindow
 import android.widget.Space
 import android.widget.TextView
+import androidx.annotation.VisibleForTesting
+import com.android.systemui.Dumpable
 import com.android.systemui.R
 import com.android.systemui.controls.ControlsMetricsLogger
 import com.android.systemui.controls.ControlsServiceInfo
 import com.android.systemui.controls.CustomIconCache
-import com.android.systemui.controls.controller.ControlInfo
 import com.android.systemui.controls.controller.ControlsController
 import com.android.systemui.controls.controller.StructureInfo
+import com.android.systemui.controls.controller.StructureInfo.Companion.EMPTY_COMPONENT
+import com.android.systemui.controls.controller.StructureInfo.Companion.EMPTY_STRUCTURE
 import com.android.systemui.controls.management.ControlAdapter
 import com.android.systemui.controls.management.ControlsEditingActivity
 import com.android.systemui.controls.management.ControlsFavoritingActivity
@@ -56,16 +61,21 @@
 import com.android.systemui.dagger.SysUISingleton
 import com.android.systemui.dagger.qualifiers.Background
 import com.android.systemui.dagger.qualifiers.Main
+import com.android.systemui.dump.DumpManager
 import com.android.systemui.globalactions.GlobalActionsPopupMenu
 import com.android.systemui.plugins.ActivityStarter
 import com.android.systemui.settings.UserFileManager
 import com.android.systemui.settings.UserTracker
-import com.android.systemui.shade.ShadeController
 import com.android.systemui.statusbar.policy.DeviceControlsControllerImpl
 import com.android.systemui.statusbar.policy.KeyguardStateController
+import com.android.systemui.util.asIndenting
 import com.android.systemui.util.concurrency.DelayableExecutor
+import com.android.systemui.util.indentIfPossible
+import com.android.wm.shell.TaskViewFactory
 import dagger.Lazy
+import java.io.PrintWriter
 import java.text.Collator
+import java.util.Optional
 import java.util.function.Consumer
 import javax.inject.Inject
 
@@ -80,39 +90,34 @@
         val controlsListingController: Lazy<ControlsListingController>,
         val controlActionCoordinator: ControlActionCoordinator,
         private val activityStarter: ActivityStarter,
-        private val shadeController: ShadeController,
         private val iconCache: CustomIconCache,
         private val controlsMetricsLogger: ControlsMetricsLogger,
         private val keyguardStateController: KeyguardStateController,
         private val userFileManager: UserFileManager,
         private val userTracker: UserTracker,
-) : ControlsUiController {
+        private val taskViewFactory: Optional<TaskViewFactory>,
+        dumpManager: DumpManager
+) : ControlsUiController, Dumpable {
 
     companion object {
         private const val PREF_COMPONENT = "controls_component"
-        private const val PREF_STRUCTURE = "controls_structure"
+        private const val PREF_STRUCTURE_OR_APP_NAME = "controls_structure"
+        private const val PREF_IS_PANEL = "controls_is_panel"
 
         private const val FADE_IN_MILLIS = 200L
-
-        private val EMPTY_COMPONENT = ComponentName("", "")
-        private val EMPTY_STRUCTURE = StructureInfo(
-            EMPTY_COMPONENT,
-            "",
-            mutableListOf<ControlInfo>()
-        )
     }
 
-    private var selectedStructure: StructureInfo = EMPTY_STRUCTURE
+    private var selectedItem: SelectedItem = SelectedItem.EMPTY_SELECTION
     private lateinit var allStructures: List<StructureInfo>
     private val controlsById = mutableMapOf<ControlKey, ControlWithState>()
     private val controlViewsById = mutableMapOf<ControlKey, ControlViewHolder>()
     private lateinit var parent: ViewGroup
-    private lateinit var lastItems: List<SelectionItem>
     private var popup: ListPopupWindow? = null
     private var hidden = true
     private lateinit var onDismiss: Runnable
     private val popupThemedContext = ContextThemeWrapper(context, R.style.Control_ListPopupWindow)
     private var retainCache = false
+    private var lastSelections = emptyList<SelectionItem>()
     private val sharedPreferences
         get() = userFileManager.getSharedPreferences(
             fileName = DeviceControlsControllerImpl.PREFS_CONTROLS_FILE,
@@ -120,6 +125,8 @@
             userId = userTracker.userId
         )
 
+    private var taskViewController: PanelTaskViewController? = null
+
     private val collator = Collator.getInstance(context.resources.configuration.locales[0])
     private val localeComparator = compareBy<SelectionItem, CharSequence>(collator) {
         it.getTitle()
@@ -128,10 +135,12 @@
     private val onSeedingComplete = Consumer<Boolean> {
         accepted ->
             if (accepted) {
-                selectedStructure = controlsController.get().getFavorites().maxByOrNull {
+                selectedItem = controlsController.get().getFavorites().maxByOrNull {
                     it.controls.size
-                } ?: EMPTY_STRUCTURE
-                updatePreferences(selectedStructure)
+                }?.let {
+                    SelectedItem.StructureItem(it)
+                } ?: SelectedItem.EMPTY_SELECTION
+                updatePreferences(selectedItem)
             }
             reload(parent)
     }
@@ -139,6 +148,10 @@
     private lateinit var activityContext: Context
     private lateinit var listingCallback: ControlsListingController.ControlsListingCallback
 
+    init {
+        dumpManager.registerDumpable(javaClass.name, this)
+    }
+
     private fun createCallback(
         onResult: (List<SelectionItem>) -> Unit
     ): ControlsListingController.ControlsListingCallback {
@@ -146,7 +159,15 @@
             override fun onServicesUpdated(serviceInfos: List<ControlsServiceInfo>) {
                 val lastItems = serviceInfos.map {
                     val uid = it.serviceInfo.applicationInfo.uid
-                    SelectionItem(it.loadLabel(), "", it.loadIcon(), it.componentName, uid)
+
+                    SelectionItem(
+                            it.loadLabel(),
+                            "",
+                            it.loadIcon(),
+                            it.componentName,
+                            uid,
+                            it.panelActivity
+                    )
                 }
                 uiExecutor.execute {
                     parent.removeAllViews()
@@ -160,11 +181,13 @@
 
     override fun resolveActivity(): Class<*> {
         val allStructures = controlsController.get().getFavorites()
-        val selectedStructure = getPreferredStructure(allStructures)
+        val selected = getPreferredSelectedItem(allStructures)
+        val anyPanels = controlsListingController.get().getCurrentServices()
+                .none { it.panelActivity != null }
 
         return if (controlsController.get().addSeedingFavoritesCallback(onSeedingComplete)) {
             ControlsActivity::class.java
-        } else if (selectedStructure.controls.isEmpty() && allStructures.size <= 1) {
+        } else if (!selected.hasControls && allStructures.size <= 1 && !anyPanels) {
             ControlsProviderSelectorActivity::class.java
         } else {
             ControlsActivity::class.java
@@ -186,31 +209,49 @@
         controlActionCoordinator.activityContext = activityContext
 
         allStructures = controlsController.get().getFavorites()
-        selectedStructure = getPreferredStructure(allStructures)
+        selectedItem = getPreferredSelectedItem(allStructures)
 
         if (controlsController.get().addSeedingFavoritesCallback(onSeedingComplete)) {
             listingCallback = createCallback(::showSeedingView)
-        } else if (selectedStructure.controls.isEmpty() && allStructures.size <= 1) {
+        } else if (
+                selectedItem !is SelectedItem.PanelItem &&
+                !selectedItem.hasControls &&
+                allStructures.size <= 1
+        ) {
             // only show initial view if there are really no favorites across any structure
-            listingCallback = createCallback(::showInitialSetupView)
+            listingCallback = createCallback(::initialView)
         } else {
-            selectedStructure.controls.map {
-                ControlWithState(selectedStructure.componentName, it, null)
-            }.associateByTo(controlsById) {
-                ControlKey(selectedStructure.componentName, it.ci.controlId)
+            val selected = selectedItem
+            if (selected is SelectedItem.StructureItem) {
+                selected.structure.controls.map {
+                    ControlWithState(selected.structure.componentName, it, null)
+                }.associateByTo(controlsById) {
+                    ControlKey(selected.structure.componentName, it.ci.controlId)
+                }
+                controlsController.get().subscribeToFavorites(selected.structure)
             }
             listingCallback = createCallback(::showControlsView)
-            controlsController.get().subscribeToFavorites(selectedStructure)
         }
 
         controlsListingController.get().addCallback(listingCallback)
     }
 
+    private fun initialView(items: List<SelectionItem>) {
+        if (items.any { it.isPanel }) {
+            // We have at least a panel, so we'll end up showing that.
+            showControlsView(items)
+        } else {
+            showInitialSetupView(items)
+        }
+    }
+
     private fun reload(parent: ViewGroup) {
         if (hidden) return
 
         controlsListingController.get().removeCallback(listingCallback)
         controlsController.get().unsubscribe()
+        taskViewController?.dismiss()
+        taskViewController = null
 
         val fadeAnim = ObjectAnimator.ofFloat(parent, "alpha", 1.0f, 0.0f)
         fadeAnim.setInterpolator(AccelerateInterpolator(1.0f))
@@ -290,27 +331,90 @@
     private fun showControlsView(items: List<SelectionItem>) {
         controlViewsById.clear()
 
-        val itemsByComponent = items.associateBy { it.componentName }
-        val itemsWithStructure = mutableListOf<SelectionItem>()
-        allStructures.mapNotNullTo(itemsWithStructure) {
+        val (panels, structures) = items.partition { it.isPanel }
+        val panelComponents = panels.map { it.componentName }.toSet()
+
+        val itemsByComponent = structures.associateBy { it.componentName }
+                .filterNot { it.key in panelComponents }
+        val panelsAndStructures = mutableListOf<SelectionItem>()
+        allStructures.mapNotNullTo(panelsAndStructures) {
             itemsByComponent.get(it.componentName)?.copy(structure = it.structure)
         }
-        itemsWithStructure.sortWith(localeComparator)
+        panelsAndStructures.addAll(panels)
 
-        val selectionItem = findSelectionItem(selectedStructure, itemsWithStructure) ?: items[0]
+        panelsAndStructures.sortWith(localeComparator)
 
-        controlsMetricsLogger.refreshBegin(selectionItem.uid, !keyguardStateController.isUnlocked())
+        lastSelections = panelsAndStructures
 
-        createListView(selectionItem)
-        createDropDown(itemsWithStructure, selectionItem)
+        val selectionItem = findSelectionItem(selectedItem, panelsAndStructures)
+                ?: if (panels.isNotEmpty()) {
+                    // If we couldn't find a good selected item, but there's at least one panel,
+                    // show a panel.
+                    panels[0]
+                } else {
+                    items[0]
+                }
+
+        maybeUpdateSelectedItem(selectionItem)
+
+        createControlsSpaceFrame()
+
+        if (taskViewFactory.isPresent && selectionItem.isPanel) {
+            createPanelView(selectionItem.panelComponentName!!)
+        } else if (!selectionItem.isPanel) {
+            controlsMetricsLogger
+                    .refreshBegin(selectionItem.uid, !keyguardStateController.isUnlocked())
+            createListView(selectionItem)
+        } else {
+            Log.w(ControlsUiController.TAG, "Not TaskViewFactory to display panel $selectionItem")
+        }
+
+        createDropDown(panelsAndStructures, selectionItem)
         createMenu()
     }
 
-    private fun createMenu() {
-        val items = arrayOf(
-            context.resources.getString(R.string.controls_menu_add),
-            context.resources.getString(R.string.controls_menu_edit)
+    private fun createPanelView(componentName: ComponentName) {
+        val pendingIntent = PendingIntent.getActivity(
+                context,
+                0,
+                Intent().setComponent(componentName),
+                PendingIntent.FLAG_IMMUTABLE
         )
+
+        parent.requireViewById<View>(R.id.controls_scroll_view).visibility = View.GONE
+        val container = parent.requireViewById<FrameLayout>(R.id.controls_panel)
+        container.visibility = View.VISIBLE
+        container.post {
+            taskViewFactory.get().create(activityContext, uiExecutor) { taskView ->
+                taskViewController = PanelTaskViewController(
+                        activityContext,
+                        uiExecutor,
+                        pendingIntent,
+                        taskView,
+                        onDismiss::run
+                ).also {
+                    container.addView(taskView)
+                    it.launchTaskView()
+                }
+            }
+        }
+    }
+
+    private fun createMenu() {
+        val isPanel = selectedItem is SelectedItem.PanelItem
+        val selectedStructure = (selectedItem as? SelectedItem.StructureItem)?.structure
+                ?: EMPTY_STRUCTURE
+
+        val items = if (isPanel) {
+            arrayOf(
+                    context.resources.getString(R.string.controls_menu_add),
+            )
+        } else {
+            arrayOf(
+                    context.resources.getString(R.string.controls_menu_add),
+                    context.resources.getString(R.string.controls_menu_edit)
+            )
+        }
         var adapter = ArrayAdapter<String>(context, R.layout.controls_more_item, items)
 
         val anchor = parent.requireViewById<ImageView>(R.id.controls_more)
@@ -331,7 +435,13 @@
                         ) {
                             when (pos) {
                                 // 0: Add Control
-                                0 -> startFavoritingActivity(selectedStructure)
+                                0 -> {
+                                    if (isPanel) {
+                                        startProviderSelectorActivity()
+                                    } else {
+                                        startFavoritingActivity(selectedStructure)
+                                    }
+                                }
                                 // 1: Edit controls
                                 1 -> startEditingActivity(selectedStructure)
                             }
@@ -353,6 +463,9 @@
             addAll(items)
         }
 
+        val iconSize = context.resources
+                .getDimensionPixelSize(R.dimen.controls_header_app_icon_size)
+
         /*
          * Default spinner widget does not work with the window type required
          * for this dialog. Use a textView with the ListPopupWindow to achieve
@@ -363,14 +476,21 @@
             // override the default color on the dropdown drawable
             (getBackground() as LayerDrawable).getDrawable(0)
                 .setTint(context.resources.getColor(R.color.control_spinner_dropdown, null))
-        }
-
-        if (items.size == 1) {
-            spinner.setBackground(null)
-            return
+            selected.icon.setBounds(0, 0, iconSize, iconSize)
+            compoundDrawablePadding = (iconSize / 2.4f).toInt()
+            setCompoundDrawablesRelative(selected.icon, null, null, null)
         }
 
         val anchor = parent.requireViewById<ViewGroup>(R.id.controls_header)
+        if (items.size == 1) {
+            spinner.setBackground(null)
+            anchor.setOnClickListener(null)
+            return
+        } else {
+            spinner.background = parent.context.resources
+                    .getDrawable(R.drawable.control_spinner_background)
+        }
+
         anchor.setOnClickListener(object : View.OnClickListener {
             override fun onClick(v: View) {
                 popup = GlobalActionsPopupMenu(
@@ -398,14 +518,20 @@
         })
     }
 
-    private fun createListView(selected: SelectionItem) {
-        val inflater = LayoutInflater.from(context)
+    private fun createControlsSpaceFrame() {
+        val inflater = LayoutInflater.from(activityContext)
         inflater.inflate(R.layout.controls_with_favorites, parent, true)
 
         parent.requireViewById<ImageView>(R.id.controls_close).apply {
             setOnClickListener { _: View -> onDismiss.run() }
             visibility = View.VISIBLE
         }
+    }
+
+    private fun createListView(selected: SelectionItem) {
+        if (selectedItem !is SelectedItem.StructureItem) return
+        val selectedStructure = (selectedItem as SelectedItem.StructureItem).structure
+        val inflater = LayoutInflater.from(activityContext)
 
         val maxColumns = ControlAdapter.findMaxColumns(activityContext.resources)
 
@@ -453,35 +579,51 @@
         }
     }
 
-    override fun getPreferredStructure(structures: List<StructureInfo>): StructureInfo {
-        if (structures.isEmpty()) return EMPTY_STRUCTURE
+    override fun getPreferredSelectedItem(structures: List<StructureInfo>): SelectedItem {
+        val sp = sharedPreferences
 
-        val component = sharedPreferences.getString(PREF_COMPONENT, null)?.let {
+        val component = sp.getString(PREF_COMPONENT, null)?.let {
             ComponentName.unflattenFromString(it)
         } ?: EMPTY_COMPONENT
-        val structure = sharedPreferences.getString(PREF_STRUCTURE, "")
-
-        return structures.firstOrNull {
-            component == it.componentName && structure == it.structure
-        } ?: structures.get(0)
+        val name = sp.getString(PREF_STRUCTURE_OR_APP_NAME, "")!!
+        val isPanel = sp.getBoolean(PREF_IS_PANEL, false)
+        return if (isPanel) {
+            SelectedItem.PanelItem(name, component)
+        } else {
+            if (structures.isEmpty()) return SelectedItem.EMPTY_SELECTION
+            SelectedItem.StructureItem(structures.firstOrNull {
+                component == it.componentName && name == it.structure
+            } ?: structures.get(0))
+        }
     }
 
-    private fun updatePreferences(si: StructureInfo) {
-        if (si == EMPTY_STRUCTURE) return
+    private fun updatePreferences(si: SelectedItem) {
         sharedPreferences.edit()
-            .putString(PREF_COMPONENT, si.componentName.flattenToString())
-            .putString(PREF_STRUCTURE, si.structure.toString())
-            .commit()
+                .putString(PREF_COMPONENT, si.componentName.flattenToString())
+                .putString(PREF_STRUCTURE_OR_APP_NAME, si.name.toString())
+                .putBoolean(PREF_IS_PANEL, si is SelectedItem.PanelItem)
+                .commit()
+    }
+
+    private fun maybeUpdateSelectedItem(item: SelectionItem): Boolean {
+        val newSelection = if (item.isPanel) {
+            SelectedItem.PanelItem(item.appName, item.componentName)
+        } else {
+            SelectedItem.StructureItem(allStructures.firstOrNull {
+                it.structure == item.structure && it.componentName == item.componentName
+            } ?: EMPTY_STRUCTURE)
+        }
+        return if (newSelection != selectedItem ) {
+            selectedItem = newSelection
+            updatePreferences(selectedItem)
+            true
+        } else {
+            false
+        }
     }
 
     private fun switchAppOrStructure(item: SelectionItem) {
-        val newSelection = allStructures.first {
-            it.structure == item.structure && it.componentName == item.componentName
-        }
-
-        if (newSelection != selectedStructure) {
-            selectedStructure = newSelection
-            updatePreferences(selectedStructure)
+        if (maybeUpdateSelectedItem(item)) {
             reload(parent)
         }
     }
@@ -505,6 +647,8 @@
 
         closeDialogs(true)
         controlsController.get().unsubscribe()
+        taskViewController?.dismiss()
+        taskViewController = null
 
         parent.removeAllViews()
         controlsById.clear()
@@ -545,20 +689,46 @@
         return row
     }
 
-    private fun findSelectionItem(si: StructureInfo, items: List<SelectionItem>): SelectionItem? =
-        items.firstOrNull {
-            it.componentName == si.componentName && it.structure == si.structure
+    private fun findSelectionItem(si: SelectedItem, items: List<SelectionItem>): SelectionItem? =
+        items.firstOrNull { it.matches(si) }
+
+    override fun dump(pw: PrintWriter, args: Array<out String>) {
+        pw.println("ControlsUiControllerImpl:")
+        pw.asIndenting().indentIfPossible {
+            println("hidden: $hidden")
+            println("selectedItem: $selectedItem")
+            println("lastSelections: $lastSelections")
         }
+    }
 }
 
-private data class SelectionItem(
+@VisibleForTesting
+internal data class SelectionItem(
     val appName: CharSequence,
     val structure: CharSequence,
     val icon: Drawable,
     val componentName: ComponentName,
-    val uid: Int
+    val uid: Int,
+    val panelComponentName: ComponentName?
 ) {
     fun getTitle() = if (structure.isEmpty()) { appName } else { structure }
+
+    val isPanel: Boolean = panelComponentName != null
+
+    fun matches(selectedItem: SelectedItem): Boolean {
+        if (componentName != selectedItem.componentName) {
+            // Not the same component so they are not the same.
+            return false
+        }
+        if (isPanel || selectedItem is SelectedItem.PanelItem) {
+            // As they have the same component, if [this.isPanel] then we may be migrating from
+            // device controls API into panel. Want this to match, even if the selectedItem is not
+            // a panel. We don't want to match on app name because that can change with locale.
+            return true
+        }
+        // Return true if we find a structure with the correct name
+        return structure == (selectedItem as SelectedItem.StructureItem).structure.structure
+    }
 }
 
 private class ItemAdapter(
diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/PanelTaskViewController.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/PanelTaskViewController.kt
new file mode 100644
index 0000000..7143be2
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/controls/ui/PanelTaskViewController.kt
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2022 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.controls.ui
+
+import android.app.ActivityOptions
+import android.app.ActivityTaskManager
+import android.app.ActivityTaskManager.INVALID_TASK_ID
+import android.app.PendingIntent
+import android.content.ComponentName
+import android.content.Context
+import android.content.Intent
+import com.android.systemui.util.boundsOnScreen
+import com.android.wm.shell.TaskView
+import java.util.concurrent.Executor
+
+class PanelTaskViewController(
+    private val activityContext: Context,
+    private val uiExecutor: Executor,
+    private val pendingIntent: PendingIntent,
+    private val taskView: TaskView,
+    private val hide: () -> Unit = {}
+) {
+
+    private var detailTaskId = INVALID_TASK_ID
+
+    private val fillInIntent =
+        Intent().apply {
+            // Apply flags to make behaviour match documentLaunchMode=always.
+            addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+            addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK)
+        }
+
+    private fun removeDetailTask() {
+        if (detailTaskId == INVALID_TASK_ID) return
+        ActivityTaskManager.getInstance().removeTask(detailTaskId)
+        detailTaskId = INVALID_TASK_ID
+    }
+
+    private val stateCallback =
+        object : TaskView.Listener {
+            override fun onInitialized() {
+
+                val options =
+                    ActivityOptions.makeCustomAnimation(
+                        activityContext,
+                        0 /* enterResId */,
+                        0 /* exitResId */
+                    )
+                options.taskAlwaysOnTop = true
+
+                taskView.post {
+                    taskView.startActivity(
+                        pendingIntent,
+                        fillInIntent,
+                        options,
+                        taskView.boundsOnScreen
+                    )
+                }
+            }
+
+            override fun onTaskRemovalStarted(taskId: Int) {
+                detailTaskId = INVALID_TASK_ID
+                dismiss()
+            }
+
+            override fun onTaskCreated(taskId: Int, name: ComponentName?) {
+                detailTaskId = taskId
+            }
+
+            override fun onReleased() {
+                removeDetailTask()
+            }
+
+            override fun onBackPressedOnTaskRoot(taskId: Int) {
+                dismiss()
+                hide()
+            }
+        }
+
+    fun dismiss() {
+        taskView.release()
+    }
+
+    fun launchTaskView() {
+        taskView.setListener(uiExecutor, stateCallback)
+    }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/dump/DumpHandler.kt b/packages/SystemUI/src/com/android/systemui/dump/DumpHandler.kt
index 609bd76..a2f65ba 100644
--- a/packages/SystemUI/src/com/android/systemui/dump/DumpHandler.kt
+++ b/packages/SystemUI/src/com/android/systemui/dump/DumpHandler.kt
@@ -22,7 +22,6 @@
 import com.android.systemui.CoreStartable
 import com.android.systemui.R
 import com.android.systemui.dump.DumpHandler.Companion.PRIORITY_ARG_CRITICAL
-import com.android.systemui.dump.DumpHandler.Companion.PRIORITY_ARG_HIGH
 import com.android.systemui.dump.DumpHandler.Companion.PRIORITY_ARG_NORMAL
 import com.android.systemui.dump.nano.SystemUIProtoDump
 import com.android.systemui.plugins.log.LogBuffer
@@ -148,12 +147,12 @@
     }
 
     private fun dumpCritical(pw: PrintWriter, args: ParsedArgs) {
-        dumpManager.dumpDumpables(pw, args.rawArgs)
+        dumpManager.dumpCritical(pw, args.rawArgs)
         dumpConfig(pw)
     }
 
     private fun dumpNormal(pw: PrintWriter, args: ParsedArgs) {
-        dumpManager.dumpBuffers(pw, args.tailLength)
+        dumpManager.dumpNormal(pw, args.rawArgs, args.tailLength)
         logBufferEulogizer.readEulogyIfPresent(pw)
     }
 
@@ -349,14 +348,12 @@
     companion object {
         const val PRIORITY_ARG = "--dump-priority"
         const val PRIORITY_ARG_CRITICAL = "CRITICAL"
-        const val PRIORITY_ARG_HIGH = "HIGH"
         const val PRIORITY_ARG_NORMAL = "NORMAL"
         const val PROTO = "--proto"
     }
 }
 
-private val PRIORITY_OPTIONS =
-        arrayOf(PRIORITY_ARG_CRITICAL, PRIORITY_ARG_HIGH, PRIORITY_ARG_NORMAL)
+private val PRIORITY_OPTIONS = arrayOf(PRIORITY_ARG_CRITICAL, PRIORITY_ARG_NORMAL)
 
 private val COMMANDS = arrayOf(
         "bugreport-critical",
diff --git a/packages/SystemUI/src/com/android/systemui/dump/DumpManager.kt b/packages/SystemUI/src/com/android/systemui/dump/DumpManager.kt
index ae78089..c982131 100644
--- a/packages/SystemUI/src/com/android/systemui/dump/DumpManager.kt
+++ b/packages/SystemUI/src/com/android/systemui/dump/DumpManager.kt
@@ -40,20 +40,54 @@
     private val buffers: MutableMap<String, RegisteredDumpable<LogBuffer>> = ArrayMap()
 
     /**
-     * Register a dumpable to be called during a bug report. The dumpable will be called during the
-     * CRITICAL section of the bug report, so don't dump an excessive amount of stuff here.
+     * Registers a dumpable to be called during the CRITICAL section of the bug report.
+     *
+     * The CRITICAL section gets very high priority during a dump, but also a very limited amount of
+     * time to do the dumping. So, please don't dump an excessive amount of stuff using CRITICAL.
+     *
+     * See [registerDumpable].
+     */
+    fun registerCriticalDumpable(name: String, module: Dumpable) {
+        registerDumpable(name, module, DumpPriority.CRITICAL)
+    }
+
+    /**
+     * Registers a dumpable to be called during the NORMAL section of the bug report.
+     *
+     * The NORMAL section gets a lower priority during a dump, but also more time. This should be
+     * used by [LogBuffer] instances, [ProtoDumpable] instances, and any [Dumpable] instances that
+     * dump a lot of information.
+     */
+    fun registerNormalDumpable(name: String, module: Dumpable) {
+        registerDumpable(name, module, DumpPriority.NORMAL)
+    }
+
+    /**
+     * Register a dumpable to be called during a bug report.
      *
      * @param name The name to register the dumpable under. This is typically the qualified class
      * name of the thing being dumped (getClass().getName()), but can be anything as long as it
      * doesn't clash with an existing registration.
+     * @param priority the priority level of this dumpable, which affects at what point in the bug
+     * report this gets dump. By default, the dumpable will be called during the CRITICAL section of
+     * the bug report, so don't dump an excessive amount of stuff here.
+     *
+     * TODO(b/259973758): Replace all calls to this method with calls to [registerCriticalDumpable]
+     * or [registerNormalDumpable] instead.
      */
     @Synchronized
-    fun registerDumpable(name: String, module: Dumpable) {
+    @JvmOverloads
+    @Deprecated("Use registerCriticalDumpable or registerNormalDumpable instead")
+    fun registerDumpable(
+        name: String,
+        module: Dumpable,
+        priority: DumpPriority = DumpPriority.CRITICAL,
+    ) {
         if (!canAssignToNameLocked(name, module)) {
             throw IllegalArgumentException("'$name' is already registered")
         }
 
-        dumpables[name] = RegisteredDumpable(name, module)
+        dumpables[name] = RegisteredDumpable(name, module, priority)
     }
 
     /**
@@ -81,7 +115,10 @@
         if (!canAssignToNameLocked(name, buffer)) {
             throw IllegalArgumentException("'$name' is already registered")
         }
-        buffers[name] = RegisteredDumpable(name, buffer)
+
+        // All buffers must be priority NORMAL, not CRITICAL, because they often contain a lot of
+        // data.
+        buffers[name] = RegisteredDumpable(name, buffer, DumpPriority.NORMAL)
     }
 
     /**
@@ -140,7 +177,35 @@
     }
 
     /**
-     * Dumps all registered dumpables to [pw]
+     * Dumps all registered dumpables with critical priority to [pw]
+     */
+    @Synchronized
+    fun dumpCritical(pw: PrintWriter, args: Array<String>) {
+        for (dumpable in dumpables.values) {
+            if (dumpable.priority == DumpPriority.CRITICAL) {
+                dumpDumpable(dumpable, pw, args)
+            }
+        }
+    }
+
+    /**
+     * To [pw], dumps (1) all registered dumpables with normal priority; and (2) all [LogBuffer]s.
+     */
+    @Synchronized
+    fun dumpNormal(pw: PrintWriter, args: Array<String>, tailLength: Int = 0) {
+        for (dumpable in dumpables.values) {
+            if (dumpable.priority == DumpPriority.NORMAL) {
+                dumpDumpable(dumpable, pw, args)
+            }
+        }
+
+        for (buffer in buffers.values) {
+            dumpBuffer(buffer, pw, tailLength)
+        }
+    }
+
+    /**
+     * Dump all the instances of [Dumpable].
      */
     @Synchronized
     fun dumpDumpables(pw: PrintWriter, args: Array<String>) {
@@ -232,7 +297,15 @@
 
 private data class RegisteredDumpable<T>(
     val name: String,
-    val dumpable: T
+    val dumpable: T,
+    val priority: DumpPriority,
 )
 
-private const val TAG = "DumpManager"
+/**
+ * The priority level for a given dumpable, which affects at what point in the bug report this gets
+ * dumped.
+ */
+enum class DumpPriority {
+    CRITICAL,
+    NORMAL,
+}
diff --git a/packages/SystemUI/src/com/android/systemui/flags/FeatureFlagsDebugStartable.kt b/packages/SystemUI/src/com/android/systemui/flags/FeatureFlagsDebugStartable.kt
index 6271334..7189f00 100644
--- a/packages/SystemUI/src/com/android/systemui/flags/FeatureFlagsDebugStartable.kt
+++ b/packages/SystemUI/src/com/android/systemui/flags/FeatureFlagsDebugStartable.kt
@@ -35,7 +35,7 @@
 ) : CoreStartable {
 
     init {
-        dumpManager.registerDumpable(FeatureFlagsDebug.TAG) { pw, args ->
+        dumpManager.registerCriticalDumpable(FeatureFlagsDebug.TAG) { pw, args ->
             featureFlags.dump(pw, args)
         }
     }
diff --git a/packages/SystemUI/src/com/android/systemui/flags/FeatureFlagsReleaseStartable.kt b/packages/SystemUI/src/com/android/systemui/flags/FeatureFlagsReleaseStartable.kt
index e7d8cc3..d088d74 100644
--- a/packages/SystemUI/src/com/android/systemui/flags/FeatureFlagsReleaseStartable.kt
+++ b/packages/SystemUI/src/com/android/systemui/flags/FeatureFlagsReleaseStartable.kt
@@ -29,7 +29,7 @@
 constructor(dumpManager: DumpManager, featureFlags: FeatureFlags) : CoreStartable {
 
     init {
-        dumpManager.registerDumpable(FeatureFlagsRelease.TAG) { pw, args ->
+        dumpManager.registerCriticalDumpable(FeatureFlagsRelease.TAG) { pw, args ->
             featureFlags.dump(pw, args)
         }
     }
diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/MinHeightScrollView.java b/packages/SystemUI/src/com/android/systemui/globalactions/MinHeightScrollView.java
deleted file mode 100644
index 622fa65..0000000
--- a/packages/SystemUI/src/com/android/systemui/globalactions/MinHeightScrollView.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.systemui.globalactions;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.view.View;
-import android.widget.ScrollView;
-
-/**
- * When measured, this view sets the minimum height of its first child to be equal to its own
- * target height.
- *
- * This ensures fall-through click handlers can be placed on this view's child component.
- */
-public class MinHeightScrollView extends ScrollView {
-    public MinHeightScrollView(Context context, AttributeSet attrs) {
-        super(context, attrs);
-    }
-
-    @Override
-    public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
-        View firstChild = getChildAt(0);
-        if (firstChild != null) {
-            firstChild.setMinimumHeight(MeasureSpec.getSize(heightMeasureSpec));
-        }
-        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
-    }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardQuickAffordanceRepository.kt b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardQuickAffordanceRepository.kt
index d300500..d95a1a7 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardQuickAffordanceRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardQuickAffordanceRepository.kt
@@ -18,14 +18,17 @@
 package com.android.systemui.keyguard.data.repository
 
 import android.content.Context
+import com.android.systemui.Dumpable
 import com.android.systemui.R
 import com.android.systemui.dagger.SysUISingleton
 import com.android.systemui.dagger.qualifiers.Application
+import com.android.systemui.dump.DumpManager
 import com.android.systemui.keyguard.data.quickaffordance.KeyguardQuickAffordanceConfig
 import com.android.systemui.keyguard.data.quickaffordance.KeyguardQuickAffordanceLegacySettingSyncer
 import com.android.systemui.keyguard.data.quickaffordance.KeyguardQuickAffordanceSelectionManager
 import com.android.systemui.keyguard.shared.model.KeyguardQuickAffordancePickerRepresentation
 import com.android.systemui.keyguard.shared.model.KeyguardSlotPickerRepresentation
+import java.io.PrintWriter
 import javax.inject.Inject
 import kotlinx.coroutines.CoroutineScope
 import kotlinx.coroutines.flow.SharingStarted
@@ -43,6 +46,7 @@
     private val selectionManager: KeyguardQuickAffordanceSelectionManager,
     legacySettingSyncer: KeyguardQuickAffordanceLegacySettingSyncer,
     private val configs: Set<@JvmSuppressWildcards KeyguardQuickAffordanceConfig>,
+    dumpManager: DumpManager,
 ) {
     /**
      * List of [KeyguardQuickAffordanceConfig] instances of the affordances at the slot with the
@@ -87,6 +91,7 @@
 
     init {
         legacySettingSyncer.startSyncing()
+        dumpManager.registerDumpable("KeyguardQuickAffordances", Dumpster())
     }
 
     /**
@@ -158,6 +163,30 @@
         return _slotPickerRepresentations
     }
 
+    private inner class Dumpster : Dumpable {
+        override fun dump(pw: PrintWriter, args: Array<out String>) {
+            val slotPickerRepresentations = getSlotPickerRepresentations()
+            val selectionsBySlotId = getSelections()
+            pw.println("Slots & selections:")
+            slotPickerRepresentations.forEach { slotPickerRepresentation ->
+                val slotId = slotPickerRepresentation.id
+                val capacity = slotPickerRepresentation.maxSelectedAffordances
+                val affordanceIds = selectionsBySlotId[slotId]
+
+                val selectionText =
+                    if (!affordanceIds.isNullOrEmpty()) {
+                        ": ${affordanceIds.joinToString(", ")}"
+                    } else {
+                        " is empty"
+                    }
+
+                pw.println("    $slotId$selectionText (capacity = $capacity)")
+            }
+            pw.println("Available affordances on device:")
+            configs.forEach { config -> pw.println("    ${config.key} (\"${config.pickerName}\")") }
+        }
+    }
+
     companion object {
         private const val SLOT_CONFIG_DELIMITER = ":"
     }
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBouncerViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBouncerViewBinder.kt
index 59b4adc..f772b17 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBouncerViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBouncerViewBinder.kt
@@ -88,7 +88,7 @@
                 }
             }
         view.repeatWhenAttached {
-            repeatOnLifecycle(Lifecycle.State.STARTED) {
+            repeatOnLifecycle(Lifecycle.State.CREATED) {
                 try {
                     viewModel.setBouncerViewDelegate(delegate)
                     launch {
diff --git a/packages/SystemUI/src/com/android/systemui/log/dagger/BiometricMessagesLog.java b/packages/SystemUI/src/com/android/systemui/log/dagger/BiometricLog.java
similarity index 95%
rename from packages/SystemUI/src/com/android/systemui/log/dagger/BiometricMessagesLog.java
rename to packages/SystemUI/src/com/android/systemui/log/dagger/BiometricLog.java
index eeadf40..4b774d3 100644
--- a/packages/SystemUI/src/com/android/systemui/log/dagger/BiometricMessagesLog.java
+++ b/packages/SystemUI/src/com/android/systemui/log/dagger/BiometricLog.java
@@ -29,5 +29,5 @@
 @Qualifier
 @Documented
 @Retention(RetentionPolicy.RUNTIME)
-public @interface BiometricMessagesLog {
+public @interface BiometricLog {
 }
diff --git a/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java b/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java
index 9adb855..74d5043 100644
--- a/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java
+++ b/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java
@@ -300,9 +300,9 @@
      */
     @Provides
     @SysUISingleton
-    @BiometricMessagesLog
-    public static LogBuffer provideBiometricMessagesLogBuffer(LogBufferFactory factory) {
-        return factory.create("BiometricMessagesLog", 150);
+    @BiometricLog
+    public static LogBuffer provideBiometricLogBuffer(LogBufferFactory factory) {
+        return factory.create("BiometricLog", 200);
     }
 
     /**
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/DeviceControlsTile.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/DeviceControlsTile.kt
index c65bd9b..41d8549 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/DeviceControlsTile.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/DeviceControlsTile.kt
@@ -32,6 +32,7 @@
 import com.android.systemui.controls.dagger.ControlsComponent.Visibility.AVAILABLE
 import com.android.systemui.controls.management.ControlsListingController
 import com.android.systemui.controls.ui.ControlsUiController
+import com.android.systemui.controls.ui.SelectedItem
 import com.android.systemui.dagger.qualifiers.Background
 import com.android.systemui.dagger.qualifiers.Main
 import com.android.systemui.plugins.ActivityStarter
@@ -125,14 +126,15 @@
         state.icon = icon
         if (controlsComponent.isEnabled() && hasControlsApps.get()) {
             if (controlsComponent.getVisibility() == AVAILABLE) {
-                val structureInfo = controlsComponent
-                    .getControlsController().get().getPreferredStructure()
-                state.state = if (structureInfo.controls.isEmpty()) {
+                val selection = controlsComponent
+                    .getControlsController().get().getPreferredSelection()
+                state.state = if (selection is SelectedItem.StructureItem &&
+                        selection.structure.controls.isEmpty()) {
                     Tile.STATE_INACTIVE
                 } else {
                     Tile.STATE_ACTIVE
                 }
-                val label = structureInfo.structure
+                val label = selection.name
                 state.secondaryLabel = if (label == tileLabel) null else label
             } else {
                 state.state = Tile.STATE_INACTIVE
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/QRCodeScannerTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/QRCodeScannerTile.java
index 1a24af1..6d50b56 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/QRCodeScannerTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/QRCodeScannerTile.java
@@ -117,6 +117,10 @@
         state.icon = ResourceIcon.get(R.drawable.ic_qr_code_scanner);
         state.state = mQRCodeScannerController.isAbleToOpenCameraApp() ? Tile.STATE_INACTIVE
                 : Tile.STATE_UNAVAILABLE;
+        // The assumption is that if the OEM has the QR code scanner module enabled then the scanner
+        // would go to "Unavailable" state only when GMS core is updating.
+        state.secondaryLabel = state.state == Tile.STATE_UNAVAILABLE
+                ? mContext.getString(R.string.qr_code_scanner_updating_secondary_label) : null;
     }
 
     @Override
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogController.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogController.java
index 4c7f10e..2e6ea0e 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogController.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogController.java
@@ -142,21 +142,28 @@
     private static final int SUBTITLE_TEXT_ALL_CARRIER_NETWORK_UNAVAILABLE =
             R.string.all_network_unavailable;
     private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
+    private static final TelephonyDisplayInfo DEFAULT_TELEPHONY_DISPLAY_INFO =
+            new TelephonyDisplayInfo(TelephonyManager.NETWORK_TYPE_UNKNOWN,
+                    TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE);
 
     static final int MAX_WIFI_ENTRY_COUNT = 3;
 
     private final FeatureFlags mFeatureFlags;
 
+    @VisibleForTesting
+    /** Should be accessible only to the main thread. */
+    final Map<Integer, TelephonyDisplayInfo> mSubIdTelephonyDisplayInfoMap = new HashMap<>();
+
     private WifiManager mWifiManager;
     private Context mContext;
     private SubscriptionManager mSubscriptionManager;
+    /** Should be accessible only to the main thread. */
     private Map<Integer, TelephonyManager> mSubIdTelephonyManagerMap = new HashMap<>();
+    /** Should be accessible only to the main thread. */
+    private Map<Integer, TelephonyCallback> mSubIdTelephonyCallbackMap = new HashMap<>();
     private TelephonyManager mTelephonyManager;
     private ConnectivityManager mConnectivityManager;
     private CarrierConfigTracker mCarrierConfigTracker;
-    private TelephonyDisplayInfo mTelephonyDisplayInfo =
-            new TelephonyDisplayInfo(TelephonyManager.NETWORK_TYPE_UNKNOWN,
-                    TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE);
     private Handler mHandler;
     private Handler mWorkerHandler;
     private MobileMappings.Config mConfig = null;
@@ -190,8 +197,6 @@
     @VisibleForTesting
     protected SubscriptionManager.OnSubscriptionsChangedListener mOnSubscriptionsChangedListener;
     @VisibleForTesting
-    protected InternetTelephonyCallback mInternetTelephonyCallback;
-    @VisibleForTesting
     protected WifiUtils.InternetIconInjector mWifiIconInjector;
     @VisibleForTesting
     protected boolean mCanConfigWifi;
@@ -290,8 +295,10 @@
         mConfig = MobileMappings.Config.readConfig(mContext);
         mTelephonyManager = mTelephonyManager.createForSubscriptionId(mDefaultDataSubId);
         mSubIdTelephonyManagerMap.put(mDefaultDataSubId, mTelephonyManager);
-        mInternetTelephonyCallback = new InternetTelephonyCallback();
-        mTelephonyManager.registerTelephonyCallback(mExecutor, mInternetTelephonyCallback);
+        InternetTelephonyCallback telephonyCallback =
+                new InternetTelephonyCallback(mDefaultDataSubId);
+        mSubIdTelephonyCallbackMap.put(mDefaultDataSubId, telephonyCallback);
+        mTelephonyManager.registerTelephonyCallback(mExecutor, telephonyCallback);
         // Listen the connectivity changes
         mConnectivityManager.registerDefaultNetworkCallback(mConnectivityManagerNetworkCallback);
         mCanConfigWifi = canConfigWifi;
@@ -304,7 +311,12 @@
         }
         mBroadcastDispatcher.unregisterReceiver(mConnectionStateReceiver);
         for (TelephonyManager tm : mSubIdTelephonyManagerMap.values()) {
-            tm.unregisterTelephonyCallback(mInternetTelephonyCallback);
+            TelephonyCallback callback = mSubIdTelephonyCallbackMap.get(tm.getSubscriptionId());
+            if (callback != null) {
+                tm.unregisterTelephonyCallback(callback);
+            } else if (DEBUG) {
+                Log.e(TAG, "Unexpected null telephony call back for Sub " + tm.getSubscriptionId());
+            }
         }
         mSubscriptionManager.removeOnSubscriptionsChangedListener(
                 mOnSubscriptionsChangedListener);
@@ -623,7 +635,9 @@
             int subId = subInfo.getSubscriptionId();
             if (mSubIdTelephonyManagerMap.get(subId) == null) {
                 TelephonyManager secondaryTm = mTelephonyManager.createForSubscriptionId(subId);
-                secondaryTm.registerTelephonyCallback(mExecutor, mInternetTelephonyCallback);
+                InternetTelephonyCallback telephonyCallback = new InternetTelephonyCallback(subId);
+                secondaryTm.registerTelephonyCallback(mExecutor, telephonyCallback);
+                mSubIdTelephonyCallbackMap.put(subId, telephonyCallback);
                 mSubIdTelephonyManagerMap.put(subId, secondaryTm);
             }
             return subId;
@@ -637,8 +651,7 @@
     }
 
     String getMobileNetworkSummary(int subId) {
-        String description = getNetworkTypeDescription(mContext, mConfig,
-                mTelephonyDisplayInfo, subId);
+        String description = getNetworkTypeDescription(mContext, mConfig, subId);
         return getMobileSummary(mContext, description, subId);
     }
 
@@ -646,7 +659,9 @@
      * Get currently description of mobile network type.
      */
     private String getNetworkTypeDescription(Context context, MobileMappings.Config config,
-            TelephonyDisplayInfo telephonyDisplayInfo, int subId) {
+            int subId) {
+        TelephonyDisplayInfo telephonyDisplayInfo =
+                mSubIdTelephonyDisplayInfoMap.getOrDefault(subId, DEFAULT_TELEPHONY_DISPLAY_INFO);
         String iconKey = getIconKey(telephonyDisplayInfo);
 
         if (mapIconSets(config) == null || mapIconSets(config).get(iconKey) == null) {
@@ -725,11 +740,10 @@
 
     Intent getSubSettingIntent(int subId) {
         final Intent intent = new Intent(Settings.ACTION_NETWORK_OPERATOR_SETTINGS);
-
         final Bundle fragmentArgs = new Bundle();
         // Special contract for Settings to highlight permission row
         fragmentArgs.putString(SETTINGS_EXTRA_FRAGMENT_ARG_KEY, AUTO_DATA_SWITCH_SETTING_R_ID);
-        fragmentArgs.putInt(Settings.EXTRA_SUB_ID, subId);
+        intent.putExtra(Settings.EXTRA_SUB_ID, subId);
         intent.putExtra(SETTINGS_EXTRA_SHOW_FRAGMENT_ARGUMENTS, fragmentArgs);
         return intent;
     }
@@ -1054,6 +1068,11 @@
             TelephonyCallback.SignalStrengthsListener,
             TelephonyCallback.UserMobileDataStateListener {
 
+        private final int mSubId;
+        private InternetTelephonyCallback(int subId) {
+            mSubId = subId;
+        }
+
         @Override
         public void onServiceStateChanged(@NonNull ServiceState serviceState) {
             mCallback.onServiceStateChanged(serviceState);
@@ -1071,7 +1090,7 @@
 
         @Override
         public void onDisplayInfoChanged(@NonNull TelephonyDisplayInfo telephonyDisplayInfo) {
-            mTelephonyDisplayInfo = telephonyDisplayInfo;
+            mSubIdTelephonyDisplayInfoMap.put(mSubId, telephonyDisplayInfo);
             mCallback.onDisplayInfoChanged(telephonyDisplayInfo);
         }
 
@@ -1196,19 +1215,30 @@
             }
             return;
         }
-
-        mDefaultDataSubId = defaultDataSubId;
         if (DEBUG) {
-            Log.d(TAG, "DDS: defaultDataSubId:" + mDefaultDataSubId);
+            Log.d(TAG, "DDS: defaultDataSubId:" + defaultDataSubId);
         }
-        if (SubscriptionManager.isUsableSubscriptionId(mDefaultDataSubId)) {
-            mTelephonyManager.unregisterTelephonyCallback(mInternetTelephonyCallback);
-            mTelephonyManager = mTelephonyManager.createForSubscriptionId(mDefaultDataSubId);
-            mSubIdTelephonyManagerMap.put(mDefaultDataSubId, mTelephonyManager);
-            mTelephonyManager.registerTelephonyCallback(mHandler::post,
-                    mInternetTelephonyCallback);
-            mCallback.onSubscriptionsChanged(mDefaultDataSubId);
+        if (SubscriptionManager.isUsableSubscriptionId(defaultDataSubId)) {
+            // clean up old defaultDataSubId
+            TelephonyCallback oldCallback = mSubIdTelephonyCallbackMap.get(mDefaultDataSubId);
+            if (oldCallback != null) {
+                mTelephonyManager.unregisterTelephonyCallback(oldCallback);
+            } else if (DEBUG) {
+                Log.e(TAG, "Unexpected null telephony call back for Sub " + mDefaultDataSubId);
+            }
+            mSubIdTelephonyCallbackMap.remove(mDefaultDataSubId);
+            mSubIdTelephonyDisplayInfoMap.remove(mDefaultDataSubId);
+            mSubIdTelephonyManagerMap.remove(mDefaultDataSubId);
+
+            // create for new defaultDataSubId
+            mTelephonyManager = mTelephonyManager.createForSubscriptionId(defaultDataSubId);
+            mSubIdTelephonyManagerMap.put(defaultDataSubId, mTelephonyManager);
+            InternetTelephonyCallback newCallback = new InternetTelephonyCallback(defaultDataSubId);
+            mSubIdTelephonyCallbackMap.put(defaultDataSubId, newCallback);
+            mTelephonyManager.registerTelephonyCallback(mHandler::post, newCallback);
+            mCallback.onSubscriptionsChanged(defaultDataSubId);
         }
+        mDefaultDataSubId = defaultDataSubId;
     }
 
     public WifiUtils.InternetIconInjector getWifiIconInjector() {
diff --git a/packages/SystemUI/src/com/android/systemui/shade/transition/ShadeTransitionController.kt b/packages/SystemUI/src/com/android/systemui/shade/transition/ShadeTransitionController.kt
index 1054aa5..07820ec 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/transition/ShadeTransitionController.kt
+++ b/packages/SystemUI/src/com/android/systemui/shade/transition/ShadeTransitionController.kt
@@ -78,7 +78,7 @@
             })
         shadeExpansionStateManager.addExpansionListener(this::onPanelExpansionChanged)
         shadeExpansionStateManager.addStateListener(this::onPanelStateChanged)
-        dumpManager.registerDumpable("ShadeTransitionController") { printWriter, _ ->
+        dumpManager.registerCriticalDumpable("ShadeTransitionController") { printWriter, _ ->
             dump(printWriter)
         }
     }
diff --git a/packages/SystemUI/src/com/android/systemui/shade/transition/SplitShadeOverScroller.kt b/packages/SystemUI/src/com/android/systemui/shade/transition/SplitShadeOverScroller.kt
index fde08ee..f95125f 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/transition/SplitShadeOverScroller.kt
+++ b/packages/SystemUI/src/com/android/systemui/shade/transition/SplitShadeOverScroller.kt
@@ -70,7 +70,7 @@
                     updateResources()
                 }
             })
-        dumpManager.registerDumpable("SplitShadeOverScroller") { printWriter, _ ->
+        dumpManager.registerCriticalDumpable("SplitShadeOverScroller") { printWriter, _ ->
             dump(printWriter)
         }
     }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeDepthController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeDepthController.kt
index b5879ec..8dc7842 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeDepthController.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeDepthController.kt
@@ -304,7 +304,7 @@
     }
 
     init {
-        dumpManager.registerDumpable(javaClass.name, this)
+        dumpManager.registerCriticalDumpable(javaClass.name, this)
         if (WAKE_UP_ANIMATION_ENABLED) {
             keyguardStateController.addCallback(keyguardStateCallback)
         }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/SplitShadeLockScreenOverScroller.kt b/packages/SystemUI/src/com/android/systemui/statusbar/SplitShadeLockScreenOverScroller.kt
index 13d8adb..572c0e0 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/SplitShadeLockScreenOverScroller.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/SplitShadeLockScreenOverScroller.kt
@@ -51,8 +51,8 @@
                     updateResources()
                 }
             })
-        dumpManager.registerDumpable("SplitShadeLockscreenOverScroller") { printWriter, _ ->
-            dump(printWriter)
+        dumpManager.registerCriticalDumpable("SplitShadeLockscreenOverScroller") { pw, _ ->
+            dump(pw)
         }
     }
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableOutlineView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableOutlineView.java
index 4fde5d0..2324627 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableOutlineView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableOutlineView.java
@@ -84,7 +84,7 @@
         int right;
         int bottom;
         int height;
-        float topRoundness = mAlwaysRoundBothCorners ? getMaxRadius() : getTopCornerRadius();
+        float topRadius = mAlwaysRoundBothCorners ? getMaxRadius() : getTopCornerRadius();
         if (!mCustomOutline) {
             // The outline just needs to be shifted if we're translating the contents. Otherwise
             // it's already in the right place.
@@ -97,7 +97,7 @@
             // If the top is rounded we want the bottom to be at most at the top roundness, in order
             // to avoid the shadow changing when scrolling up.
             bottom = Math.max(mMinimumHeightForClipping,
-                    Math.max(getActualHeight() - mClipBottomAmount, (int) (top + topRoundness)));
+                    Math.max(getActualHeight() - mClipBottomAmount, (int) (top + topRadius)));
         } else {
             left = mOutlineRect.left;
             top = mOutlineRect.top;
@@ -108,17 +108,17 @@
         if (height == 0) {
             return EMPTY_PATH;
         }
-        float bottomRoundness = mAlwaysRoundBothCorners ? getMaxRadius() : getBottomCornerRadius();
-        if (topRoundness + bottomRoundness > height) {
-            float overShoot = topRoundness + bottomRoundness - height;
+        float bottomRadius = mAlwaysRoundBothCorners ? getMaxRadius() : getBottomCornerRadius();
+        if (topRadius + bottomRadius > height) {
+            float overShoot = topRadius + bottomRadius - height;
             float currentTopRoundness = getTopRoundness();
             float currentBottomRoundness = getBottomRoundness();
-            topRoundness -= overShoot * currentTopRoundness
+            topRadius -= overShoot * currentTopRoundness
                     / (currentTopRoundness + currentBottomRoundness);
-            bottomRoundness -= overShoot * currentBottomRoundness
+            bottomRadius -= overShoot * currentBottomRoundness
                     / (currentTopRoundness + currentBottomRoundness);
         }
-        getRoundedRectPath(left, top, right, bottom, topRoundness, bottomRoundness, mTmpPath);
+        getRoundedRectPath(left, top, right, bottom, topRadius, bottomRadius, mTmpPath);
         return mTmpPath;
     }
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
index 2c096f5..073bd4b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
@@ -1553,7 +1553,7 @@
             final int pinnedHeight = firstVisibleSection != null
                     ? firstVisibleSection.getFirstVisibleChild().getPinnedHeadsUpHeight()
                     : 0;
-            return mHeadsUpInset + pinnedHeight;
+            return mHeadsUpInset - mAmbientState.getStackTopMargin() + pinnedHeight;
         }
         return getMinExpansionHeight();
     }
@@ -1809,7 +1809,8 @@
     @Override
     @ShadeViewRefactor(RefactorComponent.COORDINATOR)
     public WindowInsets onApplyWindowInsets(WindowInsets insets) {
-        mBottomInset = insets.getSystemWindowInsetBottom();
+        mBottomInset = insets.getSystemWindowInsetBottom()
+                + insets.getInsets(WindowInsets.Type.ime()).bottom;
 
         mWaterfallTopInset = 0;
         final DisplayCutout cutout = insets.getDisplayCutout();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java
index 182d397..679bcea 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java
@@ -29,7 +29,6 @@
 import android.os.PowerManager;
 import android.os.SystemClock;
 import android.os.Trace;
-import android.util.Log;
 
 import androidx.annotation.Nullable;
 
@@ -41,10 +40,10 @@
 import com.android.internal.logging.UiEventLoggerImpl;
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.internal.util.LatencyTracker;
-import com.android.keyguard.KeyguardConstants;
 import com.android.keyguard.KeyguardUpdateMonitor;
 import com.android.keyguard.KeyguardUpdateMonitorCallback;
 import com.android.keyguard.KeyguardViewController;
+import com.android.keyguard.logging.BiometricUnlockLogger;
 import com.android.systemui.Dumpable;
 import com.android.systemui.R;
 import com.android.systemui.biometrics.AuthController;
@@ -79,9 +78,6 @@
  */
 @SysUISingleton
 public class BiometricUnlockController extends KeyguardUpdateMonitorCallback implements Dumpable {
-
-    private static final String TAG = "BiometricUnlockCtrl";
-    private static final boolean DEBUG_BIO_WAKELOCK = KeyguardConstants.DEBUG_BIOMETRIC_WAKELOCK;
     private static final long BIOMETRIC_WAKELOCK_TIMEOUT_MS = 15 * 1000;
     private static final String BIOMETRIC_WAKE_LOCK_NAME = "wake-and-unlock:wakelock";
     private static final UiEventLogger UI_EVENT_LOGGER = new UiEventLoggerImpl();
@@ -176,6 +172,7 @@
     private final StatusBarStateController mStatusBarStateController;
     private final LatencyTracker mLatencyTracker;
     private final VibratorHelper mVibratorHelper;
+    private final BiometricUnlockLogger mLogger;
 
     private long mLastFpFailureUptimeMillis;
     private int mNumConsecutiveFpFailures;
@@ -262,7 +259,8 @@
     private final ScreenOffAnimationController mScreenOffAnimationController;
 
     @Inject
-    public BiometricUnlockController(DozeScrimController dozeScrimController,
+    public BiometricUnlockController(
+            DozeScrimController dozeScrimController,
             KeyguardViewMediator keyguardViewMediator, ScrimController scrimController,
             ShadeController shadeController,
             NotificationShadeWindowController notificationShadeWindowController,
@@ -272,6 +270,7 @@
             KeyguardBypassController keyguardBypassController,
             MetricsLogger metricsLogger, DumpManager dumpManager,
             PowerManager powerManager,
+            BiometricUnlockLogger biometricUnlockLogger,
             NotificationMediaManager notificationMediaManager,
             WakefulnessLifecycle wakefulnessLifecycle,
             ScreenLifecycle screenLifecycle,
@@ -308,6 +307,7 @@
         mSessionTracker = sessionTracker;
         mScreenOffAnimationController = screenOffAnimationController;
         mVibratorHelper = vibrator;
+        mLogger = biometricUnlockLogger;
 
         dumpManager.registerDumpable(getClass().getName(), this);
     }
@@ -329,9 +329,7 @@
     private final Runnable mReleaseBiometricWakeLockRunnable = new Runnable() {
         @Override
         public void run() {
-            if (DEBUG_BIO_WAKELOCK) {
-                Log.i(TAG, "biometric wakelock: TIMEOUT!!");
-            }
+            mLogger.i("biometric wakelock: TIMEOUT!!");
             releaseBiometricWakeLock();
         }
     };
@@ -339,9 +337,7 @@
     private void releaseBiometricWakeLock() {
         if (mWakeLock != null) {
             mHandler.removeCallbacks(mReleaseBiometricWakeLockRunnable);
-            if (DEBUG_BIO_WAKELOCK) {
-                Log.i(TAG, "releasing biometric wakelock");
-            }
+            mLogger.i("releasing biometric wakelock");
             mWakeLock.release();
             mWakeLock = null;
         }
@@ -372,9 +368,7 @@
             Trace.beginSection("acquiring wake-and-unlock");
             mWakeLock.acquire();
             Trace.endSection();
-            if (DEBUG_BIO_WAKELOCK) {
-                Log.i(TAG, "biometric acquired, grabbing biometric wakelock");
-            }
+            mLogger.i("biometric acquired, grabbing biometric wakelock");
             mHandler.postDelayed(mReleaseBiometricWakeLockRunnable,
                     BIOMETRIC_WAKELOCK_TIMEOUT_MS);
         }
@@ -411,7 +405,7 @@
             mKeyguardViewMediator.userActivity();
             startWakeAndUnlock(biometricSourceType, isStrongBiometric);
         } else {
-            Log.d(TAG, "onBiometricAuthenticated aborted by bypass controller");
+            mLogger.d("onBiometricAuthenticated aborted by bypass controller");
         }
     }
 
@@ -427,7 +421,7 @@
     }
 
     public void startWakeAndUnlock(@WakeAndUnlockMode int mode) {
-        Log.v(TAG, "startWakeAndUnlock(" + mode + ")");
+        mLogger.logStartWakeAndUnlock(mode);
         boolean wasDeviceInteractive = mUpdateMonitor.isDeviceInteractive();
         mMode = mode;
         mHasScreenTurnedOnSinceAuthenticating = false;
@@ -442,9 +436,7 @@
         // brightness changes due to display state transitions.
         Runnable wakeUp = ()-> {
             if (!wasDeviceInteractive || mUpdateMonitor.isDreaming()) {
-                if (DEBUG_BIO_WAKELOCK) {
-                    Log.i(TAG, "bio wakelock: Authenticated, waking up...");
-                }
+                mLogger.i("bio wakelock: Authenticated, waking up...");
                 mPowerManager.wakeUp(SystemClock.uptimeMillis(), PowerManager.WAKE_REASON_GESTURE,
                         "android.policy:BIOMETRIC");
             }
@@ -537,13 +529,16 @@
     }
 
     private @WakeAndUnlockMode int calculateModeForFingerprint(boolean isStrongBiometric) {
-        boolean unlockingAllowed =
+        final boolean unlockingAllowed =
                 mUpdateMonitor.isUnlockingWithBiometricAllowed(isStrongBiometric);
-        boolean deviceDreaming = mUpdateMonitor.isDreaming();
+        final boolean deviceInteractive = mUpdateMonitor.isDeviceInteractive();
+        final boolean keyguardShowing = mKeyguardStateController.isShowing();
+        final boolean deviceDreaming = mUpdateMonitor.isDreaming();
 
-        if (!mUpdateMonitor.isDeviceInteractive()) {
-            if (!mKeyguardStateController.isShowing()
-                    && !mScreenOffAnimationController.isKeyguardShowDelayed()) {
+        logCalculateModeForFingerprint(unlockingAllowed, deviceInteractive,
+                keyguardShowing, deviceDreaming, isStrongBiometric);
+        if (!deviceInteractive) {
+            if (!keyguardShowing && !mScreenOffAnimationController.isKeyguardShowDelayed()) {
                 if (mKeyguardStateController.isUnlocked()) {
                     return MODE_WAKE_AND_UNLOCK;
                 }
@@ -559,7 +554,7 @@
         if (unlockingAllowed && deviceDreaming) {
             return MODE_WAKE_AND_UNLOCK_FROM_DREAM;
         }
-        if (mKeyguardStateController.isShowing()) {
+        if (keyguardShowing) {
             if (mKeyguardViewController.primaryBouncerIsOrWillBeShowing() && unlockingAllowed) {
                 return MODE_DISMISS_BOUNCER;
             } else if (unlockingAllowed) {
@@ -571,14 +566,39 @@
         return MODE_NONE;
     }
 
+    private void logCalculateModeForFingerprint(boolean unlockingAllowed, boolean deviceInteractive,
+            boolean keyguardShowing, boolean deviceDreaming, boolean strongBiometric) {
+        if (unlockingAllowed) {
+            mLogger.logCalculateModeForFingerprintUnlockingAllowed(deviceInteractive,
+                    keyguardShowing, deviceDreaming);
+        } else {
+            // if unlocking isn't allowed, log more information about why unlocking may not
+            // have been allowed
+            final int strongAuthFlags = mUpdateMonitor.getStrongAuthTracker().getStrongAuthForUser(
+                    KeyguardUpdateMonitor.getCurrentUser());
+            final boolean nonStrongBiometricAllowed =
+                    mUpdateMonitor.getStrongAuthTracker()
+                            .isNonStrongBiometricAllowedAfterIdleTimeout(
+                                    KeyguardUpdateMonitor.getCurrentUser());
+
+            mLogger.logCalculateModeForFingerprintUnlockingNotAllowed(strongBiometric,
+                    strongAuthFlags, nonStrongBiometricAllowed, deviceInteractive, keyguardShowing);
+        }
+    }
+
     private @WakeAndUnlockMode int calculateModeForPassiveAuth(boolean isStrongBiometric) {
-        boolean unlockingAllowed =
+        final boolean deviceInteractive = mUpdateMonitor.isDeviceInteractive();
+        final boolean isKeyguardShowing = mKeyguardStateController.isShowing();
+        final boolean unlockingAllowed =
                 mUpdateMonitor.isUnlockingWithBiometricAllowed(isStrongBiometric);
-        boolean deviceDreaming = mUpdateMonitor.isDreaming();
-        boolean bypass = mKeyguardBypassController.getBypassEnabled()
+        final boolean deviceDreaming = mUpdateMonitor.isDreaming();
+        final boolean bypass = mKeyguardBypassController.getBypassEnabled()
                 || mAuthController.isUdfpsFingerDown();
-        if (!mUpdateMonitor.isDeviceInteractive()) {
-            if (!mKeyguardStateController.isShowing()) {
+
+        logCalculateModeForPassiveAuth(unlockingAllowed, deviceInteractive, isKeyguardShowing,
+                deviceDreaming, bypass, isStrongBiometric);
+        if (!deviceInteractive) {
+            if (!isKeyguardShowing) {
                 return bypass ? MODE_WAKE_AND_UNLOCK : MODE_ONLY_WAKE;
             } else if (!unlockingAllowed) {
                 return bypass ? MODE_SHOW_BOUNCER : MODE_NONE;
@@ -602,11 +622,11 @@
         if (unlockingAllowed && mKeyguardStateController.isOccluded()) {
             return MODE_UNLOCK_COLLAPSING;
         }
-        if (mKeyguardStateController.isShowing()) {
+        if (isKeyguardShowing) {
             if ((mKeyguardViewController.primaryBouncerIsOrWillBeShowing()
                     || mKeyguardBypassController.getAltBouncerShowing()) && unlockingAllowed) {
                 return MODE_DISMISS_BOUNCER;
-            } else if (unlockingAllowed && (bypass || mAuthController.isUdfpsFingerDown())) {
+            } else if (unlockingAllowed && bypass) {
                 return MODE_UNLOCK_COLLAPSING;
             } else {
                 return bypass ? MODE_SHOW_BOUNCER : MODE_NONE;
@@ -615,6 +635,28 @@
         return MODE_NONE;
     }
 
+    private void logCalculateModeForPassiveAuth(boolean unlockingAllowed,
+            boolean deviceInteractive, boolean keyguardShowing, boolean deviceDreaming,
+            boolean bypass, boolean strongBiometric) {
+        if (unlockingAllowed) {
+            mLogger.logCalculateModeForPassiveAuthUnlockingAllowed(
+                    deviceInteractive, keyguardShowing, deviceDreaming, bypass);
+        } else {
+            // if unlocking isn't allowed, log more information about why unlocking may not
+            // have been allowed
+            final int strongAuthFlags = mUpdateMonitor.getStrongAuthTracker().getStrongAuthForUser(
+                    KeyguardUpdateMonitor.getCurrentUser());
+            final boolean nonStrongBiometricAllowed =
+                    mUpdateMonitor.getStrongAuthTracker()
+                            .isNonStrongBiometricAllowedAfterIdleTimeout(
+                                    KeyguardUpdateMonitor.getCurrentUser());
+
+            mLogger.logCalculateModeForPassiveAuthUnlockingNotAllowed(
+                    strongBiometric, strongAuthFlags, nonStrongBiometricAllowed,
+                    deviceInteractive, keyguardShowing, bypass);
+        }
+    }
+
     @Override
     public void onBiometricAuthFailed(BiometricSourceType biometricSourceType) {
         mMetricsLogger.write(new LogMaker(MetricsEvent.BIOMETRIC_AUTH)
@@ -632,6 +674,7 @@
 
         if (!mVibratorHelper.hasVibrator()
                 && (!mUpdateMonitor.isDeviceInteractive() || mUpdateMonitor.isDreaming())) {
+            mLogger.d("wakeup device on authentication failure (device doesn't have a vibrator)");
             startWakeAndUnlock(MODE_ONLY_WAKE);
         } else if (biometricSourceType == BiometricSourceType.FINGERPRINT
                 && mUpdateMonitor.isUdfpsSupported()) {
@@ -644,6 +687,7 @@
             mLastFpFailureUptimeMillis = currUptimeMillis;
 
             if (mNumConsecutiveFpFailures >= UDFPS_ATTEMPTS_BEFORE_SHOW_BOUNCER) {
+                mLogger.logUdfpsAttemptThresholdMet(mNumConsecutiveFpFailures);
                 startWakeAndUnlock(MODE_SHOW_BOUNCER);
                 UI_EVENT_LOGGER.log(BiometricUiEvent.BIOMETRIC_BOUNCER_SHOWN, getSessionId());
                 mNumConsecutiveFpFailures = 0;
@@ -674,6 +718,7 @@
                 && (msgId == FingerprintManager.FINGERPRINT_ERROR_LOCKOUT
                 || msgId == FingerprintManager.FINGERPRINT_ERROR_LOCKOUT_PERMANENT);
         if (fingerprintLockout) {
+            mLogger.d("fingerprint locked out");
             startWakeAndUnlock(MODE_SHOW_BOUNCER);
             UI_EVENT_LOGGER.log(BiometricUiEvent.BIOMETRIC_BOUNCER_SHOWN, getSessionId());
         }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LetterboxAppearanceCalculator.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LetterboxAppearanceCalculator.kt
index 4496607..3989854 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LetterboxAppearanceCalculator.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LetterboxAppearanceCalculator.kt
@@ -62,7 +62,7 @@
     private var statusBarBoundsProvider: StatusBarBoundsProvider? = null
 
     override fun start() {
-        dumpManager.registerDumpable(javaClass.simpleName) { printWriter, _ -> dump(printWriter) }
+        dumpManager.registerCriticalDumpable(javaClass.simpleName) { pw, _ -> dump(pw) }
     }
 
     override fun stop() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeviceControlsControllerImpl.kt b/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeviceControlsControllerImpl.kt
index e326611..6c66f0b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeviceControlsControllerImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeviceControlsControllerImpl.kt
@@ -140,6 +140,9 @@
                         // is out of sync, perhaps through a device restore, and update the
                         // preference
                         addPackageToSeededSet(prefs, pkg)
+                    } else if (it.panelActivity != null) {
+                        // Do not seed for packages with panels
+                        addPackageToSeededSet(prefs, pkg)
                     } else {
                         componentsToSeed.add(it.componentName)
                     }
diff --git a/packages/SystemUI/src/com/android/systemui/user/domain/interactor/UserInteractor.kt b/packages/SystemUI/src/com/android/systemui/user/domain/interactor/UserInteractor.kt
index 6672469..c5b697c 100644
--- a/packages/SystemUI/src/com/android/systemui/user/domain/interactor/UserInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/user/domain/interactor/UserInteractor.kt
@@ -156,42 +156,64 @@
                 keyguardInteractor.isKeyguardShowing,
             ) { _, userInfos, settings, isDeviceLocked ->
                 buildList {
-                    val hasGuestUser = userInfos.any { it.isGuest }
-                    if (!hasGuestUser && canCreateGuestUser(settings)) {
-                        add(UserActionModel.ENTER_GUEST_MODE)
-                    }
-
                     if (!isDeviceLocked || settings.isAddUsersFromLockscreen) {
                         // The device is locked and our setting to allow actions that add users
-                        // from the lock-screen is not enabled. The guest action from above is
-                        // always allowed, even when the device is locked, but the various "add
-                        // user" actions below are not. We can finish building the list here.
+                        // from the lock-screen is not enabled. We can finish building the list
+                        // here.
+                        val isFullScreen = featureFlags.isEnabled(Flags.FULL_SCREEN_USER_SWITCHER)
 
-                        val canCreateUsers =
-                            UserActionsUtil.canCreateUser(
-                                manager,
-                                repository,
-                                settings.isUserSwitcherEnabled,
-                                settings.isAddUsersFromLockscreen,
-                            )
+                        val actionList: List<UserActionModel> =
+                            if (isFullScreen) {
+                                listOf(
+                                    UserActionModel.ADD_USER,
+                                    UserActionModel.ADD_SUPERVISED_USER,
+                                    UserActionModel.ENTER_GUEST_MODE,
+                                )
+                            } else {
+                                listOf(
+                                    UserActionModel.ENTER_GUEST_MODE,
+                                    UserActionModel.ADD_USER,
+                                    UserActionModel.ADD_SUPERVISED_USER,
+                                )
+                            }
+                        actionList.map {
+                            when (it) {
+                                UserActionModel.ENTER_GUEST_MODE -> {
+                                    val hasGuestUser = userInfos.any { it.isGuest }
+                                    if (!hasGuestUser && canCreateGuestUser(settings)) {
+                                        add(UserActionModel.ENTER_GUEST_MODE)
+                                    }
+                                }
+                                UserActionModel.ADD_USER -> {
+                                    val canCreateUsers =
+                                        UserActionsUtil.canCreateUser(
+                                            manager,
+                                            repository,
+                                            settings.isUserSwitcherEnabled,
+                                            settings.isAddUsersFromLockscreen,
+                                        )
 
-                        if (canCreateUsers) {
-                            add(UserActionModel.ADD_USER)
-                        }
-
-                        if (
-                            UserActionsUtil.canCreateSupervisedUser(
-                                manager,
-                                repository,
-                                settings.isUserSwitcherEnabled,
-                                settings.isAddUsersFromLockscreen,
-                                supervisedUserPackageName,
-                            )
-                        ) {
-                            add(UserActionModel.ADD_SUPERVISED_USER)
+                                    if (canCreateUsers) {
+                                        add(UserActionModel.ADD_USER)
+                                    }
+                                }
+                                UserActionModel.ADD_SUPERVISED_USER -> {
+                                    if (
+                                        UserActionsUtil.canCreateSupervisedUser(
+                                            manager,
+                                            repository,
+                                            settings.isUserSwitcherEnabled,
+                                            settings.isAddUsersFromLockscreen,
+                                            supervisedUserPackageName,
+                                        )
+                                    ) {
+                                        add(UserActionModel.ADD_SUPERVISED_USER)
+                                    }
+                                }
+                                else -> Unit
+                            }
                         }
                     }
-
                     if (
                         UserActionsUtil.canManageUsers(
                             repository,
diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java
index 63b98bb..aa17bf2 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java
@@ -72,7 +72,6 @@
 import android.os.SystemClock;
 import android.os.Trace;
 import android.os.VibrationEffect;
-import android.provider.DeviceConfig;
 import android.provider.Settings;
 import android.provider.Settings.Global;
 import android.text.InputFilter;
@@ -109,8 +108,6 @@
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 
-import com.android.internal.annotations.VisibleForTesting;
-import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
 import com.android.internal.graphics.drawable.BackgroundBlurDrawable;
 import com.android.internal.jank.InteractionJankMonitor;
 import com.android.internal.view.RotationPolicy;
@@ -128,15 +125,11 @@
 import com.android.systemui.statusbar.policy.ConfigurationController;
 import com.android.systemui.statusbar.policy.DeviceProvisionedController;
 import com.android.systemui.util.AlphaTintDrawableWrapper;
-import com.android.systemui.util.DeviceConfigProxy;
 import com.android.systemui.util.RoundedCornerProgressDrawable;
 
 import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Optional;
-import java.util.Set;
-import java.util.concurrent.Executor;
 import java.util.function.Consumer;
 
 /**
@@ -193,9 +186,6 @@
     private ViewGroup mDialogRowsView;
     private ViewGroup mRinger;
 
-    private DeviceConfigProxy mDeviceConfigProxy;
-    private Executor mExecutor;
-
     /**
      * Container for the top part of the dialog, which contains the ringer, the ringer drawer, the
      * volume rows, and the ellipsis button. This does not include the live caption button.
@@ -284,13 +274,6 @@
     private BackgroundBlurDrawable mDialogRowsViewBackground;
     private final InteractionJankMonitor mInteractionJankMonitor;
 
-    private boolean mSeparateNotification;
-
-    @VisibleForTesting
-    int mVolumeRingerIconDrawableId;
-    @VisibleForTesting
-    int mVolumeRingerMuteIconDrawableId;
-
     public VolumeDialogImpl(
             Context context,
             VolumeDialogController volumeDialogController,
@@ -300,9 +283,7 @@
             MediaOutputDialogFactory mediaOutputDialogFactory,
             VolumePanelFactory volumePanelFactory,
             ActivityStarter activityStarter,
-            InteractionJankMonitor interactionJankMonitor,
-            DeviceConfigProxy deviceConfigProxy,
-            Executor executor) {
+            InteractionJankMonitor interactionJankMonitor) {
         mContext =
                 new ContextThemeWrapper(context, R.style.volume_dialog_theme);
         mController = volumeDialogController;
@@ -342,50 +323,6 @@
         }
 
         initDimens();
-
-        mDeviceConfigProxy = deviceConfigProxy;
-        mExecutor = executor;
-        mSeparateNotification = mDeviceConfigProxy.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI,
-                SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION, false);
-        updateRingerModeIconSet();
-    }
-
-    /**
-     * If ringer and notification are the same stream (T and earlier), use notification-like bell
-     * icon set.
-     * If ringer and notification are separated, then use generic speaker icons.
-     */
-    private void updateRingerModeIconSet() {
-        if (mSeparateNotification) {
-            mVolumeRingerIconDrawableId = R.drawable.ic_speaker_on;
-            mVolumeRingerMuteIconDrawableId = R.drawable.ic_speaker_mute;
-        } else {
-            mVolumeRingerIconDrawableId = R.drawable.ic_volume_ringer;
-            mVolumeRingerMuteIconDrawableId = R.drawable.ic_volume_ringer_mute;
-        }
-
-        if (mRingerDrawerMuteIcon != null) {
-            mRingerDrawerMuteIcon.setImageResource(mVolumeRingerMuteIconDrawableId);
-        }
-        if (mRingerDrawerNormalIcon != null) {
-            mRingerDrawerNormalIcon.setImageResource(mVolumeRingerIconDrawableId);
-        }
-    }
-
-    /**
-     * Change icon for ring stream (not ringer mode icon)
-     */
-    private void updateRingRowIcon() {
-        Optional<VolumeRow> volumeRow = mRows.stream().filter(row -> row.stream == STREAM_RING)
-                .findFirst();
-        if (volumeRow.isPresent()) {
-            VolumeRow volRow = volumeRow.get();
-            volRow.iconRes = mSeparateNotification ? R.drawable.ic_ring_volume
-                    : R.drawable.ic_volume_ringer;
-            volRow.iconMuteRes = mSeparateNotification ? R.drawable.ic_ring_volume_off
-                    : R.drawable.ic_volume_ringer_mute;
-            volRow.setIcon(volRow.iconRes, mContext.getTheme());
-        }
     }
 
     @Override
@@ -402,9 +339,6 @@
         mController.getState();
 
         mConfigurationController.addCallback(this);
-
-        mDeviceConfigProxy.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_SYSTEMUI,
-                mExecutor, this::onDeviceConfigChange);
     }
 
     @Override
@@ -412,24 +346,6 @@
         mController.removeCallback(mControllerCallbackH);
         mHandler.removeCallbacksAndMessages(null);
         mConfigurationController.removeCallback(this);
-        mDeviceConfigProxy.removeOnPropertiesChangedListener(this::onDeviceConfigChange);
-    }
-
-    /**
-     * Update ringer mode icon based on the config
-     */
-    private void onDeviceConfigChange(DeviceConfig.Properties properties) {
-        Set<String> changeSet = properties.getKeyset();
-        if (changeSet.contains(SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION)) {
-            boolean newVal = properties.getBoolean(
-                    SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION, false);
-            if (newVal != mSeparateNotification) {
-                mSeparateNotification = newVal;
-                updateRingerModeIconSet();
-                updateRingRowIcon();
-
-            }
-        }
     }
 
     @Override
@@ -636,9 +552,6 @@
         mRingerDrawerNormalIcon = mDialog.findViewById(R.id.volume_drawer_normal_icon);
         mRingerDrawerNewSelectionBg = mDialog.findViewById(R.id.volume_drawer_selection_background);
 
-        mRingerDrawerMuteIcon.setImageResource(mVolumeRingerMuteIconDrawableId);
-        mRingerDrawerNormalIcon.setImageResource(mVolumeRingerIconDrawableId);
-
         setupRingerDrawer();
 
         mODICaptionsView = mDialog.findViewById(R.id.odi_captions);
@@ -662,14 +575,8 @@
             addRow(AudioManager.STREAM_MUSIC,
                     R.drawable.ic_volume_media, R.drawable.ic_volume_media_mute, true, true);
             if (!AudioSystem.isSingleVolume(mContext)) {
-                if (mSeparateNotification) {
-                    addRow(AudioManager.STREAM_RING, R.drawable.ic_ring_volume,
-                            R.drawable.ic_ring_volume_off, true, false);
-                } else {
-                    addRow(AudioManager.STREAM_RING, R.drawable.ic_volume_ringer,
-                            R.drawable.ic_volume_ringer, true, false);
-                }
-
+                addRow(AudioManager.STREAM_RING,
+                        R.drawable.ic_volume_ringer, R.drawable.ic_volume_ringer_mute, true, false);
                 addRow(STREAM_ALARM,
                         R.drawable.ic_alarm, R.drawable.ic_volume_alarm_mute, true, false);
                 addRow(AudioManager.STREAM_VOICE_CALL,
@@ -1402,7 +1309,7 @@
 
     private void showH(int reason, boolean keyguardLocked, int lockTaskModeState) {
         Trace.beginSection("VolumeDialogImpl#showH");
-        if (D.BUG) Log.d(TAG, "showH r=" + Events.SHOW_REASONS[reason]);
+        Log.i(TAG, "showH r=" + Events.SHOW_REASONS[reason]);
         mHandler.removeMessages(H.SHOW);
         mHandler.removeMessages(H.DISMISS);
         rescheduleTimeoutH();
@@ -1430,7 +1337,7 @@
         final int timeout = computeTimeoutH();
         mHandler.sendMessageDelayed(mHandler
                 .obtainMessage(H.DISMISS, Events.DISMISS_REASON_TIMEOUT, 0), timeout);
-        if (D.BUG) Log.d(TAG, "rescheduleTimeout " + timeout + " " + Debug.getCaller());
+        Log.i(TAG, "rescheduleTimeout " + timeout + " " + Debug.getCaller());
         mController.userActivity();
     }
 
@@ -1457,10 +1364,10 @@
 
     protected void dismissH(int reason) {
         Trace.beginSection("VolumeDialogImpl#dismissH");
-        if (D.BUG) {
-            Log.d(TAG, "mDialog.dismiss() reason: " + Events.DISMISS_REASONS[reason]
-                    + " from: " + Debug.getCaller());
-        }
+
+        Log.i(TAG, "mDialog.dismiss() reason: " + Events.DISMISS_REASONS[reason]
+                + " from: " + Debug.getCaller());
+
         mHandler.removeMessages(H.DISMISS);
         mHandler.removeMessages(H.SHOW);
         if (mIsAnimatingDismiss) {
@@ -1625,8 +1532,8 @@
                     mRingerIcon.setTag(Events.ICON_STATE_VIBRATE);
                     break;
                 case AudioManager.RINGER_MODE_SILENT:
-                    mRingerIcon.setImageResource(mVolumeRingerMuteIconDrawableId);
-                    mSelectedRingerIcon.setImageResource(mVolumeRingerMuteIconDrawableId);
+                    mRingerIcon.setImageResource(R.drawable.ic_volume_ringer_mute);
+                    mSelectedRingerIcon.setImageResource(R.drawable.ic_volume_ringer_mute);
                     mRingerIcon.setTag(Events.ICON_STATE_MUTE);
                     addAccessibilityDescription(mRingerIcon, RINGER_MODE_SILENT,
                             mContext.getString(R.string.volume_ringer_hint_unmute));
@@ -1635,14 +1542,14 @@
                 default:
                     boolean muted = (mAutomute && ss.level == 0) || ss.muted;
                     if (!isZenMuted && muted) {
-                        mRingerIcon.setImageResource(mVolumeRingerMuteIconDrawableId);
-                        mSelectedRingerIcon.setImageResource(mVolumeRingerMuteIconDrawableId);
+                        mRingerIcon.setImageResource(R.drawable.ic_volume_ringer_mute);
+                        mSelectedRingerIcon.setImageResource(R.drawable.ic_volume_ringer_mute);
                         addAccessibilityDescription(mRingerIcon, RINGER_MODE_NORMAL,
                                 mContext.getString(R.string.volume_ringer_hint_unmute));
                         mRingerIcon.setTag(Events.ICON_STATE_MUTE);
                     } else {
-                        mRingerIcon.setImageResource(mVolumeRingerIconDrawableId);
-                        mSelectedRingerIcon.setImageResource(mVolumeRingerIconDrawableId);
+                        mRingerIcon.setImageResource(R.drawable.ic_volume_ringer);
+                        mSelectedRingerIcon.setImageResource(R.drawable.ic_volume_ringer);
                         if (mController.hasVibrator()) {
                             addAccessibilityDescription(mRingerIcon, RINGER_MODE_NORMAL,
                                     mContext.getString(R.string.volume_ringer_hint_vibrate));
diff --git a/packages/SystemUI/src/com/android/systemui/volume/dagger/VolumeModule.java b/packages/SystemUI/src/com/android/systemui/volume/dagger/VolumeModule.java
index 8f10fa6..c5792b9 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/dagger/VolumeModule.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/dagger/VolumeModule.java
@@ -20,7 +20,6 @@
 import android.media.AudioManager;
 
 import com.android.internal.jank.InteractionJankMonitor;
-import com.android.systemui.dagger.qualifiers.Main;
 import com.android.systemui.media.dialog.MediaOutputDialogFactory;
 import com.android.systemui.plugins.ActivityStarter;
 import com.android.systemui.plugins.VolumeDialog;
@@ -28,14 +27,11 @@
 import com.android.systemui.statusbar.policy.AccessibilityManagerWrapper;
 import com.android.systemui.statusbar.policy.ConfigurationController;
 import com.android.systemui.statusbar.policy.DeviceProvisionedController;
-import com.android.systemui.util.DeviceConfigProxy;
 import com.android.systemui.volume.VolumeComponent;
 import com.android.systemui.volume.VolumeDialogComponent;
 import com.android.systemui.volume.VolumeDialogImpl;
 import com.android.systemui.volume.VolumePanelFactory;
 
-import java.util.concurrent.Executor;
-
 import dagger.Binds;
 import dagger.Module;
 import dagger.Provides;
@@ -59,9 +55,7 @@
             MediaOutputDialogFactory mediaOutputDialogFactory,
             VolumePanelFactory volumePanelFactory,
             ActivityStarter activityStarter,
-            InteractionJankMonitor interactionJankMonitor,
-            DeviceConfigProxy deviceConfigProxy,
-            @Main Executor executor) {
+            InteractionJankMonitor interactionJankMonitor) {
         VolumeDialogImpl impl = new VolumeDialogImpl(
                 context,
                 volumeDialogController,
@@ -71,9 +65,7 @@
                 mediaOutputDialogFactory,
                 volumePanelFactory,
                 activityStarter,
-                interactionJankMonitor,
-                deviceConfigProxy,
-                executor);
+                interactionJankMonitor);
         impl.setStreamImportant(AudioManager.STREAM_SYSTEM, false);
         impl.setAutomute(true);
         impl.setSilentMode(false);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/controls/management/AppAdapterTest.kt b/packages/SystemUI/tests/src/com/android/systemui/controls/management/AppAdapterTest.kt
index 1e4a9e4..765c4c0 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/controls/management/AppAdapterTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/controls/management/AppAdapterTest.kt
@@ -27,6 +27,7 @@
 import com.android.systemui.controls.ControlsServiceInfo
 import com.android.systemui.util.concurrency.FakeExecutor
 import com.android.systemui.util.mockito.any
+import com.android.systemui.util.mockito.mock
 import com.android.systemui.util.time.FakeSystemClock
 import com.google.common.truth.Truth.assertThat
 import org.junit.Before
@@ -34,9 +35,8 @@
 import org.junit.runner.RunWith
 import org.mockito.ArgumentCaptor
 import org.mockito.Mock
-import org.mockito.Mockito.mock
-import org.mockito.Mockito.verify
 import org.mockito.Mockito.`when`
+import org.mockito.Mockito.verify
 import org.mockito.MockitoAnnotations
 
 @SmallTest
@@ -70,7 +70,7 @@
     fun testOnServicesUpdated_nullLoadLabel() {
         val captor = ArgumentCaptor
             .forClass(ControlsListingController.ControlsListingCallback::class.java)
-        val controlsServiceInfo = mock(ControlsServiceInfo::class.java)
+        val controlsServiceInfo = mock<ControlsServiceInfo>()
         val serviceInfo = listOf(controlsServiceInfo)
         `when`(controlsServiceInfo.loadLabel()).thenReturn(null)
         verify(controlsListingController).observe(any(Lifecycle::class.java), captor.capture())
@@ -81,4 +81,32 @@
 
         assertThat(adapter.itemCount).isEqualTo(serviceInfo.size)
     }
+
+    @Test
+    fun testOnServicesUpdatedDoesntHavePanels() {
+        val captor = ArgumentCaptor
+                .forClass(ControlsListingController.ControlsListingCallback::class.java)
+        val serviceInfo = listOf(
+                ControlsServiceInfo("no panel", null),
+                ControlsServiceInfo("panel", mock())
+        )
+        verify(controlsListingController).observe(any(Lifecycle::class.java), captor.capture())
+
+        captor.value.onServicesUpdated(serviceInfo)
+        backgroundExecutor.runAllReady()
+        uiExecutor.runAllReady()
+
+        assertThat(adapter.itemCount).isEqualTo(1)
+    }
+
+    fun ControlsServiceInfo(
+        label: CharSequence,
+        panelComponentName: ComponentName? = null
+    ): ControlsServiceInfo {
+        return mock {
+            `when`(this.loadLabel()).thenReturn(label)
+            `when`(this.panelActivity).thenReturn(panelComponentName)
+            `when`(this.loadIcon()).thenReturn(mock())
+        }
+    }
 }
diff --git a/packages/SystemUI/tests/src/com/android/systemui/controls/management/ControlsFavoritingActivityTest.kt b/packages/SystemUI/tests/src/com/android/systemui/controls/management/ControlsFavoritingActivityTest.kt
index 0f06de2..3655232 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/controls/management/ControlsFavoritingActivityTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/controls/management/ControlsFavoritingActivityTest.kt
@@ -5,6 +5,7 @@
 import android.testing.TestableLooper
 import android.window.OnBackInvokedCallback
 import android.window.OnBackInvokedDispatcher
+import androidx.test.filters.FlakyTest
 import androidx.test.filters.SmallTest
 import androidx.test.rule.ActivityTestRule
 import androidx.test.runner.intercepting.SingleActivityFactory
@@ -79,6 +80,8 @@
         activityRule.launchActivity(intent)
     }
 
+    // b/259549854 to root-cause and fix
+    @FlakyTest
     @Test
     fun testBackCallbackRegistrationAndUnregistration() {
         // 1. ensure that launching the activity results in it registering a callback
diff --git a/packages/SystemUI/tests/src/com/android/systemui/controls/ui/ControlsUiControllerImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/controls/ui/ControlsUiControllerImplTest.kt
index 49c7442..e679b13 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/controls/ui/ControlsUiControllerImplTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/controls/ui/ControlsUiControllerImplTest.kt
@@ -17,8 +17,10 @@
 package com.android.systemui.controls.ui
 
 import android.content.ComponentName
+import android.content.Context
 import android.testing.AndroidTestingRunner
 import android.testing.TestableLooper
+import android.widget.FrameLayout
 import androidx.test.filters.SmallTest
 import com.android.systemui.SysuiTestCase
 import com.android.systemui.controls.ControlsMetricsLogger
@@ -26,6 +28,7 @@
 import com.android.systemui.controls.controller.ControlsController
 import com.android.systemui.controls.controller.StructureInfo
 import com.android.systemui.controls.management.ControlsListingController
+import com.android.systemui.dump.DumpManager
 import com.android.systemui.plugins.ActivityStarter
 import com.android.systemui.settings.UserFileManager
 import com.android.systemui.settings.UserTracker
@@ -34,9 +37,12 @@
 import com.android.systemui.statusbar.policy.KeyguardStateController
 import com.android.systemui.util.FakeSharedPreferences
 import com.android.systemui.util.concurrency.FakeExecutor
+import com.android.systemui.util.mockito.any
 import com.android.systemui.util.time.FakeSystemClock
+import com.android.wm.shell.TaskViewFactory
 import com.google.common.truth.Truth.assertThat
 import dagger.Lazy
+import java.util.Optional
 import org.junit.Before
 import org.junit.Test
 import org.junit.runner.RunWith
@@ -44,7 +50,7 @@
 import org.mockito.Mockito.anyInt
 import org.mockito.Mockito.anyString
 import org.mockito.Mockito.mock
-import org.mockito.Mockito.times
+import org.mockito.Mockito.never
 import org.mockito.Mockito.verify
 import org.mockito.Mockito.`when`
 import org.mockito.MockitoAnnotations
@@ -63,16 +69,22 @@
     @Mock lateinit var keyguardStateController: KeyguardStateController
     @Mock lateinit var userFileManager: UserFileManager
     @Mock lateinit var userTracker: UserTracker
+    @Mock lateinit var taskViewFactory: TaskViewFactory
+    @Mock lateinit var activityContext: Context
+    @Mock lateinit var dumpManager: DumpManager
     val sharedPreferences = FakeSharedPreferences()
 
     var uiExecutor = FakeExecutor(FakeSystemClock())
     var bgExecutor = FakeExecutor(FakeSystemClock())
     lateinit var underTest: ControlsUiControllerImpl
+    lateinit var parent: FrameLayout
 
     @Before
     fun setup() {
         MockitoAnnotations.initMocks(this)
 
+        parent = FrameLayout(mContext)
+
         underTest =
             ControlsUiControllerImpl(
                 Lazy { controlsController },
@@ -82,12 +94,13 @@
                 Lazy { controlsListingController },
                 controlActionCoordinator,
                 activityStarter,
-                shadeController,
                 iconCache,
                 controlsMetricsLogger,
                 keyguardStateController,
                 userFileManager,
-                userTracker
+                userTracker,
+                Optional.of(taskViewFactory),
+                dumpManager
             )
         `when`(
                 userFileManager.getSharedPreferences(
@@ -105,8 +118,8 @@
     @Test
     fun testGetPreferredStructure() {
         val structureInfo = mock(StructureInfo::class.java)
-        underTest.getPreferredStructure(listOf(structureInfo))
-        verify(userFileManager, times(2))
+        underTest.getPreferredSelectedItem(listOf(structureInfo))
+        verify(userFileManager)
             .getSharedPreferences(
                 fileName = DeviceControlsControllerImpl.PREFS_CONTROLS_FILE,
                 mode = 0,
@@ -116,25 +129,30 @@
 
     @Test
     fun testGetPreferredStructure_differentUserId() {
-        val structureInfo =
+        val selectedItems =
             listOf(
-                StructureInfo(ComponentName.unflattenFromString("pkg/.cls1"), "a", ArrayList()),
-                StructureInfo(ComponentName.unflattenFromString("pkg/.cls2"), "b", ArrayList()),
+                SelectedItem.StructureItem(
+                    StructureInfo(ComponentName.unflattenFromString("pkg/.cls1"), "a", ArrayList())
+                ),
+                SelectedItem.StructureItem(
+                    StructureInfo(ComponentName.unflattenFromString("pkg/.cls2"), "b", ArrayList())
+                ),
             )
+        val structures = selectedItems.map { it.structure }
         sharedPreferences
             .edit()
-            .putString("controls_component", structureInfo[0].componentName.flattenToString())
-            .putString("controls_structure", structureInfo[0].structure.toString())
+            .putString("controls_component", selectedItems[0].componentName.flattenToString())
+            .putString("controls_structure", selectedItems[0].name.toString())
             .commit()
 
         val differentSharedPreferences = FakeSharedPreferences()
         differentSharedPreferences
             .edit()
-            .putString("controls_component", structureInfo[1].componentName.flattenToString())
-            .putString("controls_structure", structureInfo[1].structure.toString())
+            .putString("controls_component", selectedItems[1].componentName.flattenToString())
+            .putString("controls_structure", selectedItems[1].name.toString())
             .commit()
 
-        val previousPreferredStructure = underTest.getPreferredStructure(structureInfo)
+        val previousPreferredStructure = underTest.getPreferredSelectedItem(structures)
 
         `when`(
                 userFileManager.getSharedPreferences(
@@ -146,10 +164,39 @@
             .thenReturn(differentSharedPreferences)
         `when`(userTracker.userId).thenReturn(1)
 
-        val currentPreferredStructure = underTest.getPreferredStructure(structureInfo)
+        val currentPreferredStructure = underTest.getPreferredSelectedItem(structures)
 
-        assertThat(previousPreferredStructure).isEqualTo(structureInfo[0])
-        assertThat(currentPreferredStructure).isEqualTo(structureInfo[1])
+        assertThat(previousPreferredStructure).isEqualTo(selectedItems[0])
+        assertThat(currentPreferredStructure).isEqualTo(selectedItems[1])
         assertThat(currentPreferredStructure).isNotEqualTo(previousPreferredStructure)
     }
+
+    @Test
+    fun testGetPreferredPanel() {
+        val panel = SelectedItem.PanelItem("App name", ComponentName("pkg", "cls"))
+        sharedPreferences
+            .edit()
+            .putString("controls_component", panel.componentName.flattenToString())
+            .putString("controls_structure", panel.appName.toString())
+            .putBoolean("controls_is_panel", true)
+            .commit()
+
+        val selected = underTest.getPreferredSelectedItem(emptyList())
+
+        assertThat(selected).isEqualTo(panel)
+    }
+
+    @Test
+    fun testPanelDoesNotRefreshControls() {
+        val panel = SelectedItem.PanelItem("App name", ComponentName("pkg", "cls"))
+        sharedPreferences
+            .edit()
+            .putString("controls_component", panel.componentName.flattenToString())
+            .putString("controls_structure", panel.appName.toString())
+            .putBoolean("controls_is_panel", true)
+            .commit()
+
+        underTest.show(parent, {}, activityContext)
+        verify(controlsController, never()).refreshStatus(any(), any())
+    }
 }
diff --git a/packages/SystemUI/tests/src/com/android/systemui/controls/ui/PanelTaskViewControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/controls/ui/PanelTaskViewControllerTest.kt
new file mode 100644
index 0000000..5cd2ace
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/controls/ui/PanelTaskViewControllerTest.kt
@@ -0,0 +1,154 @@
+/*
+ * Copyright (C) 2022 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.controls.ui
+
+import android.app.ActivityOptions
+import android.app.PendingIntent
+import android.content.Context
+import android.content.Intent
+import android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK
+import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
+import android.graphics.Rect
+import android.testing.AndroidTestingRunner
+import android.testing.TestableLooper
+import androidx.test.filters.SmallTest
+import com.android.systemui.SysuiTestCase
+import com.android.systemui.util.boundsOnScreen
+import com.android.systemui.util.concurrency.FakeExecutor
+import com.android.systemui.util.mockito.any
+import com.android.systemui.util.mockito.argumentCaptor
+import com.android.systemui.util.mockito.capture
+import com.android.systemui.util.mockito.eq
+import com.android.systemui.util.mockito.whenever
+import com.android.systemui.util.time.FakeSystemClock
+import com.android.wm.shell.TaskView
+import com.google.common.truth.Truth.assertThat
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.ArgumentCaptor
+import org.mockito.Captor
+import org.mockito.Mock
+import org.mockito.Mockito.verify
+import org.mockito.MockitoAnnotations
+
+@SmallTest
+@RunWith(AndroidTestingRunner::class)
+@TestableLooper.RunWithLooper
+class PanelTaskViewControllerTest : SysuiTestCase() {
+
+    companion object {
+        val FAKE_BOUNDS = Rect(10, 20, 30, 40)
+    }
+
+    @Mock private lateinit var activityContext: Context
+    @Mock private lateinit var taskView: TaskView
+    @Mock private lateinit var pendingIntent: PendingIntent
+    @Mock private lateinit var hideRunnable: () -> Unit
+
+    @Captor private lateinit var listenerCaptor: ArgumentCaptor<TaskView.Listener>
+
+    private lateinit var uiExecutor: FakeExecutor
+    private lateinit var underTest: PanelTaskViewController
+
+    @Before
+    fun setUp() {
+        MockitoAnnotations.initMocks(this)
+
+        whenever(taskView.boundsOnScreen).thenAnswer { (it.arguments[0] as Rect).set(FAKE_BOUNDS) }
+        whenever(taskView.post(any())).thenAnswer {
+            uiExecutor.execute(it.arguments[0] as Runnable)
+            true
+        }
+
+        uiExecutor = FakeExecutor(FakeSystemClock())
+
+        underTest =
+            PanelTaskViewController(
+                activityContext,
+                uiExecutor,
+                pendingIntent,
+                taskView,
+                hideRunnable
+            )
+    }
+
+    @Test
+    fun testLaunchTaskViewAttachedListener() {
+        underTest.launchTaskView()
+        verify(taskView).setListener(eq(uiExecutor), any())
+    }
+
+    @Test
+    fun testTaskViewOnInitializeStartsActivity() {
+        underTest.launchTaskView()
+        verify(taskView).setListener(any(), capture(listenerCaptor))
+
+        listenerCaptor.value.onInitialized()
+        uiExecutor.runAllReady()
+
+        val intentCaptor = argumentCaptor<Intent>()
+        val optionsCaptor = argumentCaptor<ActivityOptions>()
+
+        verify(taskView)
+            .startActivity(
+                eq(pendingIntent),
+                /* fillInIntent */ capture(intentCaptor),
+                capture(optionsCaptor),
+                eq(FAKE_BOUNDS)
+            )
+
+        assertThat(intentCaptor.value.flags)
+            .isEqualTo(FLAG_ACTIVITY_NEW_TASK or FLAG_ACTIVITY_MULTIPLE_TASK)
+        assertThat(optionsCaptor.value.taskAlwaysOnTop).isTrue()
+    }
+
+    @Test
+    fun testHideRunnableCalledWhenBackOnRoot() {
+        underTest.launchTaskView()
+        verify(taskView).setListener(any(), capture(listenerCaptor))
+
+        listenerCaptor.value.onBackPressedOnTaskRoot(0)
+
+        verify(hideRunnable).invoke()
+    }
+
+    @Test
+    fun testTaskViewReleasedOnDismiss() {
+        underTest.dismiss()
+        verify(taskView).release()
+    }
+
+    @Test
+    fun testTaskViewReleasedOnBackOnRoot() {
+        underTest.launchTaskView()
+        verify(taskView).setListener(any(), capture(listenerCaptor))
+
+        listenerCaptor.value.onBackPressedOnTaskRoot(0)
+        verify(taskView).release()
+    }
+
+    @Test
+    fun testOnTaskRemovalStarted() {
+        underTest.launchTaskView()
+        verify(taskView).setListener(any(), capture(listenerCaptor))
+
+        listenerCaptor.value.onTaskRemovalStarted(0)
+        verify(taskView).release()
+    }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/controls/ui/SelectionItemTest.kt b/packages/SystemUI/tests/src/com/android/systemui/controls/ui/SelectionItemTest.kt
new file mode 100644
index 0000000..57176f0
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/controls/ui/SelectionItemTest.kt
@@ -0,0 +1,112 @@
+package com.android.systemui.controls.ui
+
+import android.content.ComponentName
+import android.testing.AndroidTestingRunner
+import androidx.test.filters.SmallTest
+import com.android.systemui.SysuiTestCase
+import com.android.systemui.controls.controller.StructureInfo
+import com.android.systemui.util.mockito.mock
+import com.google.common.truth.Truth.assertThat
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@SmallTest
+@RunWith(AndroidTestingRunner::class)
+class SelectionItemTest : SysuiTestCase() {
+
+    @Test
+    fun testMatchBadComponentName_false() {
+        val selectionItem =
+            SelectionItem(
+                appName = "app",
+                structure = "structure",
+                icon = mock(),
+                componentName = ComponentName("pkg", "cls"),
+                uid = 0,
+                panelComponentName = null
+            )
+
+        assertThat(
+                selectionItem.matches(
+                    SelectedItem.StructureItem(
+                        StructureInfo(ComponentName("", ""), "s", emptyList())
+                    )
+                )
+            )
+            .isFalse()
+        assertThat(selectionItem.matches(SelectedItem.PanelItem("name", ComponentName("", ""))))
+            .isFalse()
+    }
+
+    @Test
+    fun testMatchSameComponentName_panelSelected_true() {
+        val componentName = ComponentName("pkg", "cls")
+
+        val selectionItem =
+            SelectionItem(
+                appName = "app",
+                structure = "structure",
+                icon = mock(),
+                componentName = componentName,
+                uid = 0,
+                panelComponentName = null
+            )
+        assertThat(selectionItem.matches(SelectedItem.PanelItem("name", componentName))).isTrue()
+    }
+
+    @Test
+    fun testMatchSameComponentName_panelSelection_true() {
+        val componentName = ComponentName("pkg", "cls")
+
+        val selectionItem =
+            SelectionItem(
+                appName = "app",
+                structure = "structure",
+                icon = mock(),
+                componentName = componentName,
+                uid = 0,
+                panelComponentName = ComponentName("pkg", "panel")
+            )
+        assertThat(selectionItem.matches(SelectedItem.PanelItem("name", componentName))).isTrue()
+    }
+
+    @Test
+    fun testMatchSameComponentSameStructure_true() {
+        val componentName = ComponentName("pkg", "cls")
+        val structureName = "structure"
+
+        val structureItem =
+            SelectedItem.StructureItem(StructureInfo(componentName, structureName, emptyList()))
+
+        val selectionItem =
+            SelectionItem(
+                appName = "app",
+                structure = structureName,
+                icon = mock(),
+                componentName = componentName,
+                uid = 0,
+                panelComponentName = null
+            )
+        assertThat(selectionItem.matches(structureItem)).isTrue()
+    }
+
+    @Test
+    fun testMatchSameComponentDifferentStructure_false() {
+        val componentName = ComponentName("pkg", "cls")
+        val structureName = "structure"
+
+        val structureItem =
+            SelectedItem.StructureItem(StructureInfo(componentName, structureName, emptyList()))
+
+        val selectionItem =
+            SelectionItem(
+                appName = "app",
+                structure = "other",
+                icon = mock(),
+                componentName = componentName,
+                uid = 0,
+                panelComponentName = null
+            )
+        assertThat(selectionItem.matches(structureItem)).isFalse()
+    }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/dump/DumpHandlerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/dump/DumpHandlerTest.kt
index 65ae90b..19135d0 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/dump/DumpHandlerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/dump/DumpHandlerTest.kt
@@ -103,8 +103,8 @@
         // THEN only the requested ones have their dump() method called
         verify(dumpable1).dump(pw, args)
         verify(dumpable2, never()).dump(
-                any(PrintWriter::class.java),
-                any(Array<String>::class.java))
+            any(PrintWriter::class.java),
+            any(Array<String>::class.java))
         verify(dumpable3).dump(pw, args)
         verify(buffer1, never()).dump(any(PrintWriter::class.java), anyInt())
         verify(buffer2).dump(pw, 0)
@@ -126,9 +126,9 @@
     @Test
     fun testCriticalDump() {
         // GIVEN a variety of registered dumpables and buffers
-        dumpManager.registerDumpable("dumpable1", dumpable1)
-        dumpManager.registerDumpable("dumpable2", dumpable2)
-        dumpManager.registerDumpable("dumpable3", dumpable3)
+        dumpManager.registerCriticalDumpable("dumpable1", dumpable1)
+        dumpManager.registerCriticalDumpable("dumpable2", dumpable2)
+        dumpManager.registerNormalDumpable("dumpable3", dumpable3)
         dumpManager.registerBuffer("buffer1", buffer1)
         dumpManager.registerBuffer("buffer2", buffer2)
 
@@ -136,10 +136,12 @@
         val args = arrayOf("--dump-priority", "CRITICAL")
         dumpHandler.dump(fd, pw, args)
 
-        // THEN all modules are dumped (but no buffers)
+        // THEN only critical modules are dumped (and no buffers)
         verify(dumpable1).dump(pw, args)
         verify(dumpable2).dump(pw, args)
-        verify(dumpable3).dump(pw, args)
+        verify(dumpable3, never()).dump(
+            any(PrintWriter::class.java),
+            any(Array<String>::class.java))
         verify(buffer1, never()).dump(any(PrintWriter::class.java), anyInt())
         verify(buffer2, never()).dump(any(PrintWriter::class.java), anyInt())
     }
@@ -147,9 +149,9 @@
     @Test
     fun testNormalDump() {
         // GIVEN a variety of registered dumpables and buffers
-        dumpManager.registerDumpable("dumpable1", dumpable1)
-        dumpManager.registerDumpable("dumpable2", dumpable2)
-        dumpManager.registerDumpable("dumpable3", dumpable3)
+        dumpManager.registerCriticalDumpable("dumpable1", dumpable1)
+        dumpManager.registerCriticalDumpable("dumpable2", dumpable2)
+        dumpManager.registerNormalDumpable("dumpable3", dumpable3)
         dumpManager.registerBuffer("buffer1", buffer1)
         dumpManager.registerBuffer("buffer2", buffer2)
 
@@ -157,16 +159,14 @@
         val args = arrayOf("--dump-priority", "NORMAL")
         dumpHandler.dump(fd, pw, args)
 
-        // THEN all buffers are dumped (but no modules)
+        // THEN the normal module and all buffers are dumped
         verify(dumpable1, never()).dump(
                 any(PrintWriter::class.java),
                 any(Array<String>::class.java))
         verify(dumpable2, never()).dump(
                 any(PrintWriter::class.java),
                 any(Array<String>::class.java))
-        verify(dumpable3, never()).dump(
-                any(PrintWriter::class.java),
-                any(Array<String>::class.java))
+        verify(dumpable3).dump(pw, args)
         verify(buffer1).dump(pw, 0)
         verify(buffer2).dump(pw, 0)
     }
diff --git a/packages/SystemUI/tests/src/com/android/systemui/dump/DumpManagerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/dump/DumpManagerTest.kt
new file mode 100644
index 0000000..0c5a74c
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/dump/DumpManagerTest.kt
@@ -0,0 +1,221 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.dump
+
+import androidx.test.filters.SmallTest
+import com.android.systemui.Dumpable
+import com.android.systemui.SysuiTestCase
+import com.android.systemui.plugins.log.LogBuffer
+import com.android.systemui.util.mockito.any
+import java.io.PrintWriter
+import org.junit.Before
+import org.junit.Test
+import org.mockito.Mock
+import org.mockito.Mockito.anyInt
+import org.mockito.Mockito.never
+import org.mockito.Mockito.verify
+import org.mockito.MockitoAnnotations
+
+@SmallTest
+class DumpManagerTest : SysuiTestCase() {
+
+    @Mock private lateinit var pw: PrintWriter
+
+    @Mock private lateinit var dumpable1: Dumpable
+    @Mock private lateinit var dumpable2: Dumpable
+    @Mock private lateinit var dumpable3: Dumpable
+
+    @Mock private lateinit var buffer1: LogBuffer
+    @Mock private lateinit var buffer2: LogBuffer
+
+    private val dumpManager = DumpManager()
+
+    @Before
+    fun setUp() {
+        MockitoAnnotations.initMocks(this)
+    }
+
+    @Test
+    fun testDumpTarget_dumpable() {
+        // GIVEN a variety of registered dumpables and buffers
+        dumpManager.registerCriticalDumpable("dumpable1", dumpable1)
+        dumpManager.registerCriticalDumpable("dumpable2", dumpable2)
+        dumpManager.registerCriticalDumpable("dumpable3", dumpable3)
+        dumpManager.registerBuffer("buffer1", buffer1)
+        dumpManager.registerBuffer("buffer2", buffer2)
+
+        // WHEN a dumpable is dumped explicitly
+        val args = arrayOf<String>()
+        dumpManager.dumpTarget("dumpable2", pw, arrayOf(), tailLength = 0)
+
+        // THEN only the requested one has their dump() method called
+        verify(dumpable1, never())
+            .dump(any(PrintWriter::class.java), any(Array<String>::class.java))
+        verify(dumpable2).dump(pw, args)
+        verify(dumpable3, never())
+            .dump(any(PrintWriter::class.java), any(Array<String>::class.java))
+        verify(buffer1, never()).dump(any(PrintWriter::class.java), anyInt())
+        verify(buffer2, never()).dump(any(PrintWriter::class.java), anyInt())
+    }
+
+    @Test
+    fun testDumpTarget_buffer() {
+        // GIVEN a variety of registered dumpables and buffers
+        dumpManager.registerCriticalDumpable("dumpable1", dumpable1)
+        dumpManager.registerCriticalDumpable("dumpable2", dumpable2)
+        dumpManager.registerCriticalDumpable("dumpable3", dumpable3)
+        dumpManager.registerBuffer("buffer1", buffer1)
+        dumpManager.registerBuffer("buffer2", buffer2)
+
+        // WHEN a buffer is dumped explicitly
+        dumpManager.dumpTarget("buffer1", pw, arrayOf(), tailLength = 14)
+
+        // THEN only the requested one has their dump() method called
+        verify(dumpable1, never())
+            .dump(any(PrintWriter::class.java), any(Array<String>::class.java))
+        verify(dumpable2, never())
+            .dump(any(PrintWriter::class.java), any(Array<String>::class.java))
+        verify(dumpable2, never())
+            .dump(any(PrintWriter::class.java), any(Array<String>::class.java))
+        verify(buffer1).dump(pw, tailLength = 14)
+        verify(buffer2, never()).dump(any(PrintWriter::class.java), anyInt())
+    }
+
+    @Test
+    fun testDumpableMatchingIsBasedOnEndOfTag() {
+        // GIVEN a dumpable registered to the manager
+        dumpManager.registerCriticalDumpable("com.android.foo.bar.dumpable1", dumpable1)
+
+        // WHEN that module is dumped
+        val args = arrayOf<String>()
+        dumpManager.dumpTarget("dumpable1", pw, arrayOf(), tailLength = 14)
+
+        // THEN its dump() method is called
+        verify(dumpable1).dump(pw, args)
+    }
+
+    @Test
+    fun testDumpDumpables() {
+        // GIVEN a variety of registered dumpables and buffers
+        dumpManager.registerCriticalDumpable("dumpable1", dumpable1)
+        dumpManager.registerCriticalDumpable("dumpable2", dumpable2)
+        dumpManager.registerNormalDumpable("dumpable3", dumpable3)
+        dumpManager.registerBuffer("buffer1", buffer1)
+        dumpManager.registerBuffer("buffer2", buffer2)
+
+        // WHEN a dumpable dump is requested
+        val args = arrayOf<String>()
+        dumpManager.dumpDumpables(pw, args)
+
+        // THEN all dumpables are dumped (both critical and normal) (and no dumpables)
+        verify(dumpable1).dump(pw, args)
+        verify(dumpable2).dump(pw, args)
+        verify(dumpable3).dump(pw, args)
+        verify(buffer1, never()).dump(any(PrintWriter::class.java), anyInt())
+        verify(buffer2, never()).dump(any(PrintWriter::class.java), anyInt())
+    }
+
+    @Test
+    fun testDumpBuffers() {
+        // GIVEN a variety of registered dumpables and buffers
+        dumpManager.registerCriticalDumpable("dumpable1", dumpable1)
+        dumpManager.registerCriticalDumpable("dumpable2", dumpable2)
+        dumpManager.registerNormalDumpable("dumpable3", dumpable3)
+        dumpManager.registerBuffer("buffer1", buffer1)
+        dumpManager.registerBuffer("buffer2", buffer2)
+
+        // WHEN a buffer dump is requested
+        dumpManager.dumpBuffers(pw, tailLength = 1)
+
+        // THEN all buffers are dumped (and no dumpables)
+        verify(dumpable1, never())
+            .dump(any(PrintWriter::class.java), any(Array<String>::class.java))
+        verify(dumpable2, never())
+            .dump(any(PrintWriter::class.java), any(Array<String>::class.java))
+        verify(dumpable3, never())
+            .dump(any(PrintWriter::class.java), any(Array<String>::class.java))
+        verify(buffer1).dump(pw, tailLength = 1)
+        verify(buffer2).dump(pw, tailLength = 1)
+    }
+
+    @Test
+    fun testCriticalDump() {
+        // GIVEN a variety of registered dumpables and buffers
+        dumpManager.registerCriticalDumpable("dumpable1", dumpable1)
+        dumpManager.registerCriticalDumpable("dumpable2", dumpable2)
+        dumpManager.registerNormalDumpable("dumpable3", dumpable3)
+        dumpManager.registerBuffer("buffer1", buffer1)
+        dumpManager.registerBuffer("buffer2", buffer2)
+
+        // WHEN a critical dump is requested
+        val args = arrayOf<String>()
+        dumpManager.dumpCritical(pw, args)
+
+        // THEN only critical modules are dumped (and no buffers)
+        verify(dumpable1).dump(pw, args)
+        verify(dumpable2).dump(pw, args)
+        verify(dumpable3, never())
+            .dump(any(PrintWriter::class.java), any(Array<String>::class.java))
+        verify(buffer1, never()).dump(any(PrintWriter::class.java), anyInt())
+        verify(buffer2, never()).dump(any(PrintWriter::class.java), anyInt())
+    }
+
+    @Test
+    fun testNormalDump() {
+        // GIVEN a variety of registered dumpables and buffers
+        dumpManager.registerCriticalDumpable("dumpable1", dumpable1)
+        dumpManager.registerCriticalDumpable("dumpable2", dumpable2)
+        dumpManager.registerNormalDumpable("dumpable3", dumpable3)
+        dumpManager.registerBuffer("buffer1", buffer1)
+        dumpManager.registerBuffer("buffer2", buffer2)
+
+        // WHEN a normal dump is requested
+        val args = arrayOf<String>()
+        dumpManager.dumpNormal(pw, args, tailLength = 2)
+
+        // THEN the normal module and all buffers are dumped
+        verify(dumpable1, never())
+            .dump(any(PrintWriter::class.java), any(Array<String>::class.java))
+        verify(dumpable2, never())
+            .dump(any(PrintWriter::class.java), any(Array<String>::class.java))
+        verify(dumpable3).dump(pw, args)
+        verify(buffer1).dump(pw, tailLength = 2)
+        verify(buffer2).dump(pw, tailLength = 2)
+    }
+
+    @Test
+    fun testUnregister() {
+        // GIVEN a variety of registered dumpables and buffers
+        dumpManager.registerCriticalDumpable("dumpable1", dumpable1)
+        dumpManager.registerCriticalDumpable("dumpable2", dumpable2)
+        dumpManager.registerNormalDumpable("dumpable3", dumpable3)
+
+        dumpManager.unregisterDumpable("dumpable2")
+        dumpManager.unregisterDumpable("dumpable3")
+
+        // WHEN a dumpables dump is requested
+        val args = arrayOf<String>()
+        dumpManager.dumpDumpables(pw, args)
+
+        // THEN the unregistered dumpables (both normal and critical) are not dumped
+        verify(dumpable1).dump(pw, args)
+        verify(dumpable2, never())
+            .dump(any(PrintWriter::class.java), any(Array<String>::class.java))
+        verify(dumpable3, never())
+            .dump(any(PrintWriter::class.java), any(Array<String>::class.java))
+    }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardQuickAffordanceProviderTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardQuickAffordanceProviderTest.kt
index 5e27a50..cedde58 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardQuickAffordanceProviderTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardQuickAffordanceProviderTest.kt
@@ -115,6 +115,7 @@
                         secureSettings = FakeSettings(),
                         selectionsManager = selectionManager,
                     ),
+                dumpManager = mock(),
             )
         underTest.interactor =
             KeyguardQuickAffordanceInteractor(
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/KeyguardQuickAffordanceRepositoryTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/KeyguardQuickAffordanceRepositoryTest.kt
index bfd5190..5c75417 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/KeyguardQuickAffordanceRepositoryTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/KeyguardQuickAffordanceRepositoryTest.kt
@@ -91,6 +91,7 @@
                         selectionsManager = selectionManager,
                     ),
                 configs = setOf(config1, config2),
+                dumpManager = mock(),
             )
     }
 
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorParameterizedTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorParameterizedTest.kt
index 1e1d3f1..c2650ec 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorParameterizedTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorParameterizedTest.kt
@@ -266,6 +266,7 @@
                         selectionsManager = selectionManager,
                     ),
                 configs = setOf(homeControls, quickAccessWallet, qrCodeScanner),
+                dumpManager = mock(),
             )
         underTest =
             KeyguardQuickAffordanceInteractor(
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorTest.kt
index 4850ea5..b790306 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorTest.kt
@@ -127,6 +127,7 @@
                         selectionsManager = selectionManager,
                     ),
                 configs = setOf(homeControls, quickAccessWallet, qrCodeScanner),
+                dumpManager = mock(),
             )
         featureFlags =
             FakeFeatureFlags().apply {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBottomAreaViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBottomAreaViewModelTest.kt
index ecc63ec..8b166bd 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBottomAreaViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBottomAreaViewModelTest.kt
@@ -155,6 +155,7 @@
                         quickAccessWalletAffordanceConfig,
                         qrCodeScannerAffordanceConfig,
                     ),
+                dumpManager = mock(),
             )
         underTest =
             KeyguardBottomAreaViewModel(
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/DeviceControlsTileTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/DeviceControlsTileTest.kt
index f7b9438e..e0b3125 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/DeviceControlsTileTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/DeviceControlsTileTest.kt
@@ -40,6 +40,7 @@
 import com.android.systemui.controls.management.ControlsListingController
 import com.android.systemui.controls.ui.ControlsActivity
 import com.android.systemui.controls.ui.ControlsUiController
+import com.android.systemui.controls.ui.SelectedItem
 import com.android.systemui.plugins.ActivityStarter
 import com.android.systemui.plugins.statusbar.StatusBarStateController
 import com.android.systemui.qs.QSHost
@@ -118,8 +119,9 @@
         `when`(qsHost.context).thenReturn(spiedContext)
         `when`(qsHost.uiEventLogger).thenReturn(uiEventLogger)
         `when`(controlsComponent.isEnabled()).thenReturn(true)
-        `when`(controlsController.getPreferredStructure())
-                .thenReturn(StructureInfo(ComponentName("pkg", "cls"), "structure", listOf()))
+        `when`(controlsController.getPreferredSelection())
+                .thenReturn(SelectedItem.StructureItem(
+                        StructureInfo(ComponentName("pkg", "cls"), "structure", listOf())))
         secureSettings.putInt(Settings.Secure.LOCKSCREEN_SHOW_CONTROLS, 1)
 
         setupControlsComponent()
@@ -226,12 +228,12 @@
                 capture(listingCallbackCaptor)
         )
         `when`(controlsComponent.getVisibility()).thenReturn(ControlsComponent.Visibility.AVAILABLE)
-        `when`(controlsController.getPreferredStructure()).thenReturn(
-            StructureInfo(
+        `when`(controlsController.getPreferredSelection()).thenReturn(
+            SelectedItem.StructureItem(StructureInfo(
                 ComponentName("pkg", "cls"),
                 "structure",
                 listOf(ControlInfo("id", "title", "subtitle", 1))
-            )
+            ))
         )
 
         listingCallbackCaptor.value.onServicesUpdated(listOf(serviceInfo))
@@ -247,8 +249,9 @@
                 capture(listingCallbackCaptor)
         )
         `when`(controlsComponent.getVisibility()).thenReturn(ControlsComponent.Visibility.AVAILABLE)
-        `when`(controlsController.getPreferredStructure())
-                .thenReturn(StructureInfo(ComponentName("pkg", "cls"), "structure", listOf()))
+        `when`(controlsController.getPreferredSelection())
+                .thenReturn(SelectedItem.StructureItem(
+                        StructureInfo(ComponentName("pkg", "cls"), "structure", listOf())))
 
         listingCallbackCaptor.value.onServicesUpdated(listOf(serviceInfo))
         testableLooper.processAllMessages()
@@ -257,6 +260,22 @@
     }
 
     @Test
+    fun testStateActiveIfPreferredIsPanel() {
+        verify(controlsListingController).observe(
+                any(LifecycleOwner::class.java),
+                capture(listingCallbackCaptor)
+        )
+        `when`(controlsComponent.getVisibility()).thenReturn(ControlsComponent.Visibility.AVAILABLE)
+        `when`(controlsController.getPreferredSelection())
+                .thenReturn(SelectedItem.PanelItem("appName", ComponentName("pkg", "cls")))
+
+        listingCallbackCaptor.value.onServicesUpdated(listOf(serviceInfo))
+        testableLooper.processAllMessages()
+
+        assertThat(tile.state.state).isEqualTo(Tile.STATE_ACTIVE)
+    }
+
+    @Test
     fun testStateInactiveIfLocked() {
         verify(controlsListingController).observe(
             any(LifecycleOwner::class.java),
@@ -303,12 +322,12 @@
         )
         `when`(controlsComponent.getVisibility()).thenReturn(ControlsComponent.Visibility.AVAILABLE)
         `when`(controlsUiController.resolveActivity()).thenReturn(ControlsActivity::class.java)
-        `when`(controlsController.getPreferredStructure()).thenReturn(
-            StructureInfo(
-                ComponentName("pkg", "cls"),
-                "structure",
-                listOf(ControlInfo("id", "title", "subtitle", 1))
-            )
+        `when`(controlsController.getPreferredSelection()).thenReturn(
+            SelectedItem.StructureItem(StructureInfo(
+                    ComponentName("pkg", "cls"),
+                    "structure",
+                    listOf(ControlInfo("id", "title", "subtitle", 1))
+            ))
         )
 
         listingCallbackCaptor.value.onServicesUpdated(listOf(serviceInfo))
@@ -334,12 +353,12 @@
         `when`(controlsComponent.getVisibility())
             .thenReturn(ControlsComponent.Visibility.AVAILABLE_AFTER_UNLOCK)
         `when`(controlsUiController.resolveActivity()).thenReturn(ControlsActivity::class.java)
-        `when`(controlsController.getPreferredStructure()).thenReturn(
-            StructureInfo(
+        `when`(controlsController.getPreferredSelection()).thenReturn(
+            SelectedItem.StructureItem(StructureInfo(
                 ComponentName("pkg", "cls"),
                 "structure",
                 listOf(ControlInfo("id", "title", "subtitle", 1))
-            )
+            ))
         )
 
         listingCallbackCaptor.value.onServicesUpdated(listOf(serviceInfo))
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/QRCodeScannerTileTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/QRCodeScannerTileTest.java
index 6a3f785..a1be2f3 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/QRCodeScannerTileTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/QRCodeScannerTileTest.java
@@ -18,6 +18,7 @@
 
 import static junit.framework.Assert.assertEquals;
 import static junit.framework.Assert.assertFalse;
+import static junit.framework.Assert.assertNull;
 
 import static org.mockito.Mockito.when;
 
@@ -112,6 +113,8 @@
         QSTile.State state = new QSTile.State();
         mTile.handleUpdateState(state, null);
         assertEquals(state.state, Tile.STATE_UNAVAILABLE);
+        assertEquals(state.secondaryLabel.toString(),
+                     mContext.getString(R.string.qr_code_scanner_updating_secondary_label));
     }
 
     @Test
@@ -120,5 +123,6 @@
         QSTile.State state = new QSTile.State();
         mTile.handleUpdateState(state, null);
         assertEquals(state.state, Tile.STATE_INACTIVE);
+        assertNull(state.secondaryLabel);
     }
 }
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogControllerTest.java
index 8d1ccd0..6d2972d 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogControllerTest.java
@@ -31,6 +31,7 @@
 
 import android.animation.Animator;
 import android.content.Intent;
+import android.content.res.Resources;
 import android.graphics.PixelFormat;
 import android.graphics.drawable.Drawable;
 import android.net.ConnectivityManager;
@@ -40,6 +41,7 @@
 import android.telephony.SignalStrength;
 import android.telephony.SubscriptionInfo;
 import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyDisplayInfo;
 import android.telephony.TelephonyManager;
 import android.testing.AndroidTestingRunner;
 import android.testing.TestableLooper;
@@ -85,6 +87,7 @@
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 @SmallTest
 @RunWith(AndroidTestingRunner.class)
@@ -753,15 +756,34 @@
     @Test
     public void getMobileNetworkSummary() {
         mFlags.set(Flags.QS_SECONDARY_DATA_SUB_INFO, true);
+        Resources res1 = mock(Resources.class);
+        doReturn("EDGE").when(res1).getString(anyInt());
+        Resources res2 = mock(Resources.class);
+        doReturn("LTE").when(res2).getString(anyInt());
+        when(SubscriptionManager.getResourcesForSubId(any(), eq(SUB_ID))).thenReturn(res1);
+        when(SubscriptionManager.getResourcesForSubId(any(), eq(SUB_ID2))).thenReturn(res2);
+
         InternetDialogController spyController = spy(mInternetDialogController);
+        Map<Integer, TelephonyDisplayInfo> mSubIdTelephonyDisplayInfoMap =
+                spyController.mSubIdTelephonyDisplayInfoMap;
+        TelephonyDisplayInfo info1 = new TelephonyDisplayInfo(TelephonyManager.NETWORK_TYPE_EDGE,
+                TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE);
+        TelephonyDisplayInfo info2 = new TelephonyDisplayInfo(TelephonyManager.NETWORK_TYPE_LTE,
+                TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE);
+
+        mSubIdTelephonyDisplayInfoMap.put(SUB_ID, info1);
+        mSubIdTelephonyDisplayInfoMap.put(SUB_ID2, info2);
+
         doReturn(SUB_ID2).when(spyController).getActiveAutoSwitchNonDdsSubId();
         doReturn(true).when(spyController).isMobileDataEnabled();
         doReturn(true).when(spyController).activeNetworkIsCellular();
         String dds = spyController.getMobileNetworkSummary(SUB_ID);
         String nonDds = spyController.getMobileNetworkSummary(SUB_ID2);
 
+        String ddsNetworkType = dds.split("/")[1];
+        String nonDdsNetworkType = nonDds.split("/")[1];
         assertThat(dds).contains(mContext.getString(R.string.mobile_data_poor_connection));
-        assertThat(dds).isNotEqualTo(nonDds);
+        assertThat(ddsNetworkType).isNotEqualTo(nonDdsNetworkType);
     }
 
     @Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationShadeDepthControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationShadeDepthControllerTest.kt
index 77b1e37..beaf300 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationShadeDepthControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationShadeDepthControllerTest.kt
@@ -131,7 +131,9 @@
 
     @Test
     fun setupListeners() {
-        verify(dumpManager).registerDumpable(anyString(), eq(notificationShadeDepthController))
+        verify(dumpManager).registerCriticalDumpable(
+            anyString(), eq(notificationShadeDepthController)
+        )
     }
 
     @Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java
index 75a3b21..d1957ac 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java
@@ -42,6 +42,7 @@
 import com.android.internal.logging.MetricsLogger;
 import com.android.internal.util.LatencyTracker;
 import com.android.keyguard.KeyguardUpdateMonitor;
+import com.android.keyguard.logging.BiometricUnlockLogger;
 import com.android.systemui.SysuiTestCase;
 import com.android.systemui.biometrics.AuthController;
 import com.android.systemui.dump.DumpManager;
@@ -78,6 +79,8 @@
     @Mock
     private KeyguardUpdateMonitor mUpdateMonitor;
     @Mock
+    private KeyguardUpdateMonitor.StrongAuthTracker mStrongAuthTracker;
+    @Mock
     private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;
     @Mock
     private NotificationShadeWindowController mNotificationShadeWindowController;
@@ -119,6 +122,8 @@
     private ScreenOffAnimationController mScreenOffAnimationController;
     @Mock
     private VibratorHelper mVibratorHelper;
+    @Mock
+    private BiometricUnlockLogger mLogger;
     private BiometricUnlockController mBiometricUnlockController;
 
     @Before
@@ -138,12 +143,13 @@
                 mKeyguardViewMediator, mScrimController, mShadeController,
                 mNotificationShadeWindowController, mKeyguardStateController, mHandler,
                 mUpdateMonitor, res.getResources(), mKeyguardBypassController,
-                mMetricsLogger, mDumpManager, mPowerManager,
+                mMetricsLogger, mDumpManager, mPowerManager, mLogger,
                 mNotificationMediaManager, mWakefulnessLifecycle, mScreenLifecycle,
                 mAuthController, mStatusBarStateController, mKeyguardUnlockAnimationController,
                 mSessionTracker, mLatencyTracker, mScreenOffAnimationController, mVibratorHelper);
         mBiometricUnlockController.setKeyguardViewController(mStatusBarKeyguardViewManager);
         mBiometricUnlockController.addBiometricModeListener(mBiometricModeListener);
+        when(mUpdateMonitor.getStrongAuthTracker()).thenReturn(mStrongAuthTracker);
     }
 
     @Test
@@ -285,6 +291,7 @@
     @Test
     public void onBiometricAuthenticated_whenFace_andBypass_encrypted_showPrimaryBouncer() {
         reset(mUpdateMonitor);
+        when(mUpdateMonitor.getStrongAuthTracker()).thenReturn(mStrongAuthTracker);
         when(mKeyguardBypassController.getBypassEnabled()).thenReturn(true);
         mBiometricUnlockController.setKeyguardViewController(mStatusBarKeyguardViewManager);
 
@@ -322,6 +329,7 @@
     @Test
     public void onBiometricAuthenticated_whenFace_noBypass_encrypted_doNothing() {
         reset(mUpdateMonitor);
+        when(mUpdateMonitor.getStrongAuthTracker()).thenReturn(mStrongAuthTracker);
         mBiometricUnlockController.setKeyguardViewController(mStatusBarKeyguardViewManager);
 
         when(mUpdateMonitor.isUnlockingWithBiometricAllowed(anyBoolean())).thenReturn(false);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/user/domain/interactor/UserInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/user/domain/interactor/UserInteractorTest.kt
index 47efcd9..50d239d 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/user/domain/interactor/UserInteractorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/user/domain/interactor/UserInteractorTest.kt
@@ -113,6 +113,7 @@
         )
 
         featureFlags = FakeFeatureFlags()
+        featureFlags.set(Flags.FULL_SCREEN_USER_SWITCHER, false)
         userRepository = FakeUserRepository()
         keyguardRepository = FakeKeyguardRepository()
         telephonyRepository = FakeTelephonyRepository()
@@ -311,6 +312,32 @@
         }
 
     @Test
+    fun `actions - device unlocked - full screen`() =
+        runBlocking(IMMEDIATE) {
+            featureFlags.set(Flags.FULL_SCREEN_USER_SWITCHER, true)
+            val userInfos = createUserInfos(count = 2, includeGuest = false)
+
+            userRepository.setUserInfos(userInfos)
+            userRepository.setSelectedUserInfo(userInfos[0])
+            userRepository.setSettings(UserSwitcherSettingsModel(isUserSwitcherEnabled = true))
+            keyguardRepository.setKeyguardShowing(false)
+            var value: List<UserActionModel>? = null
+            val job = underTest.actions.onEach { value = it }.launchIn(this)
+
+            assertThat(value)
+                .isEqualTo(
+                    listOf(
+                        UserActionModel.ADD_USER,
+                        UserActionModel.ADD_SUPERVISED_USER,
+                        UserActionModel.ENTER_GUEST_MODE,
+                        UserActionModel.NAVIGATE_TO_USER_MANAGEMENT,
+                    )
+                )
+
+            job.cancel()
+        }
+
+    @Test
     fun `actions - device unlocked user not primary - empty list`() =
         runBlocking(IMMEDIATE) {
             val userInfos = createUserInfos(count = 2, includeGuest = false)
@@ -373,7 +400,37 @@
         }
 
     @Test
-    fun `actions - device locked - only guest action and manage user is shown`() =
+    fun `actions - device locked add from lockscreen set - full list - full screen`() =
+        runBlocking(IMMEDIATE) {
+            featureFlags.set(Flags.FULL_SCREEN_USER_SWITCHER, true)
+            val userInfos = createUserInfos(count = 2, includeGuest = false)
+            userRepository.setUserInfos(userInfos)
+            userRepository.setSelectedUserInfo(userInfos[0])
+            userRepository.setSettings(
+                UserSwitcherSettingsModel(
+                    isUserSwitcherEnabled = true,
+                    isAddUsersFromLockscreen = true,
+                )
+            )
+            keyguardRepository.setKeyguardShowing(false)
+            var value: List<UserActionModel>? = null
+            val job = underTest.actions.onEach { value = it }.launchIn(this)
+
+            assertThat(value)
+                .isEqualTo(
+                    listOf(
+                        UserActionModel.ADD_USER,
+                        UserActionModel.ADD_SUPERVISED_USER,
+                        UserActionModel.ENTER_GUEST_MODE,
+                        UserActionModel.NAVIGATE_TO_USER_MANAGEMENT,
+                    )
+                )
+
+            job.cancel()
+        }
+
+    @Test
+    fun `actions - device locked - only  manage user is shown`() =
         runBlocking(IMMEDIATE) {
             val userInfos = createUserInfos(count = 2, includeGuest = false)
             userRepository.setUserInfos(userInfos)
@@ -383,13 +440,7 @@
             var value: List<UserActionModel>? = null
             val job = underTest.actions.onEach { value = it }.launchIn(this)
 
-            assertThat(value)
-                .isEqualTo(
-                    listOf(
-                        UserActionModel.ENTER_GUEST_MODE,
-                        UserActionModel.NAVIGATE_TO_USER_MANAGEMENT
-                    )
-                )
+            assertThat(value).isEqualTo(listOf(UserActionModel.NAVIGATE_TO_USER_MANAGEMENT))
 
             job.cancel()
         }
@@ -665,6 +716,33 @@
         }
 
     @Test
+    fun userRecordsFullScreen() =
+        runBlocking(IMMEDIATE) {
+            featureFlags.set(Flags.FULL_SCREEN_USER_SWITCHER, true)
+            val userInfos = createUserInfos(count = 3, includeGuest = false)
+            userRepository.setSettings(UserSwitcherSettingsModel(isUserSwitcherEnabled = true))
+            userRepository.setUserInfos(userInfos)
+            userRepository.setSelectedUserInfo(userInfos[0])
+            keyguardRepository.setKeyguardShowing(false)
+
+            testCoroutineScope.advanceUntilIdle()
+
+            assertRecords(
+                records = underTest.userRecords.value,
+                userIds = listOf(0, 1, 2),
+                selectedUserIndex = 0,
+                includeGuest = false,
+                expectedActions =
+                    listOf(
+                        UserActionModel.ADD_USER,
+                        UserActionModel.ADD_SUPERVISED_USER,
+                        UserActionModel.ENTER_GUEST_MODE,
+                        UserActionModel.NAVIGATE_TO_USER_MANAGEMENT,
+                    ),
+            )
+        }
+
+    @Test
     fun selectedUserRecord() =
         runBlocking(IMMEDIATE) {
             val userInfos = createUserInfos(count = 3, includeGuest = true)
@@ -728,8 +806,6 @@
     @Test
     fun `show user switcher - full screen disabled - shows dialog switcher`() =
         runBlocking(IMMEDIATE) {
-            featureFlags.set(Flags.FULL_SCREEN_USER_SWITCHER, false)
-
             var dialogRequest: ShowDialogRequestModel? = null
             val expandable = mock<Expandable>()
             underTest.showUserSwitcher(context, expandable)
diff --git a/packages/SystemUI/tests/src/com/android/systemui/user/ui/viewmodel/StatusBarUserChipViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/user/ui/viewmodel/StatusBarUserChipViewModelTest.kt
index 795ff17..108fa62 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/user/ui/viewmodel/StatusBarUserChipViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/user/ui/viewmodel/StatusBarUserChipViewModelTest.kt
@@ -30,6 +30,7 @@
 import com.android.systemui.SysuiTestCase
 import com.android.systemui.common.shared.model.Text
 import com.android.systemui.flags.FakeFeatureFlags
+import com.android.systemui.flags.Flags
 import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository
 import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
 import com.android.systemui.plugins.ActivityStarter
@@ -241,7 +242,8 @@
                         KeyguardInteractor(
                             repository = keyguardRepository,
                         ),
-                    featureFlags = featureFlags,
+                    featureFlags =
+                        FakeFeatureFlags().apply { set(Flags.FULL_SCREEN_USER_SWITCHER, false) },
                     manager = manager,
                     applicationScope = testScope.backgroundScope,
                     telephonyInteractor =
diff --git a/packages/SystemUI/tests/src/com/android/systemui/user/ui/viewmodel/UserSwitcherViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/user/ui/viewmodel/UserSwitcherViewModelTest.kt
index 1730b75..4b6bdac 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/user/ui/viewmodel/UserSwitcherViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/user/ui/viewmodel/UserSwitcherViewModelTest.kt
@@ -28,6 +28,7 @@
 import com.android.systemui.SysuiTestCase
 import com.android.systemui.common.shared.model.Text
 import com.android.systemui.flags.FakeFeatureFlags
+import com.android.systemui.flags.Flags
 import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository
 import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
 import com.android.systemui.plugins.ActivityStarter
@@ -148,7 +149,10 @@
                                 KeyguardInteractor(
                                     repository = keyguardRepository,
                                 ),
-                            featureFlags = FakeFeatureFlags(),
+                            featureFlags =
+                                FakeFeatureFlags().apply {
+                                    set(Flags.FULL_SCREEN_USER_SWITCHER, false)
+                                },
                             manager = manager,
                             applicationScope = injectedScope,
                             telephonyInteractor =
diff --git a/packages/SystemUI/tests/src/com/android/systemui/volume/VolumeDialogImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/volume/VolumeDialogImplTest.java
index a0b4eab..2e74bf5 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/volume/VolumeDialogImplTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/volume/VolumeDialogImplTest.java
@@ -18,7 +18,6 @@
 
 import static com.android.systemui.volume.VolumeDialogControllerImpl.STREAMS;
 
-import static junit.framework.Assert.assertEquals;
 import static junit.framework.Assert.assertTrue;
 
 import static org.mockito.ArgumentMatchers.any;
@@ -29,7 +28,6 @@
 import android.app.KeyguardManager;
 import android.media.AudioManager;
 import android.os.SystemClock;
-import android.provider.DeviceConfig;
 import android.testing.AndroidTestingRunner;
 import android.testing.TestableLooper;
 import android.view.InputDevice;
@@ -40,7 +38,6 @@
 
 import androidx.test.filters.SmallTest;
 
-import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
 import com.android.internal.jank.InteractionJankMonitor;
 import com.android.systemui.Prefs;
 import com.android.systemui.R;
@@ -52,9 +49,6 @@
 import com.android.systemui.statusbar.policy.AccessibilityManagerWrapper;
 import com.android.systemui.statusbar.policy.ConfigurationController;
 import com.android.systemui.statusbar.policy.DeviceProvisionedController;
-import com.android.systemui.util.DeviceConfigProxyFake;
-import com.android.systemui.util.concurrency.FakeExecutor;
-import com.android.systemui.util.time.FakeSystemClock;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -77,8 +71,6 @@
     View mDrawerVibrate;
     View mDrawerMute;
     View mDrawerNormal;
-    private DeviceConfigProxyFake mDeviceConfigProxy;
-    private FakeExecutor mExecutor;
 
     @Mock
     VolumeDialogController mVolumeDialogController;
@@ -105,9 +97,6 @@
 
         getContext().addMockSystemService(KeyguardManager.class, mKeyguard);
 
-        mDeviceConfigProxy = new DeviceConfigProxyFake();
-        mExecutor = new FakeExecutor(new FakeSystemClock());
-
         mDialog = new VolumeDialogImpl(
                 getContext(),
                 mVolumeDialogController,
@@ -117,9 +106,7 @@
                 mMediaOutputDialogFactory,
                 mVolumePanelFactory,
                 mActivityStarter,
-                mInteractionJankMonitor,
-                mDeviceConfigProxy,
-                mExecutor);
+                mInteractionJankMonitor);
         mDialog.init(0, null);
         State state = createShellState();
         mDialog.onStateChangedH(state);
@@ -136,9 +123,6 @@
                 VolumePrefs.SHOW_RINGER_TOAST_COUNT + 1);
 
         Prefs.putBoolean(mContext, Prefs.Key.HAS_SEEN_ODI_CAPTIONS_TOOLTIP, false);
-
-        mDeviceConfigProxy.setProperty(DeviceConfig.NAMESPACE_SYSTEMUI,
-                SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION, "false", false);
     }
 
     private State createShellState() {
@@ -308,35 +292,6 @@
                 AudioManager.RINGER_MODE_NORMAL, false);
     }
 
-    /**
-     * Ideally we would look at the ringer ImageView and check its assigned drawable id, but that
-     * API does not exist. So we do the next best thing; we check the cached icon id.
-     */
-    @Test
-    public void notificationVolumeSeparated_theRingerIconChanges() {
-        mDeviceConfigProxy.setProperty(DeviceConfig.NAMESPACE_SYSTEMUI,
-                SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION, "true", false);
-
-        mExecutor.runAllReady(); // for the config change to take effect
-
-        // assert icon is new based on res id
-        assertEquals(mDialog.mVolumeRingerIconDrawableId,
-                R.drawable.ic_speaker_on);
-        assertEquals(mDialog.mVolumeRingerMuteIconDrawableId,
-                R.drawable.ic_speaker_mute);
-    }
-
-    @Test
-    public void notificationVolumeNotSeparated_theRingerIconRemainsTheSame() {
-        mDeviceConfigProxy.setProperty(DeviceConfig.NAMESPACE_SYSTEMUI,
-                SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION, "false", false);
-
-        mExecutor.runAllReady();
-
-        assertEquals(mDialog.mVolumeRingerIconDrawableId, R.drawable.ic_volume_ringer);
-        assertEquals(mDialog.mVolumeRingerMuteIconDrawableId, R.drawable.ic_volume_ringer_mute);
-    }
-
 /*
     @Test
     public void testContentDescriptions() {
diff --git a/services/core/java/com/android/server/SystemServiceManager.java b/services/core/java/com/android/server/SystemServiceManager.java
index 78df983..166806b 100644
--- a/services/core/java/com/android/server/SystemServiceManager.java
+++ b/services/core/java/com/android/server/SystemServiceManager.java
@@ -357,13 +357,24 @@
      * Starts the given user.
      */
     public void onUserStarting(@NonNull TimingsTraceAndSlog t, @UserIdInt int userId) {
-        EventLog.writeEvent(EventLogTags.SSM_USER_STARTING, userId);
-
         final TargetUser targetUser = newTargetUser(userId);
         synchronized (mTargetUsers) {
+            // On Automotive / Headless System User Mode, the system user will be started twice:
+            // - Once by some external or local service that switches the system user to
+            //   the background.
+            // - Once by the ActivityManagerService, when the system is marked ready.
+            // These two events are not synchronized and the order of execution is
+            // non-deterministic. To avoid starting the system user twice, verify whether
+            // the system user has already been started by checking the mTargetUsers.
+            // TODO(b/242195409): this workaround shouldn't be necessary once we move
+            // the headless-user start logic to UserManager-land.
+            if (userId == UserHandle.USER_SYSTEM && mTargetUsers.contains(userId)) {
+                Slog.e(TAG, "Skipping starting system user twice");
+                return;
+            }
             mTargetUsers.put(userId, targetUser);
         }
-
+        EventLog.writeEvent(EventLogTags.SSM_USER_STARTING, userId);
         onUser(t, USER_STARTING, /* prevUser= */ null, targetUser);
     }
 
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index fde96b9..bc083f1 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -8163,15 +8163,12 @@
         mBatteryStatsService.noteEvent(BatteryStats.HistoryItem.EVENT_USER_FOREGROUND_START,
                 Integer.toString(currentUserId), currentUserId);
 
-        // On Automotive, at this point the system user has already been started and unlocked,
-        // and some of the tasks we do here have already been done. So skip those in that case.
-        // TODO(b/132262830, b/203885241): this workdound shouldn't be necessary once we move the
-        // headless-user start logic to UserManager-land
-        final boolean bootingSystemUser = currentUserId == UserHandle.USER_SYSTEM;
-
-        if (bootingSystemUser) {
-            mSystemServiceManager.onUserStarting(t, currentUserId);
-        }
+        // On Automotive / Headless System User Mode, at this point the system user has already been
+        // started and unlocked, and some of the tasks we do here have already been done. So skip
+        // those in that case. The duplicate system user start is guarded in SystemServiceManager.
+        // TODO(b/242195409): this workaround shouldn't be necessary once we move the headless-user
+        // start logic to UserManager-land.
+        mSystemServiceManager.onUserStarting(t, currentUserId);
 
         synchronized (this) {
             // Only start up encryption-aware persistent apps; once user is
@@ -8201,7 +8198,15 @@
                 t.traceEnd();
             }
 
-            if (bootingSystemUser) {
+            // Some systems - like automotive - will explicitly unlock system user then switch
+            // to a secondary user. Hence, we don't want to send duplicate broadcasts for
+            // the system user here.
+            // TODO(b/242195409): this workaround shouldn't be necessary once we move
+            // the headless-user start logic to UserManager-land.
+            final boolean isBootingSystemUser = (currentUserId == UserHandle.USER_SYSTEM)
+                    && !UserManager.isHeadlessSystemUserMode();
+
+            if (isBootingSystemUser) {
                 t.traceBegin("startHomeOnAllDisplays");
                 mAtmInternal.startHomeOnAllDisplays(currentUserId, "systemReady");
                 t.traceEnd();
@@ -8212,7 +8217,7 @@
             t.traceEnd();
 
 
-            if (bootingSystemUser) {
+            if (isBootingSystemUser) {
                 t.traceBegin("sendUserStartBroadcast");
                 final int callingUid = Binder.getCallingUid();
                 final int callingPid = Binder.getCallingPid();
@@ -8253,7 +8258,7 @@
             mAtmInternal.resumeTopActivities(false /* scheduleIdle */);
             t.traceEnd();
 
-            if (bootingSystemUser) {
+            if (isBootingSystemUser) {
                 t.traceBegin("sendUserSwitchBroadcasts");
                 mUserController.sendUserSwitchBroadcasts(-1, currentUserId);
                 t.traceEnd();
diff --git a/services/core/java/com/android/server/pm/PackageInstallerSession.java b/services/core/java/com/android/server/pm/PackageInstallerSession.java
index 37bfbb1..7c2e3ea 100644
--- a/services/core/java/com/android/server/pm/PackageInstallerSession.java
+++ b/services/core/java/com/android/server/pm/PackageInstallerSession.java
@@ -366,6 +366,14 @@
     @GuardedBy("mLock")
     private boolean mStageDirInUse = false;
 
+    /**
+     * True if the verification is already in progress. This is used to prevent running
+     * verification again while one is already in progress which will break internal states.
+     *
+     * Worker thread only.
+     */
+    private boolean mVerificationInProgress = false;
+
     /** Permissions have been accepted by the user (see {@link #setPermissionsResult}) */
     @GuardedBy("mLock")
     private boolean mPermissionsManuallyAccepted = false;
@@ -2136,6 +2144,12 @@
             return;
         }
 
+        if (mVerificationInProgress) {
+            Slog.w(TAG, "Verification is already in progress for session " + sessionId);
+            return;
+        }
+        mVerificationInProgress = true;
+
         if (params.isStaged) {
             mStagedSession.verifySession();
         } else {
diff --git a/services/core/java/com/android/server/wm/ActivityStarter.java b/services/core/java/com/android/server/wm/ActivityStarter.java
index eec7801..a3554cd 100644
--- a/services/core/java/com/android/server/wm/ActivityStarter.java
+++ b/services/core/java/com/android/server/wm/ActivityStarter.java
@@ -3037,12 +3037,6 @@
                 newParent = candidateTf;
             }
         }
-        if (newParent.asTask() == null) {
-            // only collect task-fragments.
-            // TODO(b/258095975): we probably shouldn't ever collect the parent here since it isn't
-            //                    changing. The logic that changes it should collect it.
-            newParent.mTransitionController.collect(newParent);
-        }
         if (mStartActivity.getTaskFragment() == null
                 || mStartActivity.getTaskFragment() == newParent) {
             newParent.addChild(mStartActivity, POSITION_TOP);
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index 825e9e0..70055b1 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -20,9 +20,6 @@
 import static android.app.ActivityTaskManager.RESIZE_MODE_FORCED;
 import static android.app.ActivityTaskManager.RESIZE_MODE_SYSTEM_SCREEN_ROTATION;
 import static android.app.ITaskStackListener.FORCED_RESIZEABLE_REASON_SPLIT_SCREEN;
-import static android.app.WindowConfiguration.ACTIVITY_TYPE_ASSISTANT;
-import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
-import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS;
 import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
 import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
 import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
@@ -3129,20 +3126,6 @@
     }
 
     @Override
-    int getOrientation(int candidate) {
-        return canSpecifyOrientation() ? super.getOrientation(candidate) : SCREEN_ORIENTATION_UNSET;
-    }
-
-    private boolean canSpecifyOrientation() {
-        final int windowingMode = getWindowingMode();
-        final int activityType = getActivityType();
-        return windowingMode == WINDOWING_MODE_FULLSCREEN
-                || activityType == ACTIVITY_TYPE_HOME
-                || activityType == ACTIVITY_TYPE_RECENTS
-                || activityType == ACTIVITY_TYPE_ASSISTANT;
-    }
-
-    @Override
     void forAllLeafTasks(Consumer<Task> callback, boolean traverseTopToBottom) {
         final int count = mChildren.size();
         boolean isLeafTask = true;
diff --git a/services/core/java/com/android/server/wm/TaskDisplayArea.java b/services/core/java/com/android/server/wm/TaskDisplayArea.java
index 0cadc25..1088a2e 100644
--- a/services/core/java/com/android/server/wm/TaskDisplayArea.java
+++ b/services/core/java/com/android/server/wm/TaskDisplayArea.java
@@ -27,7 +27,6 @@
 import static android.content.Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT;
 import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_BEHIND;
 import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET;
-import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
 import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
 
 import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_ORIENTATION;
@@ -649,17 +648,6 @@
             }, SCREEN_ORIENTATION_UNSET);
         }
 
-        // Apps and their containers are not allowed to specify an orientation of non floating
-        // visible tasks created by organizer and that has an adjacent task.
-        final Task nonFloatingTopTask =
-                getTask(t -> !t.getWindowConfiguration().tasksAreFloating());
-        if (nonFloatingTopTask != null) {
-            final Task task = nonFloatingTopTask.getCreatedByOrganizerTask();
-            if (task != null && task.getAdjacentTaskFragment() != null && task.isVisible()) {
-                return SCREEN_ORIENTATION_UNSPECIFIED;
-            }
-        }
-
         final int orientation = super.getOrientation(candidate);
         if (orientation != SCREEN_ORIENTATION_UNSET
                 && orientation != SCREEN_ORIENTATION_BEHIND) {
diff --git a/services/core/java/com/android/server/wm/TaskFragment.java b/services/core/java/com/android/server/wm/TaskFragment.java
index 273b4c4..7cac01f 100644
--- a/services/core/java/com/android/server/wm/TaskFragment.java
+++ b/services/core/java/com/android/server/wm/TaskFragment.java
@@ -17,7 +17,9 @@
 package com.android.server.wm;
 
 import static android.app.ActivityTaskManager.INVALID_TASK_ID;
+import static android.app.WindowConfiguration.ACTIVITY_TYPE_ASSISTANT;
 import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
+import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS;
 import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
 import static android.app.WindowConfiguration.ROTATION_UNDEFINED;
 import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
@@ -27,6 +29,8 @@
 import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
 import static android.content.pm.ActivityInfo.FLAG_ALLOW_UNTRUSTED_ACTIVITY_EMBEDDING;
 import static android.content.pm.ActivityInfo.FLAG_RESUME_WHILE_PAUSING;
+import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET;
+import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
 import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
 import static android.content.res.Configuration.ORIENTATION_PORTRAIT;
 import static android.content.res.Configuration.ORIENTATION_UNDEFINED;
@@ -76,6 +80,7 @@
 import android.app.servertransaction.NewIntentItem;
 import android.app.servertransaction.PauseActivityItem;
 import android.app.servertransaction.ResumeActivityItem;
+import android.content.pm.ActivityInfo;
 import android.content.res.Configuration;
 import android.graphics.Point;
 import android.graphics.Rect;
@@ -1807,6 +1812,51 @@
         }
     }
 
+    @ActivityInfo.ScreenOrientation
+    @Override
+    int getOrientation(@ActivityInfo.ScreenOrientation int candidate) {
+        if (shouldReportOrientationUnspecified()) {
+            return SCREEN_ORIENTATION_UNSPECIFIED;
+        }
+        if (canSpecifyOrientation()) {
+            return super.getOrientation(candidate);
+        }
+        return SCREEN_ORIENTATION_UNSET;
+    }
+
+    /**
+     * Whether or not to allow this container to specify an app requested orientation.
+     *
+     * This is different from {@link #providesOrientation()} that
+     * 1. The container may still provide an orientation even if it can't specify the app requested
+     *    one, such as {@link #shouldReportOrientationUnspecified()}
+     * 2. Even if the container can specify an app requested orientation, it may not be used by the
+     *    parent container if it is {@link ActivityInfo#SCREEN_ORIENTATION_UNSPECIFIED}.
+     */
+    boolean canSpecifyOrientation() {
+        final int windowingMode = getWindowingMode();
+        final int activityType = getActivityType();
+        return windowingMode == WINDOWING_MODE_FULLSCREEN
+                || activityType == ACTIVITY_TYPE_HOME
+                || activityType == ACTIVITY_TYPE_RECENTS
+                || activityType == ACTIVITY_TYPE_ASSISTANT;
+    }
+
+    /**
+     * Whether or not the parent container should use the orientation provided by this container
+     * even if it is {@link ActivityInfo#SCREEN_ORIENTATION_UNSPECIFIED}.
+     */
+    @Override
+    boolean providesOrientation() {
+        return super.providesOrientation() || shouldReportOrientationUnspecified();
+    }
+
+    private boolean shouldReportOrientationUnspecified() {
+        // Apps and their containers are not allowed to specify orientation from adjacent
+        // TaskFragment.
+        return getAdjacentTaskFragment() != null && isVisibleRequested();
+    }
+
     @Override
     void forAllTaskFragments(Consumer<TaskFragment> callback, boolean traverseTopToBottom) {
         super.forAllTaskFragments(callback, traverseTopToBottom);
diff --git a/services/core/java/com/android/server/wm/TaskLaunchParamsModifier.java b/services/core/java/com/android/server/wm/TaskLaunchParamsModifier.java
index 14a2d03..3949952 100644
--- a/services/core/java/com/android/server/wm/TaskLaunchParamsModifier.java
+++ b/services/core/java/com/android/server/wm/TaskLaunchParamsModifier.java
@@ -277,29 +277,31 @@
         // is set with the suggestedDisplayArea. If it is set, but the eventual TaskDisplayArea is
         // different, we should recalcuating the bounds.
         boolean hasInitialBoundsForSuggestedDisplayAreaInFreeformMode = false;
-        if (suggestedDisplayArea.inFreeformWindowingMode()) {
-            if (launchMode == WINDOWING_MODE_PINNED) {
-                if (DEBUG) appendLog("picture-in-picture");
-            } else if (!root.isResizeable()) {
-                if (shouldLaunchUnresizableAppInFreeform(root, suggestedDisplayArea, options)) {
-                    launchMode = WINDOWING_MODE_FREEFORM;
-                    if (outParams.mBounds.isEmpty()) {
-                        getTaskBounds(root, suggestedDisplayArea, layout, launchMode,
-                                hasInitialBounds, outParams.mBounds);
-                        hasInitialBoundsForSuggestedDisplayAreaInFreeformMode = true;
-                    }
-                    if (DEBUG) appendLog("unresizable-freeform");
-                } else {
-                    launchMode = WINDOWING_MODE_FULLSCREEN;
-                    outParams.mBounds.setEmpty();
-                    if (DEBUG) appendLog("unresizable-forced-maximize");
+        // shouldSetAsOverrideWindowingMode is set if the task needs to retain the launchMode
+        // regardless of the windowing mode of the parent.
+        boolean shouldSetAsOverrideWindowingMode = false;
+        if (launchMode == WINDOWING_MODE_PINNED) {
+            if (DEBUG) appendLog("picture-in-picture");
+        } else if (!root.isResizeable()) {
+            if (shouldLaunchUnresizableAppInFreeformInFreeformMode(root, suggestedDisplayArea,
+                    options)) {
+                launchMode = WINDOWING_MODE_UNDEFINED;
+                if (outParams.mBounds.isEmpty()) {
+                    getTaskBounds(root, suggestedDisplayArea, layout, launchMode, hasInitialBounds,
+                            outParams.mBounds);
+                    hasInitialBoundsForSuggestedDisplayAreaInFreeformMode = true;
                 }
+                if (DEBUG) appendLog("unresizable-freeform");
+            } else {
+                launchMode = WINDOWING_MODE_FULLSCREEN;
+                outParams.mBounds.setEmpty();
+                shouldSetAsOverrideWindowingMode = true;
+                if (DEBUG) appendLog("unresizable-forced-maximize");
             }
-        } else {
-            if (DEBUG) appendLog("non-freeform-task-display-area");
         }
         // If launch mode matches display windowing mode, let it inherit from display.
         outParams.mWindowingMode = launchMode == suggestedDisplayArea.getWindowingMode()
+                && !shouldSetAsOverrideWindowingMode
                 ? WINDOWING_MODE_UNDEFINED : launchMode;
 
         if (phase == PHASE_WINDOWING_MODE) {
@@ -650,7 +652,7 @@
         inOutBounds.offset(xOffset, yOffset);
     }
 
-    private boolean shouldLaunchUnresizableAppInFreeform(ActivityRecord activity,
+    private boolean shouldLaunchUnresizableAppInFreeformInFreeformMode(ActivityRecord activity,
             TaskDisplayArea displayArea, @Nullable ActivityOptions options) {
         if (options != null && options.getLaunchWindowingMode() == WINDOWING_MODE_FULLSCREEN) {
             // Do not launch the activity in freeform if it explicitly requested fullscreen mode.
@@ -663,8 +665,7 @@
         final int displayOrientation = orientationFromBounds(displayArea.getBounds());
         final int activityOrientation = resolveOrientation(activity, displayArea,
                 displayArea.getBounds());
-        if (displayArea.getWindowingMode() == WINDOWING_MODE_FREEFORM
-                && displayOrientation != activityOrientation) {
+        if (displayOrientation != activityOrientation) {
             return true;
         }
 
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskFragmentTest.java b/services/tests/wmtests/src/com/android/server/wm/TaskFragmentTest.java
index 3ff2c0e..97e5755 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskFragmentTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskFragmentTest.java
@@ -23,6 +23,7 @@
 import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
 import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
 import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET;
+import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
 import static android.os.Process.FIRST_APPLICATION_UID;
 
 import static com.android.dx.mockito.inline.extended.ExtendedMockito.any;
@@ -547,4 +548,31 @@
         activity0.moveFocusableActivityToTop("test");
         assertEquals(activity0, mDisplayContent.mFocusedApp);
     }
+
+    @Test
+    public void testIsVisibleWithAdjacent_reportOrientationUnspecified() {
+        final Task task = createTask(mDisplayContent);
+        final TaskFragment tf0 = createTaskFragmentWithParentTask(task);
+        final TaskFragment tf1 = createTaskFragmentWithParentTask(task);
+        tf0.setAdjacentTaskFragment(tf1);
+        tf0.setWindowingMode(WINDOWING_MODE_MULTI_WINDOW);
+        tf1.setWindowingMode(WINDOWING_MODE_MULTI_WINDOW);
+        task.setBounds(0, 0, 1200, 1000);
+        tf0.setBounds(0, 0, 600, 1000);
+        tf1.setBounds(600, 0, 1200, 1000);
+        final ActivityRecord activity0 = tf0.getTopMostActivity();
+        final ActivityRecord activity1 = tf1.getTopMostActivity();
+        doReturn(true).when(activity0).isVisibleRequested();
+        doReturn(true).when(activity1).isVisibleRequested();
+
+        assertEquals(SCREEN_ORIENTATION_UNSPECIFIED, tf0.getOrientation(SCREEN_ORIENTATION_UNSET));
+        assertEquals(SCREEN_ORIENTATION_UNSPECIFIED, tf1.getOrientation(SCREEN_ORIENTATION_UNSET));
+        assertEquals(SCREEN_ORIENTATION_UNSPECIFIED, task.getOrientation(SCREEN_ORIENTATION_UNSET));
+
+        activity0.setRequestedOrientation(SCREEN_ORIENTATION_LANDSCAPE);
+
+        assertEquals(SCREEN_ORIENTATION_UNSPECIFIED, tf0.getOrientation(SCREEN_ORIENTATION_UNSET));
+        assertEquals(SCREEN_ORIENTATION_UNSPECIFIED, tf1.getOrientation(SCREEN_ORIENTATION_UNSET));
+        assertEquals(SCREEN_ORIENTATION_UNSPECIFIED, task.getOrientation(SCREEN_ORIENTATION_UNSET));
+    }
 }
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskLaunchParamsModifierTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskLaunchParamsModifierTests.java
index 1188f49..2a88eb0 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskLaunchParamsModifierTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskLaunchParamsModifierTests.java
@@ -825,10 +825,11 @@
     }
 
     @Test
-    public void testLaunchesPortraitUnresizableOnFreeformDisplayWithFreeformSizeCompat() {
+    public void testLaunchesPortraitUnresizableOnFreeformLandscapeDisplay() {
         mAtm.mDevEnableNonResizableMultiWindow = true;
         final TestDisplayContent freeformDisplay = createNewDisplayContent(
                 WINDOWING_MODE_FREEFORM);
+        assertTrue(freeformDisplay.getBounds().width() > freeformDisplay.getBounds().height());
         final ActivityOptions options = ActivityOptions.makeBasic();
         mCurrent.mPreferredTaskDisplayArea = freeformDisplay.getDefaultTaskDisplayArea();
         mActivity.info.resizeMode = RESIZE_MODE_UNRESIZEABLE;
@@ -836,12 +837,42 @@
         assertEquals(RESULT_CONTINUE,
                 new CalculateRequestBuilder().setOptions(options).calculate());
 
-        assertEquivalentWindowingMode(WINDOWING_MODE_FREEFORM, mResult.mWindowingMode,
-                WINDOWING_MODE_FREEFORM);
+        assertEquals(WINDOWING_MODE_UNDEFINED, mResult.mWindowingMode);
     }
 
     @Test
-    public void testSkipsForceMaximizingAppsOnNonFreeformDisplay() {
+    public void testLaunchesLandscapeUnresizableOnFreeformLandscapeDisplay() {
+        mAtm.mDevEnableNonResizableMultiWindow = true;
+        final TestDisplayContent freeformDisplay = createNewDisplayContent(
+                WINDOWING_MODE_FREEFORM);
+        assertTrue(freeformDisplay.getBounds().width() > freeformDisplay.getBounds().height());
+        final ActivityOptions options = ActivityOptions.makeBasic();
+        mCurrent.mPreferredTaskDisplayArea = freeformDisplay.getDefaultTaskDisplayArea();
+        mActivity.info.resizeMode = RESIZE_MODE_UNRESIZEABLE;
+        mActivity.info.screenOrientation = SCREEN_ORIENTATION_LANDSCAPE;
+        assertEquals(RESULT_CONTINUE,
+                new CalculateRequestBuilder().setOptions(options).calculate());
+
+        assertEquals(WINDOWING_MODE_FULLSCREEN, mResult.mWindowingMode);
+    }
+
+    @Test
+    public void testLaunchesUndefinedUnresizableOnFreeformLandscapeDisplay() {
+        mAtm.mDevEnableNonResizableMultiWindow = true;
+        final TestDisplayContent freeformDisplay = createNewDisplayContent(
+                WINDOWING_MODE_FREEFORM);
+        assertTrue(freeformDisplay.getBounds().width() > freeformDisplay.getBounds().height());
+        final ActivityOptions options = ActivityOptions.makeBasic();
+        mCurrent.mPreferredTaskDisplayArea = freeformDisplay.getDefaultTaskDisplayArea();
+        mActivity.info.resizeMode = RESIZE_MODE_UNRESIZEABLE;
+        assertEquals(RESULT_CONTINUE,
+                new CalculateRequestBuilder().setOptions(options).calculate());
+
+        assertEquals(WINDOWING_MODE_FULLSCREEN, mResult.mWindowingMode);
+    }
+
+    @Test
+    public void testForceMaximizingAppsOnNonFreeformDisplay() {
         final ActivityOptions options = ActivityOptions.makeBasic();
         options.setLaunchWindowingMode(WINDOWING_MODE_FREEFORM);
         options.setLaunchBounds(new Rect(0, 0, 200, 100));
@@ -855,8 +886,9 @@
         assertEquals(RESULT_CONTINUE,
                 new CalculateRequestBuilder().setOptions(options).calculate());
 
-        assertEquivalentWindowingMode(WINDOWING_MODE_FREEFORM, mResult.mWindowingMode,
-                WINDOWING_MODE_FULLSCREEN);
+        // Non-resizable apps must be launched in fullscreen in a fullscreen display regardless of
+        // other properties.
+        assertEquals(WINDOWING_MODE_FULLSCREEN, mResult.mWindowingMode);
     }
 
     @Test
diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java
index fabab25..f90fbb2 100644
--- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java
+++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java
@@ -620,7 +620,7 @@
     private void logDetectorCreateEventIfNeeded(IHotwordRecognitionStatusCallback callback,
             int detectorType, boolean isCreated, int voiceInteractionServiceUid) {
         if (callback != null) {
-            HotwordMetricsLogger.writeDetectorCreateEvent(detectorType, true,
+            HotwordMetricsLogger.writeDetectorCreateEvent(detectorType, isCreated,
                     voiceInteractionServiceUid);
         }