Merge "show dot on shortcut when incoming notification contains exactly the same shortcut id" into ub-launcher3-qt-qpr1-dev
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java
index e1daea5..98c5502 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java
@@ -69,6 +69,7 @@
import androidx.annotation.BinderThread;
import androidx.annotation.UiThread;
+import androidx.annotation.WorkerThread;
import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.MainThreadExecutor;
@@ -146,6 +147,11 @@
private static final String TAG = "TouchInteractionService";
+ private static final String KEY_BACK_NOTIFICATION_COUNT = "backNotificationCount";
+ private static final String NOTIFY_ACTION_BACK = "com.android.quickstep.action.BACK_GESTURE";
+ private static final int MAX_BACK_NOTIFICATION_COUNT = 3;
+ private int mBackGestureNotificationCounter = -1;
+
private final IBinder mMyBinder = new IOverviewProxy.Stub() {
public void onActiveNavBarRegionChanges(Region region) {
@@ -206,6 +212,10 @@
mOverviewComponentObserver.getActivityControlHelper();
UserEventDispatcher.newInstance(getBaseContext()).logActionBack(completed, downX, downY,
isButton, gestureSwipeLeft, activityControl.getContainerType());
+
+ if (completed && !isButton && shouldNotifyBackGesture()) {
+ BACKGROUND_EXECUTOR.execute(TouchInteractionService.this::tryNotifyBackGesture);
+ }
}
public void onSystemUiStateChanged(int stateFlags) {
@@ -480,6 +490,8 @@
// Temporarily disable model preload
// new ModelPreload().start(this);
+ mBackGestureNotificationCounter = Math.max(0, Utilities.getDevicePrefs(this)
+ .getInt(KEY_BACK_NOTIFICATION_COUNT, MAX_BACK_NOTIFICATION_COUNT));
Utilities.unregisterReceiverSafely(this, mUserUnlockedReceiver);
}
@@ -866,6 +878,22 @@
mRecentsModel, mInputConsumer, isLikelyToStartNewTask, continuingLastGesture);
}
+ protected boolean shouldNotifyBackGesture() {
+ return mBackGestureNotificationCounter > 0 &&
+ mGestureBlockingActivity != null;
+ }
+
+ @WorkerThread
+ protected void tryNotifyBackGesture() {
+ if (shouldNotifyBackGesture()) {
+ mBackGestureNotificationCounter--;
+ Utilities.getDevicePrefs(this).edit()
+ .putInt(KEY_BACK_NOTIFICATION_COUNT, mBackGestureNotificationCounter).apply();
+ sendBroadcast(new Intent(NOTIFY_ACTION_BACK).setPackage(
+ mGestureBlockingActivity.getPackageName()));
+ }
+ }
+
public static void startRecentsActivityAsync(Intent intent, RecentsAnimationListener listener) {
BACKGROUND_EXECUTOR.execute(() -> ActivityManagerWrapper.getInstance()
.startRecentsActivity(intent, null, listener, null, null));
diff --git a/src/com/android/launcher3/AppWidgetsRestoredReceiver.java b/src/com/android/launcher3/AppWidgetsRestoredReceiver.java
index d949141..e3ef5d6 100644
--- a/src/com/android/launcher3/AppWidgetsRestoredReceiver.java
+++ b/src/com/android/launcher3/AppWidgetsRestoredReceiver.java
@@ -11,6 +11,7 @@
import android.util.Log;
import com.android.launcher3.LauncherSettings.Favorites;
+import com.android.launcher3.compat.UserManagerCompat;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.model.LoaderTask;
import com.android.launcher3.provider.RestoreDbTask;
@@ -18,6 +19,8 @@
import androidx.annotation.WorkerThread;
+import static android.os.Process.myUserHandle;
+
public class AppWidgetsRestoredReceiver extends BroadcastReceiver {
private static final String TAG = "AWRestoredReceiver";
@@ -77,9 +80,14 @@
state = LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY;
}
- String[] widgetIdParams = new String[] { Integer.toString(oldWidgetIds[i]) };
+ // b/135926478: Work profile widget restore is broken in platform. This forces us to
+ // recreate the widget during loading with the correct host provider.
+ long mainProfileId = UserManagerCompat.getInstance(context)
+ .getSerialNumberForUser(myUserHandle());
+ String oldWidgetId = Integer.toString(oldWidgetIds[i]);
int result = new ContentWriter(context, new ContentWriter.CommitParams(
- "appWidgetId=? and (restored & 1) = 1", widgetIdParams))
+ "appWidgetId=? and (restored & 1) = 1 and profileId=?",
+ new String[] { oldWidgetId, Long.toString(mainProfileId) }))
.put(LauncherSettings.Favorites.APPWIDGET_ID, newWidgetIds[i])
.put(LauncherSettings.Favorites.RESTORED, state)
.commit();
@@ -87,7 +95,7 @@
if (result == 0) {
Cursor cursor = cr.query(Favorites.CONTENT_URI,
new String[] {Favorites.APPWIDGET_ID},
- "appWidgetId=?", widgetIdParams, null);
+ "appWidgetId=?", new String[] { oldWidgetId }, null);
try {
if (!cursor.moveToFirst()) {
// The widget no long exists.
diff --git a/src/com/android/launcher3/popup/RemoteActionShortcut.java b/src/com/android/launcher3/popup/RemoteActionShortcut.java
index 41ab4df..5a5fbab 100644
--- a/src/com/android/launcher3/popup/RemoteActionShortcut.java
+++ b/src/com/android/launcher3/popup/RemoteActionShortcut.java
@@ -29,11 +29,12 @@
import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.R;
+import com.android.launcher3.Utilities;
import com.android.launcher3.userevent.nano.LauncherLogProto;
public class RemoteActionShortcut extends SystemShortcut<BaseDraggingActivity> {
private static final String TAG = "RemoteActionShortcut";
- private static final boolean DEBUG = false;
+ private static final boolean DEBUG = Utilities.IS_DEBUG_DEVICE;
private final RemoteAction mAction;