Merge "Make InternetTile default in SysUI." into sc-dev am: 3904d7eef7
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15443715 Change-Id: Id1c3f20d6e71c821d191e0b8c1deb2838b6a959c
This commit is contained in:
@@ -3585,7 +3585,7 @@ public class SettingsProvider extends ContentProvider {
|
||||
}
|
||||
|
||||
private final class UpgradeController {
|
||||
private static final int SETTINGS_VERSION = 203;
|
||||
private static final int SETTINGS_VERSION = 204;
|
||||
|
||||
private final int mUserId;
|
||||
|
||||
@@ -5189,6 +5189,44 @@ public class SettingsProvider extends ContentProvider {
|
||||
currentVersion = 203;
|
||||
}
|
||||
|
||||
if (currentVersion == 203) {
|
||||
// Version 204: Replace 'wifi' or 'cell' tiles with 'internet' if existed.
|
||||
final SettingsState secureSettings = getSecureSettingsLocked(userId);
|
||||
final Setting currentValue = secureSettings.getSettingLocked(Secure.QS_TILES);
|
||||
if (!currentValue.isNull()) {
|
||||
String tileList = currentValue.getValue();
|
||||
String[] tileSplit = tileList.split(",");
|
||||
final ArrayList<String> tiles = new ArrayList<String>();
|
||||
boolean hasInternetTile = false;
|
||||
for (int i = 0; i < tileSplit.length; i++) {
|
||||
String tile = tileSplit[i].trim();
|
||||
if (tile.isEmpty()) continue;
|
||||
tiles.add(tile);
|
||||
if (tile.equals("internet")) hasInternetTile = true;
|
||||
}
|
||||
if (!hasInternetTile) {
|
||||
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");
|
||||
tiles.remove("cell");
|
||||
}
|
||||
secureSettings.insertSettingOverrideableByRestoreLocked(
|
||||
Secure.QS_TILES,
|
||||
TextUtils.join(",", tiles),
|
||||
null /* tag */,
|
||||
true /* makeDefault */,
|
||||
SettingsState.SYSTEM_PACKAGE_NAME);
|
||||
}
|
||||
currentVersion = 204;
|
||||
}
|
||||
|
||||
// vXXX: Add new settings above this point.
|
||||
|
||||
if (currentVersion != newVersion) {
|
||||
|
||||
@@ -107,7 +107,7 @@
|
||||
|
||||
<!-- Tiles native to System UI. Order should match "quick_settings_tiles_default" -->
|
||||
<string name="quick_settings_tiles_stock" translatable="false">
|
||||
internet,wifi,cell,bt,flashlight,dnd,alarm,airplane,controls,wallet,rotation,battery,cast,screenrecord,mictoggle,cameratoggle,location,hotspot,inversion,saver,dark,work,night,reverse,reduce_brightness
|
||||
internet,bt,flashlight,dnd,alarm,airplane,controls,wallet,rotation,battery,cast,screenrecord,mictoggle,cameratoggle,location,hotspot,inversion,saver,dark,work,night,reverse,reduce_brightness
|
||||
</string>
|
||||
|
||||
<!-- The tiles to display in QuickSettings -->
|
||||
|
||||
@@ -51,7 +51,6 @@ import com.android.systemui.qs.external.TileServices;
|
||||
import com.android.systemui.qs.logging.QSLogger;
|
||||
import com.android.systemui.settings.UserTracker;
|
||||
import com.android.systemui.shared.plugins.PluginManager;
|
||||
import com.android.systemui.statusbar.FeatureFlags;
|
||||
import com.android.systemui.statusbar.phone.AutoTileManager;
|
||||
import com.android.systemui.statusbar.phone.StatusBar;
|
||||
import com.android.systemui.statusbar.phone.StatusBarIconController;
|
||||
@@ -512,33 +511,6 @@ public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory>, D
|
||||
}
|
||||
}
|
||||
}
|
||||
// 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 (tiles.contains("internet") || tiles.contains("wifi") || tiles.contains("cell")) {
|
||||
if (FeatureFlags.isProviderModelSettingEnabled(context)) {
|
||||
if (!tiles.contains("internet")) {
|
||||
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");
|
||||
tiles.remove("cell");
|
||||
}
|
||||
} else {
|
||||
if (tiles.contains("internet")) {
|
||||
tiles.set(tiles.indexOf("internet"), "wifi");
|
||||
tiles.add("cell");
|
||||
}
|
||||
}
|
||||
}
|
||||
return tiles;
|
||||
}
|
||||
|
||||
@@ -558,14 +530,6 @@ 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 (FeatureFlags.isProviderModelSettingEnabled(context)) {
|
||||
tiles.remove("cell");
|
||||
tiles.remove("wifi");
|
||||
} else {
|
||||
tiles.remove("internet");
|
||||
}
|
||||
return tiles;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,6 @@ import com.android.systemui.qs.dagger.QSScope;
|
||||
import com.android.systemui.qs.external.CustomTile;
|
||||
import com.android.systemui.qs.tileimpl.QSTileImpl.DrawableIcon;
|
||||
import com.android.systemui.settings.UserTracker;
|
||||
import com.android.systemui.statusbar.FeatureFlags;
|
||||
import com.android.systemui.util.leak.GarbageMonitor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -63,7 +62,6 @@ public class TileQueryHelper {
|
||||
private final Executor mBgExecutor;
|
||||
private final Context mContext;
|
||||
private final UserTracker mUserTracker;
|
||||
private final FeatureFlags mFeatureFlags;
|
||||
private TileStateListener mListener;
|
||||
|
||||
private boolean mFinished;
|
||||
@@ -73,14 +71,12 @@ public class TileQueryHelper {
|
||||
Context context,
|
||||
UserTracker userTracker,
|
||||
@Main Executor mainExecutor,
|
||||
@Background Executor bgExecutor,
|
||||
FeatureFlags featureFlags
|
||||
@Background Executor bgExecutor
|
||||
) {
|
||||
mContext = context;
|
||||
mMainExecutor = mainExecutor;
|
||||
mBgExecutor = bgExecutor;
|
||||
mUserTracker = userTracker;
|
||||
mFeatureFlags = featureFlags;
|
||||
}
|
||||
|
||||
public void setListener(TileStateListener listener) {
|
||||
@@ -121,19 +117,11 @@ public class TileQueryHelper {
|
||||
}
|
||||
|
||||
final ArrayList<QSTile> tilesToAdd = new ArrayList<>();
|
||||
// TODO(b/174753536): Move it into the config file.
|
||||
if (mFeatureFlags.isProviderModelSettingEnabled()) {
|
||||
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`.
|
||||
if (spec.startsWith(CustomTile.PREFIX)) continue;
|
||||
// TODO(b/174753536): Move it into the config file.
|
||||
final QSTile tile = host.createTile(spec);
|
||||
if (tile == null) {
|
||||
continue;
|
||||
|
||||
@@ -44,7 +44,6 @@ import android.view.View;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.dx.mockito.inline.extended.ExtendedMockito;
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.internal.logging.UiEventLogger;
|
||||
import com.android.internal.util.CollectionUtils;
|
||||
@@ -64,22 +63,18 @@ import com.android.systemui.qs.logging.QSLogger;
|
||||
import com.android.systemui.qs.tileimpl.QSTileImpl;
|
||||
import com.android.systemui.settings.UserTracker;
|
||||
import com.android.systemui.shared.plugins.PluginManager;
|
||||
import com.android.systemui.statusbar.FeatureFlags;
|
||||
import com.android.systemui.statusbar.phone.AutoTileManager;
|
||||
import com.android.systemui.statusbar.phone.StatusBar;
|
||||
import com.android.systemui.statusbar.phone.StatusBarIconController;
|
||||
import com.android.systemui.tuner.TunerService;
|
||||
import com.android.systemui.util.settings.SecureSettings;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.MockitoSession;
|
||||
import org.mockito.quality.Strictness;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.PrintWriter;
|
||||
@@ -133,16 +128,9 @@ public class QSTileHostTest extends SysuiTestCase {
|
||||
private Handler mHandler;
|
||||
private TestableLooper mLooper;
|
||||
private QSTileHost mQSTileHost;
|
||||
MockitoSession mMockingSession = null;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
// TODO(b/174753536): Remove the mMockingSession when
|
||||
// FeatureFlagUtils.SETTINGS_PROVIDER_MODEL is removed.
|
||||
mMockingSession = ExtendedMockito.mockitoSession().strictness(Strictness.LENIENT)
|
||||
.mockStatic(FeatureFlags.class).startMocking();
|
||||
ExtendedMockito.doReturn(false)
|
||||
.when(() -> FeatureFlags.isProviderModelSettingEnabled(mContext));
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mLooper = TestableLooper.get(this);
|
||||
mHandler = new Handler(mLooper.getLooper());
|
||||
@@ -156,13 +144,6 @@ public class QSTileHostTest extends SysuiTestCase {
|
||||
.thenReturn("");
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
if (mMockingSession != null) {
|
||||
mMockingSession.finishMocking();
|
||||
}
|
||||
}
|
||||
|
||||
private void setUpTileFactory() {
|
||||
when(mMockState.toString()).thenReturn(MOCK_STATE_STRING);
|
||||
// Only create this kind of tiles
|
||||
|
||||
@@ -45,13 +45,11 @@ import android.testing.AndroidTestingRunner;
|
||||
import android.testing.TestableLooper;
|
||||
import android.text.TextUtils;
|
||||
import android.util.ArraySet;
|
||||
import android.util.FeatureFlagUtils;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.dx.mockito.inline.extended.ExtendedMockito;
|
||||
import com.android.internal.logging.InstanceId;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
@@ -60,11 +58,9 @@ import com.android.systemui.plugins.qs.QSIconView;
|
||||
import com.android.systemui.plugins.qs.QSTile;
|
||||
import com.android.systemui.qs.QSTileHost;
|
||||
import com.android.systemui.settings.UserTracker;
|
||||
import com.android.systemui.statusbar.FeatureFlags;
|
||||
import com.android.systemui.util.concurrency.FakeExecutor;
|
||||
import com.android.systemui.util.time.FakeSystemClock;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -74,8 +70,6 @@ import org.mockito.Captor;
|
||||
import org.mockito.InOrder;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.MockitoSession;
|
||||
import org.mockito.quality.Strictness;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -114,7 +108,6 @@ public class TileQueryHelperTest extends SysuiTestCase {
|
||||
private PackageManager mPackageManager;
|
||||
@Mock
|
||||
private UserTracker mUserTracker;
|
||||
@Mock private FeatureFlags mFeatureFlags;
|
||||
@Captor
|
||||
private ArgumentCaptor<List<TileQueryHelper.TileInfo>> mCaptor;
|
||||
|
||||
@@ -122,18 +115,10 @@ public class TileQueryHelperTest extends SysuiTestCase {
|
||||
private TileQueryHelper mTileQueryHelper;
|
||||
private FakeExecutor mMainExecutor;
|
||||
private FakeExecutor mBgExecutor;
|
||||
MockitoSession mMockingSession = null;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
// TODO(b/174753536): Remove the mMockingSession when
|
||||
// FeatureFlagUtils.SETTINGS_PROVIDER_MODEL is removed.
|
||||
mMockingSession = ExtendedMockito.mockitoSession().strictness(Strictness.LENIENT)
|
||||
.mockStatic(FeatureFlagUtils.class).startMocking();
|
||||
ExtendedMockito.doReturn(false).when(() -> FeatureFlagUtils.isEnabled(mContext,
|
||||
FeatureFlagUtils.SETTINGS_PROVIDER_MODEL));
|
||||
|
||||
mContext.setMockPackageManager(mPackageManager);
|
||||
|
||||
mState = new QSTile.State();
|
||||
@@ -153,17 +138,10 @@ public class TileQueryHelperTest extends SysuiTestCase {
|
||||
mMainExecutor = new FakeExecutor(clock);
|
||||
mBgExecutor = new FakeExecutor(clock);
|
||||
mTileQueryHelper = new TileQueryHelper(
|
||||
mContext, mUserTracker, mMainExecutor, mBgExecutor, mFeatureFlags);
|
||||
mContext, mUserTracker, mMainExecutor, mBgExecutor);
|
||||
mTileQueryHelper.setListener(mListener);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
if (mMockingSession != null) {
|
||||
mMockingSession.finishMocking();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsFinished_falseBeforeQuerying() {
|
||||
assertFalse(mTileQueryHelper.isFinished());
|
||||
|
||||
Reference in New Issue
Block a user