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

Commit 2a8f265a authored by Mehdi Alizadeh's avatar Mehdi Alizadeh
Browse files

Enforce Swipe Up gesture to be enabled based on the shipped SDK version

Bug: 79429532
Test: Manual test
Change-Id: I12682ea3555eb3649cba4e1df018a697897f0fb6
parent fe392da3
Loading
Loading
Loading
Loading
+20 −3
Original line number Diff line number Diff line
@@ -21,9 +21,12 @@ import static com.android.systemui.shared.system.NavigationBarCompat.FLAG_HIDE_B
import static com.android.systemui.shared.system.NavigationBarCompat.FLAG_SHOW_OVERVIEW_BUTTON;
import static com.android.systemui.shared.system.SettingsCompat.SWIPE_UP_SETTING_NAME;

import static com.android.launcher3.Utilities.getSystemProperty;

import android.content.ContentResolver;
import android.content.Context;
import android.database.ContentObserver;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
@@ -91,10 +94,15 @@ public class OverviewInteractionState {
        mUiHandler = new Handler(this::handleUiMessage);
        mBgHandler = new Handler(UiThreadHelper.getBackgroundLooper(), this::handleBgMessage);

        if (shouldIgnoreSwipeUpEnabledSettings()) {
            mSwipeUpSettingObserver = null;
            mSwipeUpEnabled = true;
        } else {
            mSwipeUpSettingObserver = new SwipeUpGestureEnabledSettingObserver(mUiHandler,
                    context.getContentResolver());
            mSwipeUpSettingObserver.register();
        }
    }

    public boolean isSwipeUpGestureEnabled() {
        return mSwipeUpEnabled;
@@ -184,4 +192,13 @@ public class OverviewInteractionState {
            return Settings.Secure.getInt(mResolver, SWIPE_UP_SETTING_NAME, 0) == 1;
        }
    }

    private boolean shouldIgnoreSwipeUpEnabledSettings() {
        String sdkInt = getSystemProperty("ro.product.first_api_level", "0");
        try {
            return Integer.parseInt(sdkInt) >= Build.VERSION_CODES.P;
        } catch (Exception e) {
            return false;
        }
    }
}