Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2b739582 authored by Tomasz Wasilczyk's avatar Tomasz Wasilczyk
Browse files

Deliver callbacks also when SIM file is missing.

SIM Records read requests are supposed to execute callback at either
success or failure. The latter happens when there's an exception while
reading it, but not when the file is simply missing.

This change fixes this omission, letting the operation fail fast instead
of waiting for 5 minute CTS timeout. In this specific case, ar.exception
was not null, but ar.userObj was.

Bug: 355008150
Test: atest TelephonyManagerTest
Flag: EXEMPT bugfix
Change-Id: If45113e7d8741be14d4a77b00f0337b165d0ffbd
parent fafd207e
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
 * {@hide}
@@ -1278,15 +1279,22 @@ public class SIMRecords extends IccRecords {

                case EVENT_GET_FPLMN_SIZE_DONE:
                    ar = (AsyncResult) msg.obj;
                    int key = msg.arg2;

                    Message response;
                    Pair<Message, Object> transaction = null;
                    if (ar.exception != null && ar.userObj != null) {
                        response = (Message) ar.userObj;
                    } else {
                        transaction = retrievePendingTransaction(key);
                        response = Objects.requireNonNull(transaction.first);
                    }

                    if (ar.exception != null) {
                        Message response = (Message) ar.userObj;
                        AsyncResult.forMessage(response).exception = ar.exception;
                        response.sendToTarget();
                        break;
                    }
                    int key = msg.arg2;
                    Pair<Message, Object> transaction = retrievePendingTransaction(key);
                    Message response = transaction.first;
                    List<String> fplmns = (List<String>) transaction.second;
                    int dataLength = (int) ar.result;
                    if (dataLength < 0 || dataLength % FPLMN_BYTE_SIZE != 0) {