Merge "Make sure the correct QS tiles are used for Provider Model" into sc-dev

This commit is contained in:
Ying Xu
2021-03-25 03:49:15 +00:00
committed by Android (Google) Code Review
3 changed files with 26 additions and 40 deletions

View File

@@ -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 -->

View File

@@ -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")) {
if (tiles.contains("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");
}
} else {
tiles.remove("wifi");
}
if (tiles.contains("cell")) {
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;
}

View File

@@ -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");
}
} else {
if (possibleTiles.contains("internet")) {
possibleTiles.remove("internet");
}
if (!possibleTiles.contains("wifi")) {
possibleTiles.add("wifi");
}
if (!possibleTiles.contains("cell")) {
possibleTiles.add("cell");
}
}
if (FeatureFlagUtils.isEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL)) {
possibleTiles.remove("cell");
possibleTiles.remove("wifi");
} else {
possibleTiles.remove("internet");
}
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`.