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

Commit 52c57f73 authored by Winson Chung's avatar Winson Chung
Browse files

17/ Update activity tracker callback

- Immediately callback when scheduling activity tracker callback and the
  activity already exists
- Remove LauncherInitListenerEx, it was only used to update the prediction
  ui state, but not all of the callers of the launcher activity init
  listener actually needs this (ie. Go doesn't have overview predictions,
  overscroll input consumer/touch interaction service doesn't need it.)

  Instead we only call it in the places we need it LauncherSwipeHandler (for
  swipe up) and OverviewCommandHelper (for the nav bar button).

Bug: 141886704

Change-Id: I890a45e658be813e99b2a02f179fce611ede9ce8
parent 11aef9ef
Loading
Loading
Loading
Loading
+0 −34
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.android.launcher3;

import com.android.launcher3.appprediction.PredictionUiStateManager;
import com.android.launcher3.appprediction.PredictionUiStateManager.Client;

import java.util.function.BiPredicate;

public class LauncherInitListenerEx extends LauncherInitListener {

    public LauncherInitListenerEx(BiPredicate<Launcher, Boolean> onInitListener) {
        super(onInitListener);
    }

    @Override
    public boolean init(Launcher launcher, boolean alreadyOnHome) {
        PredictionUiStateManager.INSTANCE.get(launcher).switchClient(Client.OVERVIEW);
        return super.init(launcher, alreadyOnHome);
    }
}
+13 −2
Original line number Original line Diff line number Diff line
@@ -49,12 +49,13 @@ import androidx.annotation.UiThread;


import com.android.launcher3.DeviceProfile;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherInitListenerEx;
import com.android.launcher3.LauncherInitListener;
import com.android.launcher3.LauncherState;
import com.android.launcher3.LauncherState;
import com.android.launcher3.LauncherStateManager;
import com.android.launcher3.LauncherStateManager;
import com.android.launcher3.allapps.DiscoveryBounce;
import com.android.launcher3.allapps.DiscoveryBounce;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.AnimatorSetBuilder;
import com.android.launcher3.anim.AnimatorSetBuilder;
import com.android.launcher3.appprediction.PredictionUiStateManager;
import com.android.launcher3.uioverrides.states.OverviewState;
import com.android.launcher3.uioverrides.states.OverviewState;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.views.FloatingIconView;
import com.android.launcher3.views.FloatingIconView;
@@ -413,7 +414,7 @@ public final class LauncherActivityInterface implements BaseActivityInterface<La


    @Override
    @Override
    public ActivityInitListener createActivityInitListener(Predicate<Boolean> onInitListener) {
    public ActivityInitListener createActivityInitListener(Predicate<Boolean> onInitListener) {
        return new LauncherInitListenerEx((activity, alreadyOnHome) ->
        return new LauncherInitListener((activity, alreadyOnHome) ->
                onInitListener.test(alreadyOnHome));
                onInitListener.test(alreadyOnHome));
    }
    }


@@ -541,4 +542,14 @@ public final class LauncherActivityInterface implements BaseActivityInterface<La
        }
        }
        launcher.setOnDeferredActivityLaunchCallback(r);
        launcher.setOnDeferredActivityLaunchCallback(r);
    }
    }

    @Override
    public void updateOverviewPredictionState() {
        Launcher launcher = getCreatedActivity();
        if (launcher == null) {
            return;
        }
        PredictionUiStateManager.INSTANCE.get(launcher).switchClient(
                PredictionUiStateManager.Client.OVERVIEW);
    }
}
}
 No newline at end of file
+13 −0
Original line number Original line Diff line number Diff line
@@ -32,6 +32,7 @@ import static com.android.quickstep.GestureState.GestureEndTarget.NEW_TASK;
import static com.android.quickstep.GestureState.GestureEndTarget.RECENTS;
import static com.android.quickstep.GestureState.GestureEndTarget.RECENTS;
import static com.android.quickstep.GestureState.STATE_END_TARGET_ANIMATION_FINISHED;
import static com.android.quickstep.GestureState.STATE_END_TARGET_ANIMATION_FINISHED;
import static com.android.quickstep.MultiStateCallback.DEBUG_STATES;
import static com.android.quickstep.MultiStateCallback.DEBUG_STATES;
import static com.android.quickstep.SysUINavigationMode.Mode.TWO_BUTTONS;
import static com.android.quickstep.views.RecentsView.UPDATE_SYSUI_FLAGS_THRESHOLD;
import static com.android.quickstep.views.RecentsView.UPDATE_SYSUI_FLAGS_THRESHOLD;


import android.animation.Animator;
import android.animation.Animator;
@@ -296,6 +297,12 @@ public class LauncherSwipeHandler<T extends BaseDraggingActivity>
        }
        }


        setupRecentsViewUi();
        setupRecentsViewUi();

        if (mDeviceState.getNavMode() == TWO_BUTTONS) {
            // If the device is in two button mode, swiping up will show overview with predictions
            // so we need to kick off switching to the overview predictions as soon as possible
            mActivityInterface.updateOverviewPredictionState();
        }
        return true;
        return true;
    }
    }


@@ -426,6 +433,12 @@ public class LauncherSwipeHandler<T extends BaseDraggingActivity>
    @Override
    @Override
    public void onMotionPauseChanged(boolean isPaused) {
    public void onMotionPauseChanged(boolean isPaused) {
        setShelfState(isPaused ? PEEK : HIDE, OVERSHOOT_1_2, SHELF_ANIM_DURATION);
        setShelfState(isPaused ? PEEK : HIDE, OVERSHOOT_1_2, SHELF_ANIM_DURATION);

        if (mDeviceState.isFullyGesturalNavMode() && isPaused) {
            // In fully gestural nav mode, switch to overview predictions once the user has paused
            // (this is a no-op if the predictions are already in that state)
            mActivityInterface.updateOverviewPredictionState();
        }
    }
    }


    public void maybeUpdateRecentsAttachedState() {
    public void maybeUpdateRecentsAttachedState() {
+5 −0
Original line number Original line Diff line number Diff line
@@ -29,6 +29,7 @@ import android.view.ViewConfiguration;


import androidx.annotation.BinderThread;
import androidx.annotation.BinderThread;
import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.appprediction.PredictionUiStateManager;
import com.android.launcher3.logging.UserEventDispatcher;
import com.android.launcher3.logging.UserEventDispatcher;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.quickstep.util.ActivityInitListener;
import com.android.quickstep.util.ActivityInitListener;
@@ -212,6 +213,10 @@ public class OverviewCommandHelper {
                        LauncherLogProto.ContainerType.TASKSWITCHER);
                        LauncherLogProto.ContainerType.TASKSWITCHER);
                mUserEventLogged = true;
                mUserEventLogged = true;
            }
            }

            // Switch prediction client to overview
            PredictionUiStateManager.INSTANCE.get(activity).switchClient(
                    PredictionUiStateManager.Client.OVERVIEW);
            return mAnimationProvider.onActivityReady(activity, wasVisible);
            return mAnimationProvider.onActivityReady(activity, wasVisible);
        }
        }


+6 −0
Original line number Original line Diff line number Diff line
@@ -22,6 +22,7 @@ import android.os.Build;
import android.os.CancellationSignal;
import android.os.CancellationSignal;
import android.os.Handler;
import android.os.Handler;


import com.android.launcher3.util.ActivityTracker;
import com.android.quickstep.util.ActivityInitListener;
import com.android.quickstep.util.ActivityInitListener;
import com.android.quickstep.util.RemoteAnimationProvider;
import com.android.quickstep.util.RemoteAnimationProvider;


@@ -32,6 +33,11 @@ public class LauncherInitListener extends ActivityInitListener<Launcher> {


    private RemoteAnimationProvider mRemoteAnimationProvider;
    private RemoteAnimationProvider mRemoteAnimationProvider;


    /**
     * @param onInitListener a callback made when the activity is initialized. The callback should
     *                       return true to continue receiving callbacks (ie. for if the activity is
     *                       recreated).
     */
    public LauncherInitListener(BiPredicate<Launcher, Boolean> onInitListener) {
    public LauncherInitListener(BiPredicate<Launcher, Boolean> onInitListener) {
        super(onInitListener, Launcher.ACTIVITY_TRACKER);
        super(onInitListener, Launcher.ACTIVITY_TRACKER);
    }
    }
Loading