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

Commit df7a5269 authored by Vinit Nayak's avatar Vinit Nayak Committed by Android (Google) Code Review
Browse files

Merge "Unbind service only if it was bound" into sc-v2-dev

parents c77e3fde a26e4f8e
Loading
Loading
Loading
Loading
+15 −11
Original line number Original line Diff line number Diff line
@@ -85,7 +85,6 @@ import com.android.quickstep.util.RemoteFadeOutAnimationListener;
import com.android.quickstep.util.SplitSelectStateController;
import com.android.quickstep.util.SplitSelectStateController;
import com.android.quickstep.views.OverviewActionsView;
import com.android.quickstep.views.OverviewActionsView;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.SplitPlaceholderView;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.ActivityOptionsCompat;
import com.android.systemui.shared.system.ActivityOptionsCompat;
import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
@@ -131,7 +130,7 @@ public abstract class BaseQuickstepLauncher extends Launcher
                // Seems like there can be a race condition when user unlocks, which kills the TIS
                // Seems like there can be a race condition when user unlocks, which kills the TIS
                // process and re-starts it. I guess in the meantime service can be connected to
                // process and re-starts it. I guess in the meantime service can be connected to
                // a killed TIS? Either way, unbind and try to re-connect in that case.
                // a killed TIS? Either way, unbind and try to re-connect in that case.
                unbindService(mTisBinderConnection);
                internalUnbindToTIS();
                mHandler.postDelayed(mConnectionRunnable, BACKOFF_MILLIS);
                mHandler.postDelayed(mConnectionRunnable, BACKOFF_MILLIS);
                return;
                return;
            }
            }
@@ -159,10 +158,10 @@ public abstract class BaseQuickstepLauncher extends Launcher
    private short mConnectionAttempts;
    private short mConnectionAttempts;
    private final TaskbarStateHandler mTaskbarStateHandler = new TaskbarStateHandler(this);
    private final TaskbarStateHandler mTaskbarStateHandler = new TaskbarStateHandler(this);
    private final Handler mHandler = new Handler();
    private final Handler mHandler = new Handler();
    private boolean mTisServiceBound;


    // Will be updated when dragging from taskbar.
    // Will be updated when dragging from taskbar.
    private @Nullable DragOptions mNextWorkspaceDragOptions = null;
    private @Nullable DragOptions mNextWorkspaceDragOptions = null;
    private SplitPlaceholderView mSplitPlaceholderView;


    private @Nullable UnfoldTransitionProgressProvider mUnfoldTransitionProgressProvider;
    private @Nullable UnfoldTransitionProgressProvider mUnfoldTransitionProgressProvider;
    private @Nullable LauncherUnfoldAnimationController mLauncherUnfoldAnimationController;
    private @Nullable LauncherUnfoldAnimationController mLauncherUnfoldAnimationController;
@@ -202,7 +201,7 @@ public abstract class BaseQuickstepLauncher extends Launcher


        SysUINavigationMode.INSTANCE.get(this).removeModeChangeListener(this);
        SysUINavigationMode.INSTANCE.get(this).removeModeChangeListener(this);


        unbindService(mTisBinderConnection);
        internalUnbindToTIS();
        if (mTaskbarManager != null) {
        if (mTaskbarManager != null) {
            mTaskbarManager.clearLauncher(this);
            mTaskbarManager.clearLauncher(this);
        }
        }
@@ -363,12 +362,13 @@ public abstract class BaseQuickstepLauncher extends Launcher


    /**
    /**
     * Binds {@link #mTisBinderConnection} to {@link TouchInteractionService}. If the binding fails,
     * Binds {@link #mTisBinderConnection} to {@link TouchInteractionService}. If the binding fails,
     * attempts to retry via {@link #mConnectionRunnable}
     * attempts to retry via {@link #mConnectionRunnable}.
     * Unbind via {@link #internalUnbindToTIS()}
     */
     */
    private void internalBindToTIS() {
    private void internalBindToTIS() {
        boolean bound = bindService(new Intent(this, TouchInteractionService.class),
        mTisServiceBound = bindService(new Intent(this, TouchInteractionService.class),
                        mTisBinderConnection, 0);
                        mTisBinderConnection, 0);
        if (bound) {
        if (mTisServiceBound) {
            resetServiceBindRetryState();
            resetServiceBindRetryState();
            return;
            return;
        }
        }
@@ -380,6 +380,14 @@ public abstract class BaseQuickstepLauncher extends Launcher
        mConnectionAttempts++;
        mConnectionAttempts++;
    }
    }


    /** See {@link #internalBindToTIS()} */
    private void internalUnbindToTIS() {
        if (mTisServiceBound) {
            unbindService(mTisBinderConnection);
            mTisServiceBound = false;
        }
    }

    private void resetServiceBindRetryState() {
    private void resetServiceBindRetryState() {
        if (mHandler.hasCallbacks(mConnectionRunnable)) {
        if (mHandler.hasCallbacks(mConnectionRunnable)) {
            mHandler.removeCallbacks(mConnectionRunnable);
            mHandler.removeCallbacks(mConnectionRunnable);
@@ -417,10 +425,6 @@ public abstract class BaseQuickstepLauncher extends Launcher
        return (T) mActionsView;
        return (T) mActionsView;
    }
    }


    public SplitPlaceholderView getSplitPlaceholderView() {
        return mSplitPlaceholderView;
    }

    @Override
    @Override
    protected void closeOpenViews(boolean animate) {
    protected void closeOpenViews(boolean animate) {
        super.closeOpenViews(animate);
        super.closeOpenViews(animate);