Return ServiceState from telephonyGetServiceState
This patch returns a JSONified ServiceState
from telephonyGetServiceState and consolidates the
returned info between the polled methods and the
ServiceStateChanged event. This also adds a number
of additional fields that were previously missed
in ServiceState.
Bug: 78201525
Test: compilation
Merged-In: Ibff13b3041d188af94c4f9cd5a10d36330c0ca7c
Change-Id: Ibff13b3041d188af94c4f9cd5a10d36330c0ca7c
(cherry picked from commit 11142b98ae51c7045dc08257328fab0cb5559ad4)
diff --git a/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyConstants.java b/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyConstants.java
index 99fcbb5..9c65324 100644
--- a/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyConstants.java
+++ b/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyConstants.java
@@ -423,6 +423,24 @@
public static final String CHANNEL_NUMBER = "channelNumber";
public static final String CELL_BANDWIDTHS = "cellBandwidths";
public static final String DUPLEX_MODE = "duplexMode";
+
+ public static final String VOICE_ROAMING_TYPE = "voiceRoamingType";
+ public static final String DATA_ROAMING_TYPE = "dataRoamingType";
+ public static final String VOICE_OPERATOR_ALPHA_LONG = "voiceOperatorAlphaLong";
+ public static final String VOICE_OPERATOR_ALPHA_SHORT = "voiceOperatorAlphaShort";
+ public static final String DATA_OPERATOR_ALPHA_LONG = "dataOperatorAlphaLong";
+ public static final String DATA_OPERATOR_ALPHA_SHORT = "dataOperatorAlphaShort";
+ public static final String VOICE_OPERATOR_NUMERIC = "voiceOperatorNumeric";
+ public static final String DATA_OPERATOR_NUMERIC = "dataOperatorNumeric";
+ public static final String VOICE_RADIO_TECHNOLOGY = "voiceRadioTechnology";
+ public static final String DATA_RADIO_TECHNOLOGY = "dataRadioTechnology";
+ public static final String CSS_INDICATOR = "cssIndicator";
+ public static final String CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
+ public static final String CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
+ public static final String IS_DATA_ROAMING_FROM_REGISTRATION =
+ "isDataRoamingFromRegistration";
+ public static final String IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation";
+ public static final String LTE_EARFCN_RSRP_BOOST = "lteEarfcnRsrpBoost";
}
public static class MessageWaitingIndicatorContainer {
diff --git a/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyEvents.java b/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyEvents.java
index 7f2c676..41785c7 100644
--- a/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyEvents.java
+++ b/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyEvents.java
@@ -231,62 +231,12 @@
}
public JSONObject toJSON() throws JSONException {
- JSONObject serviceState = new JSONObject();
-
+ JSONObject serviceState =
+ com.googlecode.android_scripting.jsonrpc.JsonBuilder.buildServiceState(
+ mServiceState);
serviceState.put(
TelephonyConstants.ServiceStateContainer.SUBSCRIPTION_ID,
mSubscriptionId);
- serviceState.put(
- TelephonyConstants.ServiceStateContainer.VOICE_REG_STATE,
- TelephonyUtils.getNetworkStateString(
- mServiceState.getVoiceRegState()));
- serviceState.put(
- TelephonyConstants.ServiceStateContainer.VOICE_NETWORK_TYPE,
- TelephonyUtils.getNetworkTypeString(
- mServiceState.getVoiceNetworkType()));
- serviceState.put(
- TelephonyConstants.ServiceStateContainer.DATA_REG_STATE,
- TelephonyUtils.getNetworkStateString(
- mServiceState.getDataRegState()));
- serviceState.put(
- TelephonyConstants.ServiceStateContainer.DATA_NETWORK_TYPE,
- TelephonyUtils.getNetworkTypeString(
- mServiceState.getDataNetworkType()));
- serviceState.put(
- TelephonyConstants.ServiceStateContainer.OPERATOR_NAME,
- mServiceState.getOperatorAlphaLong());
- serviceState.put(
- TelephonyConstants.ServiceStateContainer.OPERATOR_ID,
- mServiceState.getOperatorNumeric());
- serviceState.put(
- TelephonyConstants.ServiceStateContainer.IS_MANUAL_NW_SELECTION,
- mServiceState.getIsManualSelection());
- serviceState.put(
- TelephonyConstants.ServiceStateContainer.ROAMING,
- mServiceState.getRoaming());
- serviceState.put(
- TelephonyConstants.ServiceStateContainer.IS_EMERGENCY_ONLY,
- mServiceState.isEmergencyOnly());
- serviceState.put(
- TelephonyConstants.ServiceStateContainer.NETWORK_ID,
- mServiceState.getCdmaNetworkId());
- serviceState.put(
- TelephonyConstants.ServiceStateContainer.SYSTEM_ID,
- mServiceState.getCdmaSystemId());
- serviceState.put(
- TelephonyConstants.ServiceStateContainer.SERVICE_STATE,
- mServiceStateString);
- serviceState.put(
- TelephonyConstants.ServiceStateContainer.CHANNEL_NUMBER,
- mServiceState.getChannelNumber());
- serviceState.put(
- TelephonyConstants.ServiceStateContainer.CELL_BANDWIDTHS,
- mServiceState.getCellBandwidths() != null
- ? new JSONArray(mServiceState.getCellBandwidths())
- : JSONObject.NULL);
- serviceState.put(
- TelephonyConstants.ServiceStateContainer.DUPLEX_MODE,
- mServiceState.getDuplexMode());
return serviceState;
}
diff --git a/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyManagerFacade.java b/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyManagerFacade.java
index 0f7d5b1..0e3c8cf 100644
--- a/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyManagerFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyManagerFacade.java
@@ -1235,16 +1235,15 @@
}
@Rpc(description = "Returns the service state string for default subscription ID")
- public String telephonyGetServiceState() {
+ public ServiceState telephonyGetServiceState() {
return telephonyGetServiceStateForSubscription(
SubscriptionManager.getDefaultSubscriptionId());
}
@Rpc(description = "Returns the service state string for specified subscription ID")
- public String telephonyGetServiceStateForSubscription(
+ public ServiceState telephonyGetServiceStateForSubscription(
@RpcParameter(name = "subId") Integer subId) {
- ServiceState ss = mTelephonyManager.getServiceStateForSubscriber(subId);
- return ServiceState.rilServiceStateToString(ss.getState());
+ return mTelephonyManager.getServiceStateForSubscriber(subId);
}
@Rpc(description = "Returns the call state for default subscription ID")
diff --git a/Common/src/com/googlecode/android_scripting/jsonrpc/JsonBuilder.java b/Common/src/com/googlecode/android_scripting/jsonrpc/JsonBuilder.java
index 80fb803..3e23c0c 100644
--- a/Common/src/com/googlecode/android_scripting/jsonrpc/JsonBuilder.java
+++ b/Common/src/com/googlecode/android_scripting/jsonrpc/JsonBuilder.java
@@ -70,6 +70,7 @@
import android.telephony.CellSignalStrengthWcdma;
import android.telephony.ModemActivityInfo;
import android.telephony.NeighboringCellInfo;
+import android.telephony.ServiceState;
import android.telephony.SignalStrength;
import android.telephony.SmsMessage;
import android.telephony.SubscriptionInfo;
@@ -334,6 +335,9 @@
if (data instanceof SignalStrength) {
return buildSignalStrength((SignalStrength) data);
}
+ if (data instanceof ServiceState) {
+ return buildServiceState((ServiceState) data);
+ }
return data.toString();
// throw new JSONException("Failed to build JSON result. " +
@@ -1283,6 +1287,67 @@
return info;
}
+ public static JSONObject buildServiceState(ServiceState ss) throws JSONException {
+ JSONObject info = new JSONObject();
+
+ info.put(TelephonyConstants.ServiceStateContainer.VOICE_REG_STATE,
+ TelephonyUtils.getNetworkStateString(ss.getVoiceRegState()));
+ info.put(TelephonyConstants.ServiceStateContainer.VOICE_NETWORK_TYPE,
+ TelephonyUtils.getNetworkTypeString(ss.getVoiceNetworkType()));
+ info.put(TelephonyConstants.ServiceStateContainer.DATA_REG_STATE,
+ TelephonyUtils.getNetworkStateString(ss.getDataRegState()));
+ info.put(TelephonyConstants.ServiceStateContainer.DATA_NETWORK_TYPE,
+ TelephonyUtils.getNetworkTypeString(ss.getDataNetworkType()));
+ info.put(TelephonyConstants.ServiceStateContainer.OPERATOR_NAME, ss.getOperatorAlphaLong());
+ info.put(TelephonyConstants.ServiceStateContainer.OPERATOR_ID, ss.getOperatorNumeric());
+ info.put(TelephonyConstants.ServiceStateContainer.IS_MANUAL_NW_SELECTION,
+ ss.getIsManualSelection());
+ info.put(TelephonyConstants.ServiceStateContainer.ROAMING, ss.getRoaming());
+ info.put(TelephonyConstants.ServiceStateContainer.IS_EMERGENCY_ONLY, ss.isEmergencyOnly());
+ info.put(TelephonyConstants.ServiceStateContainer.NETWORK_ID, ss.getCdmaNetworkId());
+ info.put(TelephonyConstants.ServiceStateContainer.SYSTEM_ID, ss.getCdmaSystemId());
+ info.put(TelephonyConstants.ServiceStateContainer.SERVICE_STATE,
+ TelephonyUtils.getNetworkStateString(ss.getState()));
+ info.put(TelephonyConstants.ServiceStateContainer.CHANNEL_NUMBER, ss.getChannelNumber());
+ info.put(TelephonyConstants.ServiceStateContainer.CELL_BANDWIDTHS,
+ ss.getCellBandwidths() != null
+ ? new JSONArray(ss.getCellBandwidths())
+ : JSONObject.NULL);
+ info.put(TelephonyConstants.ServiceStateContainer.DUPLEX_MODE, ss.getDuplexMode());
+ info.put(TelephonyConstants.ServiceStateContainer.VOICE_ROAMING_TYPE,
+ ss.getVoiceRoamingType());
+ info.put(TelephonyConstants.ServiceStateContainer.DATA_ROAMING_TYPE,
+ ss.getDataRoamingType());
+ info.put(TelephonyConstants.ServiceStateContainer.VOICE_OPERATOR_ALPHA_LONG,
+ ss.getVoiceOperatorAlphaLong());
+ info.put(TelephonyConstants.ServiceStateContainer.VOICE_OPERATOR_ALPHA_SHORT,
+ ss.getVoiceOperatorAlphaShort());
+ info.put(TelephonyConstants.ServiceStateContainer.VOICE_OPERATOR_NUMERIC,
+ ss.getVoiceOperatorNumeric());
+ info.put(TelephonyConstants.ServiceStateContainer.DATA_OPERATOR_ALPHA_LONG,
+ ss.getDataOperatorAlphaLong());
+ info.put(TelephonyConstants.ServiceStateContainer.DATA_OPERATOR_ALPHA_SHORT,
+ ss.getDataOperatorAlphaShort());
+ info.put(TelephonyConstants.ServiceStateContainer.DATA_OPERATOR_NUMERIC,
+ ss.getDataOperatorNumeric());
+ info.put(TelephonyConstants.ServiceStateContainer.VOICE_RADIO_TECHNOLOGY,
+ ss.getRilVoiceRadioTechnology());
+ info.put(TelephonyConstants.ServiceStateContainer.DATA_RADIO_TECHNOLOGY,
+ ss.getRilDataRadioTechnology());
+ info.put(TelephonyConstants.ServiceStateContainer.CSS_INDICATOR, ss.getCssIndicator());
+ info.put(TelephonyConstants.ServiceStateContainer.CDMA_ROAMING_INDICATOR,
+ ss.getCdmaRoamingIndicator());
+ info.put(TelephonyConstants.ServiceStateContainer.CDMA_DEFAULT_ROAMING_INDICATOR,
+ ss.getCdmaDefaultRoamingIndicator());
+ info.put(TelephonyConstants.ServiceStateContainer.IS_DATA_ROAMING_FROM_REGISTRATION,
+ ss.getDataRoamingFromRegistration());
+ info.put(TelephonyConstants.ServiceStateContainer.IS_USING_CARRIER_AGGREGATION,
+ ss.isUsingCarrierAggregation());
+ info.put(TelephonyConstants.ServiceStateContainer.LTE_EARFCN_RSRP_BOOST,
+ ss.getLteEarfcnRsrpBoost());
+ return info;
+ }
+
private JsonBuilder() {
// This is a utility class.
}