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

Commit 03870648 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6864616 from 85f5802b to rvc-qpr1-release

Change-Id: I4b17108561fc916e647a165679fa5e02e5b7da44
parents bdd5f027 85f5802b
Loading
Loading
Loading
Loading
+51 −48
Original line number Diff line number Diff line
@@ -3250,12 +3250,6 @@ public final class ActivityThread extends ClientTransactionHandler {
        sendMessage(H.CLEAN_UP_CONTEXT, cci);
    }

    @Override
    public void handleFixedRotationAdjustments(@NonNull IBinder token,
            @Nullable FixedRotationAdjustments fixedRotationAdjustments) {
        handleFixedRotationAdjustments(token, fixedRotationAdjustments, null /* overrideConfig */);
    }

    /**
     * Applies the rotation adjustments to override display information in resources belong to the
     * provided token. If the token is activity token, the adjustments also apply to application
@@ -3265,51 +3259,39 @@ public final class ActivityThread extends ClientTransactionHandler {
     * @param fixedRotationAdjustments The information to override the display adjustments of
     *                                 corresponding resources. If it is null, the exiting override
     *                                 will be cleared.
     * @param overrideConfig The override configuration of activity. It is used to override
     *                       application configuration. If it is non-null, it means the token is
     *                       confirmed as activity token. Especially when launching new activity,
     *                       {@link #mActivities} hasn't put the new token.
     */
    private void handleFixedRotationAdjustments(@NonNull IBinder token,
            @Nullable FixedRotationAdjustments fixedRotationAdjustments,
            @Nullable Configuration overrideConfig) {
        // The element of application configuration override is set only if the application
        // adjustments are needed, because activity already has its own override configuration.
        final Configuration[] appConfigOverride;
        final Consumer<DisplayAdjustments> override;
        if (fixedRotationAdjustments != null) {
            appConfigOverride = new Configuration[1];
            override = displayAdjustments -> {
                displayAdjustments.setFixedRotationAdjustments(fixedRotationAdjustments);
                if (appConfigOverride[0] != null) {
                    displayAdjustments.getConfiguration().updateFrom(appConfigOverride[0]);
                }
            };
        } else {
            appConfigOverride = null;
            override = null;
        }
    @Override
    public void handleFixedRotationAdjustments(@NonNull IBinder token,
            @Nullable FixedRotationAdjustments fixedRotationAdjustments) {
        final Consumer<DisplayAdjustments> override = fixedRotationAdjustments != null
                ? displayAdjustments -> displayAdjustments
                        .setFixedRotationAdjustments(fixedRotationAdjustments)
                : null;
        if (!mResourcesManager.overrideTokenDisplayAdjustments(token, override)) {
            // No resources are associated with the token.
            return;
        }
        if (overrideConfig == null) {
            final ActivityClientRecord r = mActivities.get(token);
            if (r == null) {
                // It is not an activity token. Nothing to do for application.
        if (mActivities.get(token) == null) {
            // Nothing to do for application if it is not an activity token.
            return;
        }
            overrideConfig = r.overrideConfig;
        }
        if (appConfigOverride != null) {
            appConfigOverride[0] = overrideConfig;

        overrideApplicationDisplayAdjustments(token, override);
    }

        // Apply the last override to application resources for compatibility. Because the Resources
        // of Display can be from application, e.g.
        //    applicationContext.getSystemService(DisplayManager.class).getDisplay(displayId)
        // and the deprecated usage:
        //    applicationContext.getSystemService(WindowManager.class).getDefaultDisplay();
    /**
     * Applies the last override to application resources for compatibility. Because the Resources
     * of Display can be from application, e.g.
     *   applicationContext.getSystemService(DisplayManager.class).getDisplay(displayId)
     * and the deprecated usage:
     *   applicationContext.getSystemService(WindowManager.class).getDefaultDisplay();
     *
     * @param token The owner and target of the override.
     * @param override The display adjustments override for application resources. If it is null,
     *                 the override of the token will be removed and pop the last one to use.
     */
    private void overrideApplicationDisplayAdjustments(@NonNull IBinder token,
            @Nullable Consumer<DisplayAdjustments> override) {
        final Consumer<DisplayAdjustments> appOverride;
        if (mActiveRotationAdjustments == null) {
            mActiveRotationAdjustments = new ArrayList<>(2);
@@ -3542,8 +3524,13 @@ public final class ActivityThread extends ClientTransactionHandler {
        // The rotation adjustments must be applied before creating the activity, so the activity
        // can get the adjusted display info during creation.
        if (r.mPendingFixedRotationAdjustments != null) {
            handleFixedRotationAdjustments(r.token, r.mPendingFixedRotationAdjustments,
                    r.overrideConfig);
            // The adjustments should have been set by handleLaunchActivity, so the last one is the
            // override for activity resources.
            if (mActiveRotationAdjustments != null && !mActiveRotationAdjustments.isEmpty()) {
                mResourcesManager.overrideTokenDisplayAdjustments(r.token,
                        mActiveRotationAdjustments.get(
                                mActiveRotationAdjustments.size() - 1).second);
            }
            r.mPendingFixedRotationAdjustments = null;
        }

@@ -3582,6 +3569,13 @@ public final class ActivityThread extends ClientTransactionHandler {
            mProfiler.startProfiling();
        }

        if (r.mPendingFixedRotationAdjustments != null) {
            // The rotation adjustments must be applied before handling configuration, so process
            // level display metrics can be adjusted.
            overrideApplicationDisplayAdjustments(r.token, adjustments ->
                    adjustments.setFixedRotationAdjustments(r.mPendingFixedRotationAdjustments));
        }

        // Make sure we are running with the most recent config.
        handleConfigurationChanged(null, null);

@@ -5777,7 +5771,15 @@ public final class ActivityThread extends ClientTransactionHandler {
            if (DEBUG_CONFIGURATION) Slog.v(TAG, "Handle configuration changed: "
                    + config);

            mResourcesManager.applyConfigurationToResourcesLocked(config, compat);
            final Resources appResources = mInitialApplication.getResources();
            if (appResources.hasOverrideDisplayAdjustments()) {
                // The value of Display#getRealSize will be adjusted by FixedRotationAdjustments,
                // but Display#getSize refers to DisplayAdjustments#mConfiguration. So the rotated
                // configuration also needs to set to the adjustments for consistency.
                appResources.getDisplayAdjustments().getConfiguration().updateFrom(config);
            }
            mResourcesManager.applyConfigurationToResourcesLocked(config, compat,
                    appResources.getDisplayAdjustments());
            updateLocaleListFromAppContext(mInitialApplication.getApplicationContext(),
                    mResourcesManager.getConfiguration().getLocales());

@@ -7390,7 +7392,8 @@ public final class ActivityThread extends ClientTransactionHandler {
                // We need to apply this change to the resources immediately, because upon returning
                // the view hierarchy will be informed about it.
                if (mResourcesManager.applyConfigurationToResourcesLocked(globalConfig,
                        null /* compat */)) {
                        null /* compat */,
                        mInitialApplication.getResources().getDisplayAdjustments())) {
                    updateLocaleListFromAppContext(mInitialApplication.getApplicationContext(),
                            mResourcesManager.getConfiguration().getLocales());

+0 −13
Original line number Diff line number Diff line
@@ -186,16 +186,6 @@ class ContextImpl extends Context {
    private static final String XATTR_INODE_CACHE = "user.inode_cache";
    private static final String XATTR_INODE_CODE_CACHE = "user.inode_code_cache";

    /**
     * Special intent extra that critical system apps can use to hide the notification for a
     * foreground service. This extra should be placed in the intent passed into {@link
     * #startForegroundService(Intent)}.
     *
     * @hide
     */
    private static final String EXTRA_HIDDEN_FOREGROUND_SERVICE =
            "android.intent.extra.HIDDEN_FOREGROUND_SERVICE";

    /**
     * Map from package name, to preference name, to cached preferences.
     */
@@ -1707,12 +1697,9 @@ class ContextImpl extends Context {
        try {
            validateServiceIntent(service);
            service.prepareToLeaveProcess(this);
            final boolean hideForegroundNotification = requireForeground
                    && service.getBooleanExtra(EXTRA_HIDDEN_FOREGROUND_SERVICE, false);
            ComponentName cn = ActivityManager.getService().startService(
                    mMainThread.getApplicationThread(), service,
                    service.resolveTypeIfNeeded(getContentResolver()), requireForeground,
                    hideForegroundNotification,
                    getOpPackageName(), getAttributionTag(), user.getIdentifier());
            if (cn != null) {
                if (cn.getPackageName().equals("!")) {
+1 −2
Original line number Diff line number Diff line
@@ -155,8 +155,7 @@ interface IActivityManager {
    boolean refContentProvider(in IBinder connection, int stableDelta, int unstableDelta);
    PendingIntent getRunningServiceControlPanel(in ComponentName service);
    ComponentName startService(in IApplicationThread caller, in Intent service,
            in String resolvedType, boolean requireForeground,
            boolean hideForegroundNotification, in String callingPackage,
            in String resolvedType, boolean requireForeground, in String callingPackage,
            in String callingFeatureId, int userId);
    @UnsupportedAppUsage
    int stopService(in IApplicationThread caller, in Intent service,
+13 −2
Original line number Diff line number Diff line
@@ -1071,12 +1071,18 @@ public class ResourcesManager {
    public final boolean applyConfigurationToResources(@NonNull Configuration config,
            @Nullable CompatibilityInfo compat) {
        synchronized(this) {
            return applyConfigurationToResourcesLocked(config, compat);
            return applyConfigurationToResourcesLocked(config, compat, null /* adjustments */);
        }
    }

    public final boolean applyConfigurationToResourcesLocked(@NonNull Configuration config,
            @Nullable CompatibilityInfo compat) {
        return applyConfigurationToResourcesLocked(config, compat, null /* adjustments */);
    }

    /** Applies the global configuration to the managed resources. */
    public final boolean applyConfigurationToResourcesLocked(@NonNull Configuration config,
            @Nullable CompatibilityInfo compat, @Nullable DisplayAdjustments adjustments) {
        try {
            Trace.traceBegin(Trace.TRACE_TAG_RESOURCES,
                    "ResourcesManager#applyConfigurationToResourcesLocked");
@@ -1100,6 +1106,11 @@ public class ResourcesManager {
                        | ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE;
            }

            if (adjustments != null) {
                // Currently the only case where the adjustment takes effect is to simulate placing
                // an app in a rotated display.
                adjustments.adjustGlobalAppMetrics(defaultDisplayMetrics);
            }
            Resources.updateSystemConfiguration(config, defaultDisplayMetrics, compat);

            ApplicationPackageManager.configurationChanged();
+2 −2
Original line number Diff line number Diff line
@@ -135,8 +135,8 @@ public class Build {
     *
     * <p>Starting with API level 29, persistent device identifiers are guarded behind additional
     * restrictions, and apps are recommended to use resettable identifiers (see <a
     * href="c"> Best practices for unique identifiers</a>). This method can be invoked if one of
     * the following requirements is met:
     * href="/training/articles/user-data-ids">Best practices for unique identifiers</a>). This
     * method can be invoked if one of the following requirements is met:
     * <ul>
     *     <li>If the calling app has been granted the READ_PRIVILEGED_PHONE_STATE permission; this
     *     is a privileged permission that can only be granted to apps preloaded on the device.
Loading