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

Commit 2bb6108f authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "Do not destroy CustomTile when in QSCustomizer" into qt-qpr1-dev am: 7891cda8

Change-Id: I39f4c9df7a49fe442f390308406c97a4c8abec0b
parents 7e22de9e 7891cda8
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -103,7 +103,9 @@ public class TileQueryHelper {


        final ArrayList<QSTile> tilesToAdd = new ArrayList<>();
        final ArrayList<QSTile> tilesToAdd = new ArrayList<>();
        for (String spec : possibleTiles) {
        for (String spec : possibleTiles) {
            // Only add current and stock tiles that can be created from QSFactoryImpl
            // Only add current and stock tiles that can be created from QSFactoryImpl.
            // Do not include CustomTile. Those will be created by `addPackageTiles`.
            if (spec.startsWith(CustomTile.PREFIX)) continue;
            final QSTile tile = host.createTile(spec);
            final QSTile tile = host.createTile(spec);
            if (tile == null) {
            if (tile == null) {
                continue;
                continue;
+15 −0
Original line number Original line Diff line number Diff line
@@ -27,6 +27,7 @@ import static org.mockito.Mockito.any;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.when;
@@ -79,12 +80,14 @@ public class TileQueryHelperTest extends SysuiTestCase {
    private static final Set<String> FACTORY_TILES = new ArraySet<>();
    private static final Set<String> FACTORY_TILES = new ArraySet<>();
    private static final String TEST_PKG = "test_pkg";
    private static final String TEST_PKG = "test_pkg";
    private static final String TEST_CLS = "test_cls";
    private static final String TEST_CLS = "test_cls";
    private static final String CUSTOM_TILE = "custom(" + TEST_PKG + "/" + TEST_CLS + ")";


    static {
    static {
        FACTORY_TILES.addAll(Arrays.asList(
        FACTORY_TILES.addAll(Arrays.asList(
                new String[]{"wifi", "bt", "cell", "dnd", "inversion", "airplane", "work",
                new String[]{"wifi", "bt", "cell", "dnd", "inversion", "airplane", "work",
                        "rotation", "flashlight", "location", "cast", "hotspot", "user", "battery",
                        "rotation", "flashlight", "location", "cast", "hotspot", "user", "battery",
                        "saver", "night", "nfc"}));
                        "saver", "night", "nfc"}));
        FACTORY_TILES.add(CUSTOM_TILE);
    }
    }


    @Mock
    @Mock
@@ -227,6 +230,18 @@ public class TileQueryHelperTest extends SysuiTestCase {
        assertFalse(specs.contains("other"));
        assertFalse(specs.contains("other"));
    }
    }


    @Test
    public void testCustomTileNotCreated() {
        Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.QS_TILES,
                CUSTOM_TILE);
        mTileQueryHelper.queryTiles(mQSTileHost);

        mBGLooper.processAllMessages();
        waitForIdleSync(Dependency.get(Dependency.MAIN_HANDLER));
      
        verify(mQSTileHost, never()).createTile(CUSTOM_TILE);
    }

    @Test
    @Test
    public void testThirdPartyTilesInactive() {
    public void testThirdPartyTilesInactive() {
        ResolveInfo resolveInfo = new ResolveInfo();
        ResolveInfo resolveInfo = new ResolveInfo();