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

Commit 084e87ae authored by Kevin Chyn's avatar Kevin Chyn Committed by Android (Google) Code Review
Browse files

Merge "Prevent activities on rear display"

parents 33ab8684 b776da88
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1412,6 +1412,7 @@ package android.hardware.display {
    method @RequiresPermission(android.Manifest.permission.OVERRIDE_DISPLAY_MODE_REQUESTS) public void setShouldAlwaysRespectAppRequestedMode(boolean);
    method @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public void setUserDisabledHdrTypes(@NonNull int[]);
    method @RequiresPermission(android.Manifest.permission.OVERRIDE_DISPLAY_MODE_REQUESTS) public boolean shouldAlwaysRespectAppRequestedMode();
    field public static final String DISPLAY_CATEGORY_REAR = "android.hardware.display.category.REAR";
    field public static final int SWITCHING_TYPE_ACROSS_AND_WITHIN_GROUPS = 2; // 0x2
    field public static final int SWITCHING_TYPE_NONE = 0; // 0x0
    field public static final int SWITCHING_TYPE_RENDER_FRAME_RATE_ONLY = 3; // 0x3
+1 −0
Original line number Diff line number Diff line
@@ -128,6 +128,7 @@ public final class DisplayManager {
     * @see #getDisplays(String)
     * @hide
     */
    @TestApi
    public static final String DISPLAY_CATEGORY_REAR =
            "android.hardware.display.category.REAR";

+5 −0
Original line number Diff line number Diff line
@@ -1161,6 +1161,11 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
            return false;
        }

        if ((displayContent.mDisplay.getFlags() & Display.FLAG_REAR) != 0) {
            Slog.w(TAG, "Launch on display check: activity launch is not allowed on rear display");
            return false;
        }

        // Check if the caller has enough privileges to embed activities and launch to private
        // displays.
        final int startAnyPerm = mService.checkPermission(INTERNAL_SYSTEM_WINDOW, callingPid,
+16 −7
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.server.wm;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
import android.hardware.devicestate.DeviceStateManager;
import android.os.Handler;
@@ -47,6 +46,7 @@ final class DeviceStateController implements DeviceStateManager.DeviceStateCallb
    private final int[] mFoldedDeviceStates;
    @NonNull
    private final int[] mRearDisplayDeviceStates;
    private final int mConcurrentDisplayDeviceState;
    @NonNull
    private final int[] mReverseRotationAroundZAxisStates;
    @GuardedBy("this")
@@ -55,12 +55,17 @@ final class DeviceStateController implements DeviceStateManager.DeviceStateCallb

    private final boolean mMatchBuiltInDisplayOrientationToDefaultDisplay;

    @Nullable
    private DeviceState mLastDeviceState;
    @NonNull
    private DeviceState mCurrentDeviceState = DeviceState.UNKNOWN;
    private int mCurrentState;

    public enum DeviceState {
        UNKNOWN, OPEN, FOLDED, HALF_FOLDED, REAR,
        UNKNOWN,
        OPEN,
        FOLDED,
        HALF_FOLDED,
        REAR,
        CONCURRENT,
    }

    DeviceStateController(@NonNull Context context, @NonNull Handler handler) {
@@ -74,6 +79,8 @@ final class DeviceStateController implements DeviceStateManager.DeviceStateCallb
                .getIntArray(R.array.config_foldedDeviceStates);
        mRearDisplayDeviceStates = context.getResources()
                .getIntArray(R.array.config_rearDisplayDeviceStates);
        mConcurrentDisplayDeviceState = context.getResources()
                .getInteger(R.integer.config_deviceStateConcurrentRearDisplay);
        mReverseRotationAroundZAxisStates = context.getResources()
                .getIntArray(R.array.config_deviceStatesToReverseDefaultDisplayRotationAroundZAxis);
        mMatchBuiltInDisplayOrientationToDefaultDisplay = context.getResources()
@@ -120,16 +127,18 @@ final class DeviceStateController implements DeviceStateManager.DeviceStateCallb
            deviceState = DeviceState.REAR;
        } else if (ArrayUtils.contains(mOpenDeviceStates, state)) {
            deviceState = DeviceState.OPEN;
        } else if (state == mConcurrentDisplayDeviceState) {
            deviceState = DeviceState.CONCURRENT;
        } else {
            deviceState = DeviceState.UNKNOWN;
        }

        if (mLastDeviceState == null || !mLastDeviceState.equals(deviceState)) {
            mLastDeviceState = deviceState;
        if (mCurrentDeviceState == null || !mCurrentDeviceState.equals(deviceState)) {
            mCurrentDeviceState = deviceState;

            synchronized (this) {
                for (Consumer<DeviceState> callback : mDeviceStateCallbacks) {
                    callback.accept(mLastDeviceState);
                    callback.accept(mCurrentDeviceState);
                }
            }
        }
+1 −0
Original line number Diff line number Diff line
@@ -1305,6 +1305,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
        return mDefaultDisplay;
    }

    @NonNull
    DisplayRotationCoordinator getDisplayRotationCoordinator() {
        return mDisplayRotationCoordinator;
    }
Loading