Merge "Only show storage category stats preferences for private volumes" into sc-dev
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 7755da4..7c2cc67 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -12816,6 +12816,9 @@
Summary indicating that a SIM has an active mobile data connection [CHAR LIMIT=50] -->
<string name="mobile_data_connection_active">Connected</string>
<!-- Provider Model:
+ Summary indicating that a active SIM and no network available [CHAR LIMIT=50] -->
+ <string name="mobile_data_no_connection">No connection</string>
+ <!-- Provider Model:
Summary indicating that a SIM has no mobile data connection [CHAR LIMIT=50] -->
<string name="mobile_data_off_summary">Internet won\u0027t auto\u2011connect</string>
<!-- Provider Model: Summary indicating that no other networks available [CHAR LIMIT=50] -->
diff --git a/src/com/android/settings/fuelgauge/BatterySettingsFeatureProvider.java b/src/com/android/settings/fuelgauge/BatterySettingsFeatureProvider.java
new file mode 100644
index 0000000..73b875b
--- /dev/null
+++ b/src/com/android/settings/fuelgauge/BatterySettingsFeatureProvider.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.fuelgauge;
+
+/**
+ * Feature provider for battery settings usage.
+ */
+public interface BatterySettingsFeatureProvider {
+
+ /**
+ * Get replacement activity for a given activity or fragment path.
+ */
+ String getReplacingActivityName(String activity);
+
+}
diff --git a/src/com/android/settings/fuelgauge/BatterySettingsFeatureProviderImpl.java b/src/com/android/settings/fuelgauge/BatterySettingsFeatureProviderImpl.java
new file mode 100644
index 0000000..e410695
--- /dev/null
+++ b/src/com/android/settings/fuelgauge/BatterySettingsFeatureProviderImpl.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.fuelgauge;
+
+/**
+ * Feature provider implementation for battery settings usage.
+ */
+public class BatterySettingsFeatureProviderImpl implements BatterySettingsFeatureProvider {
+
+ @Override
+ public String getReplacingActivityName(String activity) {
+ return null;
+ }
+}
diff --git a/src/com/android/settings/inputmethod/AvailableVirtualKeyboardFragment.java b/src/com/android/settings/inputmethod/AvailableVirtualKeyboardFragment.java
index 686558c..d41a378 100644
--- a/src/com/android/settings/inputmethod/AvailableVirtualKeyboardFragment.java
+++ b/src/com/android/settings/inputmethod/AvailableVirtualKeyboardFragment.java
@@ -91,11 +91,19 @@
List<String> permittedList = mDpm.getPermittedInputMethodsForCurrentUser();
final Context context = getPrefContext();
final List<InputMethodInfo> imis = mInputMethodSettingValues.getInputMethodList();
+ final List<InputMethodInfo> enabledImis = mImm.getEnabledInputMethodList();
final int numImis = (imis == null ? 0 : imis.size());
for (int i = 0; i < numImis; ++i) {
final InputMethodInfo imi = imis.get(i);
+ // TODO (b/182876800): Move this logic out of isAllowedByOrganization and
+ // into a new boolean.
+ // If an input method is enabled but not included in the permitted list, then set it as
+ // allowed by organization. Doing so will allow the user to disable the input method and
+ // remain complaint with the organization's policy. Once disabled, the input method
+ // cannot be re-enabled because it is not in the permitted list.
final boolean isAllowedByOrganization = permittedList == null
- || permittedList.contains(imi.getPackageName());
+ || permittedList.contains(imi.getPackageName())
+ || enabledImis.contains(imi);
final InputMethodPreference pref = new InputMethodPreference(
context, imi, true, isAllowedByOrganization, this);
pref.setIcon(imi.loadIcon(context.getPackageManager()));
diff --git a/src/com/android/settings/network/ProviderModelSliceHelper.java b/src/com/android/settings/network/ProviderModelSliceHelper.java
index 440d425..3a0ceeac 100644
--- a/src/com/android/settings/network/ProviderModelSliceHelper.java
+++ b/src/com/android/settings/network/ProviderModelSliceHelper.java
@@ -24,6 +24,7 @@
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
+import android.net.wifi.WifiManager;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
import android.telephony.SubscriptionInfo;
@@ -231,6 +232,7 @@
}
private String getMobileSummary(String networkTypeDescription) {
+ final WifiManager wifiManager = mContext.getSystemService(WifiManager.class);
String summary = networkTypeDescription;
if (isDataSimActive()) {
summary = mContext.getString(R.string.preference_summary_default_combination,
@@ -238,6 +240,8 @@
networkTypeDescription);
} else if (!isMobileDataEnabled()) {
summary = mContext.getString(R.string.mobile_data_off_summary);
+ } else if (!wifiManager.isWifiEnabled() && !isDataSimActive()) {
+ summary = mContext.getString(R.string.mobile_data_no_connection);
}
return summary;
}
diff --git a/src/com/android/settings/overlay/FeatureFactory.java b/src/com/android/settings/overlay/FeatureFactory.java
index 42d98e0..0e47556 100644
--- a/src/com/android/settings/overlay/FeatureFactory.java
+++ b/src/com/android/settings/overlay/FeatureFactory.java
@@ -32,6 +32,7 @@
import com.android.settings.dashboard.DashboardFeatureProvider;
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider;
+import com.android.settings.fuelgauge.BatterySettingsFeatureProvider;
import com.android.settings.fuelgauge.BatteryStatusFeatureProvider;
import com.android.settings.fuelgauge.PowerUsageFeatureProvider;
import com.android.settings.gestures.AssistGestureFeatureProvider;
@@ -112,6 +113,12 @@
public abstract BatteryStatusFeatureProvider getBatteryStatusFeatureProvider(
Context context);
+ /**
+ * Get implementation for Battery Settings provider.
+ */
+ public abstract BatterySettingsFeatureProvider getBatterySettingsFeatureProvider(
+ Context context);
+
public abstract DashboardFeatureProvider getDashboardFeatureProvider(Context context);
public abstract DockUpdaterFeatureProvider getDockUpdaterFeatureProvider();
diff --git a/src/com/android/settings/overlay/FeatureFactoryImpl.java b/src/com/android/settings/overlay/FeatureFactoryImpl.java
index 46b263a..dc08547 100644
--- a/src/com/android/settings/overlay/FeatureFactoryImpl.java
+++ b/src/com/android/settings/overlay/FeatureFactoryImpl.java
@@ -45,6 +45,8 @@
import com.android.settings.dashboard.suggestions.SuggestionFeatureProviderImpl;
import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider;
import com.android.settings.enterprise.EnterprisePrivacyFeatureProviderImpl;
+import com.android.settings.fuelgauge.BatterySettingsFeatureProvider;
+import com.android.settings.fuelgauge.BatterySettingsFeatureProviderImpl;
import com.android.settings.fuelgauge.BatteryStatusFeatureProvider;
import com.android.settings.fuelgauge.BatteryStatusFeatureProviderImpl;
import com.android.settings.fuelgauge.PowerUsageFeatureProvider;
@@ -86,6 +88,7 @@
private SuggestionFeatureProvider mSuggestionFeatureProvider;
private PowerUsageFeatureProvider mPowerUsageFeatureProvider;
private BatteryStatusFeatureProvider mBatteryStatusFeatureProvider;
+ private BatterySettingsFeatureProvider mBatterySettingsFeatureProvider;
private AssistGestureFeatureProvider mAssistGestureFeatureProvider;
private UserFeatureProvider mUserFeatureProvider;
private SlicesFeatureProvider mSlicesFeatureProvider;
@@ -130,6 +133,14 @@
}
@Override
+ public BatterySettingsFeatureProvider getBatterySettingsFeatureProvider(Context context) {
+ if (mBatterySettingsFeatureProvider == null) {
+ mBatterySettingsFeatureProvider = new BatterySettingsFeatureProviderImpl();
+ }
+ return mBatterySettingsFeatureProvider;
+ }
+
+ @Override
public DashboardFeatureProvider getDashboardFeatureProvider(Context context) {
if (mDashboardFeatureProvider == null) {
mDashboardFeatureProvider = new DashboardFeatureProviderImpl(
diff --git a/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java b/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java
index a48b3eb..7bd7813 100644
--- a/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java
+++ b/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java
@@ -30,6 +30,7 @@
import com.android.settings.dashboard.DashboardFeatureProvider;
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider;
+import com.android.settings.fuelgauge.BatterySettingsFeatureProvider;
import com.android.settings.fuelgauge.BatteryStatusFeatureProvider;
import com.android.settings.fuelgauge.PowerUsageFeatureProvider;
import com.android.settings.gestures.AssistGestureFeatureProvider;
@@ -58,6 +59,7 @@
public final SupportFeatureProvider supportFeatureProvider;
public final MetricsFeatureProvider metricsFeatureProvider;
public final BatteryStatusFeatureProvider batteryStatusFeatureProvider;
+ public final BatterySettingsFeatureProvider batterySettingsFeatureProvider;
public final PowerUsageFeatureProvider powerUsageFeatureProvider;
public final DashboardFeatureProvider dashboardFeatureProvider;
public final DockUpdaterFeatureProvider dockUpdaterFeatureProvider;
@@ -106,6 +108,7 @@
supportFeatureProvider = mock(SupportFeatureProvider.class);
metricsFeatureProvider = mock(MetricsFeatureProvider.class);
batteryStatusFeatureProvider = mock(BatteryStatusFeatureProvider.class);
+ batterySettingsFeatureProvider = mock(BatterySettingsFeatureProvider.class);
powerUsageFeatureProvider = mock(PowerUsageFeatureProvider.class);
dashboardFeatureProvider = mock(DashboardFeatureProvider.class);
dockUpdaterFeatureProvider = mock(DockUpdaterFeatureProvider.class);
@@ -150,6 +153,11 @@
}
@Override
+ public BatterySettingsFeatureProvider getBatterySettingsFeatureProvider(Context context) {
+ return batterySettingsFeatureProvider;
+ }
+
+ @Override
public PowerUsageFeatureProvider getPowerUsageFeatureProvider(Context context) {
return powerUsageFeatureProvider;
}
diff --git a/tests/unit/src/com/android/settings/network/ProviderModelSliceHelperTest.java b/tests/unit/src/com/android/settings/network/ProviderModelSliceHelperTest.java
index ac2e24d..9c5c88b 100644
--- a/tests/unit/src/com/android/settings/network/ProviderModelSliceHelperTest.java
+++ b/tests/unit/src/com/android/settings/network/ProviderModelSliceHelperTest.java
@@ -33,6 +33,7 @@
import android.net.Network;
import android.net.NetworkCapabilities;
import android.net.Uri;
+import android.net.wifi.WifiManager;
import android.os.PersistableBundle;
import android.telephony.CarrierConfigManager;
import android.telephony.ServiceState;
@@ -90,6 +91,8 @@
private SubscriptionInfo mDefaultDataSubscriptionInfo;
@Mock
private Drawable mDrawableWithSignalStrength;
+ @Mock
+ private WifiManager mWifiManager;
@Before
public void setUp() {
@@ -102,13 +105,23 @@
when(mContext.getSystemService(CarrierConfigManager.class)).thenReturn(
mCarrierConfigManager);
when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(mBundle);
+ mBundle.putBoolean(CarrierConfigManager.KEY_INFLATE_SIGNAL_STRENGTH_BOOL, false);
when(mContext.getSystemService(ConnectivityManager.class)).thenReturn(mConnectivityManager);
when(mConnectivityManager.getActiveNetwork()).thenReturn(mNetwork);
when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
when(mTelephonyManager.createForSubscriptionId(anyInt())).thenReturn(mTelephonyManager);
+ when(mTelephonyManager.getServiceState()).thenReturn(mServiceState);
+ when(mContext.getSystemService(WifiManager.class)).thenReturn(mWifiManager);
TestCustomSliceable testCustomSliceable = new TestCustomSliceable();
mProviderModelSliceHelper = new MockProviderModelSliceHelper(mContext, testCustomSliceable);
+
+ final int defaultDataSubId = SubscriptionManager.getDefaultDataSubscriptionId();
+ when(mDefaultDataSubscriptionInfo.getSubscriptionId()).thenReturn(defaultDataSubId);
+ when(mSubscriptionManager.getActiveSubscriptionInfo(defaultDataSubId)).thenReturn(
+ mDefaultDataSubscriptionInfo);
+ when(mSubscriptionManager.getAvailableSubscriptionInfoList()).thenReturn(
+ Arrays.asList(mDefaultDataSubscriptionInfo));
}
@Test
@@ -155,20 +168,9 @@
String expectDisplayName = "Name1";
CharSequence expectedSubtitle = Html.fromHtml("5G", Html.FROM_HTML_MODE_LEGACY);
String networkType = "5G";
-
- final int defaultDataSubId = SubscriptionManager.getDefaultDataSubscriptionId();
- when(mDefaultDataSubscriptionInfo.getSubscriptionId()).thenReturn(defaultDataSubId);
- when(mDefaultDataSubscriptionInfo.getDisplayName()).thenReturn(expectDisplayName);
- when(mSubscriptionManager.getActiveSubscriptionInfo(defaultDataSubId)).thenReturn(
- mDefaultDataSubscriptionInfo);
- when(mSubscriptionManager.getAvailableSubscriptionInfoList()).thenReturn(
- Arrays.asList(mDefaultDataSubscriptionInfo));
-
- when(mServiceState.getState()).thenReturn(ServiceState.STATE_IN_SERVICE);
- mBundle.putBoolean(CarrierConfigManager.KEY_INFLATE_SIGNAL_STRENGTH_BOOL, false);
+ mockConnections(true, ServiceState.STATE_IN_SERVICE, expectDisplayName,
+ mTelephonyManager.DATA_CONNECTED, true);
addNetworkTransportType(NetworkCapabilities.TRANSPORT_WIFI);
- when(mTelephonyManager.isDataEnabled()).thenReturn(true);
-
ListBuilder.RowBuilder testRowBuild = mProviderModelSliceHelper.createCarrierRow(
networkType);
@@ -178,7 +180,7 @@
}
@Test
- public void createCarrierRow_hasDdsAndActiveNetworkIsCellular_verifyTitleAndSummary() {
+ public void createCarrierRow_wifiOnhasDdsAndActiveNetworkIsCellular_verifyTitleAndSummary() {
String expectDisplayName = "Name1";
String networkType = "5G";
String connectedText = ResourcesUtils.getResourcesString(mContext,
@@ -186,16 +188,27 @@
CharSequence expectedSubtitle = Html.fromHtml(ResourcesUtils.getResourcesString(mContext,
"preference_summary_default_combination", connectedText, networkType),
Html.FROM_HTML_MODE_LEGACY);
+ mockConnections(true, ServiceState.STATE_IN_SERVICE, expectDisplayName,
+ mTelephonyManager.DATA_CONNECTED, true);
+ addNetworkTransportType(NetworkCapabilities.TRANSPORT_CELLULAR);
- final int defaultDataSubId = SubscriptionManager.getDefaultDataSubscriptionId();
- when(mDefaultDataSubscriptionInfo.getSubscriptionId()).thenReturn(defaultDataSubId);
- when(mDefaultDataSubscriptionInfo.getDisplayName()).thenReturn(expectDisplayName);
- when(mSubscriptionManager.getActiveSubscriptionInfo(defaultDataSubId)).thenReturn(
- mDefaultDataSubscriptionInfo);
- when(mSubscriptionManager.getAvailableSubscriptionInfoList()).thenReturn(
- Arrays.asList(mDefaultDataSubscriptionInfo));
- when(mServiceState.getState()).thenReturn(ServiceState.STATE_IN_SERVICE);
- mBundle.putBoolean(CarrierConfigManager.KEY_INFLATE_SIGNAL_STRENGTH_BOOL, false);
+ ListBuilder.RowBuilder testRowBuild = mProviderModelSliceHelper.createCarrierRow(
+ networkType);
+
+ assertThat(testRowBuild.getTitle()).isEqualTo(expectDisplayName);
+ assertThat(testRowBuild.getSubtitle()).isEqualTo(expectedSubtitle);
+ }
+
+ @Test
+ public void createCarrierRow_noNetworkAvailable_verifyTitleAndSummary() {
+ String expectDisplayName = "Name1";
+ CharSequence expectedSubtitle = Html.fromHtml(
+ ResourcesUtils.getResourcesString(mContext, "mobile_data_no_connection"),
+ Html.FROM_HTML_MODE_LEGACY);
+ String networkType = "";
+
+ mockConnections(true, ServiceState.STATE_OUT_OF_SERVICE, expectDisplayName,
+ mTelephonyManager.DATA_DISCONNECTED, false);
addNetworkTransportType(NetworkCapabilities.TRANSPORT_CELLULAR);
ListBuilder.RowBuilder testRowBuild = mProviderModelSliceHelper.createCarrierRow(
@@ -207,53 +220,40 @@
@Test
public void isNoCarrierData_mobileDataOnAndNoData_returnTrue() {
- when(mTelephonyManager.isDataEnabled()).thenReturn(true);
- when(mTelephonyManager.getDataState()).thenReturn(mTelephonyManager.DATA_DISCONNECTED);
- when(mTelephonyManager.getServiceState()).thenReturn(mServiceState);
- when(mServiceState.getState()).thenReturn(ServiceState.STATE_IN_SERVICE);
+ mockConnections(true, ServiceState.STATE_IN_SERVICE, "",
+ mTelephonyManager.DATA_DISCONNECTED, true);
assertThat(mProviderModelSliceHelper.isNoCarrierData()).isTrue();
}
@Test
public void isNoCarrierData_mobileDataOffAndOutOfService_returnTrue() {
- when(mTelephonyManager.isDataEnabled()).thenReturn(false);
- when(mTelephonyManager.getDataState()).thenReturn(mTelephonyManager.DATA_DISCONNECTED);
- when(mTelephonyManager.getServiceState()).thenReturn(mServiceState);
- when(mServiceState.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
+ mockConnections(false, ServiceState.STATE_OUT_OF_SERVICE, "",
+ mTelephonyManager.DATA_DISCONNECTED, true);
assertThat(mProviderModelSliceHelper.isNoCarrierData()).isTrue();
}
@Test
public void isNoCarrierData_mobileDataOnAndDataConnected_returnFalse() {
- when(mTelephonyManager.isDataEnabled()).thenReturn(true);
- when(mTelephonyManager.getDataState()).thenReturn(mTelephonyManager.DATA_CONNECTED);
- when(mTelephonyManager.getServiceState()).thenReturn(mServiceState);
- when(mServiceState.getState()).thenReturn(ServiceState.STATE_IN_SERVICE);
+ mockConnections(true, ServiceState.STATE_IN_SERVICE, "", mTelephonyManager.DATA_CONNECTED,
+ true);
assertThat(mProviderModelSliceHelper.isNoCarrierData()).isFalse();
}
@Test
public void isNoCarrierData_mobileDataOffAndVoiceIsInService_returnFalse() {
- when(mTelephonyManager.isDataEnabled()).thenReturn(false);
- when(mTelephonyManager.getDataState()).thenReturn(mTelephonyManager.DATA_DISCONNECTED);
- when(mTelephonyManager.getServiceState()).thenReturn(mServiceState);
- when(mServiceState.getState()).thenReturn(ServiceState.STATE_IN_SERVICE);
+ mockConnections(false, ServiceState.STATE_IN_SERVICE, "",
+ mTelephonyManager.DATA_DISCONNECTED, true);
assertThat(mProviderModelSliceHelper.isNoCarrierData()).isFalse();
}
@Test
public void getMobileDrawable_noCarrierData_getMobileDrawable() throws Throwable {
- when(mTelephonyManager.isDataEnabled()).thenReturn(false);
- when(mTelephonyManager.getDataState()).thenReturn(mTelephonyManager.DATA_DISCONNECTED);
- when(mTelephonyManager.getServiceState()).thenReturn(mServiceState);
- when(mServiceState.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
- int defaultDataSubId = SubscriptionManager.getDefaultDataSubscriptionId();
- when(mSubscriptionManager.getActiveSubscriptionInfo(defaultDataSubId)).thenReturn(
- mDefaultDataSubscriptionInfo);
+ mockConnections(false, ServiceState.STATE_OUT_OF_SERVICE, "",
+ mTelephonyManager.DATA_DISCONNECTED, true);
when(mConnectivityManager.getActiveNetwork()).thenReturn(null);
Drawable expectDrawable = mock(Drawable.class);
@@ -264,15 +264,10 @@
@Test
public void getMobileDrawable_hasCarrierDataAndDataIsOnCellular_getMobileDrawable()
throws Throwable {
- when(mTelephonyManager.isDataEnabled()).thenReturn(true);
- when(mTelephonyManager.getDataState()).thenReturn(mTelephonyManager.DATA_CONNECTED);
- when(mTelephonyManager.getServiceState()).thenReturn(mServiceState);
- when(mServiceState.getState()).thenReturn(ServiceState.STATE_IN_SERVICE);
- Drawable drawable = mock(Drawable.class);
- int defaultDataSubId = SubscriptionManager.getDefaultDataSubscriptionId();
- when(mSubscriptionManager.getActiveSubscriptionInfo(defaultDataSubId)).thenReturn(
- mDefaultDataSubscriptionInfo);
+ mockConnections(true, ServiceState.STATE_IN_SERVICE, "", mTelephonyManager.DATA_CONNECTED,
+ true);
addNetworkTransportType(NetworkCapabilities.TRANSPORT_CELLULAR);
+ Drawable drawable = mock(Drawable.class);
assertThat(mProviderModelSliceHelper.getMobileDrawable(drawable)).isEqualTo(
mDrawableWithSignalStrength);
@@ -283,14 +278,9 @@
@Test
public void getMobileDrawable_hasCarrierDataAndDataIsOnWifi_getMobileDrawable()
throws Throwable {
- when(mTelephonyManager.isDataEnabled()).thenReturn(true);
- when(mTelephonyManager.getDataState()).thenReturn(mTelephonyManager.DATA_CONNECTED);
- when(mTelephonyManager.getServiceState()).thenReturn(mServiceState);
- when(mServiceState.getState()).thenReturn(ServiceState.STATE_IN_SERVICE);
+ mockConnections(true, ServiceState.STATE_IN_SERVICE, "", mTelephonyManager.DATA_CONNECTED,
+ true);
Drawable drawable = mock(Drawable.class);
- int defaultDataSubId = SubscriptionManager.getDefaultDataSubscriptionId();
- when(mSubscriptionManager.getActiveSubscriptionInfo(defaultDataSubId)).thenReturn(
- mDefaultDataSubscriptionInfo);
addNetworkTransportType(NetworkCapabilities.TRANSPORT_WIFI);
assertThat(mProviderModelSliceHelper.getMobileDrawable(drawable)).isEqualTo(
@@ -303,6 +293,16 @@
mNetworkCapabilities);
}
+ private void mockConnections(boolean isDataEnabled, int serviceState, String expectDisplayName,
+ int getDataState, boolean isWifiEnabled) {
+ when(mTelephonyManager.isDataEnabled()).thenReturn(isDataEnabled);
+ when(mWifiManager.isWifiEnabled()).thenReturn(isWifiEnabled);
+ when(mTelephonyManager.getDataState()).thenReturn(getDataState);
+
+ when(mServiceState.getState()).thenReturn(serviceState);
+ when(mDefaultDataSubscriptionInfo.getDisplayName()).thenReturn(expectDisplayName);
+ }
+
private class TestCustomSliceable implements CustomSliceable {
TestCustomSliceable() {
}
diff --git a/tests/unit/src/com/android/settings/testutils/FakeFeatureFactory.java b/tests/unit/src/com/android/settings/testutils/FakeFeatureFactory.java
index 6955dc4..a90c9bf 100644
--- a/tests/unit/src/com/android/settings/testutils/FakeFeatureFactory.java
+++ b/tests/unit/src/com/android/settings/testutils/FakeFeatureFactory.java
@@ -28,6 +28,7 @@
import com.android.settings.dashboard.DashboardFeatureProvider;
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider;
+import com.android.settings.fuelgauge.BatterySettingsFeatureProvider;
import com.android.settings.fuelgauge.BatteryStatusFeatureProvider;
import com.android.settings.fuelgauge.PowerUsageFeatureProvider;
import com.android.settings.gestures.AssistGestureFeatureProvider;
@@ -53,6 +54,7 @@
public final SupportFeatureProvider supportFeatureProvider;
public final MetricsFeatureProvider metricsFeatureProvider;
public final BatteryStatusFeatureProvider batteryStatusFeatureProvider;
+ public final BatterySettingsFeatureProvider batterySettingsFeatureProvider;
public final PowerUsageFeatureProvider powerUsageFeatureProvider;
public final DashboardFeatureProvider dashboardFeatureProvider;
public final DockUpdaterFeatureProvider dockUpdaterFeatureProvider;
@@ -92,6 +94,7 @@
supportFeatureProvider = mock(SupportFeatureProvider.class);
metricsFeatureProvider = mock(MetricsFeatureProvider.class);
batteryStatusFeatureProvider = mock(BatteryStatusFeatureProvider.class);
+ batterySettingsFeatureProvider = mock(BatterySettingsFeatureProvider.class);
powerUsageFeatureProvider = mock(PowerUsageFeatureProvider.class);
dashboardFeatureProvider = mock(DashboardFeatureProvider.class);
dockUpdaterFeatureProvider = mock(DockUpdaterFeatureProvider.class);
@@ -136,6 +139,11 @@
}
@Override
+ public BatterySettingsFeatureProvider getBatterySettingsFeatureProvider(Context context) {
+ return batterySettingsFeatureProvider;
+ }
+
+ @Override
public PowerUsageFeatureProvider getPowerUsageFeatureProvider(Context context) {
return powerUsageFeatureProvider;
}