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

Commit 9a0e1801 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Removing separate overview prediction client

Bug: 160748731
Change-Id: Ia9ab089bc016bbaa6a19cedaee3bf12719db9da0
parent c4fff092
Loading
Loading
Loading
Loading
+1 −12
Original line number Diff line number Diff line
@@ -69,7 +69,6 @@ public class PredictionAppTracker extends AppLaunchTracker

    // Accessed only on worker thread
    private AppPredictor mHomeAppPredictor;
    private AppPredictor mRecentsOverviewPredictor;

    public PredictionAppTracker(Context context) {
        mContext = context;
@@ -97,10 +96,6 @@ public class PredictionAppTracker extends AppLaunchTracker
            mHomeAppPredictor.destroy();
            mHomeAppPredictor = null;
        }
        if (mRecentsOverviewPredictor != null) {
            mRecentsOverviewPredictor.destroy();
            mRecentsOverviewPredictor = null;
        }
    }

    @WorkerThread
@@ -142,7 +137,6 @@ public class PredictionAppTracker extends AppLaunchTracker
                // Initialize the clients
                int count = InvariantDeviceProfile.INSTANCE.get(mContext).numAllAppsColumns;
                mHomeAppPredictor = createPredictor(Client.HOME, count);
                mRecentsOverviewPredictor = createPredictor(Client.OVERVIEW, count);
                return true;
            }
            case MSG_DESTROY: {
@@ -157,12 +151,7 @@ public class PredictionAppTracker extends AppLaunchTracker
            }
            case MSG_PREDICT: {
                if (mHomeAppPredictor != null) {
                    String client = (String) msg.obj;
                    if (Client.HOME.id.equals(client)) {
                    mHomeAppPredictor.requestPredictionUpdate();
                    } else {
                        mRecentsOverviewPredictor.requestPredictionUpdate();
                    }
                }
                return true;
            }
+6 −28
Original line number Diff line number Diff line
@@ -75,8 +75,7 @@ public class PredictionUiStateManager implements StateListener<LauncherState>,

    // TODO (b/129421797): Update the client constants
    public enum Client {
        HOME("home"),
        OVERVIEW("overview");
        HOME("home");

        public final String id;

@@ -91,10 +90,9 @@ public class PredictionUiStateManager implements StateListener<LauncherState>,
    private final Context mContext;

    private final DynamicItemCache mDynamicItemCache;
    private final List[] mPredictionServicePredictions;
    private List mPredictionServicePredictions = Collections.emptyList();

    private int mMaxIconsPerRow;
    private Client mActiveClient;

    private AllAppsContainerView mAppsView;

@@ -108,16 +106,10 @@ public class PredictionUiStateManager implements StateListener<LauncherState>,

        mDynamicItemCache = new DynamicItemCache(context, this::onAppsUpdated);

        mActiveClient = Client.HOME;

        InvariantDeviceProfile idp = LauncherAppState.getIDP(context);
        mMaxIconsPerRow = idp.numColumns;

        idp.addOnChangeListener(this);
        mPredictionServicePredictions = new List[Client.values().length];
        for (int i = 0; i < mPredictionServicePredictions.length; i++) {
            mPredictionServicePredictions[i] = Collections.emptyList();
        }
        mGettingValidPredictionResults = Utilities.getDevicePrefs(context)
                .getBoolean(LAST_PREDICTION_ENABLED_STATE, true);

@@ -130,18 +122,6 @@ public class PredictionUiStateManager implements StateListener<LauncherState>,
        mMaxIconsPerRow = profile.numColumns;
    }

    public Client getClient() {
        return mActiveClient;
    }

    public void switchClient(Client client) {
        if (client == mActiveClient) {
            return;
        }
        mActiveClient = client;
        dispatchOnChange(true);
    }

    public void setTargetAppsView(AllAppsContainerView appsView) {
        if (mAppsView != null) {
            mAppsView.getAppsStore().removeUpdateListener(this);
@@ -195,10 +175,8 @@ public class PredictionUiStateManager implements StateListener<LauncherState>,
    }

    private void updatePredictionStateAfterCallback() {
        boolean validResults = false;
        for (List l : mPredictionServicePredictions) {
            validResults |= l != null && !l.isEmpty();
        }
        boolean validResults = mPredictionServicePredictions != null
                && !mPredictionServicePredictions.isEmpty();
        if (validResults != mGettingValidPredictionResults) {
            mGettingValidPredictionResults = validResults;
            Utilities.getDevicePrefs(mContext).edit()
@@ -210,7 +188,7 @@ public class PredictionUiStateManager implements StateListener<LauncherState>,

    public AppPredictor.Callback appPredictorCallback(Client client) {
        return targets -> {
            mPredictionServicePredictions[client.ordinal()] = targets;
            mPredictionServicePredictions = targets;
            updatePredictionStateAfterCallback();
        };
    }
@@ -238,7 +216,7 @@ public class PredictionUiStateManager implements StateListener<LauncherState>,

        state.apps = new ArrayList<>();

        List<AppTarget> appTargets = mPredictionServicePredictions[mActiveClient.ordinal()];
        List<AppTarget> appTargets = mPredictionServicePredictions;
        if (!appTargets.isEmpty()) {
            for (AppTarget appTarget : appTargets) {
                ComponentKey key;
+0 −13
Original line number Diff line number Diff line
@@ -38,7 +38,6 @@ import static com.android.quickstep.GestureState.STATE_END_TARGET_ANIMATION_FINI
import static com.android.quickstep.GestureState.STATE_END_TARGET_SET;
import static com.android.quickstep.GestureState.STATE_RECENTS_SCROLLING_FINISHED;
import static com.android.quickstep.MultiStateCallback.DEBUG_STATES;
import static com.android.quickstep.SysUINavigationMode.Mode.TWO_BUTTONS;
import static com.android.quickstep.util.ShelfPeekAnim.ShelfAnimState.HIDE;
import static com.android.quickstep.util.ShelfPeekAnim.ShelfAnimState.PEEK;
import static com.android.quickstep.views.RecentsView.UPDATE_SYSUI_FLAGS_THRESHOLD;
@@ -311,12 +310,6 @@ public abstract class BaseSwipeUpHandlerV2<T extends StatefulActivity<?>, Q exte
        }

        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();
        }
        linkRecentsViewScroll();

        return true;
@@ -449,12 +442,6 @@ public abstract class BaseSwipeUpHandlerV2<T extends StatefulActivity<?>, Q exte
    @Override
    public void onMotionPauseChanged(boolean isPaused) {
        setShelfState(isPaused ? PEEK : HIDE, ShelfPeekAnim.INTERPOLATOR, ShelfPeekAnim.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() {
+0 −10
Original line number Diff line number Diff line
@@ -261,16 +261,6 @@ public final class LauncherActivityInterface extends
        return true;
    }

    @Override
    public void updateOverviewPredictionState() {
        Launcher launcher = getCreatedActivity();
        if (launcher == null) {
            return;
        }
        PredictionUiStateManager.INSTANCE.get(launcher).switchClient(
                PredictionUiStateManager.Client.OVERVIEW);
    }

    @Override
    public int getContainerType() {
        final Launcher launcher = getVisibleLauncher();
+0 −5
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@ import android.view.ViewConfiguration;

import androidx.annotation.BinderThread;

import com.android.launcher3.appprediction.PredictionUiStateManager;
import com.android.launcher3.logging.UserEventDispatcher;
import com.android.launcher3.statemanager.StatefulActivity;
import com.android.launcher3.userevent.nano.LauncherLogProto;
@@ -227,10 +226,6 @@ public class OverviewCommandHelper {
                        LauncherLogProto.ContainerType.TASKSWITCHER);
                mUserEventLogged = true;
            }

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

Loading