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

Commit e161f08e authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Multi-window optimizations #3

- Make sure divider is pushing frames only if necessary
- When starting recents while docking, make sure no unnecessary
animations are played to reduce system load.

Change-Id: I536f009aef7282ed85dde79b853aeae62644f3e3
parent c3fb3143
Loading
Loading
Loading
Loading
+2 −8
Original line number Original line Diff line number Diff line
@@ -205,7 +205,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
                ? stack.indexOfStackTask(launchTarget)
                ? stack.indexOfStackTask(launchTarget)
                : 0;
                : 0;
        boolean hasNavBarScrim = (taskCount > 0) && !config.hasTransposedNavBar;
        boolean hasNavBarScrim = (taskCount > 0) && !config.hasTransposedNavBar;
        boolean animateNavBarScrim = true;
        boolean animateNavBarScrim = !launchState.launchedWhileDocking;
        mScrimViews.prepareEnterRecentsAnimation(hasNavBarScrim, animateNavBarScrim);
        mScrimViews.prepareEnterRecentsAnimation(hasNavBarScrim, animateNavBarScrim);


        // Keep track of whether we launched from the nav bar button or via alt-tab
        // Keep track of whether we launched from the nav bar button or via alt-tab
@@ -460,13 +460,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
        // wait on the system to send a signal that was never queued.
        // wait on the system to send a signal that was never queued.
        RecentsConfiguration config = Recents.getConfiguration();
        RecentsConfiguration config = Recents.getConfiguration();
        RecentsActivityLaunchState launchState = config.getLaunchState();
        RecentsActivityLaunchState launchState = config.getLaunchState();
        launchState.launchedFromHome = false;
        launchState.reset();
        launchState.launchedFromSearchHome = false;
        launchState.launchedFromAppWithThumbnail = false;
        launchState.launchedToTaskId = -1;
        launchState.launchedWithAltTab = false;
        launchState.launchedHasConfigurationChanged = false;
        launchState.launchedViaDragGesture = false;


        MetricsLogger.hidden(this, MetricsEvent.OVERVIEW_ACTIVITY);
        MetricsLogger.hidden(this, MetricsEvent.OVERVIEW_ACTIVITY);
    }
    }
+13 −0
Original line number Original line Diff line number Diff line
@@ -34,10 +34,22 @@ public class RecentsActivityLaunchState {
    public boolean launchedReuseTaskStackViews;
    public boolean launchedReuseTaskStackViews;
    public boolean launchedHasConfigurationChanged;
    public boolean launchedHasConfigurationChanged;
    public boolean launchedViaDragGesture;
    public boolean launchedViaDragGesture;
    public boolean launchedWhileDocking;
    public int launchedToTaskId;
    public int launchedToTaskId;
    public int launchedNumVisibleTasks;
    public int launchedNumVisibleTasks;
    public int launchedNumVisibleThumbnails;
    public int launchedNumVisibleThumbnails;


    public void reset() {
        launchedFromHome = false;
        launchedFromSearchHome = false;
        launchedFromAppWithThumbnail = false;
        launchedToTaskId = -1;
        launchedWithAltTab = false;
        launchedHasConfigurationChanged = false;
        launchedViaDragGesture = false;
        launchedWhileDocking = false;
    }

    /** Called when the configuration has changed, and we want to reset any configuration specific
    /** Called when the configuration has changed, and we want to reset any configuration specific
     * members. */
     * members. */
    public void updateOnConfigurationChange() {
    public void updateOnConfigurationChange() {
@@ -46,6 +58,7 @@ public class RecentsActivityLaunchState {
        // Set this flag to indicate that the configuration has changed since Recents last launched
        // Set this flag to indicate that the configuration has changed since Recents last launched
        launchedHasConfigurationChanged = true;
        launchedHasConfigurationChanged = true;
        launchedViaDragGesture = false;
        launchedViaDragGesture = false;
        launchedWhileDocking = false;
    }
    }


    /**
    /**
+7 −4
Original line number Original line Diff line number Diff line
@@ -161,6 +161,7 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
    boolean mCanReuseTaskStackViews = true;
    boolean mCanReuseTaskStackViews = true;
    boolean mDraggingInRecents;
    boolean mDraggingInRecents;
    boolean mReloadTasks;
    boolean mReloadTasks;
    boolean mLaunchedWhileDocking;


    // Task launching
    // Task launching
    Rect mSearchBarBounds = new Rect();
    Rect mSearchBarBounds = new Rect();
@@ -270,10 +271,10 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
    }
    }


    public void showRecents(boolean triggeredFromAltTab, boolean draggingInRecents,
    public void showRecents(boolean triggeredFromAltTab, boolean draggingInRecents,
            boolean animate, boolean reloadTasks) {
            boolean animate, boolean launchedWhileDockingTask) {
        mTriggeredFromAltTab = triggeredFromAltTab;
        mTriggeredFromAltTab = triggeredFromAltTab;
        mDraggingInRecents = draggingInRecents;
        mDraggingInRecents = draggingInRecents;
        mReloadTasks = reloadTasks;
        mLaunchedWhileDocking = launchedWhileDockingTask;
        if (mFastAltTabTrigger.hasTriggered()) {
        if (mFastAltTabTrigger.hasTriggered()) {
            // We are calling this from the doze trigger, so just fall through to show Recents
            // We are calling this from the doze trigger, so just fall through to show Recents
            mFastAltTabTrigger.resetTrigger();
            mFastAltTabTrigger.resetTrigger();
@@ -338,6 +339,7 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
        }
        }


        mDraggingInRecents = false;
        mDraggingInRecents = false;
        mLaunchedWhileDocking = false;
        mTriggeredFromAltTab = false;
        mTriggeredFromAltTab = false;


        try {
        try {
@@ -865,11 +867,11 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
        // In the case where alt-tab is triggered, we never get a preloadRecents() call, so we
        // In the case where alt-tab is triggered, we never get a preloadRecents() call, so we
        // should always preload the tasks now. If we are dragging in recents, reload them as
        // should always preload the tasks now. If we are dragging in recents, reload them as
        // the stacks might have changed.
        // the stacks might have changed.
        if (mReloadTasks || mTriggeredFromAltTab ||sInstanceLoadPlan == null) {
        if (mLaunchedWhileDocking || mTriggeredFromAltTab ||sInstanceLoadPlan == null) {
            // Create a new load plan if preloadRecents() was never triggered
            // Create a new load plan if preloadRecents() was never triggered
            sInstanceLoadPlan = loader.createLoadPlan(mContext);
            sInstanceLoadPlan = loader.createLoadPlan(mContext);
        }
        }
        if (mReloadTasks || mTriggeredFromAltTab || !sInstanceLoadPlan.hasTasks()) {
        if (mLaunchedWhileDocking || mTriggeredFromAltTab || !sInstanceLoadPlan.hasTasks()) {
            loader.preloadTasks(sInstanceLoadPlan, topTask.id, isTopTaskHome);
            loader.preloadTasks(sInstanceLoadPlan, topTask.id, isTopTaskHome);
        }
        }
        TaskStack stack = sInstanceLoadPlan.getTaskStack();
        TaskStack stack = sInstanceLoadPlan.getTaskStack();
@@ -957,6 +959,7 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
        launchState.launchedNumVisibleThumbnails = vr.numVisibleThumbnails;
        launchState.launchedNumVisibleThumbnails = vr.numVisibleThumbnails;
        launchState.launchedHasConfigurationChanged = false;
        launchState.launchedHasConfigurationChanged = false;
        launchState.launchedViaDragGesture = mDraggingInRecents;
        launchState.launchedViaDragGesture = mDraggingInRecents;
        launchState.launchedWhileDocking = mLaunchedWhileDocking;


        Intent intent = new Intent();
        Intent intent = new Intent();
        intent.setClassName(RECENTS_PACKAGE, mRecentsIntentActivityName);
        intent.setClassName(RECENTS_PACKAGE, mRecentsIntentActivityName);
+1 −7
Original line number Original line Diff line number Diff line
@@ -287,13 +287,7 @@ public class RecentsTvActivity extends Activity implements OnPreDrawListener {
        // wait on the system to send a signal that was never queued.
        // wait on the system to send a signal that was never queued.
        RecentsConfiguration config = Recents.getConfiguration();
        RecentsConfiguration config = Recents.getConfiguration();
        RecentsActivityLaunchState launchState = config.getLaunchState();
        RecentsActivityLaunchState launchState = config.getLaunchState();
        launchState.launchedFromHome = false;
        launchState.reset();
        launchState.launchedFromSearchHome = false;
        launchState.launchedFromAppWithThumbnail = false;
        launchState.launchedToTaskId = -1;
        launchState.launchedWithAltTab = false;
        launchState.launchedHasConfigurationChanged = false;
        launchState.launchedViaDragGesture = false;
    }
    }


    @Override
    @Override
+4 −2
Original line number Original line Diff line number Diff line
@@ -185,7 +185,8 @@ public class RecentsView extends FrameLayout {
        // If we are already occluded by the app, then just set the default background scrim now.
        // If we are already occluded by the app, then just set the default background scrim now.
        // Otherwise, defer until the enter animation completes to animate the scrim with the
        // Otherwise, defer until the enter animation completes to animate the scrim with the
        // tasks for the home animation.
        // tasks for the home animation.
        if (launchState.launchedFromAppWithThumbnail || mStack.getTaskCount() == 0) {
        if (launchState.launchedWhileDocking || launchState.launchedFromAppWithThumbnail
                || mStack.getTaskCount() == 0) {
            mBackgroundScrim.setAlpha((int) (DEFAULT_SCRIM_ALPHA * 255));
            mBackgroundScrim.setAlpha((int) (DEFAULT_SCRIM_ALPHA * 255));
        } else {
        } else {
            mBackgroundScrim.setAlpha(0);
            mBackgroundScrim.setAlpha(0);
@@ -645,7 +646,8 @@ public class RecentsView extends FrameLayout {


    public final void onBusEvent(EnterRecentsWindowAnimationCompletedEvent event) {
    public final void onBusEvent(EnterRecentsWindowAnimationCompletedEvent event) {
        RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState();
        RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState();
        if (!launchState.launchedFromAppWithThumbnail && mStack.getTaskCount() > 0) {
        if (!launchState.launchedWhileDocking && !launchState.launchedFromAppWithThumbnail
                && mStack.getTaskCount() > 0) {
            animateBackgroundScrim(DEFAULT_SCRIM_ALPHA,
            animateBackgroundScrim(DEFAULT_SCRIM_ALPHA,
                    TaskStackAnimationHelper.ENTER_FROM_HOME_TRANSLATION_DURATION);
                    TaskStackAnimationHelper.ENTER_FROM_HOME_TRANSLATION_DURATION);
        }
        }
Loading