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

Commit d76a3247 authored by Mike Kasick's avatar Mike Kasick Committed by Gerrit Code Review
Browse files

RILs: Eliminate repeated overrides of responseOperatorInfos.

- Add mQANElements field, default to 4 in RIL, use in responseOperatorInfos.
  This may be set to 5 in subclassed RIL constructors.

- Remove repeated overrides of responseOperatorInfos by subclassed RILs, as
  there's no logic change, just a disagreement as to whether the
  QUERY_AVAILABLE_NETWORKS response is an array with 4 or 5 per-network
  elements.

- Size OperatorInfo ArrayList appropriately in SemcRIL and SonyQualcommRIL.

Change-Id: I1254a670d8611f76aad13a6f197c67012c7d4c47
parent 1f395eec
Loading
Loading
Loading
Loading
+1 −27
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ public class QualcommSharedRIL extends RIL implements CommandsInterface {
    public QualcommSharedRIL(Context context, int networkMode, int cdmaSubscription) {
        super(context, networkMode, cdmaSubscription);
        mSetPreferredNetworkType = -1;
        mQANElements = 5;
    }

    @Override public void
@@ -801,31 +802,4 @@ public class QualcommSharedRIL extends RIL implements CommandsInterface {

        send(rr);
    }

    @Override
    protected Object
    responseOperatorInfos(Parcel p) {
        String strings[] = (String [])responseStrings(p);
        ArrayList<OperatorInfo> ret;

        if (strings.length % 5 != 0) {
            throw new RuntimeException(
                "RIL_REQUEST_QUERY_AVAILABLE_NETWORKS: invalid response. Got "
                + strings.length + " strings, expected multiple of 5");
        }

        ret = new ArrayList<OperatorInfo>(strings.length / 5);

        for (int i = 0 ; i < strings.length ; i += 5) {
            ret.add (
                new OperatorInfo(
                    strings[i+0],
                    strings[i+1],
                    strings[i+2],
                    strings[i+3]));
        }

        return ret;
    }

}
+9 −4
Original line number Diff line number Diff line
@@ -240,6 +240,11 @@ public class RIL extends BaseCommands implements CommandsInterface {
    // When we are testing emergency calls
    AtomicBoolean mTestingEmergencyCall = new AtomicBoolean(false);

    // Number of per-network elements expected in QUERY_AVAILABLE_NETWORKS's response.
    // 4 elements is default, but many RILs actually return 5, making it impossible to
    // divide the response array without prior knowledge of the number of elements.
    protected int mQANElements = 4;

    //***** Events

    static final int EVENT_SEND                 = 1;
@@ -3315,15 +3320,15 @@ public class RIL extends BaseCommands implements CommandsInterface {
        String strings[] = (String [])responseStrings(p);
        ArrayList<OperatorInfo> ret;

        if (strings.length % 4 != 0) {
        if (strings.length % mQANElements != 0) {
            throw new RuntimeException(
                "RIL_REQUEST_QUERY_AVAILABLE_NETWORKS: invalid response. Got "
                + strings.length + " strings, expected multible of 4");
                + strings.length + " strings, expected multiple of " + mQANElements);
        }

        ret = new ArrayList<OperatorInfo>(strings.length / 4);
        ret = new ArrayList<OperatorInfo>(strings.length / mQANElements);

        for (int i = 0 ; i < strings.length ; i += 4) {
        for (int i = 0 ; i < strings.length ; i += mQANElements) {
            ret.add (
                new OperatorInfo(
                    strings[i+0],
+1 −26
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ public class SamsungQualcommUiccRIL extends QualcommSharedRIL implements Command

    public SamsungQualcommUiccRIL(Context context, int networkMode, int cdmaSubscription) {
        super(context, networkMode, cdmaSubscription);
        mQANElements = 4;
    }

    @Override
@@ -156,32 +157,6 @@ public class SamsungQualcommUiccRIL extends QualcommSharedRIL implements Command
        send(rr);
    }

    @Override
    protected Object
    responseOperatorInfos(Parcel p) {
        String strings[] = (String [])responseStrings(p);
        ArrayList<OperatorInfo> ret;

        if (strings.length % 4 != 0) {
            throw new RuntimeException(
                "RIL_REQUEST_QUERY_AVAILABLE_NETWORKS: invalid response. Got "
                + strings.length + " strings, expected multible of 4");
        }

        ret = new ArrayList<OperatorInfo>(strings.length / 4);

        for (int i = 0 ; i < strings.length ; i += 4) {
            ret.add (
                new OperatorInfo(
                    strings[i+0],
                    strings[i+1],
                    strings[i+2],
                    strings[i+3]));
        }

        return ret;
    }

    @Override
    protected Object
    responseIccCardStatus(Parcel p) {
+1 −25
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ public class SemcRIL extends RIL implements CommandsInterface {

    public SemcRIL(Context context, int networkMode, int cdmaSubscription) {
        super(context, networkMode, cdmaSubscription);
        mQANElements = 5;
    }

    @Override
@@ -216,31 +217,6 @@ public class SemcRIL extends RIL implements CommandsInterface {
        send(rr);
    }

    @Override
    protected Object
    responseOperatorInfos(Parcel p) {
        String strings[] = (String [])responseStrings(p);
        ArrayList<OperatorInfo> ret;

        if (strings.length % 5 != 0) {
            throw new RuntimeException(
                "RIL_REQUEST_QUERY_AVAILABLE_NETWORKS: invalid response. Got "
                + strings.length + " strings, expected multible of 5");
        }

        ret = new ArrayList<OperatorInfo>(strings.length / 4);

        for (int i = 0 ; i < strings.length ; i += 5) {
            ret.add (
                new OperatorInfo(
                    strings[i+0],
                    strings[i+1],
                    strings[i+2],
                    strings[i+3]));
        }
        return ret;
    }

    @Override
    public void
    dial(String address, int clirMode, UUSInfo uusInfo, Message result) {
+1 −26
Original line number Diff line number Diff line
@@ -157,6 +157,7 @@ public class Smdk4210RIL extends RIL implements CommandsInterface {
    public Smdk4210RIL(Context context, int networkMode, int cdmaSubscription) {
        super(context, networkMode, cdmaSubscription);
        audioManager = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);
        mQANElements = 5;
    }

    @Override
@@ -737,32 +738,6 @@ public class Smdk4210RIL extends RIL implements CommandsInterface {
        return response;
    }

    @Override
    protected Object
    responseOperatorInfos(Parcel p) {
        String strings[] = (String [])responseStrings(p);
        ArrayList<OperatorInfo> ret;

        if (strings.length % 5 != 0) {
            throw new RuntimeException(
                "RIL_REQUEST_QUERY_AVAILABLE_NETWORKS: invalid response. Got "
                + strings.length + " strings, expected multible of 5");
        }

        ret = new ArrayList<OperatorInfo>(strings.length / 5);

        for (int i = 0 ; i < strings.length ; i += 5) {
            ret.add (
                new OperatorInfo(
                    strings[i+0],
                    strings[i+1],
                    strings[i+2],
                    strings[i+3]));
        }

        return ret;
    }

    @Override
    protected Object
    responseSignalStrength(Parcel p) {
Loading