summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
author Diego Vela <diegovela@google.com> 2023-09-22 18:30:43 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2023-09-22 18:30:43 +0000
commit9aa1ab6c927598bb93e084323ed7b4b42026d80d (patch)
tree8478876b9cb7d64a2361610ea2262cc8e5b538e0 /libs
parent23b9d378cdfb82c1ebfb419d8a03485650c4ae32 (diff)
parente52958999c001486f421cdc874b4727a2994ff53 (diff)
Merge "Report folding features to letterboxed apps." into udc-qpr-dev-plus-aosp
Diffstat (limited to 'libs')
-rw-r--r--libs/WindowManager/Jetpack/src/androidx/window/extensions/WindowExtensionsImpl.java9
-rw-r--r--libs/WindowManager/Jetpack/src/androidx/window/extensions/layout/WindowLayoutComponentImpl.java45
2 files changed, 6 insertions, 48 deletions
diff --git a/libs/WindowManager/Jetpack/src/androidx/window/extensions/WindowExtensionsImpl.java b/libs/WindowManager/Jetpack/src/androidx/window/extensions/WindowExtensionsImpl.java
index 55eabb039c01..9da6c10c6d74 100644
--- a/libs/WindowManager/Jetpack/src/androidx/window/extensions/WindowExtensionsImpl.java
+++ b/libs/WindowManager/Jetpack/src/androidx/window/extensions/WindowExtensionsImpl.java
@@ -19,7 +19,6 @@ package androidx.window.extensions;
import android.app.ActivityThread;
import android.app.Application;
import android.content.Context;
-import android.window.TaskFragmentOrganizer;
import androidx.annotation.NonNull;
import androidx.window.common.DeviceStateManagerFoldingFeatureProducer;
@@ -81,13 +80,7 @@ public class WindowExtensionsImpl implements WindowExtensions {
Context context = getApplication();
DeviceStateManagerFoldingFeatureProducer producer =
getFoldingFeatureProducer();
- // TODO(b/263263909) Use the organizer to tell if an Activity is embededed.
- // Need to improve our Dependency Injection and centralize the logic.
- TaskFragmentOrganizer organizer = new TaskFragmentOrganizer(command -> {
- throw new RuntimeException("Not allowed!");
- });
- mWindowLayoutComponent = new WindowLayoutComponentImpl(context, organizer,
- producer);
+ mWindowLayoutComponent = new WindowLayoutComponentImpl(context, producer);
}
}
}
diff --git a/libs/WindowManager/Jetpack/src/androidx/window/extensions/layout/WindowLayoutComponentImpl.java b/libs/WindowManager/Jetpack/src/androidx/window/extensions/layout/WindowLayoutComponentImpl.java
index 6db2ae4d2141..69c1d294eab0 100644
--- a/libs/WindowManager/Jetpack/src/androidx/window/extensions/layout/WindowLayoutComponentImpl.java
+++ b/libs/WindowManager/Jetpack/src/androidx/window/extensions/layout/WindowLayoutComponentImpl.java
@@ -24,7 +24,6 @@ import static androidx.window.util.ExtensionHelper.rotateRectToDisplayRotation;
import static androidx.window.util.ExtensionHelper.transformToWindowSpaceRect;
import android.app.Activity;
-import android.app.ActivityClient;
import android.app.Application;
import android.app.WindowConfiguration;
import android.content.ComponentCallbacks;
@@ -34,8 +33,6 @@ import android.graphics.Rect;
import android.os.Bundle;
import android.os.IBinder;
import android.util.ArrayMap;
-import android.view.WindowManager;
-import android.window.TaskFragmentOrganizer;
import androidx.annotation.GuardedBy;
import androidx.annotation.NonNull;
@@ -51,7 +48,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
-import java.util.Objects;
import java.util.Set;
/**
@@ -85,16 +81,12 @@ public class WindowLayoutComponentImpl implements WindowLayoutComponent {
private final Map<java.util.function.Consumer<WindowLayoutInfo>, Consumer<WindowLayoutInfo>>
mJavaToExtConsumers = new ArrayMap<>();
- private final TaskFragmentOrganizer mTaskFragmentOrganizer;
-
public WindowLayoutComponentImpl(@NonNull Context context,
- @NonNull TaskFragmentOrganizer taskFragmentOrganizer,
@NonNull DeviceStateManagerFoldingFeatureProducer foldingFeatureProducer) {
((Application) context.getApplicationContext())
.registerActivityLifecycleCallbacks(new NotifyOnConfigurationChanged());
mFoldingFeatureProducer = foldingFeatureProducer;
mFoldingFeatureProducer.addDataChangedCallback(this::onDisplayFeaturesChanged);
- mTaskFragmentOrganizer = taskFragmentOrganizer;
}
/** Registers to listen to {@link CommonFoldingFeature} changes */
@@ -382,38 +374,11 @@ public class WindowLayoutComponentImpl implements WindowLayoutComponent {
// Display features are not supported on secondary displays.
return false;
}
- final int windowingMode;
- IBinder activityToken = context.getActivityToken();
- if (activityToken != null) {
- final Configuration taskConfig = ActivityClient.getInstance().getTaskConfiguration(
- activityToken);
- if (taskConfig == null) {
- // If we cannot determine the task configuration for any reason, it is likely that
- // we won't be able to determine its position correctly as well. DisplayFeatures'
- // bounds in this case can't be computed correctly, so we should skip.
- return false;
- }
- final Rect taskBounds = taskConfig.windowConfiguration.getBounds();
- final WindowManager windowManager = Objects.requireNonNull(
- context.getSystemService(WindowManager.class));
- final Rect maxBounds = windowManager.getMaximumWindowMetrics().getBounds();
- boolean isTaskExpanded = maxBounds.equals(taskBounds);
- /*
- * We need to proxy being in full screen because when a user enters PiP and exits PiP
- * the task windowingMode will report multi-window/pinned until the transition is
- * finished in WM Shell.
- * maxBounds == taskWindowBounds is a proxy check to verify the window is full screen
- */
- return isTaskExpanded;
- } else {
- // TODO(b/242674941): use task windowing mode for window context that associates with
- // activity.
- windowingMode = context.getResources().getConfiguration().windowConfiguration
- .getWindowingMode();
- }
- // It is recommended not to report any display features in multi-window mode, since it
- // won't be possible to synchronize the display feature positions with window movement.
- return !WindowConfiguration.inMultiWindowMode(windowingMode);
+
+ // We do not report folding features for Activities in PiP because the bounds are
+ // not updated fast enough and the window is too small for the UI to adapt.
+ return context.getResources().getConfiguration().windowConfiguration
+ .getWindowingMode() != WindowConfiguration.WINDOWING_MODE_PINNED;
}
@GuardedBy("mLock")