Skip to content

Commit 064d2d6

Browse files
Wink SavilleAndroid (Google) Code Review
authored andcommitted
Merge "Telephony: Fix sim_refresh as per ril v6"
2 parents f46723b + 8f24145 commit 064d2d6

File tree

8 files changed

+125
-30
lines changed

8 files changed

+125
-30
lines changed

telephony/java/com/android/internal/telephony/CommandsInterface.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,6 @@ public boolean isAvailable() {
9393
static final int USSD_MODE_NOTIFY = 0;
9494
static final int USSD_MODE_REQUEST = 1;
9595

96-
// SIM Refresh results, passed up from RIL.
97-
static final int SIM_REFRESH_FILE_UPDATED = 0; // Single file updated
98-
static final int SIM_REFRESH_INIT = 1; // SIM initialized; reload all
99-
static final int SIM_REFRESH_RESET = 2; // SIM reset; may be locked
100-
10196
// GSM SMS fail cause for acknowledgeLastIncomingSMS. From TS 23.040, 9.2.3.22.
10297
static final int GSM_SMS_FAIL_CAUSE_MEMORY_CAPACITY_EXCEEDED = 0xD3;
10398
static final int GSM_SMS_FAIL_CAUSE_USIM_APP_TOOLKIT_BUSY = 0xD4;

telephony/java/com/android/internal/telephony/IccCard.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public abstract class IccCard {
4848
protected String mLogTag;
4949
protected boolean mDbg;
5050

51-
private IccCardStatus mIccCardStatus = null;
51+
protected IccCardStatus mIccCardStatus = null;
5252
protected State mState = null;
5353
private final Object mStateMonitor = new Object();
5454

@@ -911,4 +911,24 @@ public boolean hasIccCard() {
911911
private void log(String msg) {
912912
Log.d(mLogTag, "[IccCard] " + msg);
913913
}
914+
915+
protected abstract int getCurrentApplicationIndex();
916+
917+
public String getAid() {
918+
String aid = "";
919+
int appIndex = getCurrentApplicationIndex();
920+
921+
if (appIndex >= 0 && appIndex < IccCardStatus.CARD_MAX_APPS) {
922+
IccCardApplication app = mIccCardStatus.getApplication(appIndex);
923+
if (app != null) {
924+
aid = app.aid;
925+
} else {
926+
Log.e(mLogTag, "[IccCard] getAid: no current application index=" + appIndex);
927+
}
928+
} else {
929+
Log.e(mLogTag, "[IccCard] getAid: Invalid Subscription Application index=" + appIndex);
930+
}
931+
932+
return aid;
933+
}
914934
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright (C) 2011 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.android.internal.telephony;
18+
19+
/**
20+
* See also RIL_SimRefresh in include/telephony/ril.h
21+
*
22+
* {@hide}
23+
*/
24+
25+
public class IccRefreshResponse {
26+
27+
public static final int REFRESH_RESULT_FILE_UPDATE = 0; /* Single file was updated */
28+
public static final int REFRESH_RESULT_INIT = 1; /* The Icc has been initialized */
29+
public static final int REFRESH_RESULT_RESET = 2; /* The Icc was reset */
30+
31+
public int refreshResult; /* Sim Refresh result */
32+
public int efId; /* EFID */
33+
public String aid; /* null terminated string, e.g.,
34+
from 0xA0, 0x00 -> 0x41,
35+
0x30, 0x30, 0x30 */
36+
/* Example: a0000000871002f310ffff89080000ff */
37+
38+
@Override
39+
public String toString() {
40+
return "{" + refreshResult + ", " + aid +", " + efId + "}";
41+
}
42+
}

telephony/java/com/android/internal/telephony/RIL.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import com.android.internal.telephony.gsm.SuppServiceNotification;
5353
import com.android.internal.telephony.cdma.CdmaCallWaitingNotification;
5454
import com.android.internal.telephony.cdma.CdmaInformationRecords;
55+
import com.android.internal.telephony.IccRefreshResponse;
5556

5657
import java.io.ByteArrayInputStream;
5758
import java.io.DataInputStream;
@@ -2419,7 +2420,7 @@ private RILRequest findAndRemoveRequestFromList(int serial) {
24192420
case RIL_UNSOL_STK_EVENT_NOTIFY: ret = responseString(p); break;
24202421
case RIL_UNSOL_STK_CALL_SETUP: ret = responseInts(p); break;
24212422
case RIL_UNSOL_SIM_SMS_STORAGE_FULL: ret = responseVoid(p); break;
2422-
case RIL_UNSOL_SIM_REFRESH: ret = responseInts(p); break;
2423+
case RIL_UNSOL_SIM_REFRESH: ret = responseSimRefresh(p); break;
24232424
case RIL_UNSOL_CALL_RING: ret = responseCallRing(p); break;
24242425
case RIL_UNSOL_RESTRICTED_STATE_CHANGED: ret = responseInts(p); break;
24252426
case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: ret = responseVoid(p); break;
@@ -2975,6 +2976,16 @@ private void notifyRegistrantsRilConnectionChanged(int rilVer) {
29752976
return status;
29762977
}
29772978

2979+
private Object
2980+
responseSimRefresh(Parcel p) {
2981+
IccRefreshResponse response = new IccRefreshResponse();
2982+
2983+
response.refreshResult = p.readInt();
2984+
response.efId = p.readInt();
2985+
response.aid = p.readString();
2986+
return response;
2987+
}
2988+
29782989
private Object
29792990
responseCallList(Parcel p) {
29802991
int num;

telephony/java/com/android/internal/telephony/cdma/RuimCard.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,13 @@ public void dispose() {
4444
public String getServiceProviderName () {
4545
return mPhone.mIccRecords.getServiceProviderName();
4646
}
47+
48+
@Override
49+
protected int getCurrentApplicationIndex() {
50+
if (mIccCardStatus == null) {
51+
return -1;
52+
}
53+
return mIccCardStatus.getCdmaSubscriptionAppIndex();
54+
}
4755
}
4856

telephony/java/com/android/internal/telephony/cdma/RuimRecords.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.android.internal.telephony.AdnRecordCache;
3030
import com.android.internal.telephony.AdnRecordLoader;
3131
import com.android.internal.telephony.CommandsInterface;
32+
import com.android.internal.telephony.IccRefreshResponse;
3233
import com.android.internal.telephony.TelephonyProperties;
3334
import com.android.internal.telephony.cdma.RuimCard;
3435
import com.android.internal.telephony.MccTable;
@@ -300,7 +301,7 @@ public void handleMessage(Message msg) {
300301
isRecordLoadResponse = false;
301302
ar = (AsyncResult)msg.obj;
302303
if (ar.exception == null) {
303-
handleRuimRefresh((int[])(ar.result));
304+
handleRuimRefresh((IccRefreshResponse)ar.result);
304305
}
305306
break;
306307

@@ -409,24 +410,30 @@ public void setVoiceMessageWaiting(int line, int countWaiting) {
409410
((CDMAPhone) phone).notifyMessageWaitingIndicator();
410411
}
411412

412-
private void handleRuimRefresh(int[] result) {
413-
if (result == null || result.length == 0) {
414-
if (DBG) log("handleRuimRefresh without input");
413+
private void handleRuimRefresh(IccRefreshResponse refreshResponse) {
414+
if (refreshResponse == null) {
415+
if (DBG) log("handleRuimRefresh received without input");
415416
return;
416417
}
417418

418-
switch ((result[0])) {
419-
case CommandsInterface.SIM_REFRESH_FILE_UPDATED:
419+
if (refreshResponse.aid != null &&
420+
!refreshResponse.aid.equals(phone.getIccCard().getAid())) {
421+
// This is for different app. Ignore.
422+
return;
423+
}
424+
425+
switch (refreshResponse.refreshResult) {
426+
case IccRefreshResponse.REFRESH_RESULT_FILE_UPDATE:
420427
if (DBG) log("handleRuimRefresh with SIM_REFRESH_FILE_UPDATED");
421428
adnCache.reset();
422429
fetchRuimRecords();
423430
break;
424-
case CommandsInterface.SIM_REFRESH_INIT:
431+
case IccRefreshResponse.REFRESH_RESULT_INIT:
425432
if (DBG) log("handleRuimRefresh with SIM_REFRESH_INIT");
426433
// need to reload all files (that we care about)
427434
fetchRuimRecords();
428435
break;
429-
case CommandsInterface.SIM_REFRESH_RESET:
436+
case IccRefreshResponse.REFRESH_RESULT_RESET:
430437
if (DBG) log("handleRuimRefresh with SIM_REFRESH_RESET");
431438
phone.mCM.setRadioPower(false, null);
432439
/* Note: no need to call setRadioPower(true). Assuming the desired

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

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import com.android.internal.telephony.Phone;
4040
import com.android.internal.telephony.PhoneBase;
4141
import com.android.internal.telephony.SmsMessageBase;
42+
import com.android.internal.telephony.IccRefreshResponse;
4243

4344
import java.util.ArrayList;
4445

@@ -1049,7 +1050,7 @@ public void handleMessage(Message msg) {
10491050
ar = (AsyncResult)msg.obj;
10501051
if (DBG) log("Sim REFRESH with exception: " + ar.exception);
10511052
if (ar.exception == null) {
1052-
handleSimRefresh((int[])(ar.result));
1053+
handleSimRefresh((IccRefreshResponse)ar.result);
10531054
}
10541055
break;
10551056
case EVENT_GET_CFIS_DONE:
@@ -1130,27 +1131,31 @@ private void handleFileUpdate(int efid) {
11301131
}
11311132
}
11321133

1133-
private void handleSimRefresh(int[] result) {
1134-
if (result == null || result.length == 0) {
1135-
if (DBG) log("handleSimRefresh without input");
1134+
private void handleSimRefresh(IccRefreshResponse refreshResponse){
1135+
if (refreshResponse == null) {
1136+
if (DBG) log("handleSimRefresh received without input");
11361137
return;
11371138
}
11381139

1139-
switch ((result[0])) {
1140-
case CommandsInterface.SIM_REFRESH_FILE_UPDATED:
1141-
if (DBG) log("handleSimRefresh with SIM_REFRESH_FILE_UPDATED");
1142-
// result[1] contains the EFID of the updated file.
1143-
int efid = result[1];
1144-
handleFileUpdate(efid);
1140+
if (refreshResponse.aid != null &&
1141+
!refreshResponse.aid.equals(phone.getIccCard().getAid())) {
1142+
// This is for different app. Ignore.
1143+
return;
1144+
}
1145+
1146+
switch (refreshResponse.refreshResult) {
1147+
case IccRefreshResponse.REFRESH_RESULT_FILE_UPDATE:
1148+
if (DBG) log("handleSimRefresh with SIM_FILE_UPDATED");
1149+
handleFileUpdate(refreshResponse.efId);
11451150
break;
1146-
case CommandsInterface.SIM_REFRESH_INIT:
1147-
if (DBG) log("handleSimRefresh with SIM_REFRESH_INIT");
1151+
case IccRefreshResponse.REFRESH_RESULT_INIT:
1152+
if (DBG) log("handleSimRefresh with SIM_REFRESH_INIT");
11481153
// need to reload all files (that we care about)
11491154
adnCache.reset();
11501155
fetchSimRecords();
11511156
break;
1152-
case CommandsInterface.SIM_REFRESH_RESET:
1153-
if (DBG) log("handleSimRefresh with SIM_REFRESH_RESET");
1157+
case IccRefreshResponse.REFRESH_RESULT_RESET:
1158+
if (DBG) log("handleSimRefresh with SIM_REFRESH_RESET");
11541159
phone.mCM.setRadioPower(false, null);
11551160
/* Note: no need to call setRadioPower(true). Assuming the desired
11561161
* radio power state is still ON (as tracked by ServiceStateTracker),
@@ -1162,7 +1167,7 @@ private void handleSimRefresh(int[] result) {
11621167
break;
11631168
default:
11641169
// unknown refresh operation
1165-
if (DBG) log("handleSimRefresh with unknown operation");
1170+
if (DBG) log("handleSimRefresh with unknown operation");
11661171
break;
11671172
}
11681173
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,11 @@ public String getServiceProviderName () {
3939
return mPhone.mIccRecords.getServiceProviderName();
4040
}
4141

42+
@Override
43+
protected int getCurrentApplicationIndex() {
44+
if (mIccCardStatus == null) {
45+
return -1;
46+
}
47+
return mIccCardStatus.getGsmUmtsSubscriptionAppIndex();
48+
}
4249
}

0 commit comments

Comments
 (0)