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

Commit 516a53b2 authored by Chris Li's avatar Chris Li
Browse files

Guard hasWindowExtensionsEnabled

Fix: 330185990
Test: 306666082
Change-Id: I2b6a08993d7376602286a6cca1153cb5b6a0b6bf
parent a3b836fd
Loading
Loading
Loading
Loading
+20 −9
Original line number Diff line number Diff line
@@ -1476,15 +1476,26 @@ public interface WindowManager extends ViewManager {
     */
    @TestApi
    static boolean hasWindowExtensionsEnabled() {
        return HAS_WINDOW_EXTENSIONS_ON_DEVICE
                && ActivityTaskManager.supportsMultiWindow(ActivityThread.currentApplication())
        if (!Flags.enableWmExtensionsForAllFlag() && ACTIVITY_EMBEDDING_GUARD_WITH_ANDROID_15) {
            // Since enableWmExtensionsForAllFlag, HAS_WINDOW_EXTENSIONS_ON_DEVICE is now true
            // on all devices by default as a build file property.
            // Until finishing flag ramp up, only return true when
            // ACTIVITY_EMBEDDING_GUARD_WITH_ANDROID_15 is false, which is set per device by
            // OEMs.
                && (Flags.enableWmExtensionsForAllFlag()
                || !ACTIVITY_EMBEDDING_GUARD_WITH_ANDROID_15);
            return false;
        }

        if (!HAS_WINDOW_EXTENSIONS_ON_DEVICE) {
            return false;
        }

        try {
            return ActivityTaskManager.supportsMultiWindow(ActivityThread.currentApplication());
        } catch (Exception e) {
            // In case the PackageManager is not set up correctly in test.
            Log.e("WindowManager", "Unable to read if the device supports multi window", e);
            return false;
        }
    }

    /**