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

Commit 80841e1b authored by Chris Li's avatar Chris Li
Browse files

Disable AE component for device that doesn't support multi window

Low memory device that doesn't support multi window will not support AE
either.

Bug: 298139092
Test: atest WMJetpackUnitTests:WindowExtensionsTest
Change-Id: I54656fecfcd022d80d03464e111b582ac64808e8
parent c89a7bbe
Loading
Loading
Loading
Loading
+7 −1
Original line number Original line Diff line number Diff line
@@ -16,12 +16,14 @@


package androidx.window.extensions;
package androidx.window.extensions;


import android.app.ActivityTaskManager;
import android.app.ActivityThread;
import android.app.ActivityThread;
import android.app.Application;
import android.app.Application;
import android.content.Context;
import android.content.Context;
import android.window.TaskFragmentOrganizer;
import android.window.TaskFragmentOrganizer;


import androidx.annotation.NonNull;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.window.common.DeviceStateManagerFoldingFeatureProducer;
import androidx.window.common.DeviceStateManagerFoldingFeatureProducer;
import androidx.window.common.RawFoldingFeatureProducer;
import androidx.window.common.RawFoldingFeatureProducer;
import androidx.window.extensions.area.WindowAreaComponent;
import androidx.window.extensions.area.WindowAreaComponent;
@@ -111,9 +113,13 @@ public class WindowExtensionsImpl implements WindowExtensions {
     * {@link WindowExtensions#getWindowLayoutComponent()}.
     * {@link WindowExtensions#getWindowLayoutComponent()}.
     * @return {@link ActivityEmbeddingComponent} OEM implementation.
     * @return {@link ActivityEmbeddingComponent} OEM implementation.
     */
     */
    @NonNull
    @Nullable
    public ActivityEmbeddingComponent getActivityEmbeddingComponent() {
    public ActivityEmbeddingComponent getActivityEmbeddingComponent() {
        if (mSplitController == null) {
        if (mSplitController == null) {
            if (!ActivityTaskManager.supportsMultiWindow(getApplication())) {
                // Disable AE for device that doesn't support multi window.
                return null;
            }
            synchronized (mLock) {
            synchronized (mLock) {
                if (mSplitController == null) {
                if (mSplitController == null) {
                    mSplitController = new SplitController(
                    mSplitController = new SplitController(
+8 −1
Original line number Original line Diff line number Diff line
@@ -16,8 +16,11 @@


package androidx.window.extensions;
package androidx.window.extensions;


import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;

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


import android.app.ActivityTaskManager;
import android.platform.test.annotations.Presubmit;
import android.platform.test.annotations.Presubmit;


import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.ext.junit.runners.AndroidJUnit4;
@@ -52,7 +55,11 @@ public class WindowExtensionsTest {


    @Test
    @Test
    public void testGetActivityEmbeddingComponent() {
    public void testGetActivityEmbeddingComponent() {
        if (ActivityTaskManager.supportsMultiWindow(getInstrumentation().getContext())) {
            assertThat(mExtensions.getActivityEmbeddingComponent()).isNotNull();
            assertThat(mExtensions.getActivityEmbeddingComponent()).isNotNull();
        } else {
            assertThat(mExtensions.getActivityEmbeddingComponent()).isNull();
        }
    }
    }


    @Test
    @Test