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

Commit ee6f1132 authored by yinxu's avatar yinxu
Browse files

Make sure the correct QS tiles are used for Provider Model

Bug: 182430245
Test: Manual tests
Change-Id: Ida366ef42ed81aebfa998dc03ca09b44e82695d2
parent 934f10e6
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -99,7 +99,7 @@

    <!-- The default tiles to display in QuickSettings -->
    <string name="quick_settings_tiles_default" translatable="false">
        wifi,bt,dnd,flashlight,rotation,battery,cell,airplane,cast,screenrecord
        internet,wifi,bt,dnd,flashlight,rotation,battery,cell,airplane,cast,screenrecord
    </string>

    <!-- The minimum number of tiles to display in QuickSettings -->
@@ -107,7 +107,7 @@

    <!-- Tiles native to System UI. Order should match "quick_settings_tiles_default" -->
    <string name="quick_settings_tiles_stock" translatable="false">
        wifi,cell,battery,dnd,flashlight,rotation,bt,airplane,location,hotspot,inversion,saver,dark,work,cast,night,screenrecord,reverse,reduce_brightness,cameratoggle,mictoggle,controls,alarm,wallet
        internet,wifi,cell,battery,dnd,flashlight,rotation,bt,airplane,location,hotspot,inversion,saver,dark,work,cast,night,screenrecord,reverse,reduce_brightness,cameratoggle,mictoggle,controls,alarm,wallet
    </string>

    <!-- The tiles to display in QuickSettings -->
+18 −11
Original line number Diff line number Diff line
@@ -474,22 +474,21 @@ public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory>, D
        if (tiles.contains("internet") || tiles.contains("wifi") || tiles.contains("cell")) {
            if (FeatureFlagUtils.isEnabled(context, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL)) {
                if (!tiles.contains("internet")) {
                    tiles.add("internet");
                }
                    if (tiles.contains("wifi")) {
                    tiles.remove("wifi");
                        // Replace the WiFi with Internet, and remove the Cell
                        tiles.set(tiles.indexOf("wifi"), "internet");
                        tiles.remove("cell");
                    } else if (tiles.contains("cell")) {
                        // Replace the Cell with Internet
                        tiles.set(tiles.indexOf("cell"), "internet");
                    }
                if (tiles.contains("cell")) {
                } else {
                    tiles.remove("wifi");
                    tiles.remove("cell");
                }
            } else {
                if (tiles.contains("internet")) {
                    tiles.remove("internet");
                }
                if (!tiles.contains("wifi")) {
                    tiles.add("wifi");
                }
                if (!tiles.contains("cell")) {
                    tiles.set(tiles.indexOf("internet"), "wifi");
                    tiles.add("cell");
                }
            }
@@ -513,6 +512,14 @@ public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory>, D
                && GarbageMonitor.ADD_MEMORY_TILE_TO_DEFAULT_ON_DEBUGGABLE_BUILDS) {
            tiles.add(GarbageMonitor.MemoryTile.TILE_SPEC);
        }
        // TODO(b/174753536): Change the config file directly.
        // Filter out unused tiles from the default QS config.
        if (FeatureFlagUtils.isEnabled(context, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL)) {
            tiles.remove("cell");
            tiles.remove("wifi");
        } else {
            tiles.remove("internet");
        }
        return tiles;
    }

+6 −27
Original line number Diff line number Diff line
@@ -115,34 +115,13 @@ public class TileQueryHelper {

        final ArrayList<QSTile> tilesToAdd = new ArrayList<>();
        // TODO(b/174753536): Move it into the config file.
        // Only do the below hacking when at least one of the below tiles exist
        //   --InternetTile
        //   --WiFiTile
        //   --CellularTIle
        if (possibleTiles.contains("internet") || possibleTiles.contains("wifi")
                || possibleTiles.contains("cell")) {
        if (FeatureFlagUtils.isEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL)) {
                if (!possibleTiles.contains("internet")) {
                    possibleTiles.add("internet");
                }
                if (possibleTiles.contains("wifi")) {
                    possibleTiles.remove("wifi");
                }
                if (possibleTiles.contains("cell")) {
            possibleTiles.remove("cell");
                }
            possibleTiles.remove("wifi");
        } else {
                if (possibleTiles.contains("internet")) {
            possibleTiles.remove("internet");
        }
                if (!possibleTiles.contains("wifi")) {
                    possibleTiles.add("wifi");
                }
                if (!possibleTiles.contains("cell")) {
                    possibleTiles.add("cell");
                }
            }
        }

        for (String spec : possibleTiles) {
            // Only add current and stock tiles that can be created from QSFactoryImpl.
            // Do not include CustomTile. Those will be created by `addPackageTiles`.