Merge changes from topic "presubmit-am-9245c992289e4c93a8c889e00e4e103a" into tm-mainline-prod

* changes:
  [automerge] Fix crash when loading string cache 2p: 9b38947b32
  Fix crash when loading string cache
This commit is contained in:
TreeHugger Robot
2022-02-22 17:29:08 +00:00
committed by Android (Google) Code Review
2 changed files with 16 additions and 8 deletions
@@ -47,7 +47,6 @@ import com.android.launcher3.graphics.LauncherPreviewRenderer.PreviewContext;
import com.android.launcher3.model.BgDataModel; import com.android.launcher3.model.BgDataModel;
import com.android.launcher3.model.GridSizeMigrationTaskV2; import com.android.launcher3.model.GridSizeMigrationTaskV2;
import com.android.launcher3.model.LoaderTask; import com.android.launcher3.model.LoaderTask;
import com.android.launcher3.model.ModelDelegate;
import com.android.launcher3.util.ComponentKey; import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.RunnableList; import com.android.launcher3.util.RunnableList;
import com.android.launcher3.util.Themes; import com.android.launcher3.util.Themes;
@@ -156,9 +155,10 @@ public class PreviewSurfaceRenderer {
PreviewContext previewContext = new PreviewContext(inflationContext, mIdp); PreviewContext previewContext = new PreviewContext(inflationContext, mIdp);
new LoaderTask( new LoaderTask(
LauncherAppState.getInstance(previewContext), LauncherAppState.getInstance(previewContext),
null, /* bgAllAppsList= */ null,
new BgDataModel(), new BgDataModel(),
new ModelDelegate(), null) { LauncherAppState.getInstance(previewContext).getModel().getModelDelegate(),
/* results= */ null) {
@Override @Override
public void run() { public void run() {
@@ -44,11 +44,7 @@ public class ModelDelegate implements ResourceBasedOverride {
boolean isPrimaryInstance) { boolean isPrimaryInstance) {
ModelDelegate delegate = Overrides.getObject( ModelDelegate delegate = Overrides.getObject(
ModelDelegate.class, context, R.string.model_delegate_class); ModelDelegate.class, context, R.string.model_delegate_class);
delegate.mApp = app; delegate.init(context, app, appsList, dataModel, isPrimaryInstance);
delegate.mAppsList = appsList;
delegate.mDataModel = dataModel;
delegate.mIsPrimaryInstance = isPrimaryInstance;
delegate.mContext = context;
return delegate; return delegate;
} }
@@ -60,6 +56,18 @@ public class ModelDelegate implements ResourceBasedOverride {
public ModelDelegate() { } public ModelDelegate() { }
/**
* Initializes the object with the given params.
*/
private void init(Context context, LauncherAppState app, AllAppsList appsList,
BgDataModel dataModel, boolean isPrimaryInstance) {
this.mApp = app;
this.mAppsList = appsList;
this.mDataModel = dataModel;
this.mIsPrimaryInstance = isPrimaryInstance;
this.mContext = context;
}
/** /**
* Called periodically to validate and update any data * Called periodically to validate and update any data
*/ */