Merge "InputMethodManagerServiceTestBase: make robust against setup failure" into udc-dev
diff --git a/core/java/android/service/dreams/DreamActivity.java b/core/java/android/service/dreams/DreamActivity.java
index a2fa139..a389223 100644
--- a/core/java/android/service/dreams/DreamActivity.java
+++ b/core/java/android/service/dreams/DreamActivity.java
@@ -58,11 +58,13 @@
             setTitle(title);
         }
 
-        final Bundle extras = getIntent().getExtras();
-        mCallback = (DreamService.DreamActivityCallbacks) extras.getBinder(EXTRA_CALLBACK);
-
-        if (mCallback != null) {
+        final Object callback = getIntent().getExtras().getBinder(EXTRA_CALLBACK);
+        if (callback instanceof DreamService.DreamActivityCallbacks) {
+            mCallback = (DreamService.DreamActivityCallbacks) callback;
             mCallback.onActivityCreated(this);
+        } else {
+            mCallback = null;
+            finishAndRemoveTask();
         }
     }
 
diff --git a/data/keyboards/Vendor_004c_Product_0265.idc b/data/keyboards/Vendor_004c_Product_0265.idc
deleted file mode 120000
index 707dfcf..0000000
--- a/data/keyboards/Vendor_004c_Product_0265.idc
+++ /dev/null
@@ -1 +0,0 @@
-Vendor_05ac_Product_0265.idc
\ No newline at end of file
diff --git a/data/keyboards/Vendor_03f6_Product_a001.idc b/data/keyboards/Vendor_03f6_Product_a001.idc
deleted file mode 100644
index bcb4ee3..0000000
--- a/data/keyboards/Vendor_03f6_Product_a001.idc
+++ /dev/null
@@ -1,22 +0,0 @@
-# Copyright 2023 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-#
-# Brydge Touchpad
-#
-
-# Reports from this touchpad sometimes get bunched together due to Bluetooth
-# batching, leading to bad timestamps that mess up finger velocity calculations.
-# To fix this, set a fake delta using the touchpad's known report rate.
-gestureProp.Fake_Timestamp_Delta = 0.010
diff --git a/data/keyboards/Vendor_046d_Product_4011.idc b/data/keyboards/Vendor_046d_Product_4011.idc
deleted file mode 100644
index 3a23830..0000000
--- a/data/keyboards/Vendor_046d_Product_4011.idc
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright 2023 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-#
-# Logitech Wireless Touchpad
-#
-
-gestureProp.Touchpad_Stack_Version = 1
-gestureProp.IIR_b0 = 1
-gestureProp.IIR_b1 = 0
-gestureProp.IIR_b2 = 0
-gestureProp.IIR_b3 = 0
-gestureProp.IIR_a1 = 0
-gestureProp.IIR_a2 = 0
-gestureProp.Pressure_Calibration_Offset = -313.240741792594
-gestureProp.Pressure_Calibration_Slope = 4.39678062436752
-gestureProp.Max_Allowed_Pressure_Change_Per_Sec = 100000.0
-gestureProp.Max_Hysteresis_Pressure_Per_Sec = 100000.0
-gestureProp.Palm_Pressure = 100000.0
-gestureProp.Two_Finger_Vertical_Close_Distance_Thresh = 35.0
-gestureProp.Fling_Buffer_Suppress_Zero_Length_Scrolls = 0
diff --git a/data/keyboards/Vendor_046d_Product_4101.idc b/data/keyboards/Vendor_046d_Product_4101.idc
deleted file mode 100644
index 47e2530..0000000
--- a/data/keyboards/Vendor_046d_Product_4101.idc
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright 2023 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-#
-# Logitech T650
-#
-
-gestureProp.Touchpad_Stack_Version = 1
-gestureProp.IIR_b0 = 1
-gestureProp.IIR_b1 = 0
-gestureProp.IIR_b2 = 0
-gestureProp.IIR_b3 = 0
-gestureProp.IIR_a1 = 0
-gestureProp.IIR_a2 = 0
-gestureProp.Pressure_Calibration_Offset = -0.439288351750068
-gestureProp.Pressure_Calibration_Slope = 3.05998553523335
-gestureProp.Max_Allowed_Pressure_Change_Per_Sec = 100000.0
-gestureProp.Max_Hysteresis_Pressure_Per_Sec = 100000.0
-gestureProp.Two_Finger_Vertical_Close_Distance_Thresh = 35.0
-gestureProp.Fling_Buffer_Suppress_Zero_Length_Scrolls = 0
diff --git a/data/keyboards/Vendor_046d_Product_4102.idc b/data/keyboards/Vendor_046d_Product_4102.idc
deleted file mode 100644
index e33a28a..0000000
--- a/data/keyboards/Vendor_046d_Product_4102.idc
+++ /dev/null
@@ -1,24 +0,0 @@
-# Copyright 2023 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-#
-# Logitech TK820
-#
-
-gestureProp.Touchpad_Stack_Version = 2
-# Pressure jumps around a lot on this touchpad, so allow that:
-gestureProp.Max_Allowed_Pressure_Change_Per_Sec = 100000.0
-gestureProp.Max_Hysteresis_Pressure_Per_Sec = 100000.0
-gestureProp.Pressure_Calibration_Offset = -18.8078435
-gestureProp.Pressure_Calibration_Slope = 2.466208137
diff --git a/data/keyboards/Vendor_046d_Product_b00c.idc b/data/keyboards/Vendor_046d_Product_b00c.idc
deleted file mode 100644
index a49970c..0000000
--- a/data/keyboards/Vendor_046d_Product_b00c.idc
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright 2023 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-#
-# Logitech T651
-#
-
-gestureProp.Touchpad_Stack_Version = 1
-gestureProp.IIR_b0 = 1
-gestureProp.IIR_b1 = 0
-gestureProp.IIR_b2 = 0
-gestureProp.IIR_b3 = 0
-gestureProp.IIR_a1 = 0
-gestureProp.IIR_a2 = 0
-gestureProp.Pressure_Calibration_Offset = -4.46520447177073
-gestureProp.Pressure_Calibration_Slope = 3.21071719332644
-gestureProp.Max_Allowed_Pressure_Change_Per_Sec = 100000.0
-gestureProp.Max_Hysteresis_Pressure_Per_Sec = 100000.0
-gestureProp.Two_Finger_Vertical_Close_Distance_Thresh = 35.0
-gestureProp.Fling_Buffer_Suppress_Zero_Length_Scrolls = 0
diff --git a/data/keyboards/Vendor_05ac_Product_0265.idc b/data/keyboards/Vendor_05ac_Product_0265.idc
deleted file mode 100644
index d72de64..0000000
--- a/data/keyboards/Vendor_05ac_Product_0265.idc
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright 2023 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-#
-# Apple Magic Trackpad 2 configuration file
-#   Bluetooth vendor ID 004c
-#   USB vendor ID 05ac
-#
-
-gestureProp.Pressure_Calibration_Offset = 30
-gestureProp.Palm_Pressure = 250.0
-gestureProp.Palm_Width = 20.0
-gestureProp.Multiple_Palm_Width = 20.0
-
-# Enable Stationary Wiggle Filter
-gestureProp.Stationary_Wiggle_Filter_Enabled = 1
-gestureProp.Finger_Moving_Energy = 0.0008
-gestureProp.Finger_Moving_Hysteresis = 0.0004
-
-# Avoid accidental scroll/move on finger lift
-gestureProp.Max_Stationary_Move_Speed = 47
-gestureProp.Max_Stationary_Move_Speed_Hysteresis = 1
-gestureProp.Max_Stationary_Move_Suppress_Distance = 0.2
diff --git a/data/keyboards/Vendor_05ac_Product_030e.idc b/data/keyboards/Vendor_05ac_Product_030e.idc
deleted file mode 100644
index 23a2e18..0000000
--- a/data/keyboards/Vendor_05ac_Product_030e.idc
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright 2023 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-#
-# Apple Magic Trackpad
-#
-
-gestureProp.Touchpad_Stack_Version = 1
-# We are using raw touch major value as pressure value, so set the Palm
-# pressure threshold high.
-gestureProp.Palm_Pressure = 1000
-gestureProp.Compute_Surface_Area_from_Pressure = 0
-gestureProp.IIR_b0 = 1
-gestureProp.IIR_b1 = 0
-gestureProp.IIR_b2 = 0
-gestureProp.IIR_b3 = 0
-gestureProp.IIR_a1 = 0
-gestureProp.IIR_a2 = 0
-# NOTE: bias on X-axis is uncalibrated
-gestureProp.Touchpad_Device_Output_Bias_on_X-Axis = -283.3226025266607
-gestureProp.Touchpad_Device_Output_Bias_on_Y-Axis = -283.3226025266607
-gestureProp.Max_Allowed_Pressure_Change_Per_Sec = 100000.0
-gestureProp.Max_Hysteresis_Pressure_Per_Sec = 100000.0
-# Drumroll suppression causes janky movement on this touchpad.
-gestureProp.Drumroll_Suppression_Enable = 0
-gestureProp.Two_Finger_Vertical_Close_Distance_Thresh = 35.0
-gestureProp.Fling_Buffer_Suppress_Zero_Length_Scrolls = 0
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/utilities/PreviewPositionHelper.java b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/utilities/PreviewPositionHelper.java
index 8690b36..0c2341f 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/utilities/PreviewPositionHelper.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/utilities/PreviewPositionHelper.java
@@ -33,8 +33,6 @@
      */
     public static final int STAGE_POSITION_BOTTOM_OR_RIGHT = 1;
 
-    // Contains the portion of the thumbnail that is unclipped when fullscreen progress = 1.
-    private final RectF mClippedInsets = new RectF();
     private final Matrix mMatrix = new Matrix();
     private boolean mIsOrientationChanged;
     private SplitBounds mSplitBounds;
@@ -70,33 +68,6 @@
         int thumbnailRotation = thumbnailData.rotation;
         int deltaRotate = getRotationDelta(currentRotation, thumbnailRotation);
         RectF thumbnailClipHint = new RectF();
-
-        float scaledTaskbarSize;
-        float canvasScreenRatio;
-        if (mSplitBounds != null) {
-            if (mSplitBounds.appsStackedVertically) {
-                if (mDesiredStagePosition == STAGE_POSITION_TOP_OR_LEFT) {
-                    // Top app isn't cropped at all by taskbar
-                    canvasScreenRatio = 0;
-                } else {
-                    // Same as fullscreen ratio
-                    canvasScreenRatio = (float) canvasWidth / screenWidthPx;
-                }
-            } else {
-                // For landscape, scale the width
-                float taskPercent = mDesiredStagePosition == STAGE_POSITION_TOP_OR_LEFT
-                        ? mSplitBounds.leftTaskPercent
-                        : (1 - (mSplitBounds.leftTaskPercent + mSplitBounds.dividerWidthPercent));
-                // Scale landscape width to that of actual screen
-                float fullscreenTaskWidth = screenWidthPx * taskPercent;
-                canvasScreenRatio = canvasWidth / fullscreenTaskWidth;
-            }
-        } else {
-            canvasScreenRatio = (float) canvasWidth / screenWidthPx;
-        }
-        scaledTaskbarSize = taskbarSize * canvasScreenRatio;
-        thumbnailClipHint.bottom = isLargeScreen ? scaledTaskbarSize : 0;
-
         float scale = thumbnailData.scale;
         final float thumbnailScale;
 
@@ -116,10 +87,8 @@
 
             float surfaceWidth = thumbnailBounds.width() / scale;
             float surfaceHeight = thumbnailBounds.height() / scale;
-            float availableWidth = surfaceWidth
-                    - (thumbnailClipHint.left + thumbnailClipHint.right);
-            float availableHeight = surfaceHeight
-                    - (thumbnailClipHint.top + thumbnailClipHint.bottom);
+            float availableWidth = surfaceWidth;
+            float availableHeight = surfaceHeight;
 
             float canvasAspect = canvasWidth / (float) canvasHeight;
             float availableAspect = isRotated
@@ -210,8 +179,6 @@
             setThumbnailRotation(deltaRotate, thumbnailBounds);
         }
 
-        mClippedInsets.set(0, 0, 0, scaledTaskbarSize);
-
         mMatrix.postScale(thumbnailScale, thumbnailScale);
         mIsOrientationChanged = isOrientationDifferent;
     }
@@ -250,8 +217,4 @@
         }
         mMatrix.postTranslate(translateX, translateY);
     }
-
-    public RectF getClippedInsets() {
-        return mClippedInsets;
-    }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/SideFpsController.kt b/packages/SystemUI/src/com/android/systemui/biometrics/SideFpsController.kt
index f7d87fc..b62c729 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/SideFpsController.kt
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/SideFpsController.kt
@@ -64,6 +64,7 @@
 import com.android.systemui.keyguard.domain.interactor.AlternateBouncerInteractor
 import com.android.systemui.recents.OverviewProxyService
 import com.android.systemui.util.concurrency.DelayableExecutor
+import com.android.systemui.util.traceSection
 import java.io.PrintWriter
 import javax.inject.Inject
 import kotlinx.coroutines.CoroutineScope
@@ -215,7 +216,9 @@
         requests.add(request)
         mainExecutor.execute {
             if (overlayView == null) {
-                createOverlayForDisplay(reason)
+                traceSection("SideFpsController#show(request=${request.name}, reason=$reason") {
+                    createOverlayForDisplay(reason)
+                }
             } else {
                 Log.v(TAG, "overlay already shown")
             }
@@ -227,7 +230,7 @@
         requests.remove(request)
         mainExecutor.execute {
             if (requests.isEmpty()) {
-                overlayView = null
+                traceSection("SideFpsController#hide(${request.name}") { overlayView = null }
             }
         }
     }
diff --git a/packages/SystemUI/src/com/android/systemui/flags/Flags.kt b/packages/SystemUI/src/com/android/systemui/flags/Flags.kt
index cbd61ffc..265a9903 100644
--- a/packages/SystemUI/src/com/android/systemui/flags/Flags.kt
+++ b/packages/SystemUI/src/com/android/systemui/flags/Flags.kt
@@ -628,14 +628,12 @@
     @JvmField val UDFPS_ELLIPSE_DETECTION = releasedFlag(2201, "udfps_ellipse_detection")
 
     // 2300 - stylus
+    @JvmField val TRACK_STYLUS_EVER_USED = releasedFlag(2300, "track_stylus_ever_used")
     @JvmField
-    val TRACK_STYLUS_EVER_USED = unreleasedFlag(2300, "track_stylus_ever_used", teamfood = true)
-    @JvmField
-    val ENABLE_STYLUS_CHARGING_UI =
-        unreleasedFlag(2301, "enable_stylus_charging_ui", teamfood = true)
+    val ENABLE_STYLUS_CHARGING_UI = releasedFlag(2301, "enable_stylus_charging_ui")
     @JvmField
     val ENABLE_USI_BATTERY_NOTIFICATIONS =
-        unreleasedFlag(2302, "enable_usi_battery_notifications", teamfood = true)
+        releasedFlag(2302, "enable_usi_battery_notifications")
     @JvmField val ENABLE_STYLUS_EDUCATION = unreleasedFlag(2303, "enable_stylus_education")
 
     // 2400 - performance tools and debugging info
diff --git a/packages/SystemUI/src/com/android/systemui/mediaprojection/appselector/view/TaskPreviewSizeProvider.kt b/packages/SystemUI/src/com/android/systemui/mediaprojection/appselector/view/TaskPreviewSizeProvider.kt
index 1c90154..9bccb7d 100644
--- a/packages/SystemUI/src/com/android/systemui/mediaprojection/appselector/view/TaskPreviewSizeProvider.kt
+++ b/packages/SystemUI/src/com/android/systemui/mediaprojection/appselector/view/TaskPreviewSizeProvider.kt
@@ -24,6 +24,7 @@
 import com.android.systemui.mediaprojection.appselector.MediaProjectionAppSelectorScope
 import com.android.systemui.mediaprojection.appselector.view.TaskPreviewSizeProvider.TaskPreviewSizeListener
 import com.android.systemui.shared.recents.utilities.Utilities.isLargeScreen
+import com.android.systemui.shared.system.QuickStepContract
 import com.android.systemui.statusbar.policy.CallbackController
 import com.android.systemui.statusbar.policy.ConfigurationController
 import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener
@@ -61,8 +62,15 @@
         val width = windowMetrics.bounds.width()
         var height = maximumWindowHeight
 
+        // TODO(b/271410803): Read isTransientTaskbar from Launcher
         val isLargeScreen = isLargeScreen(context)
-        if (isLargeScreen) {
+        val isTransientTaskbar =
+            QuickStepContract.isGesturalMode(
+                context.resources.getInteger(
+                    com.android.internal.R.integer.config_navBarInteractionMode
+                )
+            )
+        if (isLargeScreen && !isTransientTaskbar) {
             val taskbarSize =
                 context.resources.getDimensionPixelSize(AndroidR.dimen.taskbar_frame_height)
             height -= taskbarSize
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 67ba078..4b2467d 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -17279,6 +17279,9 @@
         public ComponentName startSdkSandboxService(Intent service, int clientAppUid,
                 String clientAppPackage, String processName) throws RemoteException {
             validateSdkSandboxParams(service, clientAppUid, clientAppPackage, processName);
+            if (mAppOpsService.checkPackage(clientAppUid, clientAppPackage) != MODE_ALLOWED) {
+                throw new IllegalArgumentException("uid does not belong to provided package");
+            }
             // TODO(b/269598719): Is passing the application thread of the system_server alright?
             // e.g. the sandbox getting privileged access due to this.
             ComponentName cn = ActivityManagerService.this.startService(
@@ -17345,6 +17348,9 @@
                 String processName, long flags)
                 throws RemoteException {
             validateSdkSandboxParams(service, clientAppUid, clientAppPackage, processName);
+            if (mAppOpsService.checkPackage(clientAppUid, clientAppPackage) != MODE_ALLOWED) {
+                throw new IllegalArgumentException("uid does not belong to provided package");
+            }
             if (conn == null) {
                 throw new IllegalArgumentException("connection is null");
             }
@@ -17397,9 +17403,6 @@
             if (!UserHandle.isApp(clientAppUid)) {
                 throw new IllegalArgumentException("uid is not within application range");
             }
-            if (mAppOpsService.checkPackage(clientAppUid, clientAppPackage) != MODE_ALLOWED) {
-                throw new IllegalArgumentException("uid does not belong to provided package");
-            }
         }
 
         @Override