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

Commit 76ab2ed1 authored by Muhammed Siju's avatar Muhammed Siju
Browse files

Correct handling of modem capability query failure.

If modem capability query is not supported, getMaxDataAllowed
API causes null pointer exception. Fix the null pointer access.

Change-Id: I96a8c12fd171ffc5682eed949b2ce15ae130fcc0
parent dca77760
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -140,6 +140,7 @@ public class ModemStackController extends Handler {
    private static final int SUCCESS = 1;
    private static final int FAILURE = 0;
    private static final int PRIMARY_STACK_ID = 0;
    private static final int DEFAULT_MAX_DATA_ALLOWED = 1;

    //***** Class Variables
    private static ModemStackController sModemStackController;
@@ -624,14 +625,20 @@ public class ModemStackController extends Handler {

    public int getMaxDataAllowed() {
        logd("getMaxDataAllowed");
        List<Integer> unsortedList = new ArrayList<Integer>(mNumPhones);
        int ret = DEFAULT_MAX_DATA_ALLOWED;
        List<Integer> unsortedList = new ArrayList<Integer>();

        for (int i = 0; i < mNumPhones; i++) {
            if (mModemCapInfo[i] != null) {
                unsortedList.add(mModemCapInfo[i].getMaxDataCap());
            }
        }
        Collections.sort(unsortedList);

        return unsortedList.get(mNumPhones-1);
        int listSize = unsortedList.size();
        if (listSize > 0) {
            ret = unsortedList.get(listSize - 1);
        }
        return ret;
    }

    public int getCurrentStackIdForPhoneId(int phoneId) {