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

Commit 94302570 authored by Winson Chung's avatar Winson Chung
Browse files

Skip updating launcher state if it's already destroyed



- Prior to ag/9526193, there were a mixture of getCreatedActivity() and
  passed in Activity calls. In the cases where we used the passed in
  activity, it would happily make the call even if the activity is already
  destroyed, but since we migrated to using the unified getCreatedActivity()
  call, it results in an NPE. Since it's unnecessary to update the destroyed
  activity, we can simply skip this work.

  Long term, we should consider baking the activity associated with the
  call into the activity interface, and ensure that the interface itself
  is updated whenever the activity is recreated.

Bug: 141886704

Change-Id: I4f043e455d8d0d1c1b86362cc72618018bfbd900
Signed-off-by: default avatarWinson Chung <winsonc@google.com>
parent cebfec62
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -75,6 +75,9 @@ public final class FallbackActivityInterface implements
    @Override
    public void onSwipeUpToRecentsComplete() {
        RecentsActivity activity = getCreatedActivity();
        if (activity == null) {
            return;
        }
        RecentsView recentsView = activity.getOverviewPanel();
        recentsView.getClearAllButton().setVisibilityAlpha(1);
        recentsView.setDisallowScrollToClearAll(false);
@@ -236,12 +239,18 @@ public final class FallbackActivityInterface implements
    public void onLaunchTaskFailed() {
        // TODO: probably go back to overview instead.
        RecentsActivity activity = getCreatedActivity();
        if (activity == null) {
            return;
        }
        activity.<RecentsView>getOverviewPanel().startHome();
    }

    @Override
    public void onLaunchTaskSuccess() {
        RecentsActivity activity = getCreatedActivity();
        if (activity == null) {
            return;
        }
        activity.onTaskLaunched();
    }
}
+28 −7
Original line number Diff line number Diff line
@@ -94,6 +94,9 @@ public final class LauncherActivityInterface implements BaseActivityInterface<La
    @Override
    public void onTransitionCancelled(boolean activityVisible) {
        Launcher launcher = getCreatedActivity();
        if (launcher == null) {
            return;
        }
        LauncherState startState = launcher.getStateManager().getRestState();
        launcher.getStateManager().goToState(startState, activityVisible);
    }
@@ -102,32 +105,40 @@ public final class LauncherActivityInterface implements BaseActivityInterface<La
    public void onSwipeUpToRecentsComplete() {
        // Re apply state in case we did something funky during the transition.
        Launcher launcher = getCreatedActivity();
        if (launcher == null) {
            return;
        }
        launcher.getStateManager().reapplyState();
        DiscoveryBounce.showForOverviewIfNeeded(launcher);
    }

    @Override
    public void onSwipeUpToHomeComplete() {
        Launcher launcher = getCreatedActivity();
        if (launcher == null) {
            return;
        }
        // Ensure recents is at the correct position for NORMAL state. For example, when we detach
        // recents, we assume the first task is invisible, making translation off by one task.
        Launcher launcher = getCreatedActivity();
        launcher.getStateManager().reapplyState();
        setLauncherHideBackArrow(false);
    }

    private void setLauncherHideBackArrow(boolean hideBackArrow) {
        Launcher launcher = getCreatedActivity();
        if (launcher != null) {
            launcher.getRootView().setForceHideBackArrow(hideBackArrow);
        if (launcher == null) {
            return;
        }
        launcher.getRootView().setForceHideBackArrow(hideBackArrow);
    }

    @Override
    public void onAssistantVisibilityChanged(float visibility) {
        Launcher launcher = getCreatedActivity();
        if (launcher != null) {
            launcher.onAssistantVisibilityChanged(visibility);
        if (launcher == null) {
            return;
        }
        launcher.onAssistantVisibilityChanged(visibility);
    }

    @NonNull
@@ -476,12 +487,18 @@ public final class LauncherActivityInterface implements BaseActivityInterface<La
    @Override
    public void onLaunchTaskFailed() {
        Launcher launcher = getCreatedActivity();
        if (launcher == null) {
            return;
        }
        launcher.getStateManager().goToState(OVERVIEW);
    }

    @Override
    public void onLaunchTaskSuccess() {
        Launcher launcher = getCreatedActivity();
        if (launcher == null) {
            return;
        }
        launcher.getStateManager().moveToRestState();
    }

@@ -503,6 +520,9 @@ public final class LauncherActivityInterface implements BaseActivityInterface<La
    public void switchRunningTaskViewToScreenshot(ThumbnailData thumbnailData,
            Runnable onFinishRunnable) {
        Launcher launcher = getCreatedActivity();
        if (launcher == null) {
            return;
        }
        RecentsView recentsView = launcher.getOverviewPanel();
        if (recentsView == null) {
            if (onFinishRunnable != null) {
@@ -516,8 +536,9 @@ public final class LauncherActivityInterface implements BaseActivityInterface<La
    @Override
    public void setOnDeferredActivityLaunchCallback(Runnable r) {
        Launcher launcher = getCreatedActivity();
        if (launcher != null) {
            launcher.setOnDeferredActivityLaunchCallback(r);
        if (launcher == null) {
            return;
        }
        launcher.setOnDeferredActivityLaunchCallback(r);
    }
}
 No newline at end of file