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

Bug: 79429532
Test: Manual test
Change-Id: I12682ea3555eb3649cba4e1df018a697897f0fb6
This commit is contained in:
Mehdi Alizadeh
2018-05-08 14:08:45 -07:00
parent fe392da300
commit 2a8f265ab0

View File

@@ -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,9 +94,14 @@ public class OverviewInteractionState {
mUiHandler = new Handler(this::handleUiMessage);
mBgHandler = new Handler(UiThreadHelper.getBackgroundLooper(), this::handleBgMessage);
mSwipeUpSettingObserver = new SwipeUpGestureEnabledSettingObserver(mUiHandler,
context.getContentResolver());
mSwipeUpSettingObserver.register();
if (shouldIgnoreSwipeUpEnabledSettings()) {
mSwipeUpSettingObserver = null;
mSwipeUpEnabled = true;
} else {
mSwipeUpSettingObserver = new SwipeUpGestureEnabledSettingObserver(mUiHandler,
context.getContentResolver());
mSwipeUpSettingObserver.register();
}
}
public boolean isSwipeUpGestureEnabled() {
@@ -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;
}
}
}