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

Commit 46485c17 authored by Johannes Gallmann's avatar Johannes Gallmann Committed by Android (Google) Code Review
Browse files

Merge "Add setHasTopUi(true) during cross-activity and cross-task predictive back" into main

parents 8cfb6ca5 5cac86ac
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -107,4 +107,24 @@ public interface BackAnimation {
     * @param pilferCallback the callback to pilfer pointers.
     */
    void setPilferPointerCallback(Runnable pilferCallback);

    /**
     * Set a callback to requestTopUi.
     * @param topUiRequest the callback to requestTopUi.
     */
    void setTopUiRequestCallback(TopUiRequest topUiRequest);

    /**
     * Callback to request SysUi to call
     * {@link android.app.IActivityManager#setHasTopUi(boolean)}.
     */
    interface TopUiRequest {

        /**
         * Request {@link android.app.IActivityManager#setHasTopUi(boolean)} to be called.
         * @param requestTopUi  whether topUi should be requested or not
         * @param tag           tag of the request-source
         */
        void requestTopUi(boolean requestTopUi, String tag);
    }
}
+15 −0
Original line number Diff line number Diff line
@@ -179,6 +179,7 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
    @BackNavigationInfo.BackTargetType
    private int mPreviousNavigationType;
    private Runnable mPilferPointerCallback;
    private BackAnimation.TopUiRequest mRequestTopUiCallback;

    public BackAnimationController(
            @NonNull ShellInit shellInit,
@@ -357,6 +358,11 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
                mPilferPointerCallback = callback;
            });
        }

        @Override
        public void setTopUiRequestCallback(TopUiRequest topUiRequest) {
            mShellExecutor.execute(() -> mRequestTopUiCallback = topUiRequest);
        }
    }

    private static class IBackAnimationImpl extends IBackAnimation.Stub
@@ -557,6 +563,7 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
            if (!mShellBackAnimationRegistry.startGesture(backType)) {
                mActiveCallback = null;
            }
            requestTopUi(true, backType);
            tryPilferPointers();
        } else {
            mActiveCallback = mBackNavigationInfo.getOnBackInvokedCallback();
@@ -906,6 +913,7 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
            mPreviousNavigationType = mBackNavigationInfo.getType();
            mBackNavigationInfo.onBackNavigationFinished(triggerBack);
            mBackNavigationInfo = null;
            requestTopUi(false, mPreviousNavigationType);
        }
    }

@@ -969,6 +977,13 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
        }
    }

    private void requestTopUi(boolean hasTopUi, int backType) {
        if (mRequestTopUiCallback != null && (backType == BackNavigationInfo.TYPE_CROSS_TASK
                || backType == BackNavigationInfo.TYPE_CROSS_ACTIVITY)) {
            mRequestTopUiCallback.requestTopUi(hasTopUi, TAG);
        }
    }

    /**
     * Validate animation targets.
     */
+14 −3
Original line number Diff line number Diff line
@@ -91,6 +91,7 @@ import com.android.systemui.shared.system.QuickStepContract.SystemUiStateFlags;
import com.android.systemui.shared.system.SysUiStatsLog;
import com.android.systemui.shared.system.TaskStackChangeListener;
import com.android.systemui.shared.system.TaskStackChangeListeners;
import com.android.systemui.statusbar.NotificationShadeWindowController;
import com.android.systemui.statusbar.phone.LightBarController;
import com.android.systemui.util.concurrency.BackPanelUiThread;
import com.android.systemui.util.concurrency.UiThreadContext;
@@ -297,6 +298,7 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack
    private Date mTmpLogDate = new Date();

    private final GestureNavigationSettingsObserver mGestureNavigationSettingsObserver;
    private final NotificationShadeWindowController mNotificationShadeWindowController;

    private final NavigationEdgeBackPlugin.BackCallback mBackCallback =
            new NavigationEdgeBackPlugin.BackCallback() {
@@ -423,7 +425,8 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack
            Optional<DesktopMode> desktopModeOptional,
            FalsingManager falsingManager,
            Provider<BackGestureTfClassifierProvider> backGestureTfClassifierProviderProvider,
            Provider<LightBarController> lightBarControllerProvider) {
            Provider<LightBarController> lightBarControllerProvider,
            NotificationShadeWindowController notificationShadeWindowController) {
        mContext = context;
        mDisplayId = context.getDisplayId();
        mUiThreadContext = uiThreadContext;
@@ -479,6 +482,7 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack
                this::onNavigationSettingsChanged);

        updateCurrentUserResources();
        mNotificationShadeWindowController = notificationShadeWindowController;
    }

    public void setStateChangeCallback(Runnable callback) {
@@ -1297,6 +1301,9 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack
        mBackAnimation.setPilferPointerCallback(() -> {
            pilferPointers();
        });
        mBackAnimation.setTopUiRequestCallback(
                (requestTopUi, tag) -> mUiThreadContext.getExecutor().execute(() ->
                        mNotificationShadeWindowController.setRequestTopUi(requestTopUi, tag)));
        updateBackAnimationThresholds();
        if (mLightBarControllerProvider.get() != null) {
            mBackAnimation.setStatusBarCustomizer((appearance) -> {
@@ -1333,6 +1340,7 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack
        private final Provider<BackGestureTfClassifierProvider>
                mBackGestureTfClassifierProviderProvider;
        private final Provider<LightBarController> mLightBarControllerProvider;
        private final NotificationShadeWindowController mNotificationShadeWindowController;

        @Inject
        public Factory(OverviewProxyService overviewProxyService,
@@ -1353,7 +1361,8 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack
                        FalsingManager falsingManager,
                        Provider<BackGestureTfClassifierProvider>
                                backGestureTfClassifierProviderProvider,
                        Provider<LightBarController> lightBarControllerProvider) {
                Provider<LightBarController> lightBarControllerProvider,
                NotificationShadeWindowController notificationShadeWindowController) {
            mOverviewProxyService = overviewProxyService;
            mSysUiState = sysUiState;
            mPluginManager = pluginManager;
@@ -1372,6 +1381,7 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack
            mFalsingManager = falsingManager;
            mBackGestureTfClassifierProviderProvider = backGestureTfClassifierProviderProvider;
            mLightBarControllerProvider = lightBarControllerProvider;
            mNotificationShadeWindowController = notificationShadeWindowController;
        }

        /** Construct a {@link EdgeBackGestureHandler}. */
@@ -1396,7 +1406,8 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack
                            mDesktopModeOptional,
                            mFalsingManager,
                            mBackGestureTfClassifierProviderProvider,
                            mLightBarControllerProvider));
                            mLightBarControllerProvider,
                            mNotificationShadeWindowController));
        }
    }