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

Commit 25137534 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Fixing potential NullPointer exceptions when Launcher is

created before TouchInteractionService is initialized

SystemUiProxy is a wrapper opject which holds the state information
until the actual proxy is initialized. It is safe to be initialized
lazily.

Bug: 221961069
Test: Verified on device
Change-Id: I1a621cad52e5b8384439ef02de6b95c6452bcb06
parent 7ee087f5
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -1161,7 +1161,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
                    new LauncherAnimationRunner(mHandler, mWallpaperOpenTransitionRunner,
                            false /* startAtFrontOfQueue */), mLauncher.getIApplicationThread());
            mLauncherOpenTransition.addHomeOpenCheck(mLauncher.getComponentName());
            SystemUiProxy.INSTANCE.getNoCreate().registerRemoteTransition(mLauncherOpenTransition);
            SystemUiProxy.INSTANCE.get(mLauncher).registerRemoteTransition(mLauncherOpenTransition);
        }
        if (mBackAnimationController != null) {
            mBackAnimationController.registerBackCallbacks(mHandler);
@@ -1172,7 +1172,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
        unregisterRemoteAnimations();
        unregisterRemoteTransitions();
        mStartingWindowListener.setTransitionManager(null);
        SystemUiProxy.INSTANCE.getNoCreate().setStartingWindowListener(null);
        SystemUiProxy.INSTANCE.get(mLauncher).setStartingWindowListener(null);
    }

    private void unregisterRemoteAnimations() {
@@ -1196,7 +1196,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
        }
        if (hasControlRemoteAppTransitionPermission()) {
            if (mLauncherOpenTransition == null) return;
            SystemUiProxy.INSTANCE.getNoCreate().unregisterRemoteTransition(
            SystemUiProxy.INSTANCE.get(mLauncher).unregisterRemoteTransition(
                    mLauncherOpenTransition);
            mLauncherOpenTransition = null;
            mWallpaperOpenTransitionRunner = null;
+1 −1
Original line number Diff line number Diff line
@@ -770,7 +770,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
            // We will handle the sysui flags based on the centermost task view.
            mRecentsAnimationController.setUseLauncherSystemBarFlags(swipeUpThresholdPassed
                    ||  (quickswitchThresholdPassed && centermostTaskFlags != 0));
            mRecentsAnimationController.setSplitScreenMinimized(swipeUpThresholdPassed);
            mRecentsAnimationController.setSplitScreenMinimized(mContext, swipeUpThresholdPassed);
            // Provide a hint to WM the direction that we will be settling in case the animation
            // needs to be canceled
            mRecentsAnimationController.setWillFinishToHome(swipeUpThresholdPassed);
+4 −17
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@ import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Handler;
import android.util.Log;
import android.util.MathUtils;
import android.util.Pair;
import android.view.RemoteAnimationTarget;
@@ -55,7 +54,7 @@ import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat;
 * the app window and plays the rest of app close transitions in one go.
 *
 * This animation is used only for apps that enable back dispatching via
 * {@link android.view.OnBackInvokedDispatcher}. The controller registers
 * {@link android.window.OnBackInvokedDispatcher}. The controller registers
 * an {@link IOnBackInvokedCallback} with WM Shell and receives back dispatches when a back
 * navigation to launcher starts.
 *
@@ -66,7 +65,6 @@ import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat;
public class LauncherBackAnimationController {
    private static final int CANCEL_TRANSITION_DURATION = 233;
    private static final float MIN_WINDOW_SCALE = 0.7f;
    private static final String TAG = "LauncherBackAnimationController";
    private final QuickstepTransitionManager mQuickstepTransitionManager;
    private final Matrix mTransformMatrix = new Matrix();
    /** The window position at the beginning of the back animation. */
@@ -115,12 +113,7 @@ public class LauncherBackAnimationController {
     * @param handler Handler to the thread to run the animations on.
     */
    public void registerBackCallbacks(Handler handler) {
        SystemUiProxy systemUiProxy = SystemUiProxy.INSTANCE.getNoCreate();
        if (systemUiProxy == null) {
            Log.e(TAG, "SystemUiProxy is null. Skip registering back invocation callbacks");
            return;
        }
        systemUiProxy.setBackToLauncherCallback(
        SystemUiProxy.INSTANCE.get(mLauncher).setBackToLauncherCallback(
                new IOnBackInvokedCallback.Stub() {
                    @Override
                    public void onBackCancelled() {
@@ -170,10 +163,7 @@ public class LauncherBackAnimationController {

    /** Unregisters the back to launcher callback in shell. */
    public void unregisterBackCallbacks() {
        SystemUiProxy systemUiProxy = SystemUiProxy.INSTANCE.getNoCreate();
        if (systemUiProxy != null) {
            systemUiProxy.clearBackToLauncherCallback();
        }
        SystemUiProxy.INSTANCE.get(mLauncher).clearBackToLauncherCallback();
    }

    private void startBack(BackEvent backEvent) {
@@ -298,10 +288,7 @@ public class LauncherBackAnimationController {
        mInitialTouchPos.set(0, 0);
        mAnimatorSetInProgress = false;
        mSpringAnimationInProgress = false;
        SystemUiProxy systemUiProxy = SystemUiProxy.INSTANCE.getNoCreate();
        if (systemUiProxy != null) {
            SystemUiProxy.INSTANCE.getNoCreate().onBackToLauncherAnimationFinished();
        }
        SystemUiProxy.INSTANCE.get(mLauncher).onBackToLauncherAnimationFinished();
    }

    private void startTransitionAnimations(RectFSpringAnim springAnim, AnimatorSet anim) {
+5 −8
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
import static com.android.quickstep.TaskAnimationManager.ENABLE_SHELL_TRANSITIONS;

import android.content.Context;
import android.os.RemoteException;
import android.util.Log;
import android.view.IRecentsAnimationController;
@@ -97,24 +98,20 @@ public class RecentsAnimationController {
     * Indicates that the gesture has crossed the window boundary threshold and we should minimize
     * if we are in splitscreen.
     */
    public void setSplitScreenMinimized(boolean splitScreenMinimized) {
    public void setSplitScreenMinimized(Context context, boolean splitScreenMinimized) {
        if (!mAllowMinimizeSplitScreen) {
            return;
        }
        if (mSplitScreenMinimized != splitScreenMinimized) {
            mSplitScreenMinimized = splitScreenMinimized;
            UI_HELPER_EXECUTOR.execute(() -> {
                SystemUiProxy p = SystemUiProxy.INSTANCE.getNoCreate();
                if (p != null) {
                    p.setSplitScreenMinimized(splitScreenMinimized);
                }
            });
            UI_HELPER_EXECUTOR.execute(() -> SystemUiProxy.INSTANCE.get(context)
                    .setSplitScreenMinimized(splitScreenMinimized));
        }
    }

    /**
     * Remove task remote animation target from
     * {@link RecentsAnimationCallbacks#onTaskAppeared(RemoteAnimationTargetCompat)}}.
     * {@link RecentsAnimationCallbacks#onTasksAppeared}}.
     */
    @UiThread
    public void removeTaskTarget(@NonNull RemoteAnimationTargetCompat target) {
+2 −3
Original line number Diff line number Diff line
@@ -177,8 +177,7 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn
                    ((RecentsActivity) activityInterface.getCreatedActivity()).startHome();
                    return;
                }
                RemoteAnimationTarget[] nonAppTargets =
                        SystemUiProxy.INSTANCE.getNoCreate()
                RemoteAnimationTarget[] nonAppTargets = SystemUiProxy.INSTANCE.get(mCtx)
                        .onGoingToRecentsLegacy(false, nonHomeApps);

                if (ENABLE_QUICKSTEP_LIVE_TILE.get() && activityInterface.isInLiveTileMode()
Loading