summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/app/AppCompatTaskInfo.java32
-rw-r--r--core/java/android/companion/virtual/VirtualDeviceManager.java14
-rw-r--r--core/java/android/service/notification/ZenPolicy.java5
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeUtils.kt9
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecoration.java22
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/WindowDecoration.java9
-rw-r--r--libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt8
-rw-r--r--libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/CaptionWindowDecorationTests.kt10
-rw-r--r--libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/WindowDecorationTests.java3
-rw-r--r--packages/SystemUI/res/values/strings.xml2
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyboard/shortcut/ui/composable/ShortcutHelper.kt53
-rw-r--r--packages/SystemUI/src/com/android/systemui/util/sensors/ProximityCheck.java5
-rw-r--r--services/core/java/com/android/server/wm/AppCompatUtils.java36
-rw-r--r--services/core/java/com/android/server/wm/DesktopModeBoundsCalculator.java11
14 files changed, 179 insertions, 40 deletions
diff --git a/core/java/android/app/AppCompatTaskInfo.java b/core/java/android/app/AppCompatTaskInfo.java
index a07f620d944c..a6d3f9dba080 100644
--- a/core/java/android/app/AppCompatTaskInfo.java
+++ b/core/java/android/app/AppCompatTaskInfo.java
@@ -16,6 +16,8 @@
package android.app;
+import static android.app.TaskInfo.PROPERTY_VALUE_UNSET;
+
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.Parcel;
@@ -76,25 +78,37 @@ public class AppCompatTaskInfo implements Parcelable {
* If {@link #isLetterboxDoubleTapEnabled} it contains the current letterbox vertical position
* or {@link TaskInfo#PROPERTY_VALUE_UNSET} otherwise.
*/
- public int topActivityLetterboxVerticalPosition;
+ public int topActivityLetterboxVerticalPosition = PROPERTY_VALUE_UNSET;
/**
* If {@link #isLetterboxDoubleTapEnabled} it contains the current letterbox vertical position
* or {@link TaskInfo#PROPERTY_VALUE_UNSET} otherwise.
*/
- public int topActivityLetterboxHorizontalPosition;
+ public int topActivityLetterboxHorizontalPosition = PROPERTY_VALUE_UNSET;
/**
* If {@link #isLetterboxDoubleTapEnabled} it contains the current width of the letterboxed
* activity or {@link TaskInfo#PROPERTY_VALUE_UNSET} otherwise.
*/
- public int topActivityLetterboxWidth;
+ public int topActivityLetterboxWidth = PROPERTY_VALUE_UNSET;
/**
* If {@link #isLetterboxDoubleTapEnabled} it contains the current height of the letterboxed
* activity or {@link TaskInfo#PROPERTY_VALUE_UNSET} otherwise.
*/
- public int topActivityLetterboxHeight;
+ public int topActivityLetterboxHeight = PROPERTY_VALUE_UNSET;
+
+ /**
+ * Contains the current app height of the letterboxed activity if available or
+ * {@link TaskInfo#PROPERTY_VALUE_UNSET} otherwise.
+ */
+ public int topActivityLetterboxAppHeight = PROPERTY_VALUE_UNSET;
+
+ /**
+ * Contains the current app width of the letterboxed activity if available or
+ * {@link TaskInfo#PROPERTY_VALUE_UNSET} otherwise.
+ */
+ public int topActivityLetterboxAppWidth = PROPERTY_VALUE_UNSET;
/**
* Stores camera-related app compat information about a particular Task.
@@ -162,6 +176,8 @@ public class AppCompatTaskInfo implements Parcelable {
&& topActivityLetterboxVerticalPosition == that.topActivityLetterboxVerticalPosition
&& topActivityLetterboxWidth == that.topActivityLetterboxWidth
&& topActivityLetterboxHeight == that.topActivityLetterboxHeight
+ && topActivityLetterboxAppWidth == that.topActivityLetterboxAppWidth
+ && topActivityLetterboxAppHeight == that.topActivityLetterboxAppHeight
&& topActivityLetterboxHorizontalPosition
== that.topActivityLetterboxHorizontalPosition
&& isUserFullscreenOverrideEnabled == that.isUserFullscreenOverrideEnabled
@@ -188,6 +204,8 @@ public class AppCompatTaskInfo implements Parcelable {
== that.topActivityLetterboxHorizontalPosition
&& topActivityLetterboxWidth == that.topActivityLetterboxWidth
&& topActivityLetterboxHeight == that.topActivityLetterboxHeight
+ && topActivityLetterboxAppWidth == that.topActivityLetterboxAppWidth
+ && topActivityLetterboxAppHeight == that.topActivityLetterboxAppHeight
&& isUserFullscreenOverrideEnabled == that.isUserFullscreenOverrideEnabled
&& isSystemFullscreenOverrideEnabled == that.isSystemFullscreenOverrideEnabled
&& cameraCompatTaskInfo.equalsForCompatUi(that.cameraCompatTaskInfo);
@@ -208,6 +226,8 @@ public class AppCompatTaskInfo implements Parcelable {
topActivityLetterboxHorizontalPosition = source.readInt();
topActivityLetterboxWidth = source.readInt();
topActivityLetterboxHeight = source.readInt();
+ topActivityLetterboxAppWidth = source.readInt();
+ topActivityLetterboxAppHeight = source.readInt();
isUserFullscreenOverrideEnabled = source.readBoolean();
isSystemFullscreenOverrideEnabled = source.readBoolean();
cameraCompatTaskInfo = source.readTypedObject(CameraCompatTaskInfo.CREATOR);
@@ -229,6 +249,8 @@ public class AppCompatTaskInfo implements Parcelable {
dest.writeInt(topActivityLetterboxHorizontalPosition);
dest.writeInt(topActivityLetterboxWidth);
dest.writeInt(topActivityLetterboxHeight);
+ dest.writeInt(topActivityLetterboxAppWidth);
+ dest.writeInt(topActivityLetterboxAppHeight);
dest.writeBoolean(isUserFullscreenOverrideEnabled);
dest.writeBoolean(isSystemFullscreenOverrideEnabled);
dest.writeTypedObject(cameraCompatTaskInfo, flags);
@@ -250,6 +272,8 @@ public class AppCompatTaskInfo implements Parcelable {
+ topActivityLetterboxHorizontalPosition
+ " topActivityLetterboxWidth=" + topActivityLetterboxWidth
+ " topActivityLetterboxHeight=" + topActivityLetterboxHeight
+ + " topActivityLetterboxAppWidth=" + topActivityLetterboxAppWidth
+ + " topActivityLetterboxAppHeight=" + topActivityLetterboxAppHeight
+ " isUserFullscreenOverrideEnabled=" + isUserFullscreenOverrideEnabled
+ " isSystemFullscreenOverrideEnabled=" + isSystemFullscreenOverrideEnabled
+ " cameraCompatTaskInfo=" + cameraCompatTaskInfo.toString()
diff --git a/core/java/android/companion/virtual/VirtualDeviceManager.java b/core/java/android/companion/virtual/VirtualDeviceManager.java
index 42da7e9e1815..d89ffc996151 100644
--- a/core/java/android/companion/virtual/VirtualDeviceManager.java
+++ b/core/java/android/companion/virtual/VirtualDeviceManager.java
@@ -837,8 +837,15 @@ public final class VirtualDeviceManager {
* components.</p>
* <p>Any change to the exemptions will only be applied for new activity launches.</p>
*
+ * @param componentName the component name to be exempt from the activity launch policy.
+ * @param displayId the ID of the display, for which to apply the exemption. The display
+ * must belong to the virtual device.
+ * @throws IllegalArgumentException if the specified display does not belong to the virtual
+ * device.
+ *
* @see #removeActivityPolicyExemption
* @see #setDevicePolicy
+ * @see Display#getDisplayId
*/
@FlaggedApi(android.companion.virtualdevice.flags.Flags.FLAG_ACTIVITY_CONTROL_API)
@RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
@@ -861,8 +868,15 @@ public final class VirtualDeviceManager {
* <p>Note that changing the activity launch policy will clear current set of exempt
* components.</p>
*
+ * @param componentName the component name to be removed from the exemption list.
+ * @param displayId the ID of the display, for which to apply the exemption. The display
+ * must belong to the virtual device.
+ * @throws IllegalArgumentException if the specified display does not belong to the virtual
+ * device.
+ *
* @see #addActivityPolicyExemption
* @see #setDevicePolicy
+ * @see Display#getDisplayId
*/
@FlaggedApi(android.companion.virtualdevice.flags.Flags.FLAG_ACTIVITY_CONTROL_API)
@RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
diff --git a/core/java/android/service/notification/ZenPolicy.java b/core/java/android/service/notification/ZenPolicy.java
index 910c4626ea96..2669391b4d45 100644
--- a/core/java/android/service/notification/ZenPolicy.java
+++ b/core/java/android/service/notification/ZenPolicy.java
@@ -1240,7 +1240,10 @@ public final class ZenPolicy implements Parcelable {
return "invalidState{" + state + "}";
}
- private String peopleTypeToString(@PeopleType int peopleType) {
+ /**
+ * @hide
+ */
+ public static String peopleTypeToString(@PeopleType int peopleType) {
switch (peopleType) {
case PEOPLE_TYPE_ANYONE:
return "anyone";
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeUtils.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeUtils.kt
index 9fcf73d2c375..026094cd6f2a 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeUtils.kt
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeUtils.kt
@@ -63,7 +63,8 @@ fun calculateInitialBounds(
if (taskInfo.isResizeable) {
if (isFixedOrientationPortrait(topActivityInfo.screenOrientation)) {
// Respect apps fullscreen width
- Size(taskInfo.appCompatTaskInfo.topActivityLetterboxWidth, idealSize.height)
+ Size(taskInfo.appCompatTaskInfo.topActivityLetterboxAppWidth,
+ idealSize.height)
} else {
idealSize
}
@@ -79,7 +80,7 @@ fun calculateInitialBounds(
// Respect apps fullscreen height and apply custom app width
Size(
customPortraitWidthForLandscapeApp,
- taskInfo.appCompatTaskInfo.topActivityLetterboxHeight
+ taskInfo.appCompatTaskInfo.topActivityLetterboxAppHeight
)
} else {
idealSize
@@ -143,9 +144,9 @@ fun maximizeSizeGivenAspectRatio(
/** Calculates the aspect ratio of an activity from its fullscreen bounds. */
fun calculateAspectRatio(taskInfo: RunningTaskInfo): Float {
+ val appLetterboxWidth = taskInfo.appCompatTaskInfo.topActivityLetterboxAppWidth
+ val appLetterboxHeight = taskInfo.appCompatTaskInfo.topActivityLetterboxAppHeight
if (taskInfo.appCompatTaskInfo.topActivityBoundsLetterboxed) {
- val appLetterboxWidth = taskInfo.appCompatTaskInfo.topActivityLetterboxWidth
- val appLetterboxHeight = taskInfo.appCompatTaskInfo.topActivityLetterboxHeight
return maxOf(appLetterboxWidth, appLetterboxHeight) /
minOf(appLetterboxWidth, appLetterboxHeight).toFloat()
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecoration.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecoration.java
index 9de065129e47..401b78df026a 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecoration.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecoration.java
@@ -30,6 +30,7 @@ import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.Color;
+import android.graphics.Insets;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.drawable.GradientDrawable;
@@ -37,10 +38,12 @@ import android.graphics.drawable.VectorDrawable;
import android.os.Handler;
import android.util.Size;
import android.view.Choreographer;
+import android.view.InsetsState;
import android.view.MotionEvent;
import android.view.SurfaceControl;
import android.view.View;
import android.view.ViewConfiguration;
+import android.view.WindowInsets;
import android.view.WindowManager;
import android.window.WindowContainerTransaction;
@@ -195,7 +198,8 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
RelayoutParams relayoutParams,
ActivityManager.RunningTaskInfo taskInfo,
boolean applyStartTransactionOnDraw,
- boolean setTaskCropAndPosition) {
+ boolean setTaskCropAndPosition,
+ InsetsState displayInsetsState) {
relayoutParams.reset();
relayoutParams.mRunningTaskInfo = taskInfo;
relayoutParams.mLayoutResId = R.layout.caption_window_decor;
@@ -223,6 +227,8 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
controlsElement.mWidthResId = R.dimen.caption_right_buttons_width;
controlsElement.mAlignment = RelayoutParams.OccludingCaptionElement.Alignment.END;
relayoutParams.mOccludingCaptionElements.add(controlsElement);
+ relayoutParams.mCaptionTopPadding = getTopPadding(relayoutParams,
+ taskInfo.getConfiguration().windowConfiguration.getBounds(), displayInsetsState);
}
@SuppressLint("MissingPermission")
@@ -238,7 +244,7 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
final WindowContainerTransaction wct = new WindowContainerTransaction();
updateRelayoutParams(mRelayoutParams, taskInfo, applyStartTransactionOnDraw,
- setTaskCropAndPosition);
+ setTaskCropAndPosition, mDisplayController.getInsetsState(taskInfo.displayId));
relayout(mRelayoutParams, startT, finishT, wct, oldRootView, mResult);
// After this line, mTaskInfo is up-to-date and should be used instead of taskInfo
@@ -344,6 +350,18 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
mDragResizeListener = null;
}
+ private static int getTopPadding(RelayoutParams params, Rect taskBounds,
+ InsetsState insetsState) {
+ if (!params.mRunningTaskInfo.isFreeform()) {
+ Insets systemDecor = insetsState.calculateInsets(taskBounds,
+ WindowInsets.Type.systemBars() & ~WindowInsets.Type.captionBar(),
+ false /* ignoreVisibility */);
+ return systemDecor.top;
+ } else {
+ return 0;
+ }
+ }
+
/**
* Checks whether the touch event falls inside the customizable caption region.
*/
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/WindowDecoration.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/WindowDecoration.java
index 4cab6e483430..c15411b758b6 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/WindowDecoration.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/WindowDecoration.java
@@ -239,7 +239,8 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
outResult.mHeight = taskBounds.height();
outResult.mRootView.setTaskFocusState(mTaskInfo.isFocused);
final Resources resources = mDecorWindowContext.getResources();
- outResult.mCaptionHeight = loadDimensionPixelSize(resources, params.mCaptionHeightId);
+ outResult.mCaptionHeight = loadDimensionPixelSize(resources, params.mCaptionHeightId)
+ + params.mCaptionTopPadding;
outResult.mCaptionWidth = params.mCaptionWidthId != Resources.ID_NULL
? loadDimensionPixelSize(resources, params.mCaptionWidthId) : taskBounds.width();
outResult.mCaptionX = (outResult.mWidth - outResult.mCaptionWidth) / 2;
@@ -459,6 +460,7 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
}
mViewHost.getRootSurfaceControl().applyTransactionOnDraw(onDrawTransaction);
}
+ outResult.mRootView.setPadding(0, params.mCaptionTopPadding, 0, 0);
mViewHost.setView(outResult.mRootView, lp);
Trace.endSection();
} else {
@@ -469,6 +471,7 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
}
mViewHost.getRootSurfaceControl().applyTransactionOnDraw(onDrawTransaction);
}
+ outResult.mRootView.setPadding(0, params.mCaptionTopPadding, 0, 0);
mViewHost.relayout(lp);
Trace.endSection();
}
@@ -700,6 +703,8 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
int mShadowRadiusId;
int mCornerRadius;
+ int mCaptionTopPadding;
+
Configuration mWindowDecorConfig;
boolean mApplyStartTransactionOnDraw;
@@ -716,6 +721,8 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
mShadowRadiusId = Resources.ID_NULL;
mCornerRadius = 0;
+ mCaptionTopPadding = 0;
+
mApplyStartTransactionOnDraw = false;
mSetTaskPositionAndCrop = false;
mWindowDecorConfig = null;
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt
index dc65a77d182b..76939f61832f 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt
@@ -2735,14 +2735,14 @@ class DesktopTasksControllerTest : ShellTestCase() {
screenOrientation == SCREEN_ORIENTATION_PORTRAIT) {
// Letterbox to portrait size
appCompatTaskInfo.topActivityBoundsLetterboxed = true
- appCompatTaskInfo.topActivityLetterboxWidth = 1200
- appCompatTaskInfo.topActivityLetterboxHeight = 1600
+ appCompatTaskInfo.topActivityLetterboxAppWidth = 1200
+ appCompatTaskInfo.topActivityLetterboxAppHeight = 1600
} else if (deviceOrientation == ORIENTATION_PORTRAIT &&
screenOrientation == SCREEN_ORIENTATION_LANDSCAPE) {
// Letterbox to landscape size
appCompatTaskInfo.topActivityBoundsLetterboxed = true
- appCompatTaskInfo.topActivityLetterboxWidth = 1600
- appCompatTaskInfo.topActivityLetterboxHeight = 1200
+ appCompatTaskInfo.topActivityLetterboxAppWidth = 1600
+ appCompatTaskInfo.topActivityLetterboxAppHeight = 1200
}
} else {
appCompatTaskInfo.topActivityBoundsLetterboxed = false
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/CaptionWindowDecorationTests.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/CaptionWindowDecorationTests.kt
index 261d4b5e7d1a..d141c2d771ce 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/CaptionWindowDecorationTests.kt
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/CaptionWindowDecorationTests.kt
@@ -21,6 +21,7 @@ import android.app.WindowConfiguration
import android.content.ComponentName
import android.testing.AndroidTestingRunner
import android.view.Display
+import android.view.InsetsState
import android.view.WindowInsetsController
import androidx.test.filters.SmallTest
import com.android.wm.shell.ShellTestCase
@@ -45,7 +46,8 @@ class CaptionWindowDecorationTests : ShellTestCase() {
relayoutParams,
taskInfo,
true,
- false
+ false,
+ InsetsState()
)
Truth.assertThat(relayoutParams.hasInputFeatureSpy()).isTrue()
@@ -63,7 +65,8 @@ class CaptionWindowDecorationTests : ShellTestCase() {
relayoutParams,
taskInfo,
true,
- false
+ false,
+ InsetsState()
)
Truth.assertThat(relayoutParams.hasInputFeatureSpy()).isFalse()
@@ -77,7 +80,8 @@ class CaptionWindowDecorationTests : ShellTestCase() {
relayoutParams,
taskInfo,
true,
- false
+ false,
+ InsetsState()
)
Truth.assertThat(relayoutParams.mOccludingCaptionElements.size).isEqualTo(2)
Truth.assertThat(relayoutParams.mOccludingCaptionElements[0].mAlignment).isEqualTo(
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/WindowDecorationTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/WindowDecorationTests.java
index e6e2d0928240..2ec3ab52725e 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/WindowDecorationTests.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/WindowDecorationTests.java
@@ -867,6 +867,7 @@ public class WindowDecorationTests extends ShellTestCase {
final TestWindowDecoration windowDecor = createWindowDecoration(
new TestRunningTaskInfoBuilder().build());
mRelayoutParams.mApplyStartTransactionOnDraw = true;
+ mRelayoutResult.mRootView = mMockView;
windowDecor.updateViewHost(mRelayoutParams, mMockSurfaceControlStartT, mRelayoutResult);
@@ -878,6 +879,7 @@ public class WindowDecorationTests extends ShellTestCase {
final TestWindowDecoration windowDecor = createWindowDecoration(
new TestRunningTaskInfoBuilder().build());
mRelayoutParams.mApplyStartTransactionOnDraw = true;
+ mRelayoutResult.mRootView = mMockView;
assertThrows(IllegalArgumentException.class,
() -> windowDecor.updateViewHost(
@@ -889,6 +891,7 @@ public class WindowDecorationTests extends ShellTestCase {
final TestWindowDecoration windowDecor = createWindowDecoration(
new TestRunningTaskInfoBuilder().build());
mRelayoutParams.mApplyStartTransactionOnDraw = false;
+ mRelayoutResult.mRootView = mMockView;
windowDecor.updateViewHost(mRelayoutParams, null /* onDrawTransaction */, mRelayoutResult);
}
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index fe49f3a12277..19eebf53c03e 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -3651,6 +3651,8 @@
hasn't typed in anything in the search box yet. The helper is a component that shows the
user which keyboard shortcuts they can use. [CHAR LIMIT=NONE] -->
<string name="shortcut_helper_search_placeholder">Search shortcuts</string>
+ <!-- Text shown when a search query didn't produce any results. [CHAR LIMIT=NONE] -->
+ <string name="shortcut_helper_no_search_results">No search results</string>
<!-- Content description of the icon that allows to collapse a keyboard shortcut helper category
panel. The helper is a component that shows the user which keyboard shortcuts they can
use. The helper shows shortcuts in categories, which can be collapsed or expanded.
diff --git a/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/ui/composable/ShortcutHelper.kt b/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/ui/composable/ShortcutHelper.kt
index 67aeddefcb4a..63f3d52b2d2d 100644
--- a/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/ui/composable/ShortcutHelper.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/ui/composable/ShortcutHelper.kt
@@ -36,6 +36,7 @@ import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.FlowRowScope
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
@@ -208,9 +209,24 @@ private fun ShortcutHelperSinglePane(
Spacer(modifier = Modifier.height(6.dp))
ShortcutsSearchBar(onSearchQueryChanged)
Spacer(modifier = Modifier.height(16.dp))
- CategoriesPanelSinglePane(searchQuery, categories, selectedCategoryType, onCategorySelected)
- Spacer(modifier = Modifier.weight(1f))
- KeyboardSettings(onClick = onKeyboardSettingsClicked)
+ if (categories.isEmpty()) {
+ Box(modifier = Modifier.weight(1f)) {
+ NoSearchResultsText(horizontalPadding = 16.dp, fillHeight = true)
+ }
+ } else {
+ CategoriesPanelSinglePane(
+ searchQuery,
+ categories,
+ selectedCategoryType,
+ onCategorySelected
+ )
+ Spacer(modifier = Modifier.weight(1f))
+ }
+ KeyboardSettings(
+ horizontalPadding = 16.dp,
+ verticalPadding = 32.dp,
+ onClick = onKeyboardSettingsClicked
+ )
}
}
@@ -429,7 +445,7 @@ private fun ShortcutHelperTwoPane(
@Composable
private fun EndSidePanel(searchQuery: String, modifier: Modifier, category: ShortcutCategory?) {
if (category == null) {
- // TODO(b/353953351) - Show a "no results" UI?
+ NoSearchResultsText(horizontalPadding = 24.dp, fillHeight = false)
return
}
LazyColumn(modifier.nestedScroll(rememberNestedScrollInteropConnection())) {
@@ -441,6 +457,24 @@ private fun EndSidePanel(searchQuery: String, modifier: Modifier, category: Shor
}
@Composable
+private fun NoSearchResultsText(horizontalPadding: Dp, fillHeight: Boolean) {
+ var modifier = Modifier.fillMaxWidth()
+ if (fillHeight) {
+ modifier = modifier.fillMaxHeight()
+ }
+ Text(
+ stringResource(R.string.shortcut_helper_no_search_results),
+ style = MaterialTheme.typography.bodyMedium,
+ color = MaterialTheme.colorScheme.onSurface,
+ modifier =
+ modifier
+ .padding(vertical = 8.dp)
+ .background(MaterialTheme.colorScheme.surfaceBright, RoundedCornerShape(28.dp))
+ .padding(horizontal = horizontalPadding, vertical = 24.dp)
+ )
+}
+
+@Composable
private fun SubCategoryContainerDualPane(searchQuery: String, subCategory: ShortcutSubCategory) {
Surface(
modifier = Modifier.fillMaxWidth(),
@@ -659,7 +693,11 @@ private fun StartSidePanel(
Spacer(modifier = Modifier.heightIn(8.dp))
CategoriesPanelTwoPane(categories, selectedCategory, onCategoryClicked)
Spacer(modifier = Modifier.weight(1f))
- KeyboardSettings(onKeyboardSettingsClicked)
+ KeyboardSettings(
+ horizontalPadding = 24.dp,
+ verticalPadding = 24.dp,
+ onKeyboardSettingsClicked
+ )
}
}
@@ -805,10 +843,9 @@ private fun ShortcutsSearchBar(onQueryChange: (String) -> Unit) {
}
@Composable
-private fun KeyboardSettings(onClick: () -> Unit) {
+private fun KeyboardSettings(horizontalPadding: Dp, verticalPadding: Dp, onClick: () -> Unit) {
val interactionSource = remember { MutableInteractionSource() }
val isFocused by interactionSource.collectIsFocusedAsState()
-
Surface(
onClick = onClick,
shape = RoundedCornerShape(24.dp),
@@ -834,7 +871,7 @@ private fun KeyboardSettings(onClick: () -> Unit) {
color = MaterialTheme.colorScheme.onSurfaceVariant,
fontSize = 16.sp
)
- Spacer(modifier = Modifier.width(8.dp))
+ Spacer(modifier = Modifier.weight(1f))
Icon(
imageVector = Icons.AutoMirrored.Default.OpenInNew,
contentDescription = null,
diff --git a/packages/SystemUI/src/com/android/systemui/util/sensors/ProximityCheck.java b/packages/SystemUI/src/com/android/systemui/util/sensors/ProximityCheck.java
index c06a3a1e200c..373417b7bd68 100644
--- a/packages/SystemUI/src/com/android/systemui/util/sensors/ProximityCheck.java
+++ b/packages/SystemUI/src/com/android/systemui/util/sensors/ProximityCheck.java
@@ -86,11 +86,12 @@ public class ProximityCheck implements Runnable {
}
private void onProximityEvent(ThresholdSensorEvent proximityEvent) {
- mCallbacks.forEach(
+ List<Consumer<Boolean>> oldCallbacks = mCallbacks;
+ mCallbacks = new ArrayList<>();
+ oldCallbacks.forEach(
booleanConsumer ->
booleanConsumer.accept(
proximityEvent == null ? null : proximityEvent.getBelow()));
- mCallbacks.clear();
unregister();
mRegistered.set(false);
}
diff --git a/services/core/java/com/android/server/wm/AppCompatUtils.java b/services/core/java/com/android/server/wm/AppCompatUtils.java
index 8c5193ef4a52..d98c2b37d8cf 100644
--- a/services/core/java/com/android/server/wm/AppCompatUtils.java
+++ b/services/core/java/com/android/server/wm/AppCompatUtils.java
@@ -89,13 +89,32 @@ class AppCompatUtils {
return activityRecord.info.isChangeEnabled(overrideChangeId);
}
+ /**
+ * Attempts to return the app bounds (bounds without insets) of the top most opaque activity. If
+ * these are not available, it defaults to the bounds of the activity which include insets. In
+ * the event the activity is in Size Compat Mode, the Size Compat bounds are returned instead.
+ */
+ @NonNull
+ static Rect getAppBounds(@NonNull ActivityRecord activityRecord) {
+ // TODO(b/268458693): Refactor configuration inheritance in case of translucent activities
+ final Rect appBounds = activityRecord.getConfiguration().windowConfiguration.getAppBounds();
+ if (appBounds == null) {
+ return activityRecord.getBounds();
+ }
+ return activityRecord.mAppCompatController.getTransparentPolicy()
+ .findOpaqueNotFinishingActivityBelow()
+ .map(AppCompatUtils::getAppBounds)
+ .orElseGet(() -> {
+ if (activityRecord.hasSizeCompatBounds()) {
+ return activityRecord.getScreenResolvedBounds();
+ }
+ return appBounds;
+ });
+ }
+
static void fillAppCompatTaskInfo(@NonNull Task task, @NonNull TaskInfo info,
@Nullable ActivityRecord top) {
final AppCompatTaskInfo appCompatTaskInfo = info.appCompatTaskInfo;
- appCompatTaskInfo.topActivityLetterboxVerticalPosition = TaskInfo.PROPERTY_VALUE_UNSET;
- appCompatTaskInfo.topActivityLetterboxHorizontalPosition = TaskInfo.PROPERTY_VALUE_UNSET;
- appCompatTaskInfo.topActivityLetterboxWidth = TaskInfo.PROPERTY_VALUE_UNSET;
- appCompatTaskInfo.topActivityLetterboxHeight = TaskInfo.PROPERTY_VALUE_UNSET;
appCompatTaskInfo.cameraCompatTaskInfo.freeformCameraCompatMode =
CameraCompatTaskInfo.CAMERA_COMPAT_FREEFORM_NONE;
if (top == null) {
@@ -124,8 +143,13 @@ class AppCompatUtils {
.getAppCompatAspectRatioOverrides().isSystemOverrideToFullscreenEnabled();
appCompatTaskInfo.isFromLetterboxDoubleTap = reachabilityOverrides.isFromDoubleTap();
- appCompatTaskInfo.topActivityLetterboxWidth = top.getBounds().width();
- appCompatTaskInfo.topActivityLetterboxHeight = top.getBounds().height();
+ final Rect bounds = top.getBounds();
+ final Rect appBounds = getAppBounds(top);
+ appCompatTaskInfo.topActivityLetterboxWidth = bounds.width();
+ appCompatTaskInfo.topActivityLetterboxHeight = bounds.height();
+ appCompatTaskInfo.topActivityLetterboxAppWidth = appBounds.width();
+ appCompatTaskInfo.topActivityLetterboxAppHeight = appBounds.height();
+
// We need to consider if letterboxed or pillarboxed.
// TODO(b/336807329) Encapsulate reachability logic
appCompatTaskInfo.isLetterboxDoubleTapEnabled = reachabilityOverrides
diff --git a/services/core/java/com/android/server/wm/DesktopModeBoundsCalculator.java b/services/core/java/com/android/server/wm/DesktopModeBoundsCalculator.java
index 9996bbcb6597..3e55e2d9b25c 100644
--- a/services/core/java/com/android/server/wm/DesktopModeBoundsCalculator.java
+++ b/services/core/java/com/android/server/wm/DesktopModeBoundsCalculator.java
@@ -234,12 +234,13 @@ public final class DesktopModeBoundsCalculator {
float desiredAspectRatio = 0;
if (taskInfo.isRunning) {
final AppCompatTaskInfo appCompatTaskInfo = taskInfo.appCompatTaskInfo;
+ final int appLetterboxWidth =
+ taskInfo.appCompatTaskInfo.topActivityLetterboxAppWidth;
+ final int appLetterboxHeight =
+ taskInfo.appCompatTaskInfo.topActivityLetterboxAppHeight;
if (appCompatTaskInfo.topActivityBoundsLetterboxed) {
- desiredAspectRatio = (float) Math.max(
- appCompatTaskInfo.topActivityLetterboxWidth,
- appCompatTaskInfo.topActivityLetterboxHeight)
- / Math.min(appCompatTaskInfo.topActivityLetterboxWidth,
- appCompatTaskInfo.topActivityLetterboxHeight);
+ desiredAspectRatio = (float) Math.max(appLetterboxWidth, appLetterboxHeight)
+ / Math.min(appLetterboxWidth, appLetterboxHeight);
} else {
desiredAspectRatio = Math.max(fullscreenHeight, fullscreenWidth)
/ Math.min(fullscreenHeight, fullscreenWidth);