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

Commit d38b842d authored by codeworkx's avatar codeworkx
Browse files

Smdk4210RIL: fix signalstrength

based on http://review.cyanogenmod.com/#/c/18220/

Change-Id: I872221e58e89412fcecf67c7208ab2c89aac7c04
parent 44f9c784
Loading
Loading
Loading
Loading
+18 −7
Original line number Diff line number Diff line
@@ -620,20 +620,29 @@ public class Smdk4210RIL extends RIL implements CommandsInterface {
        int numInts = 12;
        int response[];

        /* TODO: Add SignalStrength class to match RIL_SignalStrength */
        // Get raw data
        response = new int[numInts];
        for (int i = 0 ; i < numInts ; i++) {
            response[i] = p.readInt();
        }

        // SamsungRIL is a v3 RIL, fill the rest with -1
        for (int i = 7; i < numInts; i++) {
            response[i] = -1;
        Log.d(LOG_TAG, "responseSignalStength BEFORE: gsmDbm=" + response[0]);

        //Samsung sends the count of bars that should be displayed instead of
        //a real signal strength
        int num_bars = (response[0] & 0xff00) >> 8;

        // Translate number of bars into something SignalStrength.java can understand
        switch (num_bars) {
            case 0  : response[0] = 1;     break; // map to 0 bars
            case 1  : response[0] = 3;     break; // map to 1 bar
            case 2  : response[0] = 5;     break; // map to 2 bars
            case 3  : response[0] = 8;     break; // map to 3 bars
            case 4  : response[0] = 12;    break; // map to 4 bars
            case 5  : response[0] = 15;    break; // map to 4 bars but give an extra 10 dBm
            default : response[0] &= 0xff; break; // no idea; just pass value through
        }

        /* Matching Samsung signal strength to asu.
           Method taken from Samsungs cdma/gsmSignalStateTracker */
        response[0] = ((response[0] & 0xFF00) >> 8) * 3; //gsmDbm
        response[1] = -1; //gsmEcio
        response[2] = (response[2] < 0)?-120:-response[2]; //cdmaDbm
        response[3] = (response[3] < 0)?-160:-response[3]; //cdmaEcio
@@ -643,6 +652,8 @@ public class Smdk4210RIL extends RIL implements CommandsInterface {
            response[6] = -1;
        }

        Log.d(LOG_TAG, "responseSignalStength AFTER: gsmDbm=" + response[0]);

        return response;
    }
}