Skip to content

Commit cf1250c

Browse files
Jean-Baptiste QueruAndroid Code Review
authored andcommitted
Merge "Support to display message when operation is blocked due to FDN being enabled"
2 parents ef2cf71 + 18573e9 commit cf1250c

File tree

6 files changed

+52
-6
lines changed

6 files changed

+52
-6
lines changed

core/res/res/values/strings.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@
6060
<!-- Displayed when the user dialed an MMI code whose function
6161
could not be performed. This will be displayed in a toast. -->
6262
<string name="mmiError">Connection problem or invalid MMI code.</string>
63+
<!-- Displayed when the user dialed an MMI code whose function
64+
could not be performed because FDN is enabled. This will be displayed in a toast. -->
65+
<string name="mmiFdnError">Operation is restricted to fixed dialing numbers only.</string>
66+
6367
<!-- Displayed when a phone feature such as call barring was activated. -->
6468
<string name="serviceEnabled">Service was enabled.</string>
6569
<!-- Displayed in front of the list of a set of service classes

telephony/java/android/telephony/SmsManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,4 +398,6 @@ private ArrayList<SmsMessage> createMessageListFromRawRecords(List<SmsRawData> r
398398
static public final int RESULT_ERROR_NO_SERVICE = 4;
399399
/** Failed because we reached the sending queue limit. {@hide} */
400400
static public final int RESULT_ERROR_LIMIT_EXCEEDED = 5;
401+
/** Failed because FDN is enabled. {@hide} */
402+
static public final int RESULT_ERROR_FDN_CHECK_FAILURE = 6;
401403
}

telephony/java/com/android/internal/telephony/CommandException.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ public enum Error {
3737
OP_NOT_ALLOWED_DURING_VOICE_CALL,
3838
OP_NOT_ALLOWED_BEFORE_REG_NW,
3939
SMS_FAIL_RETRY,
40+
SIM_ABSENT,
41+
SUBSCRIPTION_NOT_AVAILABLE,
42+
MODE_NOT_SUPPORTED,
43+
FDN_CHECK_FAILURE,
4044
}
4145

4246
public CommandException(Error e) {
@@ -68,6 +72,14 @@ public CommandException(Error e) {
6872
return new CommandException(Error.OP_NOT_ALLOWED_BEFORE_REG_NW);
6973
case RILConstants.SMS_SEND_FAIL_RETRY:
7074
return new CommandException(Error.SMS_FAIL_RETRY);
75+
case RILConstants.SIM_ABSENT:
76+
return new CommandException(Error.SIM_ABSENT);
77+
case RILConstants.SUBSCRIPTION_NOT_AVAILABLE:
78+
return new CommandException(Error.SUBSCRIPTION_NOT_AVAILABLE);
79+
case RILConstants.MODE_NOT_SUPPORTED:
80+
return new CommandException(Error.MODE_NOT_SUPPORTED);
81+
case RILConstants.FDN_CHECK_FAILURE:
82+
return new CommandException(Error.FDN_CHECK_FAILURE);
7183
default:
7284
Log.e("GSM", "Unrecognized RIL errno " + ril_errno);
7385
return new CommandException(Error.INVALID_RESPONSE);

telephony/java/com/android/internal/telephony/RILConstants.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ class C */
4545
int OP_NOT_ALLOWED_BEFORE_REG_NW = 9; /* request is not allowed before device registers to
4646
network */
4747
int SMS_SEND_FAIL_RETRY = 10; /* send sms fail and need retry */
48+
int SIM_ABSENT = 11; /* ICC card is absent */
49+
int SUBSCRIPTION_NOT_AVAILABLE = 12; /* fail to find CDMA subscription from specified
50+
location */
51+
int MODE_NOT_SUPPORTED = 13; /* HW does not support preferred network type */
52+
int FDN_CHECK_FAILURE = 14; /* send operation barred error when FDN is enabled */
4853

4954
/* NETWORK_MODE_* See ril.h RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE */
5055
int NETWORK_MODE_WCDMA_PREF = 0; /* GSM/WCDMA (WCDMA preferred) */

telephony/java/com/android/internal/telephony/SMSDispatcher.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
import static android.telephony.SmsManager.RESULT_ERROR_NULL_PDU;
6363
import static android.telephony.SmsManager.RESULT_ERROR_RADIO_OFF;
6464
import static android.telephony.SmsManager.RESULT_ERROR_LIMIT_EXCEEDED;
65+
import static android.telephony.SmsManager.RESULT_ERROR_FDN_CHECK_FAILURE;
6566

6667

6768
public abstract class SMSDispatcher extends Handler {
@@ -499,13 +500,20 @@ protected void handleSendComplete(AsyncResult ar) {
499500
Message retryMsg = obtainMessage(EVENT_SEND_RETRY, tracker);
500501
sendMessageDelayed(retryMsg, SEND_RETRY_DELAY);
501502
} else if (tracker.mSentIntent != null) {
503+
int error = RESULT_ERROR_GENERIC_FAILURE;
504+
505+
if (((CommandException)(ar.exception)).getCommandError()
506+
== CommandException.Error.FDN_CHECK_FAILURE) {
507+
error = RESULT_ERROR_FDN_CHECK_FAILURE;
508+
}
502509
// Done retrying; return an error to the app.
503510
try {
504511
Intent fillIn = new Intent();
505512
if (ar.result != null) {
506513
fillIn.putExtra("errorCode", ((SmsResponse)ar.result).errorCode);
507514
}
508-
tracker.mSentIntent.send(mContext, RESULT_ERROR_GENERIC_FAILURE, fillIn);
515+
tracker.mSentIntent.send(mContext, error, fillIn);
516+
509517
} catch (CanceledException ex) {}
510518
}
511519
}

telephony/java/com/android/internal/telephony/gsm/GsmMmiCode.java

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -832,8 +832,7 @@ void sendUssd(String ussdMessage) {
832832

833833
if (ar.exception != null) {
834834
state = State.FAILED;
835-
message = context.getText(
836-
com.android.internal.R.string.mmiError);
835+
message = getErrorMessage(ar);
837836

838837
phone.onMMIDone(this);
839838
}
@@ -852,6 +851,19 @@ void sendUssd(String ussdMessage) {
852851
}
853852
//***** Private instance methods
854853

854+
private CharSequence getErrorMessage(AsyncResult ar) {
855+
856+
if (ar.exception instanceof CommandException) {
857+
CommandException.Error err = ((CommandException)(ar.exception)).getCommandError();
858+
if (err == CommandException.Error.FDN_CHECK_FAILURE) {
859+
Log.i(LOG_TAG, "FDN_CHECK_FAILURE");
860+
return context.getText(com.android.internal.R.string.mmiFdnError);
861+
}
862+
}
863+
864+
return context.getText(com.android.internal.R.string.mmiError);
865+
}
866+
855867
private CharSequence getScString() {
856868
if (sc != null) {
857869
if (isServiceCodeCallBarring(sc)) {
@@ -904,6 +916,9 @@ private CharSequence getScString() {
904916
sb.append("\n");
905917
sb.append(context.getText(
906918
com.android.internal.R.string.needPuk2));
919+
} else if (err == CommandException.Error.FDN_CHECK_FAILURE) {
920+
Log.i(LOG_TAG, "FDN_CHECK_FAILURE");
921+
sb.append(context.getText(com.android.internal.R.string.mmiFdnError));
907922
} else {
908923
sb.append(context.getText(
909924
com.android.internal.R.string.mmiError));
@@ -953,7 +968,7 @@ private CharSequence getScString() {
953968

954969
if (ar.exception != null) {
955970
state = State.FAILED;
956-
sb.append(context.getText(com.android.internal.R.string.mmiError));
971+
sb.append(getErrorMessage(ar));
957972
} else {
958973
int clirArgs[];
959974

@@ -1123,7 +1138,7 @@ private CharSequence getScString() {
11231138

11241139
if (ar.exception != null) {
11251140
state = State.FAILED;
1126-
sb.append(context.getText(com.android.internal.R.string.mmiError));
1141+
sb.append(getErrorMessage(ar));
11271142
} else {
11281143
CallForwardInfo infos[];
11291144

@@ -1175,7 +1190,7 @@ private CharSequence getScString() {
11751190

11761191
if (ar.exception != null) {
11771192
state = State.FAILED;
1178-
sb.append(context.getText(com.android.internal.R.string.mmiError));
1193+
sb.append(getErrorMessage(ar));
11791194
} else {
11801195
int[] ints = (int[])ar.result;
11811196

0 commit comments

Comments
 (0)