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

Commit d7445b6c authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 8788209 from 362a8f75 to tm-qpr1-release

Change-Id: Ia30f32eb01ae20fa6c234551fca7b9b83cd09a25
parents 404b2e3f 362a8f75
Loading
Loading
Loading
Loading
+13 −11
Original line number Diff line number Diff line
@@ -5863,16 +5863,16 @@ public final class ActivityThread extends ClientTransactionHandler

        final boolean movedToDifferentDisplay = isDifferentDisplay(activity.getDisplayId(),
                displayId);
        final Configuration currentResConfig = activity.getResources().getConfiguration();
        final int diff = currentResConfig.diffPublicOnly(newConfig);
        final boolean hasPublicResConfigChange = diff != 0;
        final Configuration currentConfig = activity.mCurrentConfig;
        final int diff = currentConfig.diffPublicOnly(newConfig);
        final boolean hasPublicConfigChange = diff != 0;
        final ActivityClientRecord r = getActivityClient(activityToken);
        // TODO(b/173090263): Use diff instead after the improvement of AssetManager and
        // ResourcesImpl constructions.
        final boolean shouldUpdateResources = hasPublicResConfigChange
                || shouldUpdateResources(activityToken, currentResConfig, newConfig,
                amOverrideConfig, movedToDifferentDisplay, hasPublicResConfigChange);
        final boolean shouldReportChange = shouldReportChange(activity.mCurrentConfig, newConfig,
        final boolean shouldUpdateResources = hasPublicConfigChange
                || shouldUpdateResources(activityToken, currentConfig, newConfig, amOverrideConfig,
                movedToDifferentDisplay, hasPublicConfigChange);
        final boolean shouldReportChange = shouldReportChange(diff, currentConfig, newConfig,
                r != null ? r.mSizeConfigurations : null,
                activity.mActivityInfo.getRealConfigChanged());
        // Nothing significant, don't proceed with updating and reporting.
@@ -5896,6 +5896,9 @@ public final class ActivityThread extends ClientTransactionHandler
                amOverrideConfig, contextThemeWrapperOverrideConfig);
        mResourcesManager.updateResourcesForActivity(activityToken, finalOverrideConfig, displayId);

        activity.mConfigChangeFlags = 0;
        activity.mCurrentConfig = new Configuration(newConfig);

        // Apply the ContextThemeWrapper override if necessary.
        // NOTE: Make sure the configurations are not modified, as they are treated as immutable
        // in many places.
@@ -5906,10 +5909,8 @@ public final class ActivityThread extends ClientTransactionHandler
            activity.dispatchMovedToDisplay(displayId, configToReport);
        }

        activity.mConfigChangeFlags = 0;
        if (shouldReportChange) {
            activity.mCalled = false;
            activity.mCurrentConfig = new Configuration(newConfig);
            activity.onConfigurationChanged(configToReport);
            if (!activity.mCalled) {
                throw new SuperNotCalledException("Activity " + activity.getLocalClassName() +
@@ -5924,6 +5925,8 @@ public final class ActivityThread extends ClientTransactionHandler
     * Returns {@code true} if {@link Activity#onConfigurationChanged(Configuration)} should be
     * dispatched.
     *
     * @param publicDiff Usually computed by {@link Configuration#diffPublicOnly(Configuration)}.
     *                   This parameter is to prevent we compute it again.
     * @param currentConfig The current configuration cached in {@link Activity#mCurrentConfig}.
     *                      It is {@code null} before the first config update from the server side.
     * @param newConfig The updated {@link Configuration}
@@ -5932,10 +5935,9 @@ public final class ActivityThread extends ClientTransactionHandler
     * @return {@code true} if the config change should be reported to the Activity
     */
    @VisibleForTesting
    public static boolean shouldReportChange(@Nullable Configuration currentConfig,
    public static boolean shouldReportChange(int publicDiff, @Nullable Configuration currentConfig,
            @NonNull Configuration newConfig, @Nullable SizeConfigurationBuckets sizeBuckets,
            int handledConfigChanges) {
        final int publicDiff = currentConfig.diffPublicOnly(newConfig);
        // Don't report the change if there's no public diff between current and new config.
        if (publicDiff == 0) {
            return false;
+34 −10
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ import android.os.Parcelable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -173,38 +172,63 @@ public final class ProgramList implements AutoCloseable {
        }
    }

    void apply(@NonNull Chunk chunk) {
    void apply(Chunk chunk) {
        List<ProgramSelector.Identifier> removedList = new ArrayList<>();
        List<ProgramSelector.Identifier> changedList = new ArrayList<>();
        List<ProgramList.ListCallback> listCallbacksCopied;
        List<OnCompleteListener> onCompleteListenersCopied = new ArrayList<>();
        synchronized (mLock) {
            if (mIsClosed) return;

            mIsComplete = false;
            listCallbacksCopied = new ArrayList<>(mListCallbacks);

            if (chunk.isPurge()) {
                new HashSet<>(mPrograms.keySet()).stream().forEach(id -> removeLocked(id));
                for (ProgramSelector.Identifier id : mPrograms.keySet()) {
                    removeLocked(id, removedList);
                }
            }

            chunk.getRemoved().stream().forEach(id -> removeLocked(id));
            chunk.getModified().stream().forEach(info -> putLocked(info));
            chunk.getRemoved().stream().forEach(id -> removeLocked(id, removedList));
            chunk.getModified().stream().forEach(info -> putLocked(info, changedList));

            if (chunk.isComplete()) {
                mIsComplete = true;
                mOnCompleteListeners.forEach(cb -> cb.onComplete());
                onCompleteListenersCopied = new ArrayList<>(mOnCompleteListeners);
            }
        }

        for (int i = 0; i < removedList.size(); i++) {
            for (int cbIndex = 0; cbIndex < listCallbacksCopied.size(); cbIndex++) {
                listCallbacksCopied.get(cbIndex).onItemRemoved(removedList.get(i));
            }
        }
        for (int i = 0; i < changedList.size(); i++) {
            for (int cbIndex = 0; cbIndex < listCallbacksCopied.size(); cbIndex++) {
                listCallbacksCopied.get(cbIndex).onItemChanged(changedList.get(i));
            }
        }
        if (chunk.isComplete()) {
            for (int cbIndex = 0; cbIndex < onCompleteListenersCopied.size(); cbIndex++) {
                onCompleteListenersCopied.get(cbIndex).onComplete();
            }
        }
    }

    private void putLocked(@NonNull RadioManager.ProgramInfo value) {
    private void putLocked(RadioManager.ProgramInfo value,
            List<ProgramSelector.Identifier> changedIdentifierList) {
        ProgramSelector.Identifier key = value.getSelector().getPrimaryId();
        mPrograms.put(Objects.requireNonNull(key), value);
        ProgramSelector.Identifier sel = value.getSelector().getPrimaryId();
        mListCallbacks.forEach(cb -> cb.onItemChanged(sel));
        changedIdentifierList.add(sel);
    }

    private void removeLocked(@NonNull ProgramSelector.Identifier key) {
    private void removeLocked(ProgramSelector.Identifier key,
            List<ProgramSelector.Identifier> removedIdentifierList) {
        RadioManager.ProgramInfo removed = mPrograms.remove(Objects.requireNonNull(key));
        if (removed == null) return;
        ProgramSelector.Identifier sel = removed.getSelector().getPrimaryId();
        mListCallbacks.forEach(cb -> cb.onItemRemoved(sel));
        removedIdentifierList.add(sel);
    }

    /**
+12 −4
Original line number Diff line number Diff line
@@ -2816,10 +2816,6 @@ public final class ViewRootImpl implements ViewParent,
        // Execute enqueued actions on every traversal in case a detached view enqueued an action
        getRunQueue().executeActions(mAttachInfo.mHandler);

        if (mApplyInsetsRequested) {
            dispatchApplyInsets(host);
        }

        if (mFirst) {
            // make sure touch mode code executes by setting cached value
            // to opposite of the added touch mode.
@@ -2883,6 +2879,18 @@ public final class ViewRootImpl implements ViewParent,
            }
        }

        if (mApplyInsetsRequested) {
            dispatchApplyInsets(host);
            if (mLayoutRequested) {
                // Short-circuit catching a new layout request here, so
                // we don't need to go through two layout passes when things
                // change due to fitting system windows, which can happen a lot.
                windowSizeMayChange |= measureHierarchy(host, lp,
                        mView.getContext().getResources(),
                        desiredWindowWidth, desiredWindowHeight);
            }
        }

        if (layoutRequested) {
            // Clear this now, so that if anything requests a layout in the
            // rest of this function we will catch it and re-run a full
+10 −10
Original line number Diff line number Diff line
@@ -207,8 +207,8 @@ public class ActivityThreadClientTest {
        final Configuration currentConfig = new Configuration();

        assertFalse("Must not report change if no public diff",
                shouldReportChange(currentConfig, newConfig, null /* sizeBuckets */,
                        0 /* handledConfigChanges */));
                shouldReportChange(0 /* publicDiff */, currentConfig, newConfig,
                null /* sizeBuckets */, 0 /* handledConfigChanges */));

        final int[] verticalThresholds = {100, 400};
        final SizeConfigurationBuckets buckets = new SizeConfigurationBuckets(
@@ -221,25 +221,25 @@ public class ActivityThreadClientTest {
        newConfig.screenHeightDp = 300;

        assertFalse("Must not report changes if the diff is small and not handled",
                shouldReportChange(currentConfig, newConfig, buckets,
                        CONFIG_FONT_SCALE /* handledConfigChanges */));
                shouldReportChange(CONFIG_SCREEN_SIZE /* publicDiff */, currentConfig,
                newConfig, buckets, CONFIG_FONT_SCALE /* handledConfigChanges */));

        assertTrue("Must report changes if the small diff is handled",
                shouldReportChange(currentConfig, newConfig, buckets,
                        CONFIG_SCREEN_SIZE /* handledConfigChanges */));
                shouldReportChange(CONFIG_SCREEN_SIZE /* publicDiff */, currentConfig, newConfig,
                buckets, CONFIG_SCREEN_SIZE /* handledConfigChanges */));

        currentConfig.fontScale = 0.8f;
        newConfig.fontScale = 1.2f;

        assertTrue("Must report handled changes regardless of small unhandled change",
                shouldReportChange(currentConfig, newConfig, buckets,
                        CONFIG_FONT_SCALE /* handledConfigChanges */));
                shouldReportChange(CONFIG_SCREEN_SIZE | CONFIG_FONT_SCALE /* publicDiff */,
                currentConfig, newConfig, buckets, CONFIG_FONT_SCALE /* handledConfigChanges */));

        newConfig.screenHeightDp = 500;

        assertFalse("Must not report changes if there's unhandled big changes",
                shouldReportChange(currentConfig, newConfig, buckets,
                        CONFIG_FONT_SCALE /* handledConfigChanges */));
                shouldReportChange(CONFIG_SCREEN_SIZE | CONFIG_FONT_SCALE /* publicDiff */,
                currentConfig, newConfig, buckets, CONFIG_FONT_SCALE /* handledConfigChanges */));
    }

    private void recreateAndVerifyNoRelaunch(ActivityThread activityThread, TestActivity activity) {
+8 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.SystemProperties;
import android.util.ArraySet;
import android.util.Log;
import android.util.Pair;
@@ -70,6 +71,8 @@ import java.util.function.Consumer;
public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmentCallback,
        ActivityEmbeddingComponent {
    static final String TAG = "SplitController";
    static final boolean ENABLE_SHELL_TRANSITIONS =
            SystemProperties.getBoolean("persist.wm.debug.shell_transit", false);

    @VisibleForTesting
    @GuardedBy("mLock")
@@ -332,6 +335,11 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
     * bounds is large enough for at least one split rule.
     */
    private void updateAnimationOverride(@NonNull TaskContainer taskContainer) {
        if (ENABLE_SHELL_TRANSITIONS) {
            // TODO(b/207070762): cleanup with legacy app transition
            // Animation will be handled by WM Shell with Shell transition enabled.
            return;
        }
        if (!taskContainer.isTaskBoundsInitialized()
                || !taskContainer.isWindowingModeInitialized()) {
            // We don't know about the Task bounds/windowingMode yet.
Loading