Merge "Implement main functions to consolidate signal strength request"
diff --git a/src/java/com/android/internal/telephony/RadioIndication.java b/src/java/com/android/internal/telephony/RadioIndication.java
index 7951592..893378f 100644
--- a/src/java/com/android/internal/telephony/RadioIndication.java
+++ b/src/java/com/android/internal/telephony/RadioIndication.java
@@ -86,6 +86,7 @@
import android.hardware.radio.V1_0.SuppSvcNotification;
import android.hardware.radio.V1_2.CellConnectionStatus;
import android.hardware.radio.V1_6.IRadioIndication;
+import android.hardware.radio.V1_6.PhysicalChannelConfig.Band;
import android.os.AsyncResult;
import android.os.RemoteException;
import android.sysprop.TelephonyProperties;
@@ -1175,7 +1176,7 @@
builder.setFrequencyRange(config.rfInfo.range());
break;
case android.hardware.radio.V1_4.RadioFrequencyInfo.hidl_discriminator.channelNumber:
- builder.setChannelNumber(config.rfInfo.channelNumber());
+ builder.setDownlinkChannelNumber(config.rfInfo.channelNumber());
break;
default:
mRil.riljLoge("Unsupported frequency type " + config.rfInfo.getDiscriminator());
@@ -1196,6 +1197,35 @@
}
}
+ /**
+ * Set the band from the physical channel config.
+ *
+ * @param builder the builder of {@link PhysicalChannelConfig}.
+ * @param config physical channel config from ril.
+ */
+ public void setBandToBuilder(PhysicalChannelConfig.Builder builder,
+ android.hardware.radio.V1_6.PhysicalChannelConfig config) {
+
+ android.hardware.radio.V1_6.PhysicalChannelConfig.Band band = config.band;
+
+ switch (band.getDiscriminator()) {
+ case Band.hidl_discriminator.geranBand:
+ builder.setBand(band.geranBand());
+ break;
+ case Band.hidl_discriminator.utranBand:
+ builder.setBand(band.utranBand());
+ break;
+ case Band.hidl_discriminator.eutranBand:
+ builder.setBand(band.eutranBand());
+ break;
+ case Band.hidl_discriminator.ngranBand:
+ builder.setBand(band.ngranBand());
+ break;
+ default:
+ mRil.riljLoge("Unsupported band type " + band.getDiscriminator());
+ }
+ }
+
private void physicalChannelConfigsIndication(List<? extends Object> configs) {
List<PhysicalChannelConfig> response = new ArrayList<>(configs.size());
for (Object obj : configs) {
@@ -1216,7 +1246,22 @@
response.add(builder.setCellConnectionStatus(
convertConnectionStatusFromCellConnectionStatus(config.base.status))
.setCellBandwidthDownlinkKhz(config.base.cellBandwidthDownlink)
- .setRat(ServiceState.rilRadioTechnologyToNetworkType(config.rat))
+ .setNetworkType(ServiceState.rilRadioTechnologyToNetworkType(config.rat))
+ .setPhysicalCellId(config.physicalCellId)
+ .setContextIds(config.contextIds.stream().mapToInt(x -> x).toArray())
+ .build());
+ } else if (obj instanceof android.hardware.radio.V1_6.PhysicalChannelConfig) {
+ android.hardware.radio.V1_6.PhysicalChannelConfig config =
+ (android.hardware.radio.V1_6.PhysicalChannelConfig) obj;
+ PhysicalChannelConfig.Builder builder = new PhysicalChannelConfig.Builder();
+ setBandToBuilder(builder, config);
+ response.add(builder.setCellConnectionStatus(
+ convertConnectionStatusFromCellConnectionStatus(config.status))
+ .setDownlinkChannelNumber(config.downlinkChannelNumber)
+ .setUplinkChannelNumber(config.uplinkChannelNumber)
+ .setCellBandwidthDownlinkKhz(config.cellBandwidthDownlink)
+ .setCellBandwidthUplinkKhz(config.cellBandwidthUplink)
+ .setNetworkType(ServiceState.rilRadioTechnologyToNetworkType(config.rat))
.setPhysicalCellId(config.physicalCellId)
.setContextIds(config.contextIds.stream().mapToInt(x -> x).toArray())
.build());
diff --git a/src/java/com/android/internal/telephony/SMSDispatcher.java b/src/java/com/android/internal/telephony/SMSDispatcher.java
index 71ca823..6774d46 100644
--- a/src/java/com/android/internal/telephony/SMSDispatcher.java
+++ b/src/java/com/android/internal/telephony/SMSDispatcher.java
@@ -17,14 +17,6 @@
package com.android.internal.telephony;
import static android.Manifest.permission.SEND_SMS_NO_CONFIRMATION;
-import static android.telephony.SmsManager.RESULT_ERROR_GENERIC_FAILURE;
-import static android.telephony.SmsManager.RESULT_ERROR_LIMIT_EXCEEDED;
-import static android.telephony.SmsManager.RESULT_ERROR_NONE;
-import static android.telephony.SmsManager.RESULT_ERROR_NO_SERVICE;
-import static android.telephony.SmsManager.RESULT_ERROR_NULL_PDU;
-import static android.telephony.SmsManager.RESULT_ERROR_RADIO_OFF;
-import static android.telephony.SmsManager.RESULT_ERROR_SHORT_CODE_NEVER_ALLOWED;
-import static android.telephony.SmsManager.RESULT_ERROR_SHORT_CODE_NOT_ALLOWED;
import static com.android.internal.telephony.IccSmsInterfaceManager.SMS_MESSAGE_PERIOD_NOT_SPECIFIED;
import static com.android.internal.telephony.IccSmsInterfaceManager.SMS_MESSAGE_PRIORITY_NOT_SPECIFIED;
@@ -308,7 +300,7 @@
Rlog.d(TAG, "SMSDispatcher: EVENT_SENDING_NOT_ALLOWED - "
+ "sending SHORT_CODE_NEVER_ALLOWED error code.");
handleSmsTrackersFailure(
- trackers, RESULT_ERROR_SHORT_CODE_NEVER_ALLOWED, NO_ERROR_CODE);
+ trackers, SmsManager.RESULT_ERROR_SHORT_CODE_NEVER_ALLOWED, NO_ERROR_CODE);
break;
}
@@ -318,21 +310,21 @@
int error;
if (msg.arg1 == ConfirmDialogListener.SHORT_CODE_MSG) {
if (msg.arg2 == ConfirmDialogListener.NEVER_ALLOW) {
- error = RESULT_ERROR_SHORT_CODE_NEVER_ALLOWED;
+ error = SmsManager.RESULT_ERROR_SHORT_CODE_NEVER_ALLOWED;
Rlog.d(TAG, "SMSDispatcher: EVENT_STOP_SENDING - "
+ "sending SHORT_CODE_NEVER_ALLOWED error code.");
} else {
- error = RESULT_ERROR_SHORT_CODE_NOT_ALLOWED;
+ error = SmsManager.RESULT_ERROR_SHORT_CODE_NOT_ALLOWED;
Rlog.d(TAG, "SMSDispatcher: EVENT_STOP_SENDING - "
+ "sending SHORT_CODE_NOT_ALLOWED error code.");
}
} else if (msg.arg1 == ConfirmDialogListener.RATE_LIMIT) {
- error = RESULT_ERROR_LIMIT_EXCEEDED;
+ error = SmsManager.RESULT_ERROR_LIMIT_EXCEEDED;
Rlog.d(TAG, "SMSDispatcher: EVENT_STOP_SENDING - "
+ "sending LIMIT_EXCEEDED error code.");
} else {
- error = SmsManager.RESULT_UNEXPECTED_EVENT_STOP_SENDING;
- Rlog.e(TAG, "SMSDispatcher: EVENT_STOP_SENDING - unexpected cases.");
+ error = SmsManager.RESULT_UNEXPECTED_EVENT_STOP_SENDING;
+ Rlog.e(TAG, "SMSDispatcher: EVENT_STOP_SENDING - unexpected cases.");
}
handleSmsTrackersFailure(trackers, error, NO_ERROR_CODE);
@@ -785,11 +777,13 @@
}
int ss = mPhone.getServiceState().getState();
+ int error = rilErrorToSmsManagerResult(
+ ((CommandException) (ar.exception)).getCommandError());
if (tracker.mImsRetry > 0 && ss != ServiceState.STATE_IN_SERVICE) {
// This is retry after failure over IMS but voice is not available.
- // Set retry to max allowed, so no retry is sent and
- // cause RESULT_ERROR_GENERIC_FAILURE to be returned to app.
+ // Set retry to max allowed, so no retry is sent and cause
+ // SmsManager.RESULT_ERROR_GENERIC_FAILURE to be returned to app.
tracker.mRetryCount = MAX_SEND_RETRIES;
Rlog.d(TAG, "handleSendComplete: Skipping retry: "
@@ -811,9 +805,8 @@
getNotInServiceError(ss),
tracker.mMessageId,
tracker.isFromDefaultSmsApplication(mContext));
- } else if ((((CommandException)(ar.exception)).getCommandError()
- == CommandException.Error.SMS_FAIL_RETRY) &&
- tracker.mRetryCount < MAX_SEND_RETRIES) {
+ } else if (error == SmsManager.RESULT_RIL_SMS_SEND_FAIL_RETRY
+ && tracker.mRetryCount < MAX_SEND_RETRIES) {
// Retry after a delay if needed.
// TODO: According to TS 23.040, 9.2.3.6, we should resend
// with the same TP-MR as the failed message, and
@@ -836,8 +829,6 @@
tracker.isFromDefaultSmsApplication(mContext));
} else {
int errorCode = (smsResponse != null) ? smsResponse.mErrorCode : NO_ERROR_CODE;
- int error = rilErrorToSmsManagerResult(((CommandException) (ar.exception))
- .getCommandError());
tracker.onFailed(mContext, error, errorCode);
mPhone.getSmsStats().onOutgoingSms(
tracker.mImsRetry > 0 /* isOverIms */,
@@ -903,7 +894,7 @@
case BLOCKED_DUE_TO_CALL:
return SmsManager.RESULT_RIL_BLOCKED_DUE_TO_CALL;
default:
- return RESULT_ERROR_GENERIC_FAILURE;
+ return SmsManager.RESULT_ERROR_GENERIC_FAILURE;
}
}
@@ -914,9 +905,9 @@
@SmsManager.Result
protected static int getNotInServiceError(int ss) {
if (ss == ServiceState.STATE_POWER_OFF) {
- return RESULT_ERROR_RADIO_OFF;
+ return SmsManager.RESULT_ERROR_RADIO_OFF;
}
- return RESULT_ERROR_NO_SERVICE;
+ return SmsManager.RESULT_ERROR_NO_SERVICE;
}
/**
@@ -932,13 +923,65 @@
* broadcast when the message is successfully sent, or failed.
* The result code will be <code>Activity.RESULT_OK<code> for success,
* or one of these errors:<br>
- * <code>RESULT_ERROR_GENERIC_FAILURE</code><br>
- * <code>RESULT_ERROR_RADIO_OFF</code><br>
- * <code>RESULT_ERROR_NULL_PDU</code><br>
- * <code>RESULT_ERROR_NO_SERVICE</code><br>.
- * For <code>RESULT_ERROR_GENERIC_FAILURE</code> the sentIntent may include
- * the extra "errorCode" containing a radio technology specific value,
- * generally only useful for troubleshooting.<br>
+ * <code>SmsManager.RESULT_ERROR_GENERIC_FAILURE</code><br>
+ * <code>SmsManager.RESULT_ERROR_RADIO_OFF</code><br>
+ * <code>SmsManager.RESULT_ERROR_NULL_PDU</code><br>
+ * <code>SmsManager.RESULT_ERROR_NO_SERVICE</code><br>
+ * <code>SmsManager.RESULT_ERROR_LIMIT_EXCEEDED</code><br>
+ * <code>SmsManager.RESULT_ERROR_FDN_CHECK_FAILURE</code><br>
+ * <code>SmsManager.RESULT_ERROR_SHORT_CODE_NOT_ALLOWED</code><br>
+ * <code>SmsManager.RESULT_ERROR_SHORT_CODE_NEVER_ALLOWED</code><br>
+ * <code>SmsManager.RESULT_RADIO_NOT_AVAILABLE</code><br>
+ * <code>SmsManager.RESULT_NETWORK_REJECT</code><br>
+ * <code>SmsManager.RESULT_INVALID_ARGUMENTS</code><br>
+ * <code>SmsManager.RESULT_INVALID_STATE</code><br>
+ * <code>SmsManager.RESULT_NO_MEMORY</code><br>
+ * <code>SmsManager.RESULT_INVALID_SMS_FORMAT</code><br>
+ * <code>SmsManager.RESULT_SYSTEM_ERROR</code><br>
+ * <code>SmsManager.RESULT_MODEM_ERROR</code><br>
+ * <code>SmsManager.RESULT_NETWORK_ERROR</code><br>
+ * <code>SmsManager.RESULT_ENCODING_ERROR</code><br>
+ * <code>SmsManager.RESULT_INVALID_SMSC_ADDRESS</code><br>
+ * <code>SmsManager.RESULT_OPERATION_NOT_ALLOWED</code><br>
+ * <code>SmsManager.RESULT_INTERNAL_ERROR</code><br>
+ * <code>SmsManager.RESULT_NO_RESOURCES</code><br>
+ * <code>SmsManager.RESULT_CANCELLED</code><br>
+ * <code>SmsManager.RESULT_REQUEST_NOT_SUPPORTED</code><br>
+ * <code>SmsManager.RESULT_NO_BLUETOOTH_SERVICE</code><br>
+ * <code>SmsManager.RESULT_INVALID_BLUETOOTH_ADDRESS</code><br>
+ * <code>SmsManager.RESULT_BLUETOOTH_DISCONNECTED</code><br>
+ * <code>SmsManager.RESULT_UNEXPECTED_EVENT_STOP_SENDING</code><br>
+ * <code>SmsManager.RESULT_SMS_BLOCKED_DURING_EMERGENCY</code><br>
+ * <code>SmsManager.RESULT_SMS_SEND_RETRY_FAILED</code><br>
+ * <code>SmsManager.RESULT_REMOTE_EXCEPTION</code><br>
+ * <code>SmsManager.RESULT_NO_DEFAULT_SMS_APP</code><br>
+ * <code>SmsManager.RESULT_RIL_RADIO_NOT_AVAILABLE</code><br>
+ * <code>SmsManager.RESULT_RIL_SMS_SEND_FAIL_RETRY</code><br>
+ * <code>SmsManager.RESULT_RIL_NETWORK_REJECT</code><br>
+ * <code>SmsManager.RESULT_RIL_INVALID_STATE</code><br>
+ * <code>SmsManager.RESULT_RIL_INVALID_ARGUMENTS</code><br>
+ * <code>SmsManager.RESULT_RIL_NO_MEMORY</code><br>
+ * <code>SmsManager.RESULT_RIL_REQUEST_RATE_LIMITED</code><br>
+ * <code>SmsManager.RESULT_RIL_INVALID_SMS_FORMAT</code><br>
+ * <code>SmsManager.RESULT_RIL_SYSTEM_ERR</code><br>
+ * <code>SmsManager.RESULT_RIL_ENCODING_ERR</code><br>
+ * <code>SmsManager.RESULT_RIL_INVALID_SMSC_ADDRESS</code><br>
+ * <code>SmsManager.RESULT_RIL_MODEM_ERR</code><br>
+ * <code>SmsManager.RESULT_RIL_NETWORK_ERR</code><br>
+ * <code>SmsManager.RESULT_RIL_INTERNAL_ERR</code><br>
+ * <code>SmsManager.RESULT_RIL_REQUEST_NOT_SUPPORTED</code><br>
+ * <code>SmsManager.RESULT_RIL_INVALID_MODEM_STATE</code><br>
+ * <code>SmsManager.RESULT_RIL_NETWORK_NOT_READY</code><br>
+ * <code>SmsManager.RESULT_RIL_OPERATION_NOT_ALLOWED</code><br>
+ * <code>SmsManager.RESULT_RIL_NO_RESOURCES</code><br>
+ * <code>SmsManager.RESULT_RIL_CANCELLED</code><br>
+ * <code>SmsManager.RESULT_RIL_SIM_ABSENT</code><br>
+ * <code>SmsManager.RESULT_RIL_SIMULTANEOUS_SMS_AND_CALL_NOT_ALLOWED</code><br>
+ * <code>SmsManager.RESULT_RIL_ACCESS_BARRED</code><br>
+ * <code>SmsManager.RESULT_RIL_BLOCKED_DUE_TO_CALL</code><br>
+ * For <code>SmsManager.RESULT_ERROR_GENERIC_FAILURE</code> or any of the RESULT_RIL errors,
+ * the sentIntent may include the extra "errorCode" containing a radio technology specific
+ * value, generally only useful for troubleshooting.<br>
* The per-application based SMS control checks sentIntent. If sentIntent
* is NULL the caller will be checked against all unknown applications,
* which cause smaller number of SMS to be sent in checking period.
@@ -969,7 +1012,8 @@
/**
* Send a text based SMS.
- * @param destAddr the address to send the message to
+ *
+ * @param destAddr the address to send the message to
* @param scAddr is the service center address or null to use
* the current default SMSC
* @param text the body of the message to send
@@ -977,13 +1021,65 @@
* broadcast when the message is successfully sent, or failed.
* The result code will be <code>Activity.RESULT_OK<code> for success,
* or one of these errors:<br>
- * <code>RESULT_ERROR_GENERIC_FAILURE</code><br>
- * <code>RESULT_ERROR_RADIO_OFF</code><br>
- * <code>RESULT_ERROR_NULL_PDU</code><br>
- * <code>RESULT_ERROR_NO_SERVICE</code><br>.
- * For <code>RESULT_ERROR_GENERIC_FAILURE</code> the sentIntent may include
- * the extra "errorCode" containing a radio technology specific value,
- * generally only useful for troubleshooting.<br>
+ * <code>SmsManager.RESULT_ERROR_GENERIC_FAILURE</code><br>
+ * <code>SmsManager.RESULT_ERROR_RADIO_OFF</code><br>
+ * <code>SmsManager.RESULT_ERROR_NULL_PDU</code><br>
+ * <code>SmsManager.RESULT_ERROR_NO_SERVICE</code><br>
+ * <code>SmsManager.RESULT_ERROR_LIMIT_EXCEEDED</code><br>
+ * <code>SmsManager.RESULT_ERROR_FDN_CHECK_FAILURE</code><br>
+ * <code>SmsManager.RESULT_ERROR_SHORT_CODE_NOT_ALLOWED</code><br>
+ * <code>SmsManager.RESULT_ERROR_SHORT_CODE_NEVER_ALLOWED</code><br>
+ * <code>SmsManager.RESULT_RADIO_NOT_AVAILABLE</code><br>
+ * <code>SmsManager.RESULT_NETWORK_REJECT</code><br>
+ * <code>SmsManager.RESULT_INVALID_ARGUMENTS</code><br>
+ * <code>SmsManager.RESULT_INVALID_STATE</code><br>
+ * <code>SmsManager.RESULT_NO_MEMORY</code><br>
+ * <code>SmsManager.RESULT_INVALID_SMS_FORMAT</code><br>
+ * <code>SmsManager.RESULT_SYSTEM_ERROR</code><br>
+ * <code>SmsManager.RESULT_MODEM_ERROR</code><br>
+ * <code>SmsManager.RESULT_NETWORK_ERROR</code><br>
+ * <code>SmsManager.RESULT_ENCODING_ERROR</code><br>
+ * <code>SmsManager.RESULT_INVALID_SMSC_ADDRESS</code><br>
+ * <code>SmsManager.RESULT_OPERATION_NOT_ALLOWED</code><br>
+ * <code>SmsManager.RESULT_INTERNAL_ERROR</code><br>
+ * <code>SmsManager.RESULT_NO_RESOURCES</code><br>
+ * <code>SmsManager.RESULT_CANCELLED</code><br>
+ * <code>SmsManager.RESULT_REQUEST_NOT_SUPPORTED</code><br>
+ * <code>SmsManager.RESULT_NO_BLUETOOTH_SERVICE</code><br>
+ * <code>SmsManager.RESULT_INVALID_BLUETOOTH_ADDRESS</code><br>
+ * <code>SmsManager.RESULT_BLUETOOTH_DISCONNECTED</code><br>
+ * <code>SmsManager.RESULT_UNEXPECTED_EVENT_STOP_SENDING</code><br>
+ * <code>SmsManager.RESULT_SMS_BLOCKED_DURING_EMERGENCY</code><br>
+ * <code>SmsManager.RESULT_SMS_SEND_RETRY_FAILED</code><br>
+ * <code>SmsManager.RESULT_REMOTE_EXCEPTION</code><br>
+ * <code>SmsManager.RESULT_NO_DEFAULT_SMS_APP</code><br>
+ * <code>SmsManager.RESULT_RIL_RADIO_NOT_AVAILABLE</code><br>
+ * <code>SmsManager.RESULT_RIL_SMS_SEND_FAIL_RETRY</code><br>
+ * <code>SmsManager.RESULT_RIL_NETWORK_REJECT</code><br>
+ * <code>SmsManager.RESULT_RIL_INVALID_STATE</code><br>
+ * <code>SmsManager.RESULT_RIL_INVALID_ARGUMENTS</code><br>
+ * <code>SmsManager.RESULT_RIL_NO_MEMORY</code><br>
+ * <code>SmsManager.RESULT_RIL_REQUEST_RATE_LIMITED</code><br>
+ * <code>SmsManager.RESULT_RIL_INVALID_SMS_FORMAT</code><br>
+ * <code>SmsManager.RESULT_RIL_SYSTEM_ERR</code><br>
+ * <code>SmsManager.RESULT_RIL_ENCODING_ERR</code><br>
+ * <code>SmsManager.RESULT_RIL_INVALID_SMSC_ADDRESS</code><br>
+ * <code>SmsManager.RESULT_RIL_MODEM_ERR</code><br>
+ * <code>SmsManager.RESULT_RIL_NETWORK_ERR</code><br>
+ * <code>SmsManager.RESULT_RIL_INTERNAL_ERR</code><br>
+ * <code>SmsManager.RESULT_RIL_REQUEST_NOT_SUPPORTED</code><br>
+ * <code>SmsManager.RESULT_RIL_INVALID_MODEM_STATE</code><br>
+ * <code>SmsManager.RESULT_RIL_NETWORK_NOT_READY</code><br>
+ * <code>SmsManager.RESULT_RIL_OPERATION_NOT_ALLOWED</code><br>
+ * <code>SmsManager.RESULT_RIL_NO_RESOURCES</code><br>
+ * <code>SmsManager.RESULT_RIL_CANCELLED</code><br>
+ * <code>SmsManager.RESULT_RIL_SIM_ABSENT</code><br>
+ * <code>SmsManager.RESULT_RIL_SIMULTANEOUS_SMS_AND_CALL_NOT_ALLOWED</code><br>
+ * <code>SmsManager.RESULT_RIL_ACCESS_BARRED</code><br>
+ * <code>SmsManager.RESULT_RIL_BLOCKED_DUE_TO_CALL</code><br>
+ * For <code>SmsManager.RESULT_ERROR_GENERIC_FAILURE</code> or any of the RESULT_RIL errors,
+ * the sentIntent may include the extra "errorCode" containing a radio technology specific
+ * value, generally only useful for troubleshooting.<br>
* The per-application based SMS control checks sentIntent. If sentIntent
* is NULL the caller will be checked against all unknown applications,
* which cause smaller number of SMS to be sent in checking period.
@@ -992,7 +1088,7 @@
* @param messageUri optional URI of the message if it is already stored in the system
* @param callingPkg the calling package name
* @param persistMessage whether to save the sent message into SMS DB for a
- * non-default SMS app.
+ * non-default SMS app.
*
* @param priority Priority level of the message
* Refer specification See 3GPP2 C.S0015-B, v2.0, table 4.5.9-1
@@ -1041,7 +1137,7 @@
private void triggerSentIntentForFailure(PendingIntent sentIntent) {
if (sentIntent != null) {
try {
- sentIntent.send(RESULT_ERROR_GENERIC_FAILURE);
+ sentIntent.send(SmsManager.RESULT_ERROR_GENERIC_FAILURE);
} catch (CanceledException ex) {
Rlog.e(TAG, "Intent has been canceled!");
}
@@ -1096,27 +1192,83 @@
/**
* Send a multi-part text based SMS.
- * @param destAddr the address to send the message to
+ *
+ * @param destAddr the address to send the message to
* @param scAddr is the service center address or null to use
- * the current default SMSC
+ * the current default SMSC
* @param parts an <code>ArrayList</code> of strings that, in order,
- * comprise the original message
+ * comprise the original message
* @param sentIntents if not null, an <code>ArrayList</code> of
- * <code>PendingIntent</code>s (one for each message part) that is
- * broadcast when the corresponding message part has been sent.
- * The result code will be <code>Activity.RESULT_OK<code> for success,
- * or one of these errors:
- * <code>RESULT_ERROR_GENERIC_FAILURE</code>
- * <code>RESULT_ERROR_RADIO_OFF</code>
- * <code>RESULT_ERROR_NULL_PDU</code>
- * <code>RESULT_ERROR_NO_SERVICE</code>.
+ * <code>PendingIntent</code>s (one for each message part) that is
+ * broadcast when the corresponding message part has been sent.
+ * The result code will be <code>Activity.RESULT_OK<code> for success,
+ * or one of these errors:
+ * <code>SmsManager.RESULT_ERROR_GENERIC_FAILURE</code><br>
+ * <code>SmsManager.RESULT_ERROR_RADIO_OFF</code><br>
+ * <code>SmsManager.RESULT_ERROR_NULL_PDU</code><br>
+ * <code>SmsManager.RESULT_ERROR_NO_SERVICE</code><br>
+ * <code>SmsManager.RESULT_ERROR_LIMIT_EXCEEDED</code><br>
+ * <code>SmsManager.RESULT_ERROR_FDN_CHECK_FAILURE</code><br>
+ * <code>SmsManager.RESULT_ERROR_SHORT_CODE_NOT_ALLOWED</code><br>
+ * <code>SmsManager.RESULT_ERROR_SHORT_CODE_NEVER_ALLOWED</code><br>
+ * <code>SmsManager.RESULT_RADIO_NOT_AVAILABLE</code><br>
+ * <code>SmsManager.RESULT_NETWORK_REJECT</code><br>
+ * <code>SmsManager.RESULT_INVALID_ARGUMENTS</code><br>
+ * <code>SmsManager.RESULT_INVALID_STATE</code><br>
+ * <code>SmsManager.RESULT_NO_MEMORY</code><br>
+ * <code>SmsManager.RESULT_INVALID_SMS_FORMAT</code><br>
+ * <code>SmsManager.RESULT_SYSTEM_ERROR</code><br>
+ * <code>SmsManager.RESULT_MODEM_ERROR</code><br>
+ * <code>SmsManager.RESULT_NETWORK_ERROR</code><br>
+ * <code>SmsManager.RESULT_ENCODING_ERROR</code><br>
+ * <code>SmsManager.RESULT_INVALID_SMSC_ADDRESS</code><br>
+ * <code>SmsManager.RESULT_OPERATION_NOT_ALLOWED</code><br>
+ * <code>SmsManager.RESULT_INTERNAL_ERROR</code><br>
+ * <code>SmsManager.RESULT_NO_RESOURCES</code><br>
+ * <code>SmsManager.RESULT_CANCELLED</code><br>
+ * <code>SmsManager.RESULT_REQUEST_NOT_SUPPORTED</code><br>
+ * <code>SmsManager.RESULT_NO_BLUETOOTH_SERVICE</code><br>
+ * <code>SmsManager.RESULT_INVALID_BLUETOOTH_ADDRESS</code><br>
+ * <code>SmsManager.RESULT_BLUETOOTH_DISCONNECTED</code><br>
+ * <code>SmsManager.RESULT_UNEXPECTED_EVENT_STOP_SENDING</code><br>
+ * <code>SmsManager.RESULT_SMS_BLOCKED_DURING_EMERGENCY</code><br>
+ * <code>SmsManager.RESULT_SMS_SEND_RETRY_FAILED</code><br>
+ * <code>SmsManager.RESULT_REMOTE_EXCEPTION</code><br>
+ * <code>SmsManager.RESULT_NO_DEFAULT_SMS_APP</code><br>
+ * <code>SmsManager.RESULT_RIL_RADIO_NOT_AVAILABLE</code><br>
+ * <code>SmsManager.RESULT_RIL_SMS_SEND_FAIL_RETRY</code><br>
+ * <code>SmsManager.RESULT_RIL_NETWORK_REJECT</code><br>
+ * <code>SmsManager.RESULT_RIL_INVALID_STATE</code><br>
+ * <code>SmsManager.RESULT_RIL_INVALID_ARGUMENTS</code><br>
+ * <code>SmsManager.RESULT_RIL_NO_MEMORY</code><br>
+ * <code>SmsManager.RESULT_RIL_REQUEST_RATE_LIMITED</code><br>
+ * <code>SmsManager.RESULT_RIL_INVALID_SMS_FORMAT</code><br>
+ * <code>SmsManager.RESULT_RIL_SYSTEM_ERR</code><br>
+ * <code>SmsManager.RESULT_RIL_ENCODING_ERR</code><br>
+ * <code>SmsManager.RESULT_RIL_INVALID_SMSC_ADDRESS</code><br>
+ * <code>SmsManager.RESULT_RIL_MODEM_ERR</code><br>
+ * <code>SmsManager.RESULT_RIL_NETWORK_ERR</code><br>
+ * <code>SmsManager.RESULT_RIL_INTERNAL_ERR</code><br>
+ * <code>SmsManager.RESULT_RIL_REQUEST_NOT_SUPPORTED</code><br>
+ * <code>SmsManager.RESULT_RIL_INVALID_MODEM_STATE</code><br>
+ * <code>SmsManager.RESULT_RIL_NETWORK_NOT_READY</code><br>
+ * <code>SmsManager.RESULT_RIL_OPERATION_NOT_ALLOWED</code><br>
+ * <code>SmsManager.RESULT_RIL_NO_RESOURCES</code><br>
+ * <code>SmsManager.RESULT_RIL_CANCELLED</code><br>
+ * <code>SmsManager.RESULT_RIL_SIM_ABSENT</code><br>
+ * <code>SmsManager.RESULT_RIL_SIMULTANEOUS_SMS_AND_CALL_NOT_ALLOWED</code><br>
+ * <code>SmsManager.RESULT_RIL_ACCESS_BARRED</code><br>
+ * <code>SmsManager.RESULT_RIL_BLOCKED_DUE_TO_CALL</code><br>
+ * For <code>SmsManager.RESULT_ERROR_GENERIC_FAILURE</code> or any of the RESULT_RIL errors,
+ * the sentIntent may include the extra "errorCode" containing a radio technology specific
+ * value, generally only useful for troubleshooting.<br>
* The per-application based SMS control checks sentIntent. If sentIntent
* is NULL the caller will be checked against all unknown applications,
* which cause smaller number of SMS to be sent in checking period.
* @param deliveryIntents if not null, an <code>ArrayList</code> of
- * <code>PendingIntent</code>s (one for each message part) that is
- * broadcast when the corresponding message part has been delivered
- * to the recipient. The raw pdu of the status report is in the
+ * <code>PendingIntent</code>s (one for each message part) that is
+ * broadcast when the corresponding message part has been delivered
+ * to the recipient. The raw pdu of the status report is in the
* @param messageUri optional URI of the message if it is already stored in the system
* @param callingPkg the calling package name
* @param persistMessage whether to save the sent message into SMS DB for a
@@ -1303,6 +1455,7 @@
/**
* Send a single or a multi-part SMS
+ *
* @param trackers each tracker will contain:
* -smsc the SMSC to send the message through, or NULL for the
* default SMSC
@@ -1311,10 +1464,65 @@
* broadcast when the message is successfully sent, or failed.
* The result code will be <code>Activity.RESULT_OK<code> for success,
* or one of these errors:
- * <code>RESULT_ERROR_GENERIC_FAILURE</code>
- * <code>RESULT_ERROR_RADIO_OFF</code>
- * <code>RESULT_ERROR_NULL_PDU</code>
- * <code>RESULT_ERROR_NO_SERVICE</code>.
+ * <code>SmsManager.RESULT_ERROR_GENERIC_FAILURE</code><br>
+ * <code>SmsManager.RESULT_ERROR_RADIO_OFF</code><br>
+ * <code>SmsManager.RESULT_ERROR_NULL_PDU</code><br>
+ * <code>SmsManager.RESULT_ERROR_NO_SERVICE</code><br>
+ * <code>SmsManager.RESULT_ERROR_LIMIT_EXCEEDED</code><br>
+ * <code>SmsManager.RESULT_ERROR_FDN_CHECK_FAILURE</code><br>
+ * <code>SmsManager.RESULT_ERROR_SHORT_CODE_NOT_ALLOWED</code><br>
+ * <code>SmsManager.RESULT_ERROR_SHORT_CODE_NEVER_ALLOWED</code><br>
+ * <code>SmsManager.RESULT_RADIO_NOT_AVAILABLE</code><br>
+ * <code>SmsManager.RESULT_NETWORK_REJECT</code><br>
+ * <code>SmsManager.RESULT_INVALID_ARGUMENTS</code><br>
+ * <code>SmsManager.RESULT_INVALID_STATE</code><br>
+ * <code>SmsManager.RESULT_NO_MEMORY</code><br>
+ * <code>SmsManager.RESULT_INVALID_SMS_FORMAT</code><br>
+ * <code>SmsManager.RESULT_SYSTEM_ERROR</code><br>
+ * <code>SmsManager.RESULT_MODEM_ERROR</code><br>
+ * <code>SmsManager.RESULT_NETWORK_ERROR</code><br>
+ * <code>SmsManager.RESULT_ENCODING_ERROR</code><br>
+ * <code>SmsManager.RESULT_INVALID_SMSC_ADDRESS</code><br>
+ * <code>SmsManager.RESULT_OPERATION_NOT_ALLOWED</code><br>
+ * <code>SmsManager.RESULT_INTERNAL_ERROR</code><br>
+ * <code>SmsManager.RESULT_NO_RESOURCES</code><br>
+ * <code>SmsManager.RESULT_CANCELLED</code><br>
+ * <code>SmsManager.RESULT_REQUEST_NOT_SUPPORTED</code><br>
+ * <code>SmsManager.RESULT_NO_BLUETOOTH_SERVICE</code><br>
+ * <code>SmsManager.RESULT_INVALID_BLUETOOTH_ADDRESS</code><br>
+ * <code>SmsManager.RESULT_BLUETOOTH_DISCONNECTED</code><br>
+ * <code>SmsManager.RESULT_UNEXPECTED_EVENT_STOP_SENDING</code><br>
+ * <code>SmsManager.RESULT_SMS_BLOCKED_DURING_EMERGENCY</code><br>
+ * <code>SmsManager.RESULT_SMS_SEND_RETRY_FAILED</code><br>
+ * <code>SmsManager.RESULT_REMOTE_EXCEPTION</code><br>
+ * <code>SmsManager.RESULT_NO_DEFAULT_SMS_APP</code><br>
+ * <code>SmsManager.RESULT_RIL_RADIO_NOT_AVAILABLE</code><br>
+ * <code>SmsManager.RESULT_RIL_SMS_SEND_FAIL_RETRY</code><br>
+ * <code>SmsManager.RESULT_RIL_NETWORK_REJECT</code><br>
+ * <code>SmsManager.RESULT_RIL_INVALID_STATE</code><br>
+ * <code>SmsManager.RESULT_RIL_INVALID_ARGUMENTS</code><br>
+ * <code>SmsManager.RESULT_RIL_NO_MEMORY</code><br>
+ * <code>SmsManager.RESULT_RIL_REQUEST_RATE_LIMITED</code><br>
+ * <code>SmsManager.RESULT_RIL_INVALID_SMS_FORMAT</code><br>
+ * <code>SmsManager.RESULT_RIL_SYSTEM_ERR</code><br>
+ * <code>SmsManager.RESULT_RIL_ENCODING_ERR</code><br>
+ * <code>SmsManager.RESULT_RIL_INVALID_SMSC_ADDRESS</code><br>
+ * <code>SmsManager.RESULT_RIL_MODEM_ERR</code><br>
+ * <code>SmsManager.RESULT_RIL_NETWORK_ERR</code><br>
+ * <code>SmsManager.RESULT_RIL_INTERNAL_ERR</code><br>
+ * <code>SmsManager.RESULT_RIL_REQUEST_NOT_SUPPORTED</code><br>
+ * <code>SmsManager.RESULT_RIL_INVALID_MODEM_STATE</code><br>
+ * <code>SmsManager.RESULT_RIL_NETWORK_NOT_READY</code><br>
+ * <code>SmsManager.RESULT_RIL_OPERATION_NOT_ALLOWED</code><br>
+ * <code>SmsManager.RESULT_RIL_NO_RESOURCES</code><br>
+ * <code>SmsManager.RESULT_RIL_CANCELLED</code><br>
+ * <code>SmsManager.RESULT_RIL_SIM_ABSENT</code><br>
+ * <code>SmsManager.RESULT_RIL_SIMULTANEOUS_SMS_AND_CALL_NOT_ALLOWED</code><br>
+ * <code>SmsManager.RESULT_RIL_ACCESS_BARRED</code><br>
+ * <code>SmsManager.RESULT_RIL_BLOCKED_DUE_TO_CALL</code><br>
+ * For <code>SmsManager.RESULT_ERROR_GENERIC_FAILURE</code> or any of the RESULT_RIL errors,
+ * the sentIntent may include the extra "errorCode" containing a radio technology specific
+ * value, generally only useful for troubleshooting.<br>
* The per-application based SMS control checks sentIntent. If sentIntent
* is NULL the caller will be checked against all unknown applications,
* which cause smaller number of SMS to be sent in checking period.
@@ -1325,21 +1533,21 @@
*/
@VisibleForTesting
public void sendRawPdu(SmsTracker[] trackers) {
- @SmsManager.Result int error = RESULT_ERROR_NONE;
+ @SmsManager.Result int error = SmsManager.RESULT_ERROR_NONE;
PackageInfo appInfo = null;
if (mSmsSendDisabled) {
Rlog.e(TAG, "Device does not support sending sms.");
- error = RESULT_ERROR_NO_SERVICE;
+ error = SmsManager.RESULT_ERROR_NO_SERVICE;
} else {
for (SmsTracker tracker : trackers) {
if (tracker.getData().get(MAP_KEY_PDU) == null) {
Rlog.e(TAG, "Empty PDU");
- error = RESULT_ERROR_NULL_PDU;
+ error = SmsManager.RESULT_ERROR_NULL_PDU;
break;
}
}
- if (error == RESULT_ERROR_NONE) {
+ if (error == SmsManager.RESULT_ERROR_NONE) {
UserHandle userHandle = UserHandle.of(trackers[0].mUserId);
PackageManager pm = mContext.createContextAsUser(userHandle, 0).getPackageManager();
@@ -1352,12 +1560,12 @@
} catch (PackageManager.NameNotFoundException e) {
Rlog.e(TAG, "Can't get calling app package info: refusing to send SMS"
+ " id: " + getMultiTrackermessageId(trackers));
- error = RESULT_ERROR_GENERIC_FAILURE;
+ error = SmsManager.RESULT_ERROR_GENERIC_FAILURE;
}
}
}
- if (error != RESULT_ERROR_NONE) {
+ if (error != SmsManager.RESULT_ERROR_NONE) {
handleSmsTrackersFailure(trackers, error, NO_ERROR_CODE);
return;
}
@@ -1496,7 +1704,8 @@
// Deny sending message when the queue limit is reached.
Rlog.e(TAG, "Denied because queue limit reached"
+ " id: " + getMultiTrackermessageId(trackers));
- handleSmsTrackersFailure(trackers, RESULT_ERROR_LIMIT_EXCEEDED, NO_ERROR_CODE);
+ handleSmsTrackersFailure(
+ trackers, SmsManager.RESULT_ERROR_LIMIT_EXCEEDED, NO_ERROR_CODE);
return true;
}
mPendingTrackerCount++;
@@ -1942,11 +2151,11 @@
private void reportAnomaly(int error, int errorCode) {
switch (error) {
// Exclude known failed reason
- case RESULT_ERROR_NO_SERVICE:
- case RESULT_ERROR_RADIO_OFF:
- case RESULT_ERROR_LIMIT_EXCEEDED:
- case RESULT_ERROR_SHORT_CODE_NEVER_ALLOWED:
- case RESULT_ERROR_SHORT_CODE_NOT_ALLOWED:
+ case SmsManager.RESULT_ERROR_NO_SERVICE:
+ case SmsManager.RESULT_ERROR_RADIO_OFF:
+ case SmsManager.RESULT_ERROR_LIMIT_EXCEEDED:
+ case SmsManager.RESULT_ERROR_SHORT_CODE_NEVER_ALLOWED:
+ case SmsManager.RESULT_ERROR_SHORT_CODE_NOT_ALLOWED:
case SmsManager.RESULT_SMS_BLOCKED_DURING_EMERGENCY:
break;
// Dump bugreport for analysis
diff --git a/src/java/com/android/internal/telephony/ServiceStateTracker.java b/src/java/com/android/internal/telephony/ServiceStateTracker.java
index 7c2bf89..66cc005 100755
--- a/src/java/com/android/internal/telephony/ServiceStateTracker.java
+++ b/src/java/com/android/internal/telephony/ServiceStateTracker.java
@@ -1329,8 +1329,10 @@
case EVENT_IMS_STATE_DONE:
ar = (AsyncResult) msg.obj;
if (ar.exception == null) {
- int[] responseArray = (int[])ar.result;
- mImsRegistered = (responseArray[0] == 1) ? true : false;
+ final int[] responseArray = (int[]) ar.result;
+ final boolean imsRegistered = responseArray[0] == 1;
+ mPhone.setImsRegistrationState(imsRegistered);
+ mImsRegistered = imsRegistered;
}
break;
@@ -1854,7 +1856,7 @@
private int[] getBandwidthsFromConfigs(List<PhysicalChannelConfig> list) {
return list.stream()
- .map(PhysicalChannelConfig::getCellBandwidthDownlink)
+ .map(PhysicalChannelConfig::getCellBandwidthDownlinkKhz)
.mapToInt(Integer::intValue)
.toArray();
}
@@ -3051,7 +3053,7 @@
mRadioPowerLog.log(tmpLog);
}
- if (mPhone.isPhoneTypeGsm() && mAlarmSwitch) {
+ if (mAlarmSwitch) {
if(DBG) log("mAlarmSwitch == true");
Context context = mPhone.getContext();
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
@@ -3066,7 +3068,7 @@
} else if ((!mDesiredPowerState || mRadioDisabledByCarrier) && mCi.getRadioState()
== TelephonyManager.RADIO_POWER_ON) {
// If it's on and available and we want it off gracefully
- if (mPhone.isPhoneTypeGsm() && mPowerOffDelayNeed) {
+ if (mPowerOffDelayNeed) {
if (mImsRegistrationOnOff && !mAlarmSwitch) {
if(DBG) log("mImsRegistrationOnOff == true");
Context context = mPhone.getContext();
@@ -3203,15 +3205,25 @@
sendMessage(obtainMessage(EVENT_IMS_SERVICE_STATE_CHANGED));
}
- public void setImsRegistrationState(boolean registered) {
- log("ImsRegistrationState - registered : " + registered);
+ /**
+ * Sets the Ims registration state. If the 3 second shut down timer has begun and the state
+ * is set to unregistered, the timer is cancelled and the radio is shutdown immediately.
+ *
+ * @param registered whether ims is registered
+ */
+ public void setImsRegistrationState(final boolean registered) {
+ log("setImsRegistrationState: {registered=" + registered
+ + " mImsRegistrationOnOff=" + mImsRegistrationOnOff
+ + " mAlarmSwitch=" + mAlarmSwitch
+ + "}");
if (mImsRegistrationOnOff && !registered) {
if (mAlarmSwitch) {
mImsRegistrationOnOff = registered;
- Context context = mPhone.getContext();
- AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
+ final Context context = mPhone.getContext();
+ final AlarmManager am =
+ (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
am.cancel(mRadioOffIntent);
mAlarmSwitch = false;
diff --git a/src/java/com/android/internal/telephony/SmsDispatchersController.java b/src/java/com/android/internal/telephony/SmsDispatchersController.java
index fc3c679..ddaf571 100644
--- a/src/java/com/android/internal/telephony/SmsDispatchersController.java
+++ b/src/java/com/android/internal/telephony/SmsDispatchersController.java
@@ -605,13 +605,65 @@
* broadcast when the message is successfully sent, or failed.
* The result code will be <code>Activity.RESULT_OK<code> for success,
* or one of these errors:<br>
- * <code>RESULT_ERROR_GENERIC_FAILURE</code><br>
- * <code>RESULT_ERROR_RADIO_OFF</code><br>
- * <code>RESULT_ERROR_NULL_PDU</code><br>
- * <code>RESULT_ERROR_NO_SERVICE</code><br>.
- * For <code>RESULT_ERROR_GENERIC_FAILURE</code> the sentIntent may include
- * the extra "errorCode" containing a radio technology specific value,
- * generally only useful for troubleshooting.<br>
+ * <code>SmsManager.RESULT_ERROR_GENERIC_FAILURE</code><br>
+ * <code>SmsManager.RESULT_ERROR_RADIO_OFF</code><br>
+ * <code>SmsManager.RESULT_ERROR_NULL_PDU</code><br>
+ * <code>SmsManager.RESULT_ERROR_NO_SERVICE</code><br>
+ * <code>SmsManager.RESULT_ERROR_LIMIT_EXCEEDED</code><br>
+ * <code>SmsManager.RESULT_ERROR_FDN_CHECK_FAILURE</code><br>
+ * <code>SmsManager.RESULT_ERROR_SHORT_CODE_NOT_ALLOWED</code><br>
+ * <code>SmsManager.RESULT_ERROR_SHORT_CODE_NEVER_ALLOWED</code><br>
+ * <code>SmsManager.RESULT_RADIO_NOT_AVAILABLE</code><br>
+ * <code>SmsManager.RESULT_NETWORK_REJECT</code><br>
+ * <code>SmsManager.RESULT_INVALID_ARGUMENTS</code><br>
+ * <code>SmsManager.RESULT_INVALID_STATE</code><br>
+ * <code>SmsManager.RESULT_NO_MEMORY</code><br>
+ * <code>SmsManager.RESULT_INVALID_SMS_FORMAT</code><br>
+ * <code>SmsManager.RESULT_SYSTEM_ERROR</code><br>
+ * <code>SmsManager.RESULT_MODEM_ERROR</code><br>
+ * <code>SmsManager.RESULT_NETWORK_ERROR</code><br>
+ * <code>SmsManager.RESULT_ENCODING_ERROR</code><br>
+ * <code>SmsManager.RESULT_INVALID_SMSC_ADDRESS</code><br>
+ * <code>SmsManager.RESULT_OPERATION_NOT_ALLOWED</code><br>
+ * <code>SmsManager.RESULT_INTERNAL_ERROR</code><br>
+ * <code>SmsManager.RESULT_NO_RESOURCES</code><br>
+ * <code>SmsManager.RESULT_CANCELLED</code><br>
+ * <code>SmsManager.RESULT_REQUEST_NOT_SUPPORTED</code><br>
+ * <code>SmsManager.RESULT_NO_BLUETOOTH_SERVICE</code><br>
+ * <code>SmsManager.RESULT_INVALID_BLUETOOTH_ADDRESS</code><br>
+ * <code>SmsManager.RESULT_BLUETOOTH_DISCONNECTED</code><br>
+ * <code>SmsManager.RESULT_UNEXPECTED_EVENT_STOP_SENDING</code><br>
+ * <code>SmsManager.RESULT_SMS_BLOCKED_DURING_EMERGENCY</code><br>
+ * <code>SmsManager.RESULT_SMS_SEND_RETRY_FAILED</code><br>
+ * <code>SmsManager.RESULT_REMOTE_EXCEPTION</code><br>
+ * <code>SmsManager.RESULT_NO_DEFAULT_SMS_APP</code><br>
+ * <code>SmsManager.RESULT_RIL_RADIO_NOT_AVAILABLE</code><br>
+ * <code>SmsManager.RESULT_RIL_SMS_SEND_FAIL_RETRY</code><br>
+ * <code>SmsManager.RESULT_RIL_NETWORK_REJECT</code><br>
+ * <code>SmsManager.RESULT_RIL_INVALID_STATE</code><br>
+ * <code>SmsManager.RESULT_RIL_INVALID_ARGUMENTS</code><br>
+ * <code>SmsManager.RESULT_RIL_NO_MEMORY</code><br>
+ * <code>SmsManager.RESULT_RIL_REQUEST_RATE_LIMITED</code><br>
+ * <code>SmsManager.RESULT_RIL_INVALID_SMS_FORMAT</code><br>
+ * <code>SmsManager.RESULT_RIL_SYSTEM_ERR</code><br>
+ * <code>SmsManager.RESULT_RIL_ENCODING_ERR</code><br>
+ * <code>SmsManager.RESULT_RIL_INVALID_SMSC_ADDRESS</code><br>
+ * <code>SmsManager.RESULT_RIL_MODEM_ERR</code><br>
+ * <code>SmsManager.RESULT_RIL_NETWORK_ERR</code><br>
+ * <code>SmsManager.RESULT_RIL_INTERNAL_ERR</code><br>
+ * <code>SmsManager.RESULT_RIL_REQUEST_NOT_SUPPORTED</code><br>
+ * <code>SmsManager.RESULT_RIL_INVALID_MODEM_STATE</code><br>
+ * <code>SmsManager.RESULT_RIL_NETWORK_NOT_READY</code><br>
+ * <code>SmsManager.RESULT_RIL_OPERATION_NOT_ALLOWED</code><br>
+ * <code>SmsManager.RESULT_RIL_NO_RESOURCES</code><br>
+ * <code>SmsManager.RESULT_RIL_CANCELLED</code><br>
+ * <code>SmsManager.RESULT_RIL_SIM_ABSENT</code><br>
+ * <code>SmsManager.RESULT_RIL_SIMULTANEOUS_SMS_AND_CALL_NOT_ALLOWED</code><br>
+ * <code>SmsManager.RESULT_RIL_ACCESS_BARRED</code><br>
+ * <code>SmsManager.RESULT_RIL_BLOCKED_DUE_TO_CALL</code><br>
+ * For <code>SmsManager.RESULT_ERROR_GENERIC_FAILURE</code> or any of the RESULT_RIL errors,
+ * the sentIntent may include the extra "errorCode" containing a radio technology specific
+ * value, generally only useful for troubleshooting.<br>
* The per-application based SMS control checks sentIntent. If sentIntent
* is NULL the caller will be checked against all unknown applications,
* which cause smaller number of SMS to be sent in checking period.
@@ -635,7 +687,8 @@
/**
* Send a text based SMS.
- * @param destAddr the address to send the message to
+ *
+ * @param destAddr the address to send the message to
* @param scAddr is the service center address or null to use
* the current default SMSC
* @param text the body of the message to send
@@ -643,13 +696,65 @@
* broadcast when the message is successfully sent, or failed.
* The result code will be <code>Activity.RESULT_OK<code> for success,
* or one of these errors:<br>
- * <code>RESULT_ERROR_GENERIC_FAILURE</code><br>
- * <code>RESULT_ERROR_RADIO_OFF</code><br>
- * <code>RESULT_ERROR_NULL_PDU</code><br>
- * <code>RESULT_ERROR_NO_SERVICE</code><br>.
- * For <code>RESULT_ERROR_GENERIC_FAILURE</code> the sentIntent may include
- * the extra "errorCode" containing a radio technology specific value,
- * generally only useful for troubleshooting.<br>
+ * <code>SmsManager.RESULT_ERROR_GENERIC_FAILURE</code><br>
+ * <code>SmsManager.RESULT_ERROR_RADIO_OFF</code><br>
+ * <code>SmsManager.RESULT_ERROR_NULL_PDU</code><br>
+ * <code>SmsManager.RESULT_ERROR_NO_SERVICE</code><br>
+ * <code>SmsManager.RESULT_ERROR_LIMIT_EXCEEDED</code><br>
+ * <code>SmsManager.RESULT_ERROR_FDN_CHECK_FAILURE</code><br>
+ * <code>SmsManager.RESULT_ERROR_SHORT_CODE_NOT_ALLOWED</code><br>
+ * <code>SmsManager.RESULT_ERROR_SHORT_CODE_NEVER_ALLOWED</code><br>
+ * <code>SmsManager.RESULT_RADIO_NOT_AVAILABLE</code><br>
+ * <code>SmsManager.RESULT_NETWORK_REJECT</code><br>
+ * <code>SmsManager.RESULT_INVALID_ARGUMENTS</code><br>
+ * <code>SmsManager.RESULT_INVALID_STATE</code><br>
+ * <code>SmsManager.RESULT_NO_MEMORY</code><br>
+ * <code>SmsManager.RESULT_INVALID_SMS_FORMAT</code><br>
+ * <code>SmsManager.RESULT_SYSTEM_ERROR</code><br>
+ * <code>SmsManager.RESULT_MODEM_ERROR</code><br>
+ * <code>SmsManager.RESULT_NETWORK_ERROR</code><br>
+ * <code>SmsManager.RESULT_ENCODING_ERROR</code><br>
+ * <code>SmsManager.RESULT_INVALID_SMSC_ADDRESS</code><br>
+ * <code>SmsManager.RESULT_OPERATION_NOT_ALLOWED</code><br>
+ * <code>SmsManager.RESULT_INTERNAL_ERROR</code><br>
+ * <code>SmsManager.RESULT_NO_RESOURCES</code><br>
+ * <code>SmsManager.RESULT_CANCELLED</code><br>
+ * <code>SmsManager.RESULT_REQUEST_NOT_SUPPORTED</code><br>
+ * <code>SmsManager.RESULT_NO_BLUETOOTH_SERVICE</code><br>
+ * <code>SmsManager.RESULT_INVALID_BLUETOOTH_ADDRESS</code><br>
+ * <code>SmsManager.RESULT_BLUETOOTH_DISCONNECTED</code><br>
+ * <code>SmsManager.RESULT_UNEXPECTED_EVENT_STOP_SENDING</code><br>
+ * <code>SmsManager.RESULT_SMS_BLOCKED_DURING_EMERGENCY</code><br>
+ * <code>SmsManager.RESULT_SMS_SEND_RETRY_FAILED</code><br>
+ * <code>SmsManager.RESULT_REMOTE_EXCEPTION</code><br>
+ * <code>SmsManager.RESULT_NO_DEFAULT_SMS_APP</code><br>
+ * <code>SmsManager.RESULT_RIL_RADIO_NOT_AVAILABLE</code><br>
+ * <code>SmsManager.RESULT_RIL_SMS_SEND_FAIL_RETRY</code><br>
+ * <code>SmsManager.RESULT_RIL_NETWORK_REJECT</code><br>
+ * <code>SmsManager.RESULT_RIL_INVALID_STATE</code><br>
+ * <code>SmsManager.RESULT_RIL_INVALID_ARGUMENTS</code><br>
+ * <code>SmsManager.RESULT_RIL_NO_MEMORY</code><br>
+ * <code>SmsManager.RESULT_RIL_REQUEST_RATE_LIMITED</code><br>
+ * <code>SmsManager.RESULT_RIL_INVALID_SMS_FORMAT</code><br>
+ * <code>SmsManager.RESULT_RIL_SYSTEM_ERR</code><br>
+ * <code>SmsManager.RESULT_RIL_ENCODING_ERR</code><br>
+ * <code>SmsManager.RESULT_RIL_INVALID_SMSC_ADDRESS</code><br>
+ * <code>SmsManager.RESULT_RIL_MODEM_ERR</code><br>
+ * <code>SmsManager.RESULT_RIL_NETWORK_ERR</code><br>
+ * <code>SmsManager.RESULT_RIL_INTERNAL_ERR</code><br>
+ * <code>SmsManager.RESULT_RIL_REQUEST_NOT_SUPPORTED</code><br>
+ * <code>SmsManager.RESULT_RIL_INVALID_MODEM_STATE</code><br>
+ * <code>SmsManager.RESULT_RIL_NETWORK_NOT_READY</code><br>
+ * <code>SmsManager.RESULT_RIL_OPERATION_NOT_ALLOWED</code><br>
+ * <code>SmsManager.RESULT_RIL_NO_RESOURCES</code><br>
+ * <code>SmsManager.RESULT_RIL_CANCELLED</code><br>
+ * <code>SmsManager.RESULT_RIL_SIM_ABSENT</code><br>
+ * <code>SmsManager.RESULT_RIL_SIMULTANEOUS_SMS_AND_CALL_NOT_ALLOWED</code><br>
+ * <code>SmsManager.RESULT_RIL_ACCESS_BARRED</code><br>
+ * <code>SmsManager.RESULT_RIL_BLOCKED_DUE_TO_CALL</code><br>
+ * For <code>SmsManager.RESULT_ERROR_GENERIC_FAILURE</code> or any of the RESULT_RIL errors,
+ * the sentIntent may include the extra "errorCode" containing a radio technology specific
+ * value, generally only useful for troubleshooting.<br>
* The per-application based SMS control checks sentIntent. If sentIntent
* is NULL the caller will be checked against all unknown applications,
* which cause smaller number of SMS to be sent in checking period.
@@ -658,7 +763,7 @@
* @param messageUri optional URI of the message if it is already stored in the system
* @param callingPkg the calling package name
* @param persistMessage whether to save the sent message into SMS DB for a
- * non-default SMS app.
+ * non-default SMS app.
* @param priority Priority level of the message
* Refer specification See 3GPP2 C.S0015-B, v2.0, table 4.5.9-1
* ---------------------------------
@@ -701,31 +806,87 @@
/**
* Send a multi-part text based SMS.
- * @param destAddr the address to send the message to
+ *
+ * @param destAddr the address to send the message to
* @param scAddr is the service center address or null to use
- * the current default SMSC
+ * the current default SMSC
* @param parts an <code>ArrayList</code> of strings that, in order,
- * comprise the original message
+ * comprise the original message
* @param sentIntents if not null, an <code>ArrayList</code> of
- * <code>PendingIntent</code>s (one for each message part) that is
- * broadcast when the corresponding message part has been sent.
- * The result code will be <code>Activity.RESULT_OK<code> for success,
- * or one of these errors:
- * <code>RESULT_ERROR_GENERIC_FAILURE</code>
- * <code>RESULT_ERROR_RADIO_OFF</code>
- * <code>RESULT_ERROR_NULL_PDU</code>
- * <code>RESULT_ERROR_NO_SERVICE</code>.
+ * <code>PendingIntent</code>s (one for each message part) that is
+ * broadcast when the corresponding message part has been sent.
+ * The result code will be <code>Activity.RESULT_OK<code> for success,
+ * or one of these errors:<br>
+ * <code>SmsManager.RESULT_ERROR_GENERIC_FAILURE</code><br>
+ * <code>SmsManager.RESULT_ERROR_RADIO_OFF</code><br>
+ * <code>SmsManager.RESULT_ERROR_NULL_PDU</code><br>
+ * <code>SmsManager.RESULT_ERROR_NO_SERVICE</code><br>
+ * <code>SmsManager.RESULT_ERROR_LIMIT_EXCEEDED</code><br>
+ * <code>SmsManager.RESULT_ERROR_FDN_CHECK_FAILURE</code><br>
+ * <code>SmsManager.RESULT_ERROR_SHORT_CODE_NOT_ALLOWED</code><br>
+ * <code>SmsManager.RESULT_ERROR_SHORT_CODE_NEVER_ALLOWED</code><br>
+ * <code>SmsManager.RESULT_RADIO_NOT_AVAILABLE</code><br>
+ * <code>SmsManager.RESULT_NETWORK_REJECT</code><br>
+ * <code>SmsManager.RESULT_INVALID_ARGUMENTS</code><br>
+ * <code>SmsManager.RESULT_INVALID_STATE</code><br>
+ * <code>SmsManager.RESULT_NO_MEMORY</code><br>
+ * <code>SmsManager.RESULT_INVALID_SMS_FORMAT</code><br>
+ * <code>SmsManager.RESULT_SYSTEM_ERROR</code><br>
+ * <code>SmsManager.RESULT_MODEM_ERROR</code><br>
+ * <code>SmsManager.RESULT_NETWORK_ERROR</code><br>
+ * <code>SmsManager.RESULT_ENCODING_ERROR</code><br>
+ * <code>SmsManager.RESULT_INVALID_SMSC_ADDRESS</code><br>
+ * <code>SmsManager.RESULT_OPERATION_NOT_ALLOWED</code><br>
+ * <code>SmsManager.RESULT_INTERNAL_ERROR</code><br>
+ * <code>SmsManager.RESULT_NO_RESOURCES</code><br>
+ * <code>SmsManager.RESULT_CANCELLED</code><br>
+ * <code>SmsManager.RESULT_REQUEST_NOT_SUPPORTED</code><br>
+ * <code>SmsManager.RESULT_NO_BLUETOOTH_SERVICE</code><br>
+ * <code>SmsManager.RESULT_INVALID_BLUETOOTH_ADDRESS</code><br>
+ * <code>SmsManager.RESULT_BLUETOOTH_DISCONNECTED</code><br>
+ * <code>SmsManager.RESULT_UNEXPECTED_EVENT_STOP_SENDING</code><br>
+ * <code>SmsManager.RESULT_SMS_BLOCKED_DURING_EMERGENCY</code><br>
+ * <code>SmsManager.RESULT_SMS_SEND_RETRY_FAILED</code><br>
+ * <code>SmsManager.RESULT_REMOTE_EXCEPTION</code><br>
+ * <code>SmsManager.RESULT_NO_DEFAULT_SMS_APP</code><br>
+ * <code>SmsManager.RESULT_RIL_RADIO_NOT_AVAILABLE</code><br>
+ * <code>SmsManager.RESULT_RIL_SMS_SEND_FAIL_RETRY</code><br>
+ * <code>SmsManager.RESULT_RIL_NETWORK_REJECT</code><br>
+ * <code>SmsManager.RESULT_RIL_INVALID_STATE</code><br>
+ * <code>SmsManager.RESULT_RIL_INVALID_ARGUMENTS</code><br>
+ * <code>SmsManager.RESULT_RIL_NO_MEMORY</code><br>
+ * <code>SmsManager.RESULT_RIL_REQUEST_RATE_LIMITED</code><br>
+ * <code>SmsManager.RESULT_RIL_INVALID_SMS_FORMAT</code><br>
+ * <code>SmsManager.RESULT_RIL_SYSTEM_ERR</code><br>
+ * <code>SmsManager.RESULT_RIL_ENCODING_ERR</code><br>
+ * <code>SmsManager.RESULT_RIL_INVALID_SMSC_ADDRESS</code><br>
+ * <code>SmsManager.RESULT_RIL_MODEM_ERR</code><br>
+ * <code>SmsManager.RESULT_RIL_NETWORK_ERR</code><br>
+ * <code>SmsManager.RESULT_RIL_INTERNAL_ERR</code><br>
+ * <code>SmsManager.RESULT_RIL_REQUEST_NOT_SUPPORTED</code><br>
+ * <code>SmsManager.RESULT_RIL_INVALID_MODEM_STATE</code><br>
+ * <code>SmsManager.RESULT_RIL_NETWORK_NOT_READY</code><br>
+ * <code>SmsManager.RESULT_RIL_OPERATION_NOT_ALLOWED</code><br>
+ * <code>SmsManager.RESULT_RIL_NO_RESOURCES</code><br>
+ * <code>SmsManager.RESULT_RIL_CANCELLED</code><br>
+ * <code>SmsManager.RESULT_RIL_SIM_ABSENT</code><br>
+ * <code>SmsManager.RESULT_RIL_SIMULTANEOUS_SMS_AND_CALL_NOT_ALLOWED</code><br>
+ * <code>SmsManager.RESULT_RIL_ACCESS_BARRED</code><br>
+ * <code>SmsManager.RESULT_RIL_BLOCKED_DUE_TO_CALL</code><br>
+ * For <code>SmsManager.RESULT_ERROR_GENERIC_FAILURE</code> or any of the RESULT_RIL errors,
+ * the sentIntent may include the extra "errorCode" containing a radio technology specific
+ * value, generally only useful for troubleshooting.<br>
* The per-application based SMS control checks sentIntent. If sentIntent
* is NULL the caller will be checked against all unknown applications,
* which cause smaller number of SMS to be sent in checking period.
* @param deliveryIntents if not null, an <code>ArrayList</code> of
- * <code>PendingIntent</code>s (one for each message part) that is
- * broadcast when the corresponding message part has been delivered
- * to the recipient. The raw pdu of the status report is in the
+ * <code>PendingIntent</code>s (one for each message part) that is
+ * broadcast when the corresponding message part has been delivered
+ * to the recipient. The raw pdu of the status report is in the
* @param messageUri optional URI of the message if it is already stored in the system
* @param callingPkg the calling package name
* @param persistMessage whether to save the sent message into SMS DB for a
- * non-default SMS app.
+ * non-default SMS app.
* @param priority Priority level of the message
* Refer specification See 3GPP2 C.S0015-B, v2.0, table 4.5.9-1
* ---------------------------------
diff --git a/src/java/com/android/internal/telephony/imsphone/ImsPhone.java b/src/java/com/android/internal/telephony/imsphone/ImsPhone.java
index dca68a0..b9f4a64 100644
--- a/src/java/com/android/internal/telephony/imsphone/ImsPhone.java
+++ b/src/java/com/android/internal/telephony/imsphone/ImsPhone.java
@@ -2100,11 +2100,6 @@
RegistrationManager.REGISTRATION_STATE_NOT_REGISTERED);
}
- public void setImsRegistrationState(@RegistrationManager.ImsRegistrationState int value) {
- if (DBG) logd("setImsRegistrationState: " + value);
- mImsMmTelRegistrationHelper.updateRegistrationState(value);
- }
-
@Override
public void callEndCleanupHandOverCallIfAny() {
mCT.callEndCleanupHandOverCallIfAny();
@@ -2387,12 +2382,13 @@
@Override
public void handleImsRegistered(int imsRadioTech) {
if (DBG) {
- logd("onImsMmTelConnected imsRadioTech="
+ logd("handleImsRegistered: onImsMmTelConnected imsRadioTech="
+ AccessNetworkConstants.transportTypeToString(imsRadioTech));
}
- mRegLocalLog.log("onImsMmTelConnected imsRadioTech="
+ mRegLocalLog.log("handleImsRegistered: onImsMmTelConnected imsRadioTech="
+ AccessNetworkConstants.transportTypeToString(imsRadioTech));
setServiceState(ServiceState.STATE_IN_SERVICE);
+ getDefaultPhone().setImsRegistrationState(true);
mMetrics.writeOnImsConnectionState(mPhoneId, ImsConnectionState.State.CONNECTED, null);
mImsStats.onImsRegistered(imsRadioTech);
}
@@ -2400,12 +2396,13 @@
@Override
public void handleImsRegistering(int imsRadioTech) {
if (DBG) {
- logd("onImsMmTelProgressing imsRadioTech="
+ logd("handleImsRegistering: onImsMmTelProgressing imsRadioTech="
+ AccessNetworkConstants.transportTypeToString(imsRadioTech));
}
- mRegLocalLog.log("onImsMmTelProgressing imsRadioTech="
+ mRegLocalLog.log("handleImsRegistering: onImsMmTelProgressing imsRadioTech="
+ AccessNetworkConstants.transportTypeToString(imsRadioTech));
setServiceState(ServiceState.STATE_OUT_OF_SERVICE);
+ getDefaultPhone().setImsRegistrationState(false);
mMetrics.writeOnImsConnectionState(mPhoneId, ImsConnectionState.State.PROGRESSING,
null);
mImsStats.onImsRegistering(imsRadioTech);
@@ -2413,10 +2410,15 @@
@Override
public void handleImsUnregistered(ImsReasonInfo imsReasonInfo) {
- if (DBG) logd("onImsMmTelDisconnected imsReasonInfo=" + imsReasonInfo);
- mRegLocalLog.log("onImsMmTelDisconnected imsRadioTech=" + imsReasonInfo);
+ if (DBG) {
+ logd("handleImsUnregistered: onImsMmTelDisconnected imsReasonInfo="
+ + imsReasonInfo);
+ }
+ mRegLocalLog.log("handleImsUnregistered: onImsMmTelDisconnected imsRadioTech="
+ + imsReasonInfo);
setServiceState(ServiceState.STATE_OUT_OF_SERVICE);
processDisconnectReason(imsReasonInfo);
+ getDefaultPhone().setImsRegistrationState(false);
mMetrics.writeOnImsConnectionState(mPhoneId, ImsConnectionState.State.DISCONNECTED,
imsReasonInfo);
mImsStats.onImsUnregistered(imsReasonInfo);
diff --git a/src/java/com/android/internal/telephony/imsphone/ImsRegistrationCallbackHelper.java b/src/java/com/android/internal/telephony/imsphone/ImsRegistrationCallbackHelper.java
index 33c16e2..115f6fe 100644
--- a/src/java/com/android/internal/telephony/imsphone/ImsRegistrationCallbackHelper.java
+++ b/src/java/com/android/internal/telephony/imsphone/ImsRegistrationCallbackHelper.java
@@ -109,8 +109,9 @@
public synchronized void updateRegistrationState(
@RegistrationManager.ImsRegistrationState int newState) {
synchronized (mLock) {
- Log.d(TAG, "updateRegistrationState: registration state from " + mRegistrationState
- + " to " + newState);
+ Log.d(TAG, "updateRegistrationState: registration state from "
+ + RegistrationManager.registrationStateToString(mRegistrationState)
+ + " to " + RegistrationManager.registrationStateToString(newState));
mRegistrationState = newState;
}
}
diff --git a/src/java/com/android/internal/telephony/metrics/SmsStats.java b/src/java/com/android/internal/telephony/metrics/SmsStats.java
index 44182c8..5268aba 100644
--- a/src/java/com/android/internal/telephony/metrics/SmsStats.java
+++ b/src/java/com/android/internal/telephony/metrics/SmsStats.java
@@ -63,7 +63,7 @@
import java.util.Random;
-/** Collects voice call events per phone ID for the pulled atom. */
+/** Collects sms events per phone ID for the pulled atom. */
public class SmsStats {
private static final String TAG = SmsStats.class.getSimpleName();
diff --git a/tests/telephonytests/src/com/android/internal/telephony/PhysicalChannelConfigTest.java b/tests/telephonytests/src/com/android/internal/telephony/PhysicalChannelConfigTest.java
index 944dfa4..64cddc5 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/PhysicalChannelConfigTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/PhysicalChannelConfigTest.java
@@ -17,63 +17,157 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.fail;
+
import android.os.Parcel;
+import android.telephony.AccessNetworkConstants;
import android.telephony.PhysicalChannelConfig;
import android.telephony.PhysicalChannelConfig.Builder;
import android.telephony.ServiceState;
+import android.telephony.TelephonyManager;
import org.junit.Test;
/** Unit test for {@link android.telephony.PhysicalChannelConfig}. */
public class PhysicalChannelConfigTest {
- private static final int RAT = ServiceState.RIL_RADIO_TECHNOLOGY_LTE;
+ private static final int NETWORK_TYPE_NR = TelephonyManager.NETWORK_TYPE_NR;
+ private static final int NETWORK_TYPE_LTE = TelephonyManager.NETWORK_TYPE_LTE;
+ private static final int NETWORK_TYPE_UMTS = TelephonyManager.NETWORK_TYPE_UMTS;
+ private static final int NETWORK_TYPE_GSM = TelephonyManager.NETWORK_TYPE_GSM;
private static final int CONNECTION_STATUS = PhysicalChannelConfig.CONNECTION_PRIMARY_SERVING;
private static final int CELL_BANDWIDTH = 12345;
private static final int FREQUENCY_RANGE = 1;
private static final int CHANNEL_NUMBER = 1234;
private static final int[] CONTEXT_IDS = new int[] {123, 555, 1, 0};
private static final int PHYSICAL_CELL_ID = 502;
+ private static final int BAND = 1;
+ public static final int INVALID_FREQUENCY = -1;
+
+ private PhysicalChannelConfig mPhysicalChannelConfig;
+
+ private void setUpPhysicalChannelConfig(int networkType, int band, int downlinkChannelNumber,
+ int uplinkChannelNumber, int frequencyRange) {
+ mPhysicalChannelConfig = new Builder()
+ .setCellConnectionStatus(CONNECTION_STATUS)
+ .setCellBandwidthDownlinkKhz(CELL_BANDWIDTH)
+ .setCellBandwidthUplinkKhz(CELL_BANDWIDTH)
+ .setContextIds(CONTEXT_IDS)
+ .setPhysicalCellId(PHYSICAL_CELL_ID)
+ .setNetworkType(networkType)
+ .setFrequencyRange(frequencyRange)
+ .setDownlinkChannelNumber(downlinkChannelNumber)
+ .setUplinkChannelNumber(uplinkChannelNumber)
+ .setBand(band)
+ .build();
+ }
+
+ @Test
+ public void testDownlinkFrequencyForNrArfcn(){
+ setUpPhysicalChannelConfig(NETWORK_TYPE_NR, AccessNetworkConstants.NgranBands.BAND_1,
+ CHANNEL_NUMBER, CHANNEL_NUMBER, ServiceState.FREQUENCY_RANGE_MID);
+
+ // 3GPP TS 38.104 Table 5.4.2.1-1, {@link AccessNetworkUtils#getFrequencyFromNrArfcn}.
+ // Formula of NR-ARFCN convert to actual frequency:
+ // Actual frequency(kHz) = (RANGE_OFFSET + GLOBAL_KHZ * (ARFCN - ARFCN_OFFSET))
+ assertThat(mPhysicalChannelConfig.getDownlinkFrequencyKhz()).isEqualTo(6170);
+ }
+
+ @Test
+ public void testDownlinkandUplinkFrequencyForEarfcn(){
+ setUpPhysicalChannelConfig(NETWORK_TYPE_LTE, AccessNetworkConstants.EutranBand.BAND_3,
+ CHANNEL_NUMBER, 19500, ServiceState.FREQUENCY_RANGE_MID);
+
+ // 3GPP TS 36.101 Table 5.7.3-1, {@link AccessNetworkUtils#getFrequencyFromEarfcn}.
+ // Formula of E-UTRA ARFCN convert to actual frequency:
+ // Actual frequency(kHz) = (DOWNLINK_LOW + 0.1 * (ARFCN - DOWNLINK_OFFSET)) * FREQUENCY_KHZ
+ // Actual frequency(kHz) = (UPLINK_LOW + 0.1 * (ARFCN - UPLINK_OFFSET)) * FREQUENCY_KHZ
+ assertThat(mPhysicalChannelConfig.getDownlinkFrequencyKhz()).isEqualTo(1808400);
+ assertThat(mPhysicalChannelConfig.getUplinkFrequencyKhz()).isEqualTo(1740000);
+ }
+
+ @Test
+ public void testDownlinkandUplinkFrequencyForUarfcn(){
+ setUpPhysicalChannelConfig(NETWORK_TYPE_UMTS, AccessNetworkConstants.UtranBand.BAND_3,
+ CHANNEL_NUMBER, 940, ServiceState.FREQUENCY_RANGE_MID);
+
+ // 3GPP TS 25.101, {@link AccessNetworkUtils#getFrequencyFromUarfcn}.
+ // Formula of UTRA ARFCN convert to actual frequency:
+ // For general bands:
+ // Downlink actual frequency(kHz) = (DOWNLINK_OFFSET + 0.2 * ARFCN) * FREQUENCY_KHZ
+ // Uplink actual frequency(kHz) = (UPLINK_OFFSET + 0.2 * ARFCN) * FREQUENCY_KHZ
+ assertThat(mPhysicalChannelConfig.getDownlinkFrequencyKhz()).isEqualTo(1821800);
+ assertThat(mPhysicalChannelConfig.getUplinkFrequencyKhz()).isEqualTo(1713000);
+ }
+
+ @Test
+ public void testDownlinkFrequencyForArfcn(){
+ setUpPhysicalChannelConfig(NETWORK_TYPE_GSM, AccessNetworkConstants.GeranBand.BAND_450,
+ 270, 270, ServiceState.FREQUENCY_RANGE_LOW);
+
+ // 3GPP TS 45.005 Table 2-1 Dynamically mapped ARFCN
+ // Formula of Geran ARFCN convert to actual frequency:
+ // Uplink actual frequency(kHz) =
+ // (UPLINK_FREQUENCY_FIRST + 0.2 * (ARFCN - ARFCN_RANGE_FIRST)) * FREQUENCY_KHZ
+ // Downlink actual frequency(kHz) = Uplink actual frequency + 10
+ assertThat(mPhysicalChannelConfig.getDownlinkFrequencyKhz()).isEqualTo(452810);
+ }
+
+ @Test
+ public void testDownlinkandUplinkFrequencyForEarfcnWithIncorrectRange() {
+ setUpPhysicalChannelConfig(NETWORK_TYPE_LTE, AccessNetworkConstants.EutranBand.BAND_3,
+ 900, 900, ServiceState.FREQUENCY_RANGE_MID);
+
+ assertThat(mPhysicalChannelConfig.getDownlinkFrequencyKhz()).isEqualTo(INVALID_FREQUENCY);
+ }
+
+ @Test
+ public void testFrequencyRangeWithoutBand() {
+ try {
+ setUpPhysicalChannelConfig(NETWORK_TYPE_UMTS, 0, CHANNEL_NUMBER, CHANNEL_NUMBER,
+ ServiceState.FREQUENCY_RANGE_UNKNOWN);
+ fail("Frequency range: 0 is invalid.");
+ } catch (IllegalArgumentException e) {
+ }
+ }
+
+ @Test
+ public void testFrequencyRangeForNrArfcn() {
+ setUpPhysicalChannelConfig(NETWORK_TYPE_NR, AccessNetworkConstants.NgranBands.BAND_79,
+ 4500, 4500, ServiceState.FREQUENCY_RANGE_HIGH);
+
+ assertThat(mPhysicalChannelConfig.getFrequencyRange()).isEqualTo(
+ ServiceState.FREQUENCY_RANGE_HIGH);
+ }
@Test
public void testBuilder() {
- PhysicalChannelConfig config = new Builder()
- .setRat(RAT)
- .setCellConnectionStatus(CONNECTION_STATUS)
- .setCellBandwidthDownlinkKhz(CELL_BANDWIDTH)
- .setFrequencyRange(FREQUENCY_RANGE)
- .setChannelNumber(CHANNEL_NUMBER)
- .setContextIds(CONTEXT_IDS)
- .setPhysicalCellId(PHYSICAL_CELL_ID)
- .build();
+ setUpPhysicalChannelConfig(NETWORK_TYPE_LTE, BAND, CHANNEL_NUMBER, CHANNEL_NUMBER,
+ FREQUENCY_RANGE);
- assertThat(config.getNetworkType()).isEqualTo(RAT);
- assertThat(config.getConnectionStatus()).isEqualTo(CONNECTION_STATUS);
- assertThat(config.getCellBandwidthDownlink()).isEqualTo(CELL_BANDWIDTH);
- assertThat(config.getFrequencyRange()).isEqualTo(FREQUENCY_RANGE);
- assertThat(config.getChannelNumber()).isEqualTo(CHANNEL_NUMBER);
- assertThat(config.getContextIds()).isEqualTo(CONTEXT_IDS);
- assertThat(config.getPhysicalCellId()).isEqualTo(PHYSICAL_CELL_ID);
+ assertThat(mPhysicalChannelConfig.getNetworkType()).isEqualTo(NETWORK_TYPE_LTE);
+ assertThat(mPhysicalChannelConfig.getConnectionStatus()).isEqualTo(CONNECTION_STATUS);
+ assertThat(mPhysicalChannelConfig.getCellBandwidthDownlinkKhz()).isEqualTo(CELL_BANDWIDTH);
+ assertThat(mPhysicalChannelConfig.getCellBandwidthUplinkKhz()).isEqualTo(CELL_BANDWIDTH);
+ assertThat(mPhysicalChannelConfig.getFrequencyRange()).isEqualTo(FREQUENCY_RANGE);
+ assertThat(mPhysicalChannelConfig.getChannelNumber()).isEqualTo(CHANNEL_NUMBER);
+ assertThat(mPhysicalChannelConfig.getContextIds()).isEqualTo(CONTEXT_IDS);
+ assertThat(mPhysicalChannelConfig.getPhysicalCellId()).isEqualTo(PHYSICAL_CELL_ID);
+ assertThat(mPhysicalChannelConfig.getDownlinkChannelNumber()).isEqualTo(CHANNEL_NUMBER);
+ assertThat(mPhysicalChannelConfig.getUplinkChannelNumber()).isEqualTo(CHANNEL_NUMBER);
}
@Test
public void testParcel() {
- PhysicalChannelConfig config = new Builder()
- .setRat(RAT)
- .setCellConnectionStatus(CONNECTION_STATUS)
- .setCellBandwidthDownlinkKhz(CELL_BANDWIDTH)
- .setFrequencyRange(FREQUENCY_RANGE)
- .setChannelNumber(CHANNEL_NUMBER)
- .setContextIds(CONTEXT_IDS)
- .setPhysicalCellId(PHYSICAL_CELL_ID)
- .build();
+ setUpPhysicalChannelConfig(NETWORK_TYPE_LTE, BAND, CHANNEL_NUMBER, CHANNEL_NUMBER,
+ ServiceState.FREQUENCY_RANGE_MID);
Parcel parcel = Parcel.obtain();
- config.writeToParcel(parcel, 0 /* flags */);
+ mPhysicalChannelConfig.writeToParcel(parcel, 0 /* flags */);
parcel.setDataPosition(0);
PhysicalChannelConfig fromParcel = PhysicalChannelConfig.CREATOR.createFromParcel(parcel);
- assertThat(fromParcel).isEqualTo(config);
+ assertThat(fromParcel).isEqualTo(mPhysicalChannelConfig);
}
}
diff --git a/tests/telephonytests/src/com/android/internal/telephony/ServiceStateTrackerTest.java b/tests/telephonytests/src/com/android/internal/telephony/ServiceStateTrackerTest.java
index 583eb82..339e0cf 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/ServiceStateTrackerTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/ServiceStateTrackerTest.java
@@ -36,9 +36,10 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import android.app.IAlarmManager;
+import android.app.AlarmManager;
import android.app.Notification;
import android.app.NotificationManager;
+import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -125,7 +126,7 @@
@Mock
private Handler mTestHandler;
@Mock
- protected IAlarmManager mAlarmManager;
+ protected AlarmManager mAlarmManager;
private CellularNetworkService mCellularNetworkService;
@@ -231,6 +232,8 @@
logd("ServiceStateTrackerTest +Setup!");
super.setUp("ServiceStateTrackerTest");
+ doReturn(mAlarmManager).when(mContext).getSystemService(eq(Context.ALARM_SERVICE));
+
mContextFixture.putResource(R.string.config_wwan_network_service_package,
"com.android.phone");
mContextFixture.putResource(R.string.config_wlan_network_service_package,
@@ -1919,6 +1922,25 @@
@Test
@SmallTest
+ public void testSetImsRegisteredStateRunsShutdownImmediately() throws Exception {
+ doReturn(true).when(mPhone).isPhoneTypeGsm();
+ sst.setImsRegistrationState(true);
+ mSimulatedCommands.setRadioPowerFailResponse(false);
+ sst.setRadioPower(true);
+ waitForLastHandlerAction(mSSTTestHandler.getThreadHandler());
+
+ assertEquals(TelephonyManager.RADIO_POWER_ON, mSimulatedCommands.getRadioState());
+ sst.requestShutdown();
+ waitForLastHandlerAction(mSSTTestHandler.getThreadHandler());
+
+ sst.setImsRegistrationState(false);
+ verify(mAlarmManager).cancel(any(PendingIntent.class));
+ waitForLastHandlerAction(mSSTTestHandler.getThreadHandler());
+ assertEquals(TelephonyManager.RADIO_POWER_UNAVAILABLE, mSimulatedCommands.getRadioState());
+ }
+
+ @Test
+ @SmallTest
public void testSetTimeFromNITZStr() throws Exception {
{
// Mock sending incorrect nitz str from RIL
diff --git a/tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneTest.java b/tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneTest.java
index 921a78b..f9885a5 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneTest.java
@@ -668,7 +668,7 @@
@SmallTest
public void testImsRegistered() throws Exception {
mImsPhoneUT.setServiceState(ServiceState.STATE_IN_SERVICE);
- mImsPhoneUT.setImsRegistrationState(RegistrationManager.REGISTRATION_STATE_REGISTERED);
+ mImsPhoneUT.setImsRegistered(true);
assertTrue(mImsPhoneUT.isImsRegistered());
LinkedBlockingQueue<Integer> result = new LinkedBlockingQueue<>(1);
@@ -680,23 +680,9 @@
@Test
@SmallTest
- public void testImsRegistering() throws Exception {
- mImsPhoneUT.setServiceState(ServiceState.STATE_OUT_OF_SERVICE);
- mImsPhoneUT.setImsRegistrationState(RegistrationManager.REGISTRATION_STATE_REGISTERING);
- assertFalse(mImsPhoneUT.isImsRegistered());
-
- LinkedBlockingQueue<Integer> result = new LinkedBlockingQueue<>(1);
- mImsPhoneUT.getImsRegistrationState(result::offer);
- Integer regResult = result.poll(1000, TimeUnit.MILLISECONDS);
- assertNotNull(regResult);
- assertEquals(RegistrationManager.REGISTRATION_STATE_REGISTERING, regResult.intValue());
- }
-
- @Test
- @SmallTest
public void testImsDeregistered() throws Exception {
mImsPhoneUT.setServiceState(ServiceState.STATE_OUT_OF_SERVICE);
- mImsPhoneUT.setImsRegistrationState(RegistrationManager.REGISTRATION_STATE_NOT_REGISTERED);
+ mImsPhoneUT.setImsRegistered(false);
assertFalse(mImsPhoneUT.isImsRegistered());
LinkedBlockingQueue<Integer> result = new LinkedBlockingQueue<>(1);