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

Commit 6e1ce8cc authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Fixing out of order taskbar callbacks

OnCreate can come before onDestroy for a previous activity which can
cause the callbacks for taskbar to get cleared

Bug: 190170303
Test: Presubmit
Change-Id: I48334605384d4604043a50ffc3d137f84575148a
parent 485796e8
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -132,7 +132,7 @@ public abstract class BaseQuickstepLauncher extends Launcher

        unbindService(mTisBinderConnection);
        if (mTaskbarManager != null) {
            mTaskbarManager.setLauncher(null);
            mTaskbarManager.clearLauncher(this);
        }
        super.onDestroy();
    }
+1 −1
Original line number Diff line number Diff line
@@ -98,11 +98,11 @@ public class LauncherTaskbarUIController extends TaskbarUIController {

    @Override
    protected void onDestroy() {
        onLauncherResumedOrPaused(false);
        mIconAlignmentForResumedState.finishAnimation();
        mIconAlignmentForGestureState.finishAnimation();

        mHotseatController.cleanup();
        setTaskbarViewVisible(true);
        mLauncher.getHotseat().setIconsAlpha(1f);
        mLauncher.setTaskbarUIController(null);
    }
+17 −6
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ import android.content.Context;
import android.hardware.display.DisplayManager;
import android.view.Display;

import androidx.annotation.Nullable;
import androidx.annotation.NonNull;

import com.android.launcher3.BaseQuickstepLauncher;
import com.android.launcher3.DeviceProfile;
@@ -103,14 +103,25 @@ public class TaskbarManager implements DisplayController.DisplayInfoChangeListen
    }

    /**
     * Sets or clears a launcher to act as taskbar callback
     * Sets a launcher to act as taskbar callback
     */
    public void setLauncher(@Nullable BaseQuickstepLauncher launcher) {
    public void setLauncher(@NonNull BaseQuickstepLauncher launcher) {
        mLauncher = launcher;
        if (mTaskbarActivityContext != null) {
            mTaskbarActivityContext.setUIController(mLauncher == null
                    ? TaskbarUIController.DEFAULT
                    : new LauncherTaskbarUIController(launcher, mTaskbarActivityContext));
            mTaskbarActivityContext.setUIController(
                    new LauncherTaskbarUIController(launcher, mTaskbarActivityContext));
        }
    }

    /**
     * Clears a previously set Launcher
     */
    public void clearLauncher(@NonNull BaseQuickstepLauncher launcher) {
        if (mLauncher == launcher) {
            mLauncher = null;
            if (mTaskbarActivityContext != null) {
                mTaskbarActivityContext.setUIController(TaskbarUIController.DEFAULT);
            }
        }
    }