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

Commit bf56db4b authored by Jiaming Liu's avatar Jiaming Liu
Browse files

Update EXTENSIONS_VERSION_CURRENT_PLATFORM to 7

Bug: 340583542
Bug: 293658614
Flag: com.android.window.flags.activity_embedding_animation_customization_flag
Test: atest WindowExtensionsImplTest WindowExtensionsTest SplitControllerTest
Change-Id: I48802c9f6bbdf657061b3889eff416a5e6bef552
parent aa97cd9d
Loading
Loading
Loading
Loading
+22 −8
Original line number Diff line number Diff line
@@ -39,6 +39,8 @@ import androidx.window.extensions.embedding.SplitController;
import androidx.window.extensions.layout.WindowLayoutComponent;
import androidx.window.extensions.layout.WindowLayoutComponentImpl;

import com.android.window.flags.Flags;

import java.util.Objects;


@@ -55,11 +57,9 @@ class WindowExtensionsImpl implements WindowExtensions {
     */
    private static final int NO_LEVEL_OVERRIDE = -1;

    /**
     * The min version of the WM Extensions that must be supported in the current platform version.
     */
    @VisibleForTesting
    static final int EXTENSIONS_VERSION_CURRENT_PLATFORM = 6;
    private static final int EXTENSIONS_VERSION_V7 = 7;

    private static final int EXTENSIONS_VERSION_V6 = 6;

    private final Object mLock = new Object();
    private volatile DeviceStateManagerFoldingFeatureProducer mFoldingFeatureProducer;
@@ -67,7 +67,6 @@ class WindowExtensionsImpl implements WindowExtensions {
    private volatile SplitController mSplitController;
    private volatile WindowAreaComponent mWindowAreaComponent;

    private final int mVersion = EXTENSIONS_VERSION_CURRENT_PLATFORM;
    private final boolean mIsActivityEmbeddingEnabled;

    WindowExtensionsImpl() {
@@ -76,9 +75,22 @@ class WindowExtensionsImpl implements WindowExtensions {
        Log.i(TAG, generateLogMessage());
    }

    /**
     * The min version of the WM Extensions that must be supported in the current platform version.
     */
    @VisibleForTesting
    static int getExtensionsVersionCurrentPlatform() {
        if (Flags.activityEmbeddingAnimationCustomizationFlag()) {
            // Activity Embedding animation customization is the only major feature for v7.
            return EXTENSIONS_VERSION_V7;
        } else {
            return EXTENSIONS_VERSION_V6;
        }
    }

    private String generateLogMessage() {
        final StringBuilder logBuilder = new StringBuilder("Initializing Window Extensions, "
                + "vendor API level=" + mVersion);
                + "vendor API level=" + getExtensionsVersionCurrentPlatform());
        final int levelOverride = getLevelOverride();
        if (levelOverride != NO_LEVEL_OVERRIDE) {
            logBuilder.append(", override to ").append(levelOverride);
@@ -91,7 +103,9 @@ class WindowExtensionsImpl implements WindowExtensions {
    @Override
    public int getVendorApiLevel() {
        final int levelOverride = getLevelOverride();
        return (levelOverride != NO_LEVEL_OVERRIDE) ? levelOverride : mVersion;
        return (levelOverride != NO_LEVEL_OVERRIDE)
                ? levelOverride
                : getExtensionsVersionCurrentPlatform();
    }

    private int getLevelOverride() {
+2 −2
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

package androidx.window.extensions;

import static androidx.window.extensions.WindowExtensionsImpl.EXTENSIONS_VERSION_CURRENT_PLATFORM;
import static androidx.window.extensions.WindowExtensionsImpl.getExtensionsVersionCurrentPlatform;

import static com.google.common.truth.Truth.assertThat;

@@ -59,7 +59,7 @@ public class WindowExtensionsTest {
    @Test
    public void testGetVendorApiLevel_extensionsEnabled_matchesCurrentVersion() {
        assumeTrue(WindowManager.hasWindowExtensionsEnabled());
        assertThat(mVersion).isEqualTo(EXTENSIONS_VERSION_CURRENT_PLATFORM);
        assertThat(mVersion).isEqualTo(getExtensionsVersionCurrentPlatform());
    }

    @Test