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

Commit d1288a7e authored by Tiger Huang's avatar Tiger Huang Committed by Android (Google) Code Review
Browse files

Merge "Respect the edge-to-edge flags in splash screen window" into main

parents 44011813 ed236963
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -23,7 +23,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;
@@ -37,7 +36,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;
@@ -1790,8 +1788,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;
@@ -2644,6 +2645,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
@@ -47,6 +47,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;
@@ -389,10 +390,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) {
            getAttributes().privateFlags |= PRIVATE_FLAG_EDGE_TO_EDGE_ENFORCED;
            mDecorFitsSystemWindows = false;
@@ -433,6 +431,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