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

Commit 2b3b20c3 authored by Andrii Kulian's avatar Andrii Kulian Committed by Android (Google) Code Review
Browse files

Merge changes from topic "app_config_compat"

* changes:
  Update resource config for default display
  Override process config to match activity config
  Set parent for WindowProcessController
parents 77740176 946e8df6
Loading
Loading
Loading
Loading
+21 −30
Original line number Original line Diff line number Diff line
@@ -1208,8 +1208,7 @@ public class ResourcesManager {
                WeakReference<ResourcesImpl> weakImplRef = mResourceImpls.valueAt(i);
                WeakReference<ResourcesImpl> weakImplRef = mResourceImpls.valueAt(i);
                ResourcesImpl r = weakImplRef != null ? weakImplRef.get() : null;
                ResourcesImpl r = weakImplRef != null ? weakImplRef.get() : null;
                if (r != null) {
                if (r != null) {
                    applyConfigurationToResourcesLocked(config, compat, tmpConfig,
                    applyConfigurationToResourcesLocked(config, compat, tmpConfig, key, r);
                            defaultDisplayMetrics, key, r);
                } else {
                } else {
                    mResourceImpls.removeAt(i);
                    mResourceImpls.removeAt(i);
                }
                }
@@ -1224,8 +1223,7 @@ public class ResourcesManager {
                }
                }


                applyConfigurationToResourcesLocked(config, compat, tmpConfig,
                applyConfigurationToResourcesLocked(config, compat, tmpConfig,
                        defaultDisplayMetrics, resourcesWithLoaders.resourcesKey(),
                        resourcesWithLoaders.resourcesKey(), resources.getImpl());
                        resources.getImpl());
            }
            }


            return changes != 0;
            return changes != 0;
@@ -1236,30 +1234,26 @@ public class ResourcesManager {


    private void applyConfigurationToResourcesLocked(@NonNull Configuration config,
    private void applyConfigurationToResourcesLocked(@NonNull Configuration config,
            @Nullable CompatibilityInfo compat, Configuration tmpConfig,
            @Nullable CompatibilityInfo compat, Configuration tmpConfig,
            DisplayMetrics defaultDisplayMetrics, ResourcesKey key, ResourcesImpl resourcesImpl) {
            ResourcesKey key, ResourcesImpl resourcesImpl) {
        if (DEBUG || DEBUG_CONFIGURATION) {
        if (DEBUG || DEBUG_CONFIGURATION) {
            Slog.v(TAG, "Changing resources "
            Slog.v(TAG, "Changing resources "
                    + resourcesImpl + " config to: " + config);
                    + resourcesImpl + " config to: " + config);
        }
        }
        int displayId = key.mDisplayId;
        int displayId = key.mDisplayId;
        boolean isDefaultDisplay = (displayId == Display.DEFAULT_DISPLAY);
        DisplayMetrics dm = defaultDisplayMetrics;
        final boolean hasOverrideConfiguration = key.hasOverrideConfiguration();
        final boolean hasOverrideConfiguration = key.hasOverrideConfiguration();
        if (!isDefaultDisplay || hasOverrideConfiguration) {
        tmpConfig.setTo(config);
        tmpConfig.setTo(config);


            // Get new DisplayMetrics based on the DisplayAdjustments given
        // Get new DisplayMetrics based on the DisplayAdjustments given to the ResourcesImpl. Update
            // to the ResourcesImpl. Update a copy if the CompatibilityInfo
        // a copy if the CompatibilityInfo changed, because the ResourcesImpl object will handle the
            // changed, because the ResourcesImpl object will handle the
        // update internally.
        // update internally.
        DisplayAdjustments daj = resourcesImpl.getDisplayAdjustments();
        DisplayAdjustments daj = resourcesImpl.getDisplayAdjustments();
        if (compat != null) {
        if (compat != null) {
            daj = new DisplayAdjustments(daj);
            daj = new DisplayAdjustments(daj);
            daj.setCompatibilityInfo(compat);
            daj.setCompatibilityInfo(compat);
        }
        }
            dm = getDisplayMetrics(displayId, daj);
        daj.setConfiguration(config);

        DisplayMetrics dm = getDisplayMetrics(displayId, daj);
            if (!isDefaultDisplay) {
        if (displayId != Display.DEFAULT_DISPLAY) {
            applyNonDefaultDisplayMetricsToConfiguration(dm, tmpConfig);
            applyNonDefaultDisplayMetricsToConfiguration(dm, tmpConfig);
        }
        }


@@ -1267,9 +1261,6 @@ public class ResourcesManager {
            tmpConfig.updateFrom(key.mOverrideConfiguration);
            tmpConfig.updateFrom(key.mOverrideConfiguration);
        }
        }
        resourcesImpl.updateConfiguration(tmpConfig, dm, compat);
        resourcesImpl.updateConfiguration(tmpConfig, dm, compat);
        } else {
            resourcesImpl.updateConfiguration(config, dm, compat);
        }
    }
    }


    /**
    /**
+4 −3
Original line number Original line Diff line number Diff line
@@ -26,6 +26,7 @@ import android.annotation.TestApi;
import android.app.KeyguardManager;
import android.app.KeyguardManager;
import android.compat.annotation.UnsupportedAppUsage;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Point;
import android.graphics.Point;
import android.media.projection.MediaProjection;
import android.media.projection.MediaProjection;
import android.os.Handler;
import android.os.Handler;
@@ -400,10 +401,10 @@ public final class DisplayManager {
        if (display == null) {
        if (display == null) {
            // TODO: We cannot currently provide any override configurations for metrics on displays
            // TODO: We cannot currently provide any override configurations for metrics on displays
            // other than the display the context is associated with.
            // other than the display the context is associated with.
            final Context context = mContext.getDisplayId() == displayId
            final Resources resources = mContext.getDisplayId() == displayId
                    ? mContext : mContext.getApplicationContext();
                    ? mContext.getResources() : null;


            display = mGlobal.getCompatibleDisplay(displayId, context.getResources());
            display = mGlobal.getCompatibleDisplay(displayId, resources);
            if (display != null) {
            if (display != null) {
                mDisplays.put(displayId, display);
                mDisplays.put(displayId, display);
            }
            }
+1 −1
Original line number Original line Diff line number Diff line
@@ -454,7 +454,7 @@ public final class Display {
        mResources = res;
        mResources = res;
        mDisplayAdjustments = mResources != null
        mDisplayAdjustments = mResources != null
            ? new DisplayAdjustments(mResources.getConfiguration())
            ? new DisplayAdjustments(mResources.getConfiguration())
            : daj != null ? new DisplayAdjustments(daj) : null;
            : daj != null ? new DisplayAdjustments(daj) : new DisplayAdjustments();
        mIsValid = true;
        mIsValid = true;


        // Cache properties that cannot change as long as the display is valid.
        // Cache properties that cannot change as long as the display is valid.
+8 −2
Original line number Original line Diff line number Diff line
@@ -1680,6 +1680,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        if (root == this) {
        if (root == this) {
            task.setRootProcess(proc);
            task.setRootProcess(proc);
        }
        }
        proc.addActivityIfNeeded(this);
    }
    }


    boolean hasProcess() {
    boolean hasProcess() {
@@ -6918,7 +6919,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        // Update last reported values.
        // Update last reported values.
        final Configuration newMergedOverrideConfig = getMergedOverrideConfiguration();
        final Configuration newMergedOverrideConfig = getMergedOverrideConfiguration();


        setLastReportedConfiguration(mAtmService.getGlobalConfiguration(), newMergedOverrideConfig);
        setLastReportedConfiguration(getProcessGlobalConfiguration(), newMergedOverrideConfig);


        if (mState == INITIALIZING) {
        if (mState == INITIALIZING) {
            // No need to relaunch or schedule new config for activity that hasn't been launched
            // No need to relaunch or schedule new config for activity that hasn't been launched
@@ -7017,6 +7018,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        return true;
        return true;
    }
    }


    /** Get process configuration, or global config if the process is not set. */
    private Configuration getProcessGlobalConfiguration() {
        return app != null ? app.getConfiguration() : mAtmService.getGlobalConfiguration();
    }

    /**
    /**
     * When assessing a configuration change, decide if the changes flags and the new configurations
     * When assessing a configuration change, decide if the changes flags and the new configurations
     * should cause the Activity to relaunch.
     * should cause the Activity to relaunch.
@@ -7129,7 +7135,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            startRelaunching();
            startRelaunching();
            final ClientTransactionItem callbackItem = ActivityRelaunchItem.obtain(pendingResults,
            final ClientTransactionItem callbackItem = ActivityRelaunchItem.obtain(pendingResults,
                    pendingNewIntents, configChangeFlags,
                    pendingNewIntents, configChangeFlags,
                    new MergedConfiguration(mAtmService.getGlobalConfiguration(),
                    new MergedConfiguration(getProcessGlobalConfiguration(),
                            getMergedOverrideConfiguration()),
                            getMergedOverrideConfiguration()),
                    preserveWindow);
                    preserveWindow);
            final ActivityLifecycleItem lifecycleItem;
            final ActivityLifecycleItem lifecycleItem;
+0 −2
Original line number Original line Diff line number Diff line
@@ -848,8 +848,6 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {


            if (DEBUG_ALL) Slog.v(TAG, "Launching: " + r);
            if (DEBUG_ALL) Slog.v(TAG, "Launching: " + r);


            proc.addActivityIfNeeded(r);

            final LockTaskController lockTaskController = mService.getLockTaskController();
            final LockTaskController lockTaskController = mService.getLockTaskController();
            if (task.mLockTaskAuth == LOCK_TASK_AUTH_LAUNCHABLE
            if (task.mLockTaskAuth == LOCK_TASK_AUTH_LAUNCHABLE
                    || task.mLockTaskAuth == LOCK_TASK_AUTH_LAUNCHABLE_PRIV
                    || task.mLockTaskAuth == LOCK_TASK_AUTH_LAUNCHABLE_PRIV
Loading