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

Commit 9d7bffe3 authored by Stefan Andonian's avatar Stefan Andonian
Browse files

Fix NPE in LauncherPreviewRenderer.

The LauncherBinder is null in LauncherPreviewRenderer, which was
causing an NPE in LoaderTask.

Bug: 279347305
Test: Used logs to verify that the LauncherPreviewRenderer was actually
loading using the LoaderTask. Most of the time, it does not, so that is
why I didn't catch this before pushing it.

Change-Id: Ic5b45abfdeb73a4bbe1f521ae4d627b6cfcfec54
parent 15bc0d38
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -51,7 +51,9 @@ import com.android.launcher3.Utilities;
import com.android.launcher3.Workspace;
import com.android.launcher3.graphics.LauncherPreviewRenderer.PreviewContext;
import com.android.launcher3.model.BgDataModel;
import com.android.launcher3.model.BgDataModel.Callbacks;
import com.android.launcher3.model.GridSizeMigrationUtil;
import com.android.launcher3.model.LauncherBinder;
import com.android.launcher3.model.LoaderTask;
import com.android.launcher3.model.ModelDbController;
import com.android.launcher3.provider.LauncherDbUtils;
@@ -226,12 +228,14 @@ public class PreviewSurfaceRenderer {
            LauncherAppState.getInstance(previewContext)
                    .getModel().getModelDbController().clearEmptyDbFlag();

            BgDataModel bgModel = new BgDataModel();
            new LoaderTask(
                    LauncherAppState.getInstance(previewContext),
                    /* bgAllAppsList= */ null,
                    new BgDataModel(),
                    bgModel,
                    LauncherAppState.getInstance(previewContext).getModel().getModelDelegate(),
                    /* results= */ null) {
                    new LauncherBinder(LauncherAppState.getInstance(previewContext), bgModel,
                            /* bgAllAppsList= */ null, new Callbacks[0])) {

                @Override
                public void run() {
+6 −3
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ import android.util.ArrayMap;
import android.util.Log;
import android.util.LongSparseArray;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.android.launcher3.DeviceProfile;
@@ -118,6 +119,7 @@ public class LoaderTask implements Runnable {

    private static final boolean DEBUG = true;

    @NonNull
    protected final LauncherAppState mApp;
    private final AllAppsList mBgAllAppsList;
    protected final BgDataModel mBgDataModel;
@@ -125,6 +127,7 @@ public class LoaderTask implements Runnable {

    private FirstScreenBroadcast mFirstScreenBroadcast;

    @NonNull
    private final LauncherBinder mLauncherBinder;

    private final LauncherApps mLauncherApps;
@@ -145,11 +148,11 @@ public class LoaderTask implements Runnable {
    private boolean mItemsDeleted = false;
    private String mDbName;

    public LoaderTask(LauncherAppState app, AllAppsList bgAllAppsList, BgDataModel dataModel,
            ModelDelegate modelDelegate, LauncherBinder launcherBinder) {
    public LoaderTask(@NonNull LauncherAppState app, AllAppsList bgAllAppsList, BgDataModel bgModel,
            ModelDelegate modelDelegate, @NonNull LauncherBinder launcherBinder) {
        mApp = app;
        mBgAllAppsList = bgAllAppsList;
        mBgDataModel = dataModel;
        mBgDataModel = bgModel;
        mModelDelegate = modelDelegate;
        mLauncherBinder = launcherBinder;