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

Commit ac562929 authored by Mariia Sandrikova's avatar Mariia Sandrikova
Browse files

Clean up ADB commands for letterbox and display API sandboxing.

Changes that introduced these commands: ag/13754186 and ag/14161637 (one of many changes).

Fix: 219505867
Test: atest WmTests
Change-Id: I4164bb6bf1b9f8b5eb6ee8fdea083a08102512f1
Merged-In: Ibe60793b381e61d56f57f8d2309754eedc84bddf
parent 0aa4fa44
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -6228,6 +6228,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
    /**
    /**
     * Sets if Display APIs should be sandboxed to the activity window bounds.
     * Sets if Display APIs should be sandboxed to the activity window bounds.
     */
     */
    @VisibleForTesting
    void setSandboxDisplayApis(boolean sandboxDisplayApis) {
    void setSandboxDisplayApis(boolean sandboxDisplayApis) {
        mSandboxDisplayApis = sandboxDisplayApis;
        mSandboxDisplayApis = sandboxDisplayApis;
    }
    }
+8 −129
Original line number Original line Diff line number Diff line
@@ -22,6 +22,7 @@ import android.content.Context;
import android.graphics.Color;
import android.graphics.Color;


import com.android.internal.R;
import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;


import java.lang.annotation.Retention;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.RetentionPolicy;
@@ -156,6 +157,7 @@ final class LetterboxConfiguration {
     * com.android.internal.R.dimen.config_fixedOrientationLetterboxAspectRatio} will be ignored and
     * com.android.internal.R.dimen.config_fixedOrientationLetterboxAspectRatio} will be ignored and
     * the framework implementation will be used to determine the aspect ratio.
     * the framework implementation will be used to determine the aspect ratio.
     */
     */
    @VisibleForTesting
    void setFixedOrientationLetterboxAspectRatio(float aspectRatio) {
    void setFixedOrientationLetterboxAspectRatio(float aspectRatio) {
        mFixedOrientationLetterboxAspectRatio = aspectRatio;
        mFixedOrientationLetterboxAspectRatio = aspectRatio;
    }
    }
@@ -164,6 +166,7 @@ final class LetterboxConfiguration {
     * Resets the aspect ratio of letterbox for fixed orientation to {@link
     * Resets the aspect ratio of letterbox for fixed orientation to {@link
     * com.android.internal.R.dimen.config_fixedOrientationLetterboxAspectRatio}.
     * com.android.internal.R.dimen.config_fixedOrientationLetterboxAspectRatio}.
     */
     */
    @VisibleForTesting
    void resetFixedOrientationLetterboxAspectRatio() {
    void resetFixedOrientationLetterboxAspectRatio() {
        mFixedOrientationLetterboxAspectRatio = mContext.getResources().getFloat(
        mFixedOrientationLetterboxAspectRatio = mContext.getResources().getFloat(
                com.android.internal.R.dimen.config_fixedOrientationLetterboxAspectRatio);
                com.android.internal.R.dimen.config_fixedOrientationLetterboxAspectRatio);
@@ -176,25 +179,6 @@ final class LetterboxConfiguration {
        return mFixedOrientationLetterboxAspectRatio;
        return mFixedOrientationLetterboxAspectRatio;
    }
    }


    /**
     * Overrides corners raidus for activities presented in the letterbox mode. If given value < 0,
     * both it and a value of {@link
     * com.android.internal.R.integer.config_letterboxActivityCornersRadius} will be ignored and
     * corners of the activity won't be rounded.
     */
    void setLetterboxActivityCornersRadius(int cornersRadius) {
        mLetterboxActivityCornersRadius = cornersRadius;
    }

    /**
     * Resets corners raidus for activities presented in the letterbox mode to {@link
     * com.android.internal.R.integer.config_letterboxActivityCornersRadius}.
     */
    void resetLetterboxActivityCornersRadius() {
        mLetterboxActivityCornersRadius = mContext.getResources().getInteger(
                com.android.internal.R.integer.config_letterboxActivityCornersRadius);
    }

    /**
    /**
     * Whether corners of letterboxed activities are rounded.
     * Whether corners of letterboxed activities are rounded.
     */
     */
@@ -226,34 +210,6 @@ final class LetterboxConfiguration {
        return Color.valueOf(mContext.getResources().getColor(colorId));
        return Color.valueOf(mContext.getResources().getColor(colorId));
    }
    }



    /**
     * Sets color of letterbox background which is used when {@link
     * #getLetterboxBackgroundType()} is {@link #LETTERBOX_BACKGROUND_SOLID_COLOR} or as
     * fallback for other backfround types.
     */
    void setLetterboxBackgroundColor(Color color) {
        mLetterboxBackgroundColorOverride = color;
    }

    /**
     * Sets color ID of letterbox background which is used when {@link
     * #getLetterboxBackgroundType()} is {@link #LETTERBOX_BACKGROUND_SOLID_COLOR} or as
     * fallback for other backfround types.
     */
    void setLetterboxBackgroundColorResourceId(int colorId) {
        mLetterboxBackgroundColorResourceIdOverride = colorId;
    }

    /**
     * Resets color of letterbox background to {@link
     * com.android.internal.R.color.config_letterboxBackgroundColor}.
     */
    void resetLetterboxBackgroundColor() {
        mLetterboxBackgroundColorOverride = null;
        mLetterboxBackgroundColorResourceIdOverride = null;
    }

    /**
    /**
     * Gets {@link LetterboxBackgroundType} specified in {@link
     * Gets {@link LetterboxBackgroundType} specified in {@link
     * com.android.internal.R.integer.config_letterboxBackgroundType} or over via ADB command.
     * com.android.internal.R.integer.config_letterboxBackgroundType} or over via ADB command.
@@ -263,19 +219,6 @@ final class LetterboxConfiguration {
        return mLetterboxBackgroundType;
        return mLetterboxBackgroundType;
    }
    }


    /** Sets letterbox background type. */
    void setLetterboxBackgroundType(@LetterboxBackgroundType int backgroundType) {
        mLetterboxBackgroundType = backgroundType;
    }

    /**
     * Resets cletterbox background type to {@link
     * com.android.internal.R.integer.config_letterboxBackgroundType}.
     */
    void resetLetterboxBackgroundType() {
        mLetterboxBackgroundType = readLetterboxBackgroundTypeFromConfig(mContext);
    }

    /** Returns a string representing the given {@link LetterboxBackgroundType}. */
    /** Returns a string representing the given {@link LetterboxBackgroundType}. */
    static String letterboxBackgroundTypeToString(
    static String letterboxBackgroundTypeToString(
            @LetterboxBackgroundType int backgroundType) {
            @LetterboxBackgroundType int backgroundType) {
@@ -304,27 +247,6 @@ final class LetterboxConfiguration {
                    ? backgroundType : LETTERBOX_BACKGROUND_SOLID_COLOR;
                    ? backgroundType : LETTERBOX_BACKGROUND_SOLID_COLOR;
    }
    }


    /**
     * Overrides alpha of a black scrim shown over wallpaper for {@link
     * #LETTERBOX_BACKGROUND_WALLPAPER} option in {@link mLetterboxBackgroundType}.
     *
     * <p>If given value is < 0 or >= 1, both it and a value of {@link
     * com.android.internal.R.dimen.config_letterboxBackgroundWallaperDarkScrimAlpha} are ignored
     * and 0.0 (transparent) is instead.
     */
    void setLetterboxBackgroundWallpaperDarkScrimAlpha(float alpha) {
        mLetterboxBackgroundWallpaperDarkScrimAlpha = alpha;
    }

    /**
     * Resets alpha of a black scrim shown over wallpaper letterbox background to {@link
     * com.android.internal.R.dimen.config_letterboxBackgroundWallaperDarkScrimAlpha}.
     */
    void resetLetterboxBackgroundWallpaperDarkScrimAlpha() {
        mLetterboxBackgroundWallpaperDarkScrimAlpha = mContext.getResources().getFloat(
                com.android.internal.R.dimen.config_letterboxBackgroundWallaperDarkScrimAlpha);
    }

    /**
    /**
     * Gets alpha of a black scrim shown over wallpaper letterbox background.
     * Gets alpha of a black scrim shown over wallpaper letterbox background.
     */
     */
@@ -332,28 +254,6 @@ final class LetterboxConfiguration {
        return mLetterboxBackgroundWallpaperDarkScrimAlpha;
        return mLetterboxBackgroundWallpaperDarkScrimAlpha;
    }
    }


    /**
     * Overrides blur radius for {@link #LETTERBOX_BACKGROUND_WALLPAPER} option in
     * {@link mLetterboxBackgroundType}.
     *
     * <p> If given value <= 0, both it and a value of {@link
     * com.android.internal.R.dimen.config_letterboxBackgroundWallpaperBlurRadius} are ignored
     * and 0 is used instead.
     */
    void setLetterboxBackgroundWallpaperBlurRadius(int radius) {
        mLetterboxBackgroundWallpaperBlurRadius = radius;
    }

    /**
     * Resets blur raidus for {@link #LETTERBOX_BACKGROUND_WALLPAPER} option in {@link
     * mLetterboxBackgroundType} to {@link
     * com.android.internal.R.dimen.config_letterboxBackgroundWallpaperBlurRadius}.
     */
    void resetLetterboxBackgroundWallpaperBlurRadius() {
        mLetterboxBackgroundWallpaperBlurRadius = mContext.getResources().getDimensionPixelSize(
                com.android.internal.R.dimen.config_letterboxBackgroundWallpaperBlurRadius);
    }

    /**
    /**
     * Gets blur raidus for {@link #LETTERBOX_BACKGROUND_WALLPAPER} option in {@link
     * Gets blur raidus for {@link #LETTERBOX_BACKGROUND_WALLPAPER} option in {@link
     * mLetterboxBackgroundType}.
     * mLetterboxBackgroundType}.
@@ -381,6 +281,7 @@ final class LetterboxConfiguration {
     * com.android.internal.R.dimen.config_letterboxHorizontalPositionMultiplier} are ignored and
     * com.android.internal.R.dimen.config_letterboxHorizontalPositionMultiplier} are ignored and
     * central position (0.5) is used.
     * central position (0.5) is used.
     */
     */
    @VisibleForTesting
    void setLetterboxHorizontalPositionMultiplier(float multiplier) {
    void setLetterboxHorizontalPositionMultiplier(float multiplier) {
        mLetterboxHorizontalPositionMultiplier = multiplier;
        mLetterboxHorizontalPositionMultiplier = multiplier;
    }
    }
@@ -389,6 +290,7 @@ final class LetterboxConfiguration {
     * Resets horizontal position of a center of the letterboxed app window to {@link
     * Resets horizontal position of a center of the letterboxed app window to {@link
     * com.android.internal.R.dimen.config_letterboxHorizontalPositionMultiplier}.
     * com.android.internal.R.dimen.config_letterboxHorizontalPositionMultiplier}.
     */
     */
    @VisibleForTesting
    void resetLetterboxHorizontalPositionMultiplier() {
    void resetLetterboxHorizontalPositionMultiplier() {
        mLetterboxHorizontalPositionMultiplier = mContext.getResources().getFloat(
        mLetterboxHorizontalPositionMultiplier = mContext.getResources().getFloat(
                com.android.internal.R.dimen.config_letterboxHorizontalPositionMultiplier);
                com.android.internal.R.dimen.config_letterboxHorizontalPositionMultiplier);
@@ -406,6 +308,7 @@ final class LetterboxConfiguration {
     * Overrides whether reachability repositioning is allowed for letterboxed fullscreen apps in
     * Overrides whether reachability repositioning is allowed for letterboxed fullscreen apps in
     * landscape device orientation.
     * landscape device orientation.
     */
     */
    @VisibleForTesting
    void setIsReachabilityEnabled(boolean enabled) {
    void setIsReachabilityEnabled(boolean enabled) {
        mIsReachabilityEnabled = enabled;
        mIsReachabilityEnabled = enabled;
    }
    }
@@ -414,6 +317,7 @@ final class LetterboxConfiguration {
     * Resets whether reachability repositioning is allowed for letterboxed fullscreen apps in
     * Resets whether reachability repositioning is allowed for letterboxed fullscreen apps in
     * landscape device orientation to {@link R.bool.config_letterboxIsReachabilityEnabled}.
     * landscape device orientation to {@link R.bool.config_letterboxIsReachabilityEnabled}.
     */
     */
    @VisibleForTesting
    void resetIsReachabilityEnabled() {
    void resetIsReachabilityEnabled() {
        mIsReachabilityEnabled = mContext.getResources().getBoolean(
        mIsReachabilityEnabled = mContext.getResources().getBoolean(
                R.bool.config_letterboxIsReachabilityEnabled);
                R.bool.config_letterboxIsReachabilityEnabled);
@@ -429,22 +333,6 @@ final class LetterboxConfiguration {
        return mDefaultPositionForReachability;
        return mDefaultPositionForReachability;
    }
    }


    /**
     * Overrides default horizonal position of the letterboxed app window when reachability
     * is enabled.
     */
    void setDefaultPositionForReachability(@LetterboxReachabilityPosition int position) {
        mDefaultPositionForReachability = position;
    }

    /**
     * Resets default horizontal position of the letterboxed app window when reachability is
     * enabled to {@link R.integer.config_letterboxDefaultPositionForReachability}.
     */
    void resetDefaultPositionForReachability() {
        mDefaultPositionForReachability = readLetterboxReachabilityPositionFromConfig(mContext);
    }

    @LetterboxReachabilityPosition
    @LetterboxReachabilityPosition
    private static int readLetterboxReachabilityPositionFromConfig(Context context) {
    private static int readLetterboxReachabilityPositionFromConfig(Context context) {
        int position = context.getResources().getInteger(
        int position = context.getResources().getInteger(
@@ -516,17 +404,8 @@ final class LetterboxConfiguration {
    /**
    /**
     * Overrides whether education is allowed for letterboxed fullscreen apps.
     * Overrides whether education is allowed for letterboxed fullscreen apps.
     */
     */
    @VisibleForTesting
    void setIsEducationEnabled(boolean enabled) {
    void setIsEducationEnabled(boolean enabled) {
        mIsEducationEnabled = enabled;
        mIsEducationEnabled = enabled;
    }
    }

    /**
     * Resets whether education is allowed for letterboxed fullscreen apps to
     * {@link R.bool.config_letterboxIsEducationEnabled}.
     */
    void resetIsEducationEnabled() {
        mIsEducationEnabled = mContext.getResources().getBoolean(
                R.bool.config_letterboxIsEducationEnabled);
    }

}
}
+0 −19
Original line number Original line Diff line number Diff line
@@ -5702,25 +5702,6 @@ public class WindowManagerService extends IWindowManager.Stub
        }
        }
    }
    }


    void setSandboxDisplayApis(int displayId, boolean sandboxDisplayApis) {
        if (mContext.checkCallingOrSelfPermission(WRITE_SECURE_SETTINGS)
                != PackageManager.PERMISSION_GRANTED) {
            throw new SecurityException("Must hold permission " + WRITE_SECURE_SETTINGS);
        }

        final long ident = Binder.clearCallingIdentity();
        try {
            synchronized (mGlobalLock) {
                final DisplayContent displayContent = mRoot.getDisplayContent(displayId);
                if (displayContent != null) {
                    displayContent.setSandboxDisplayApis(sandboxDisplayApis);
                }
            }
        } finally {
            Binder.restoreCallingIdentity(ident);
        }
    }

    /** The global settings only apply to default display. */
    /** The global settings only apply to default display. */
    private boolean applyForcedPropertiesForDefaultDisplay() {
    private boolean applyForcedPropertiesForDefaultDisplay() {
        boolean changed = false;
        boolean changed = false;
+0 −506

File changed.

Preview size limit exceeded, changes collapsed.