Merge branch 'heads/android-14.0.0_r18' into 14-dev
This commit is contained in:
1 parent
32700b0100
commit
cc8f9828ab
756 files changed
+23785
-12235
No files matched your search
@@ -50,11 +50,12 @@ import android.os.UserHandle;
|
||||
import android.util.Log;
|
||||
import android.util.StatsEvent;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
import androidx.annotation.AnyThread;
|
||||
import androidx.annotation.CallSuper;
|
||||
import androidx.annotation.Keep;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.annotation.WorkerThread;
|
||||
|
||||
import com.android.launcher3.InvariantDeviceProfile;
|
||||
@@ -99,10 +100,12 @@ public class QuickstepModelDelegate extends ModelDelegate {
|
||||
private static final boolean IS_DEBUG = false;
|
||||
private static final String TAG = "QuickstepModelDelegate";
|
||||
|
||||
private final PredictorState mAllAppsState = new PredictorState(CONTAINER_PREDICTION, "all_apps_predictions");
|
||||
private final PredictorState mHotseatState = new PredictorState(CONTAINER_HOTSEAT_PREDICTION,
|
||||
"hotseat_predictions");
|
||||
private final PredictorState mWidgetsRecommendationState = new PredictorState(CONTAINER_WIDGETS_PREDICTION,
|
||||
@VisibleForTesting
|
||||
final PredictorState mAllAppsState = new PredictorState(CONTAINER_PREDICTION, "all_apps_predictions");
|
||||
@VisibleForTesting
|
||||
final PredictorState mHotseatState = new PredictorState(CONTAINER_HOTSEAT_PREDICTION, "hotseat_predictions");
|
||||
@VisibleForTesting
|
||||
final PredictorState mWidgetsRecommendationState = new PredictorState(CONTAINER_WIDGETS_PREDICTION,
|
||||
"widgets_prediction");
|
||||
|
||||
private final InvariantDeviceProfile mIDP;
|
||||
@@ -361,12 +364,7 @@ public class QuickstepModelDelegate extends ModelDelegate {
|
||||
.build()));
|
||||
|
||||
// TODO: get bundle
|
||||
registerPredictor(mHotseatState, apm.createAppPredictionSession(
|
||||
new AppPredictionContext.Builder(context)
|
||||
.setUiSurface("hotseat")
|
||||
.setPredictedTargetCount(mIDP.numDatabaseHotseatIcons)
|
||||
.setExtras(convertDataModelToAppTargetBundle(context, mDataModel))
|
||||
.build()));
|
||||
registerHotseatPredictor(apm, context);
|
||||
|
||||
registerWidgetsPredictor(apm.createAppPredictionSession(
|
||||
new AppPredictionContext.Builder(context)
|
||||
@@ -376,6 +374,29 @@ public class QuickstepModelDelegate extends ModelDelegate {
|
||||
.build()));
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
private void recreateHotseatPredictor() {
|
||||
mHotseatState.destroyPredictor();
|
||||
if (!mActive) {
|
||||
return;
|
||||
}
|
||||
Context context = mApp.getContext();
|
||||
AppPredictionManager apm = context.getSystemService(AppPredictionManager.class);
|
||||
if (apm == null) {
|
||||
return;
|
||||
}
|
||||
registerHotseatPredictor(apm, context);
|
||||
}
|
||||
|
||||
private void registerHotseatPredictor(AppPredictionManager apm, Context context) {
|
||||
registerPredictor(mHotseatState, apm.createAppPredictionSession(
|
||||
new AppPredictionContext.Builder(context)
|
||||
.setUiSurface("hotseat")
|
||||
.setPredictedTargetCount(mIDP.numDatabaseHotseatIcons)
|
||||
.setExtras(convertDataModelToAppTargetBundle(context, mDataModel))
|
||||
.build()));
|
||||
}
|
||||
|
||||
private void registerPredictor(PredictorState state, AppPredictor predictor) {
|
||||
state.setTargets(Collections.emptyList());
|
||||
state.predictor = predictor;
|
||||
@@ -416,7 +437,8 @@ public class QuickstepModelDelegate extends ModelDelegate {
|
||||
mWidgetsRecommendationState.predictor.requestPredictionUpdate();
|
||||
}
|
||||
|
||||
private void onAppTargetEvent(AppTargetEvent event, int client) {
|
||||
@VisibleForTesting
|
||||
void onAppTargetEvent(AppTargetEvent event, int client) {
|
||||
PredictorState state;
|
||||
switch (client) {
|
||||
case CONTAINER_PREDICTION:
|
||||
@@ -434,6 +456,13 @@ public class QuickstepModelDelegate extends ModelDelegate {
|
||||
state.predictor.notifyAppTargetEvent(event);
|
||||
Log.d(TAG, "notifyAppTargetEvent action=" + event.getAction()
|
||||
+ " launchLocation=" + event.getLaunchLocation());
|
||||
if (state == mHotseatState
|
||||
&& (event.getAction() == AppTargetEvent.ACTION_PIN
|
||||
|| event.getAction() == AppTargetEvent.ACTION_UNPIN)) {
|
||||
// Recreate hot seat predictor when we need to query for hot seat due to pin or
|
||||
// unpin app icons.
|
||||
recreateHotseatPredictor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user