Expose ServiceState#getDataNetworkType in telephony provider
Bug: 182601774
Test: atest com.android.phone.ServiceStateProviderTest
Change-Id: I2102f21ff95ae1fba88dabe3691a0a1ec478a2a1
diff --git a/src/com/android/phone/ServiceStateProvider.java b/src/com/android/phone/ServiceStateProvider.java
index a7d27d5..63bc600 100644
--- a/src/com/android/phone/ServiceStateProvider.java
+++ b/src/com/android/phone/ServiceStateProvider.java
@@ -18,6 +18,7 @@
import static android.provider.Telephony.ServiceStateTable;
import static android.provider.Telephony.ServiceStateTable.CONTENT_URI;
+import static android.provider.Telephony.ServiceStateTable.DATA_NETWORK_TYPE;
import static android.provider.Telephony.ServiceStateTable.IS_MANUAL_NETWORK_SELECTION;
import static android.provider.Telephony.ServiceStateTable.VOICE_REG_STATE;
import static android.provider.Telephony.ServiceStateTable.getUriForSubscriptionId;
@@ -257,6 +258,7 @@
IS_USING_CARRIER_AGGREGATION,
OPERATOR_ALPHA_LONG_RAW,
OPERATOR_ALPHA_SHORT_RAW,
+ DATA_NETWORK_TYPE,
};
@Override
@@ -392,6 +394,7 @@
final int is_using_carrier_aggregation = (ss.isUsingCarrierAggregation()) ? 1 : 0;
final String operator_alpha_long_raw = ss.getOperatorAlphaLongRaw();
final String operator_alpha_short_raw = ss.getOperatorAlphaShortRaw();
+ final int data_network_type = ss.getDataNetworkType();
return buildSingleRowResult(projection, sColumns, new Object[] {
voice_reg_state,
@@ -418,6 +421,7 @@
is_using_carrier_aggregation,
operator_alpha_long_raw,
operator_alpha_short_raw,
+ data_network_type,
});
}
}
@@ -480,6 +484,10 @@
context.getContentResolver().notifyChange(
getUriForSubscriptionIdAndField(subId, DATA_ROAMING_TYPE), null, false);
}
+ if (firstUpdate || dataNetworkTypeChanged(oldSS, newSS)) {
+ context.getContentResolver().notifyChange(
+ getUriForSubscriptionIdAndField(subId, DATA_NETWORK_TYPE), null, false);
+ }
}
private static boolean voiceRegStateChanged(ServiceState oldSS, ServiceState newSS) {
@@ -498,6 +506,10 @@
return oldSS.getDataRoamingType() != newSS.getDataRoamingType();
}
+ private static boolean dataNetworkTypeChanged(ServiceState oldSS, ServiceState newSS) {
+ return oldSS.getDataNetworkType() != newSS.getDataNetworkType();
+ }
+
/**
* Notify interested apps that the ServiceState has changed.
*
@@ -517,7 +529,8 @@
// If oldSS is null and newSS is not (e.g. first update of service state) this will also
// notify
if (oldSS == null || voiceRegStateChanged(oldSS, newSS) || dataRegStateChanged(oldSS, newSS)
- || voiceRoamingTypeChanged(oldSS, newSS) || dataRoamingTypeChanged(oldSS, newSS)) {
+ || voiceRoamingTypeChanged(oldSS, newSS) || dataRoamingTypeChanged(oldSS, newSS)
+ || dataNetworkTypeChanged(oldSS, newSS)) {
context.getContentResolver().notifyChange(getUriForSubscriptionId(subId), null, false);
}
}