Merge "Fix lock contention while swiping up" into ub-launcher3-edmonton
diff --git a/quickstep/src/com/android/quickstep/OverviewInteractionState.java b/quickstep/src/com/android/quickstep/OverviewInteractionState.java
index 8923608..9416a29 100644
--- a/quickstep/src/com/android/quickstep/OverviewInteractionState.java
+++ b/quickstep/src/com/android/quickstep/OverviewInteractionState.java
@@ -21,9 +21,12 @@
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;
@@ -33,6 +36,8 @@
import android.util.Log;
import com.android.launcher3.MainThreadExecutor;
+import com.android.launcher3.Utilities;
+import com.android.launcher3.allapps.DiscoveryBounce;
import com.android.launcher3.util.UiThreadHelper;
import com.android.systemui.shared.recents.ISystemUiProxy;
@@ -52,6 +57,8 @@
private static final String TAG = "OverviewFlags";
+ private static final String HAS_ENABLED_QUICKSTEP_ONCE = "launcher.has_enabled_quickstep_once";
+
// We do not need any synchronization for this variable as its only written on UI thread.
private static OverviewInteractionState INSTANCE;
@@ -77,6 +84,7 @@
private final SwipeUpGestureEnabledSettingObserver mSwipeUpSettingObserver;
+ private final Context mContext;
private final Handler mUiHandler;
private final Handler mBgHandler;
@@ -88,12 +96,18 @@
private Runnable mOnSwipeUpSettingChangedListener;
private OverviewInteractionState(Context context) {
+ mContext = context;
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() {
@@ -125,6 +139,8 @@
break;
case MSG_SET_SWIPE_UP_ENABLED:
mSwipeUpEnabled = msg.arg1 != 0;
+ resetHomeBounceSeenOnQuickstepEnabledFirstTime();
+
if (mOnSwipeUpSettingChangedListener != null) {
mOnSwipeUpSettingChangedListener.run();
}
@@ -171,6 +187,7 @@
mResolver.registerContentObserver(Settings.Secure.getUriFor(SWIPE_UP_SETTING_NAME),
false, this);
mSwipeUpEnabled = getValue();
+ resetHomeBounceSeenOnQuickstepEnabledFirstTime();
}
@Override
@@ -184,4 +201,23 @@
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;
+ }
+ }
+
+ private void resetHomeBounceSeenOnQuickstepEnabledFirstTime() {
+ if (mSwipeUpEnabled && !Utilities.getPrefs(mContext).getBoolean(
+ HAS_ENABLED_QUICKSTEP_ONCE, true)) {
+ Utilities.getPrefs(mContext).edit()
+ .putBoolean(HAS_ENABLED_QUICKSTEP_ONCE, true)
+ .putBoolean(DiscoveryBounce.HOME_BOUNCE_SEEN, false)
+ .apply();
+ }
+ }
}
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index bd7e6eb..25d9bb6 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -195,7 +195,7 @@
// Variables relating to the creation of user folders by hovering shortcuts over shortcuts
private static final int FOLDER_CREATION_TIMEOUT = 0;
- public static final int REORDER_TIMEOUT = 350;
+ public static final int REORDER_TIMEOUT = 650;
private final Alarm mFolderCreationAlarm = new Alarm();
private final Alarm mReorderAlarm = new Alarm();
private PreviewBackground mFolderCreateBg;