Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 739f0cfa authored by Mariia Sandrikova's avatar Mariia Sandrikova Committed by Automerger Merge Worker
Browse files

Merge "Per-app compat treatment for setRequestedOrientation loops." into...

Merge "Per-app compat treatment for setRequestedOrientation loops." into tm-qpr-dev am: 300cd48c am: ead0f1a1

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20838889



Change-Id: I00c50dfe4b723e55eea6374dfbbadf56533ef18c
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents e37b48ec ead0f1a1
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -1065,6 +1065,19 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
    @Retention(RetentionPolicy.SOURCE)
    public @interface SizeChangesSupportMode {}

    /**
     * This change id enables compat policy that ignores app requested orientation in
     * response to an app calling {@link android.app.Activity#setRequestedOrientation}. See
     * com.android.server.wm.LetterboxUiController#shouldIgnoreRequestedOrientation for
     * details.
     * @hide
     */
    @ChangeId
    @Overridable
    @Disabled
    public static final long OVERRIDE_ENABLE_COMPAT_IGNORE_REQUESTED_ORIENTATION =
            254631730L; // buganizer id

    /**
     * This change id forces the packages it is applied to never have Display API sandboxing
     * applied for a letterbox or SCM activity. The Display APIs will continue to provide
+39 −0
Original line number Diff line number Diff line
@@ -813,6 +813,45 @@ public interface WindowManager extends ViewManager {
        int SCREENSHOT_VENDOR_GESTURE = 6;
    }

    /**
     * Activity level {@link android.content.pm.PackageManager.Property PackageManager
     * .Property} for an app to inform the system that the activity can be opted-in or opted-out
     * from the compatibility treatment that avoids {@link
     * android.app.Activity#setRequestedOrientation} loops. The loop can be trigerred by
     * ignoreRequestedOrientation display setting enabled on the device or by the landscape natural
     * orientation of the device.
     *
     * <p>The treatment is disabled by default but device manufacturers can enable the treatment
     * using their discretion to improve display compatibility.
     *
     * <p>With this property set to {@code true}, the system could ignore {@link
     * android.app.Activity#setRequestedOrientation} call from an app if one of the following
     * conditions are true:
     * <ul>
     *     <li>Activity is relaunching due to the previous {@link
     *     android.app.Activity#setRequestedOrientation} call.
     *     <li>Camera compatibility force rotation treatment is active for the package.
     * </ul>
     *
     * <p>Setting this property to {@code false} informs the system that the activity must be
     * opted-out from the compatibility treatment even if the device manufacturer has opted the app
     * into the treatment.
     *
     * <p><b>Syntax:</b>
     * <pre>
     * &lt;activity&gt;
     *   &lt;property
     *     android:name="android.window.PROPERTY_COMPAT_IGNORE_REQUESTED_ORIENTATION"
     *     android:value="true|false"/&gt;
     * &lt;/activity&gt;
     * </pre>
     *
     * @hide
     */
    // TODO(b/263984287): Make this public API.
    String PROPERTY_COMPAT_IGNORE_REQUESTED_ORIENTATION =
            "android.window.PROPERTY_COMPAT_IGNORE_REQUESTED_ORIENTATION";

    /**
     * @hide
     */
+5 −0
Original line number Diff line number Diff line
@@ -5360,6 +5360,11 @@
        If given value is outside of this range, the option 0 (top) is assummed. -->
    <integer name="config_letterboxDefaultPositionForTabletopModeReachability">0</integer>

    <!-- Whether should ignore app requested orientation in response to an app
         calling Activity#setRequestedOrientation. See
         LetterboxUiController#shouldIgnoreRequestedOrientation for details. -->
    <bool name="config_letterboxIsPolicyForIgnoringRequestedOrientationEnabled">false</bool>

    <!-- Whether displaying letterbox education is enabled for letterboxed fullscreen apps. -->
    <bool name="config_letterboxIsEducationEnabled">false</bool>

+1 −0
Original line number Diff line number Diff line
@@ -4430,6 +4430,7 @@
  <java-symbol type="integer" name="config_letterboxDefaultPositionForVerticalReachability" />
  <java-symbol type="integer" name="config_letterboxDefaultPositionForBookModeReachability" />
  <java-symbol type="integer" name="config_letterboxDefaultPositionForTabletopModeReachability" />
  <java-symbol type="bool" name="config_letterboxIsPolicyForIgnoringRequestedOrientationEnabled" />
  <java-symbol type="bool" name="config_letterboxIsEducationEnabled" />
  <java-symbol type="dimen" name="config_letterboxDefaultMinAspectRatioForUnresizableApps" />
  <java-symbol type="bool" name="config_letterboxIsSplitScreenAspectRatioForUnresizableAppsEnabled" />
+20 −5
Original line number Diff line number Diff line
@@ -1451,8 +1451,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                updatePictureInPictureMode(null, false);
            } else {
                mLastReportedMultiWindowMode = inMultiWindowMode;
                ensureActivityConfiguration(0 /* globalChanges */, PRESERVE_WINDOWS,
                        false /* ignoreVisibility */);
                ensureActivityConfiguration(0 /* globalChanges */, PRESERVE_WINDOWS);
            }
        }
    }
@@ -3981,6 +3980,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    }

    void finishRelaunching() {
        mLetterboxUiController.setRelauchingAfterRequestedOrientationChanged(false);
        mTaskSupervisor.getActivityMetricsLogger().notifyActivityRelaunched(this);

        if (mPendingRelaunchCount > 0) {
@@ -7724,13 +7724,17 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    }

    void setRequestedOrientation(int requestedOrientation) {
        if (mLetterboxUiController.shouldIgnoreRequestedOrientation(requestedOrientation)) {
            return;
        }
        setOrientation(requestedOrientation, this);

        // Push the new configuration to the requested app in case where it's not pushed, e.g. when
        // the request is handled at task level with letterbox.
        if (!getMergedOverrideConfiguration().equals(
                mLastReportedConfiguration.getMergedConfiguration())) {
            ensureActivityConfiguration(0 /* globalChanges */, false /* preserveWindow */);
            ensureActivityConfiguration(0 /* globalChanges */, false /* preserveWindow */,
                    false /* ignoreVisibility */, true /* isRequestedOrientationChanged */);
        }

        mAtmService.getTaskChangeNotificationController().notifyActivityRequestedOrientationChanged(
@@ -9060,7 +9064,13 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A

    boolean ensureActivityConfiguration(int globalChanges, boolean preserveWindow) {
        return ensureActivityConfiguration(globalChanges, preserveWindow,
                false /* ignoreVisibility */);
                false /* ignoreVisibility */, false /* isRequestedOrientationChanged */);
    }

    boolean ensureActivityConfiguration(int globalChanges, boolean preserveWindow,
            boolean ignoreVisibility) {
        return ensureActivityConfiguration(globalChanges, preserveWindow, ignoreVisibility,
                false /* isRequestedOrientationChanged */);
    }

    /**
@@ -9074,11 +9084,13 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
     *                         (stopped state). This is useful for the case where we know the
     *                         activity will be visible soon and we want to ensure its configuration
     *                         before we make it visible.
     * @param isRequestedOrientationChanged whether this is triggered in response to an app calling
     *                                      {@link android.app.Activity#setRequestedOrientation}.
     * @return False if the activity was relaunched and true if it wasn't relaunched because we
     *         can't or the app handles the specific configuration that is changing.
     */
    boolean ensureActivityConfiguration(int globalChanges, boolean preserveWindow,
            boolean ignoreVisibility) {
            boolean ignoreVisibility, boolean isRequestedOrientationChanged) {
        final Task rootTask = getRootTask();
        if (rootTask.mConfigWillChange) {
            ProtoLog.v(WM_DEBUG_CONFIGURATION, "Skipping config check "
@@ -9202,6 +9214,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            } else {
                mRelaunchReason = RELAUNCH_REASON_NONE;
            }
            if (isRequestedOrientationChanged) {
                mLetterboxUiController.setRelauchingAfterRequestedOrientationChanged(true);
            }
            if (mState == PAUSING) {
                // A little annoying: we are waiting for this activity to finish pausing. Let's not
                // do anything now, but just flag that it needs to be restarted when done pausing.
Loading