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

Commit b0adac23 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Removing access to LauncherModel.getCallbacks

Bug: 137568159
Change-Id: Ic074dec6a8981a4b9aabf028cf3b878b532abb11
parent a0db584e
Loading
Loading
Loading
Loading
+3 −4
Original line number Original line Diff line number Diff line
@@ -69,7 +69,6 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
    public static final int FLAG_ACTIVITY_PAUSED = 1;
    public static final int FLAG_ACTIVITY_PAUSED = 1;
    public static final int FLAG_LOADER_RUNNING = 2;
    public static final int FLAG_LOADER_RUNNING = 2;
    public static final int FLAG_DRAG_AND_DROP = 4;
    public static final int FLAG_DRAG_AND_DROP = 4;
    public static final int FLAG_BULK_ADD = 4;


    // Determines whether to defer installing shortcuts immediately until
    // Determines whether to defer installing shortcuts immediately until
    // processAllPendingInstalls() is called.
    // processAllPendingInstalls() is called.
@@ -110,8 +109,7 @@ public class InstallShortcutReceiver extends BroadcastReceiver {


    @WorkerThread
    @WorkerThread
    private static void flushQueueInBackground(Context context) {
    private static void flushQueueInBackground(Context context) {
        LauncherModel model = LauncherAppState.getInstance(context).getModel();
        if (Launcher.ACTIVITY_TRACKER.getCreatedActivity() == null) {
        if (model.getCallback() == null) {
            // Launcher not loaded
            // Launcher not loaded
            return;
            return;
        }
        }
@@ -146,7 +144,8 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
        }
        }
        prefs.edit().remove(APPS_PENDING_INSTALL).apply();
        prefs.edit().remove(APPS_PENDING_INSTALL).apply();
        if (!installQueue.isEmpty()) {
        if (!installQueue.isEmpty()) {
            model.addAndBindAddedWorkspaceItems(installQueue);
            LauncherAppState.getInstance(context).getModel()
                    .addAndBindAddedWorkspaceItems(installQueue);
        }
        }
    }
    }


+2 −3
Original line number Original line Diff line number Diff line
@@ -29,7 +29,6 @@ import com.android.launcher3.DeviceProfile;
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherModel;
import com.android.launcher3.LauncherState;
import com.android.launcher3.LauncherState;
import com.android.launcher3.R;
import com.android.launcher3.R;
import com.android.launcher3.allapps.AllAppsStore;
import com.android.launcher3.allapps.AllAppsStore;
@@ -170,7 +169,7 @@ public class TestInformationHandler implements ResourceBasedOverride {
    }
    }


    protected boolean isLauncherInitialized() {
    protected boolean isLauncherInitialized() {
        final LauncherModel model = LauncherAppState.getInstance(mContext).getModel();
        return Launcher.ACTIVITY_TRACKER.getCreatedActivity() == null
        return model.getCallback() == null || model.isModelLoaded();
                || LauncherAppState.getInstance(mContext).getModel().isModelLoaded();
    }
    }
}
}
+3 −11
Original line number Original line Diff line number Diff line
@@ -48,7 +48,6 @@ import androidx.test.uiautomator.Until;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.Launcher;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherModel;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.LauncherState;
import com.android.launcher3.LauncherState;
import com.android.launcher3.LauncherStateManager;
import com.android.launcher3.LauncherStateManager;
@@ -183,7 +182,7 @@ public abstract class AbstractLauncherUiTest {
    public void verifyLauncherState() {
    public void verifyLauncherState() {
        try {
        try {
            // Limits UI tests affecting tests running after them.
            // Limits UI tests affecting tests running after them.
            waitForModelLoaded();
            mLauncher.waitForLauncherInitialized();
        } catch (Throwable t) {
        } catch (Throwable t) {
            Log.e(TAG,
            Log.e(TAG,
                    "Couldn't deinit after a test, exiting tests, see logs for failures that "
                    "Couldn't deinit after a test, exiting tests, see logs for failures that "
@@ -222,14 +221,7 @@ public abstract class AbstractLauncherUiTest {
        } catch (Throwable t) {
        } catch (Throwable t) {
            throw new IllegalArgumentException(t);
            throw new IllegalArgumentException(t);
        }
        }
        waitForModelLoaded();
        mLauncher.waitForLauncherInitialized();
    }

    protected void waitForModelLoaded() {
        waitForLauncherCondition("Launcher model didn't load", launcher -> {
            final LauncherModel model = LauncherAppState.getInstance(mTargetContext).getModel();
            return model.getCallback() == null || model.isModelLoaded();
        });
    }
    }


    /**
    /**
@@ -258,7 +250,7 @@ public abstract class AbstractLauncherUiTest {


        // Launch the home activity
        // Launch the home activity
        mDevice.pressHome();
        mDevice.pressHome();
        waitForModelLoaded();
        mLauncher.waitForLauncherInitialized();
    }
    }


    /**
    /**
+1 −1
Original line number Original line Diff line number Diff line
@@ -495,7 +495,7 @@ public final class LauncherInstrumentation {
        }
        }
    }
    }


    private void waitForLauncherInitialized() {
    public void waitForLauncherInitialized() {
        for (int i = 0; i < 100; ++i) {
        for (int i = 0; i < 100; ++i) {
            if (getTestInfo(
            if (getTestInfo(
                    TestProtocol.REQUEST_IS_LAUNCHER_INITIALIZED).
                    TestProtocol.REQUEST_IS_LAUNCHER_INITIALIZED).