From fa652a8a4f91482ea066388e935944846847f582 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Wed, 17 Jul 2019 11:59:24 -0700 Subject: [PATCH 1/3] Updating to use deferred cancel api - Also updating the sysui flag to home's flags when passing some threshold - Also ensure we don't allow swipe up when QS is open Bug: 137196872 Bug: 135969043 Change-Id: I476eee7f02ae86aa795fceabb304bcaa7416ef9c --- .../src/com/android/quickstep/RecentsAnimationWrapper.java | 4 ++-- .../src/com/android/quickstep/TouchInteractionService.java | 2 ++ .../com/android/quickstep/WindowTransformSwipeHandler.java | 3 ++- .../inputconsumers/FallbackNoButtonInputConsumer.java | 4 +++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/RecentsAnimationWrapper.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/RecentsAnimationWrapper.java index ca89c33929..e51ba631bf 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/RecentsAnimationWrapper.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/RecentsAnimationWrapper.java @@ -188,9 +188,9 @@ public class RecentsAnimationWrapper { return true; } - public void setCancelWithDeferredScreenshot(boolean deferredWithScreenshot) { + public void setDeferCancelUntilNextTransition(boolean defer, boolean screenshot) { if (targetSet != null) { - targetSet.controller.setCancelWithDeferredScreenshot(deferredWithScreenshot); + targetSet.controller.setDeferCancelUntilNextTransition(defer, screenshot); } } 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 5afc73cc1c..e1daea5e7e 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java @@ -31,6 +31,7 @@ import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_H import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NAV_BAR_HIDDEN; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_OVERVIEW_DISABLED; +import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_QUICK_SETTINGS_EXPANDED; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_SCREEN_PINNING; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING_OCCLUDED; import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.ACTIVITY_TYPE_ASSISTANT; @@ -569,6 +570,7 @@ public class TouchInteractionService extends Service implements private boolean validSystemUiFlags() { return (mSystemUiStateFlags & SYSUI_STATE_NAV_BAR_HIDDEN) == 0 && (mSystemUiStateFlags & SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED) == 0 + && (mSystemUiStateFlags & SYSUI_STATE_QUICK_SETTINGS_EXPANDED) == 0 && ((mSystemUiStateFlags & SYSUI_STATE_HOME_DISABLED) == 0 || (mSystemUiStateFlags & SYSUI_STATE_OVERVIEW_DISABLED) == 0); } diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java index 363e4cc6be..11d1a24340 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java @@ -1186,7 +1186,8 @@ public class WindowTransformSwipeHandler private void setupLauncherUiAfterSwipeUpToRecentsAnimation() { endLauncherTransitionController(); mActivityControlHelper.onSwipeUpToRecentsComplete(mActivity); - mRecentsAnimationWrapper.setCancelWithDeferredScreenshot(true); + mRecentsAnimationWrapper.setDeferCancelUntilNextTransition(true /* defer */, + true /* screenshot */); mRecentsView.onSwipeUpAnimationSuccess(); RecentsModel.INSTANCE.get(mContext).onOverviewShown(false, TAG); diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/FallbackNoButtonInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/FallbackNoButtonInputConsumer.java index 631c34c22d..6ec1da0c48 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/FallbackNoButtonInputConsumer.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/FallbackNoButtonInputConsumer.java @@ -50,6 +50,7 @@ import com.android.quickstep.fallback.FallbackRecentsView; import com.android.quickstep.util.ObjectWrapper; import com.android.quickstep.util.RectFSpringAnim; import com.android.quickstep.util.SwipeAnimationTargetSet; +import com.android.quickstep.views.RecentsView; import com.android.quickstep.views.TaskView; import com.android.systemui.shared.recents.model.ThumbnailData; import com.android.systemui.shared.system.ActivityManagerWrapper; @@ -335,7 +336,8 @@ public class FallbackNoButtonInputConsumer extends ThumbnailData thumbnail = mRecentsAnimationWrapper.targetSet.controller.screenshotTask(mRunningTaskId); - mRecentsAnimationWrapper.setCancelWithDeferredScreenshot(true); + mRecentsAnimationWrapper.setDeferCancelUntilNextTransition(true /* defer */, + false /* screenshot */); ActivityOptions options = ActivityOptions.makeCustomAnimation(mContext, 0, 0); ActivityOptionsCompat.setFreezeRecentTasksList(options); From c302baced05a39ac908a106998d300b9989df750 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Mon, 29 Jul 2019 11:10:04 -0700 Subject: [PATCH 2/3] Notifying the geature guide app when back gesture is performed so that user onboarding can the updated accordingly Bug: 138403212 Change-Id: Ib4e1cde0b2c746f955d5a58251c8ab653dadbc67 --- .../quickstep/TouchInteractionService.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) 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 e1daea5e7e..98c550293a 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 android.view.WindowManager; 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 @@ public class TouchInteractionService extends Service implements 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 @@ public class TouchInteractionService extends Service implements 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 @@ public class TouchInteractionService extends Service implements // 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 @@ public class TouchInteractionService extends Service implements 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)); From 3e90b4c7aea374411f23e908b1da46331db64b59 Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Tue, 30 Jul 2019 09:03:12 -0700 Subject: [PATCH 3/3] Fix bug where work profile widgets are restored with main profile provider. * Platform bug causes work profile widgets to be restored with main profile provider. * If we skip restore the widgets under the work profile during restore, then launcher will re-create the widget but with the correct profile provider. * Needs to be fixed in platform, but this launcher side change will work for now. Bug: 135926478 Change-Id: I80300c83e82cea9da84fdcdf7ad03188769b6cac --- .../launcher3/AppWidgetsRestoredReceiver.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/com/android/launcher3/AppWidgetsRestoredReceiver.java b/src/com/android/launcher3/AppWidgetsRestoredReceiver.java index d9491419fd..e3ef5d64e7 100644 --- a/src/com/android/launcher3/AppWidgetsRestoredReceiver.java +++ b/src/com/android/launcher3/AppWidgetsRestoredReceiver.java @@ -11,6 +11,7 @@ import android.database.Cursor; 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 com.android.launcher3.util.ContentWriter; 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 @@ public class AppWidgetsRestoredReceiver extends BroadcastReceiver { 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 @@ public class AppWidgetsRestoredReceiver extends BroadcastReceiver { 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.