Skip to content

Commit c0ebaea

Browse files
author
Catherine Liu
committed
Fix Force Close when enable airplane mode
In GSMPhone handler for message EVENT_RADIO_OFF_OR_NOT_AVAILABLE, the for loop was trying to remove all pending MMI code starting from the index 0 of the ArrayList mPendingMMIs. When mPendingMMIs has more than 1 item in the list, after the 1st one in the list was removed, the rest in the list were shifted. The 2nd one became 1st. Assume the list size is 2, if now the for loop goes to index 1, access to mPendingMMIs.get(1) will result a null pointer access, and cause a Force Close. To fix it, make the for loop to begin with the last one in the ArrayList mPendingMMIs. Change-Id: I3e60086186851b1d6c10fefdb086aa0ae3e16048
1 parent 3d7f0cb commit c0ebaea

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1240,7 +1240,7 @@ public void handleMessage (Message msg) {
12401240
// If the radio shuts off or resets while one of these
12411241
// is pending, we need to clean up.
12421242

1243-
for (int i = 0, s = mPendingMMIs.size() ; i < s; i++) {
1243+
for (int i = mPendingMMIs.size() - 1; i >= 0; i--) {
12441244
if (mPendingMMIs.get(i).isPendingUSSD()) {
12451245
mPendingMMIs.get(i).onUssdFinishedError();
12461246
}

0 commit comments

Comments
 (0)