Do not reload launcher when changing active display

> Updating IDP to use fixed bitmap sizes, so that the cache
  stays valid
> Caching last known windowMetrices for non-active displays and
  using estimation only when the cache is not available
> Only reloading model if IDP change could have affected the model
> Remove unnecessary listeners from IDP which are already controlled by
  model lifecycle

Bug: 191657065
Test: Manual
Change-Id: Ia8e6dfafd0977e62aa3fcf367ad79f7a49b2df51
This commit is contained in:
Sunny Goyal
2021-08-24 16:23:29 -07:00
parent ee3814de1a
commit 6e6f79933e
11 changed files with 237 additions and 206 deletions

View File

@@ -44,7 +44,6 @@ import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.InvariantDeviceProfile.OnIDPChangeListener;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.logging.InstanceId;
import com.android.launcher3.logging.InstanceIdSequence;
@@ -68,7 +67,7 @@ import java.util.stream.IntStream;
/**
* Model delegate which loads prediction items
*/
public class QuickstepModelDelegate extends ModelDelegate implements OnIDPChangeListener {
public class QuickstepModelDelegate extends ModelDelegate {
public static final String LAST_PREDICTION_ENABLED_STATE = "last_prediction_enabled_state";
private static final String LAST_SNAPSHOT_TIME_MILLIS = "LAST_SNAPSHOT_TIME_MILLIS";
@@ -93,7 +92,6 @@ public class QuickstepModelDelegate extends ModelDelegate implements OnIDPChange
mAppEventProducer = new AppEventProducer(context, this::onAppTargetEvent);
mIDP = InvariantDeviceProfile.INSTANCE.get(context);
mIDP.addOnChangeListener(this);
StatsLogCompatManager.LOGS_CONSUMER.add(mAppEventProducer);
}
@@ -179,7 +177,6 @@ public class QuickstepModelDelegate extends ModelDelegate implements OnIDPChange
StatsLogCompatManager.LOGS_CONSUMER.remove(mAppEventProducer);
destroyPredictors();
mIDP.removeOnChangeListener(this);
}
private void destroyPredictors() {
@@ -250,12 +247,6 @@ public class QuickstepModelDelegate extends ModelDelegate implements OnIDPChange
mWidgetsRecommendationState.predictor.requestPredictionUpdate();
}
@Override
public void onIdpChanged(InvariantDeviceProfile profile) {
// Reinitialize everything
Executors.MODEL_EXECUTOR.execute(this::recreatePredictors);
}
private void onAppTargetEvent(AppTargetEvent event, int client) {
PredictorState state = client == CONTAINER_PREDICTION ? mAllAppsState : mHotseatState;
if (state.predictor != null) {