Merge "Attach FingerprintEnrollEnrollingRfps fragment"
diff --git a/src/com/android/settings/network/ProviderModelSliceHelper.java b/src/com/android/settings/network/ProviderModelSliceHelper.java
index 32a475a..e0d1eb1 100644
--- a/src/com/android/settings/network/ProviderModelSliceHelper.java
+++ b/src/com/android/settings/network/ProviderModelSliceHelper.java
@@ -61,6 +61,7 @@
/**
* The helper is for slice of carrier and non-Carrier, used by ProviderModelSlice.
+ * TODO: Remove the class in U because Settings does not use slice anymore.
*/
public class ProviderModelSliceHelper {
private static final String TAG = "ProviderModelSlice";
@@ -140,7 +141,7 @@
numLevels += 1;
}
return MobileNetworkUtils.getSignalStrengthIcon(mContext, level, numLevels,
- NO_CELL_DATA_TYPE_ICON, false);
+ NO_CELL_DATA_TYPE_ICON, false, false);
}
/**
diff --git a/src/com/android/settings/network/SubscriptionsPreferenceController.java b/src/com/android/settings/network/SubscriptionsPreferenceController.java
index 4ce7d26..9cd49c8 100644
--- a/src/com/android/settings/network/SubscriptionsPreferenceController.java
+++ b/src/com/android/settings/network/SubscriptionsPreferenceController.java
@@ -36,10 +36,12 @@
import android.telephony.SignalStrength;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyCallback;
import android.telephony.TelephonyDisplayInfo;
import android.telephony.TelephonyManager;
import android.text.Html;
import android.util.ArraySet;
+import android.util.Log;
import androidx.annotation.VisibleForTesting;
import androidx.collection.ArrayMap;
@@ -78,7 +80,8 @@
public class SubscriptionsPreferenceController extends AbstractPreferenceController implements
LifecycleObserver, SubscriptionsChangeListener.SubscriptionsChangeListenerClient,
MobileDataEnabledListener.Client, DataConnectivityListener.Client,
- SignalStrengthListener.Callback, TelephonyDisplayInfoListener.Callback {
+ SignalStrengthListener.Callback, TelephonyDisplayInfoListener.Callback,
+ TelephonyCallback.CarrierNetworkListener {
private static final String TAG = "SubscriptionsPrefCntrlr";
private UpdateListener mUpdateListener;
@@ -93,6 +96,7 @@
private TelephonyDisplayInfoListener mTelephonyDisplayInfoListener;
private WifiPickerTrackerHelper mWifiPickerTrackerHelper;
private final WifiManager mWifiManager;
+ private boolean mCarrierNetworkChangeMode;
@VisibleForTesting
final BroadcastReceiver mConnectionChangeReceiver = new BroadcastReceiver() {
@@ -283,8 +287,8 @@
? false
: regInfo.isRegistered();
final boolean isCarrierNetworkActive = isCarrierNetworkActive();
- String result = mSubsPrefCtrlInjector.getNetworkType(
- mContext, mConfig, mTelephonyDisplayInfo, subId, isCarrierNetworkActive);
+ String result = mSubsPrefCtrlInjector.getNetworkType(mContext, mConfig,
+ mTelephonyDisplayInfo, subId, isCarrierNetworkActive, mCarrierNetworkChangeMode);
if (mSubsPrefCtrlInjector.isActiveCellularNetwork(mContext) || isCarrierNetworkActive) {
if (result.isEmpty()) {
result = mContext.getString(isDds ? R.string.mobile_data_connection_active
@@ -335,7 +339,8 @@
|| (!isDds(subId) && tmForSubId.isMobileDataPolicyEnabled(
TelephonyManager.MOBILE_DATA_POLICY_AUTO_DATA_SWITCH));
if (isDataInService || isVoiceInService || isCarrierNetworkActive) {
- icon = mSubsPrefCtrlInjector.getIcon(mContext, level, numLevels, !isDataEnabled);
+ icon = mSubsPrefCtrlInjector.getIcon(mContext, level, numLevels, !isDataEnabled,
+ mCarrierNetworkChangeMode);
}
final boolean isActiveCellularNetwork =
@@ -472,6 +477,12 @@
update();
}
+ @Override
+ public void onCarrierNetworkChange(boolean active) {
+ mCarrierNetworkChangeMode = active;
+ update();
+ }
+
public void setWifiPickerTrackerHelper(WifiPickerTrackerHelper helper) {
mWifiPickerTrackerHelper = helper;
}
@@ -549,44 +560,39 @@
}
/**
- * Gets current mobile network type.
+ * Gets current network type of Carrier Wi-Fi Network or Cellular.
*/
public String getNetworkType(Context context, Config config,
- TelephonyDisplayInfo telephonyDisplayInfo, int subId) {
- String iconKey = getIconKey(telephonyDisplayInfo);
- MobileIconGroup iconGroup = mapIconSets(config).get(iconKey);
- int resId = 0;
- if (iconGroup != null) {
- resId = iconGroup.dataContentDescription;
+ TelephonyDisplayInfo telephonyDisplayInfo, int subId, boolean isCarrierWifiNetwork,
+ boolean carrierNetworkChanged) {
+ MobileIconGroup iconGroup = null;
+ if (isCarrierWifiNetwork) {
+ iconGroup = TelephonyIcons.CARRIER_MERGED_WIFI;
+ } else if (carrierNetworkChanged) {
+ iconGroup = TelephonyIcons.CARRIER_NETWORK_CHANGE;
+ } else {
+ String iconKey = getIconKey(telephonyDisplayInfo);
+ iconGroup = mapIconSets(config).get(iconKey);
}
+
+ if (iconGroup == null) {
+ Log.d(TAG, "Can not get the network's icon and description.");
+ return "";
+ }
+
+ int resId = iconGroup.dataContentDescription;
return resId != 0
? SubscriptionManager.getResourcesForSubId(context, subId).getString(resId)
: "";
}
/**
- * Gets current network type of Carrier Wi-Fi Network or Cellular.
- */
- public String getNetworkType(Context context, Config config,
- TelephonyDisplayInfo telephonyDisplayInfo, int subId,
- boolean isCarrierWifiNetwork) {
- if (isCarrierWifiNetwork) {
- MobileIconGroup carrierMergedWifiIconGroup = TelephonyIcons.CARRIER_MERGED_WIFI;
- int resId = carrierMergedWifiIconGroup.dataContentDescription;
- return resId != 0
- ? SubscriptionManager.getResourcesForSubId(context, subId)
- .getString(resId) : "";
- } else {
- return getNetworkType(context, config, telephonyDisplayInfo, subId);
- }
- }
-
- /**
* Gets signal icon with different signal level.
*/
- public Drawable getIcon(Context context, int level, int numLevels, boolean cutOut) {
+ public Drawable getIcon(Context context, int level, int numLevels, boolean cutOut,
+ boolean carrierNetworkChanged) {
return MobileNetworkUtils.getSignalStrengthIcon(context, level, numLevels,
- NO_CELL_DATA_TYPE_ICON, cutOut);
+ NO_CELL_DATA_TYPE_ICON, cutOut, carrierNetworkChanged);
}
}
}
diff --git a/src/com/android/settings/network/telephony/MobileNetworkUtils.java b/src/com/android/settings/network/telephony/MobileNetworkUtils.java
index 599fa6b..423ba2f 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkUtils.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkUtils.java
@@ -613,10 +613,11 @@
}
public static Drawable getSignalStrengthIcon(Context context, int level, int numLevels,
- int iconType, boolean cutOut) {
+ int iconType, boolean cutOut, boolean carrierNetworkChanged) {
final SignalDrawable signalDrawable = new SignalDrawable(context);
signalDrawable.setLevel(
- SignalDrawable.getState(level, numLevels, cutOut));
+ carrierNetworkChanged ? SignalDrawable.getCarrierChangeState(numLevels)
+ : SignalDrawable.getState(level, numLevels, cutOut));
// Make the network type drawable
final Drawable networkDrawable =
diff --git a/src/com/android/settings/network/telephony/NetworkOperatorPreference.java b/src/com/android/settings/network/telephony/NetworkOperatorPreference.java
index 397bf36..7404aa4 100644
--- a/src/com/android/settings/network/telephony/NetworkOperatorPreference.java
+++ b/src/com/android/settings/network/telephony/NetworkOperatorPreference.java
@@ -260,6 +260,6 @@
}
final Context context = getContext();
setIcon(MobileNetworkUtils.getSignalStrengthIcon(context, level, NUM_SIGNAL_STRENGTH_BINS,
- getIconIdForCell(mCellInfo), false));
+ getIconIdForCell(mCellInfo), false, false));
}
}
diff --git a/tests/unit/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java b/tests/unit/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java
index ebcb102..c4abdd1 100644
--- a/tests/unit/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java
@@ -275,7 +275,8 @@
true, ServiceState.STATE_IN_SERVICE);
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
doReturn(networkType)
- .when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false));
+ .when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false),
+ eq(false));
mController.onResume();
mController.displayPreference(mPreferenceScreen);
@@ -295,7 +296,7 @@
true, ServiceState.STATE_IN_SERVICE);
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
doReturn(networkType)
- .when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(true));
+ .when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(true), eq(false));
doReturn(true).when(mWifiPickerTrackerHelper).isCarrierNetworkActive();
mController.onResume();
@@ -317,7 +318,8 @@
setupGetIconConditions(sub.get(0).getSubscriptionId(), false, false,
true, ServiceState.STATE_IN_SERVICE);
doReturn(networkType)
- .when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false));
+ .when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false),
+ eq(false));
mController.onResume();
mController.displayPreference(mPreferenceScreen);
@@ -336,7 +338,8 @@
setupGetIconConditions(sub.get(0).getSubscriptionId(), false, true,
true, ServiceState.STATE_IN_SERVICE);
doReturn(networkType)
- .when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false));
+ .when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false),
+ eq(false));
when(mTelephonyManager.isDataEnabled()).thenReturn(true);
mController.onResume();
@@ -371,7 +374,8 @@
true, ServiceState.STATE_IN_SERVICE);
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
doReturn(networkType)
- .when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false));
+ .when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false),
+ eq(false));
when(mTelephonyManager.isDataEnabled()).thenReturn(true);
mController.onResume();
@@ -397,7 +401,8 @@
true, ServiceState.STATE_IN_SERVICE);
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
doReturn(networkType)
- .when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false));
+ .when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false),
+ eq(false));
mController.onResume();
mController.displayPreference(mPreferenceScreen);
@@ -424,7 +429,8 @@
false, ServiceState.STATE_OUT_OF_SERVICE);
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
doReturn(networkType)
- .when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false));
+ .when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false),
+ eq(false));
mController.onResume();
mController.displayPreference(mPreferenceScreen);
@@ -491,7 +497,7 @@
doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
Drawable icon = mock(Drawable.class);
when(mTelephonyManager.isDataEnabled()).thenReturn(true);
- doReturn(icon).when(sInjector).getIcon(any(), anyInt(), anyInt(), eq(false));
+ doReturn(icon).when(sInjector).getIcon(any(), anyInt(), anyInt(), eq(false), eq(false));
setupGetIconConditions(sub.get(0).getSubscriptionId(), true, true,
true, ServiceState.STATE_IN_SERVICE);
@@ -509,7 +515,7 @@
doReturn(subs.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
Drawable icon = mock(Drawable.class);
when(mTelephonyManager.isDataEnabled()).thenReturn(true);
- doReturn(icon).when(sInjector).getIcon(any(), anyInt(), anyInt(), eq(false));
+ doReturn(icon).when(sInjector).getIcon(any(), anyInt(), anyInt(), eq(false), eq(false));
setupGetIconConditions(subId, false, true,
true, ServiceState.STATE_IN_SERVICE);
mController.onResume();
@@ -527,7 +533,7 @@
doReturn(subs.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
Drawable icon = mock(Drawable.class);
when(mTelephonyManager.isDataEnabled()).thenReturn(false);
- doReturn(icon).when(sInjector).getIcon(any(), anyInt(), anyInt(), eq(true));
+ doReturn(icon).when(sInjector).getIcon(any(), anyInt(), anyInt(), eq(true), eq(false));
setupGetIconConditions(subId, false, false,
false, ServiceState.STATE_IN_SERVICE);
@@ -559,7 +565,8 @@
mController.getIcon(SUB_ID);
- verify(sInjector).getIcon(any(), eq(SIGNAL_STRENGTH_GOOD), anyInt(), anyBoolean());
+ verify(sInjector).getIcon(any(), eq(SIGNAL_STRENGTH_GOOD), anyInt(), anyBoolean(),
+ anyBoolean());
}
@Test
@@ -576,7 +583,7 @@
mController.getIcon(SUB_ID);
- verify(sInjector).getIcon(any(), eq(WIFI_LEVEL_MAX), anyInt(), anyBoolean());
+ verify(sInjector).getIcon(any(), eq(WIFI_LEVEL_MAX), anyInt(), anyBoolean(), anyBoolean());
}
@Test