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

Commit ed236963 authored by Tiger's avatar Tiger
Browse files

Respect the edge-to-edge flags in splash screen window

This CL will only set LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS by default
when the edge-to-edge policy is enforced in the app.

Bug: 309578419
Test: Open Calculator in landscape with a device with a display cutout.
      See if the splash screen and the main window are both laid out
      into the cutout area or both not laid out into the cutout area.
Change-Id: I75a219748627ff17f8d0229356512251b8962867
parent af51f24d
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.TestApi;
import android.app.Activity;
import android.app.compat.CompatChanges;
import android.compat.annotation.ChangeId;
import android.compat.annotation.Disabled;
import android.compat.annotation.EnabledSince;
@@ -36,7 +35,6 @@ import android.content.res.TypedArray;
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.UserHandle;
import android.util.ArraySet;
import android.util.Printer;
import android.window.OnBackInvokedCallback;
@@ -1786,8 +1784,7 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
     * @hide
     */
    public boolean isChangeEnabled(long changeId) {
        return CompatChanges.isChangeEnabled(changeId, applicationInfo.packageName,
                UserHandle.getUserHandleForUid(applicationInfo.uid));
        return applicationInfo.isChangeEnabled(changeId);
    }

    /** @hide */
+12 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.app.compat.CompatChanges;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.pm.PackageManager.NameNotFoundException;
@@ -2631,6 +2632,17 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        return (privateFlags & ApplicationInfo.PRIVATE_FLAG_IS_RESOURCE_OVERLAY) != 0;
    }

    /**
     * Checks if a changeId is enabled for the current user
     * @param changeId The changeId to verify
     * @return True of the changeId is enabled
     * @hide
     */
    public boolean isChangeEnabled(long changeId) {
        return CompatChanges.isChangeEnabled(changeId, packageName,
                UserHandle.getUserHandleForUid(uid));
    }

    /**
     * @return whether the app has requested exemption from the foreground service restrictions.
     * This does not take any affect for now.
+18 −4
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import android.compat.annotation.EnabledSince;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources.Theme;
@@ -388,10 +389,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
        mProxyOnBackInvokedDispatcher = new ProxyOnBackInvokedDispatcher(context);
        mAllowFloatingWindowsFillScreen = context.getResources().getBoolean(
                com.android.internal.R.bool.config_allowFloatingWindowsFillScreen);
        mEdgeToEdgeEnforced =
                context.getApplicationInfo().targetSdkVersion >= ENFORCE_EDGE_TO_EDGE_SDK_VERSION
                        || (CompatChanges.isChangeEnabled(ENFORCE_EDGE_TO_EDGE)
                                && Flags.enforceEdgeToEdge());
        mEdgeToEdgeEnforced = isEdgeToEdgeEnforced(context.getApplicationInfo(), true /* local */);
        if (mEdgeToEdgeEnforced) {
            mDecorFitsSystemWindows = false;
        }
@@ -431,6 +429,22 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
        mActivityConfigCallback = activityConfigCallback;
    }

    /**
     * Returns whether the given application is enforced to go edge-to-edge.
     *
     * @param info The application to query.
     * @param local Whether this is called from the process of the given application.
     * @return {@code true} if edge-to-edge is enforced. Otherwise, {@code false}.
     */
    public static boolean isEdgeToEdgeEnforced(ApplicationInfo info, boolean local) {
        return info.targetSdkVersion >= ENFORCE_EDGE_TO_EDGE_SDK_VERSION
                || (Flags.enforceEdgeToEdge() && (local
                        // Calling this doesn't require a permission.
                        ? CompatChanges.isChangeEnabled(ENFORCE_EDGE_TO_EDGE)
                        // Calling this requires permissions.
                        : info.isChangeEnabled(ENFORCE_EDGE_TO_EDGE)));
    }

    @Override
    public final void setContainer(Window container) {
        super.setContainer(container);
+9 −5
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.graphics.palette.Palette;
import com.android.internal.graphics.palette.Quantizer;
import com.android.internal.graphics.palette.VariationalKMeansQuantizer;
import com.android.internal.policy.PhoneWindow;
import com.android.internal.protolog.common.ProtoLog;
import com.android.launcher3.icons.BaseIconFactory;
import com.android.launcher3.icons.IconProvider;
@@ -245,16 +246,19 @@ public class SplashscreenContentDrawer {
        } else {
            windowFlags |= WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
        }
        params.layoutInDisplayCutoutMode = a.getInt(
                R.styleable.Window_windowLayoutInDisplayCutoutMode,
                WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS);
        params.windowAnimations = a.getResourceId(R.styleable.Window_windowAnimationStyle, 0);
        a.recycle();

        final ActivityManager.RunningTaskInfo taskInfo = windowInfo.taskInfo;
        final ActivityInfo activityInfo = windowInfo.targetActivityInfo != null
                ? windowInfo.targetActivityInfo
                : taskInfo.topActivityInfo;
        params.layoutInDisplayCutoutMode = a.getInt(
                R.styleable.Window_windowLayoutInDisplayCutoutMode,
                PhoneWindow.isEdgeToEdgeEnforced(activityInfo.applicationInfo, false /* local */)
                        ? WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS
                        : params.layoutInDisplayCutoutMode);
        params.windowAnimations = a.getResourceId(R.styleable.Window_windowAnimationStyle, 0);
        a.recycle();

        final int displayId = taskInfo.displayId;
        // Assumes it's safe to show starting windows of launched apps while
        // the keyguard is being hidden. This is okay because starting windows never show