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

Commit 0b27ffc1 authored by Zongheng Wang's avatar Zongheng Wang Committed by android-build-merger
Browse files

Merge "Add local function to replace SmsHeader.fromByteArray"

am: 0919c4f2

Change-Id: I89f99a6268050c3dfdaf42930b0ba90977041ab4
parents 0932cafe 0919c4f2
Loading
Loading
Loading
Loading
+32 −3
Original line number Diff line number Diff line
@@ -47,6 +47,13 @@ public class BluetoothMapSmsPdu {
    public static final int SMS_TYPE_GSM = 1;
    public static final int SMS_TYPE_CDMA = 2;

    /**
     * from SMS user data header information element identifiers.
     * (see TS 23.040 9.2.3.24)
     */
    private static final int ELT_ID_NATIONAL_LANGUAGE_SINGLE_SHIFT     = 0x24;
    private static final int ELT_ID_NATIONAL_LANGUAGE_LOCKING_SHIFT    = 0x25;


    /* We need to handle the SC-address mentioned in errata 4335.
     * Since the definition could be read in three different ways, I have asked
@@ -343,9 +350,9 @@ public class BluetoothMapSmsPdu {
                    } catch (IOException e) {
                        Log.w(TAG, "unable to read userDataHeader", e);
                    }
                    SmsHeader userDataHeader = SmsHeader.fromByteArray(udh);
                    mLanguageTable = userDataHeader.languageTable;
                    mLanguageShiftTable = userDataHeader.languageShiftTable;
                    int[] tableValue = getTableFromByteArray(udh);
                    mLanguageTable = tableValue[0];
                    mLanguageShiftTable = tableValue[1];

                    int headerBits = (userDataHeaderLength + 1) * 8;
                    int headerSeptets = headerBits / 7;
@@ -790,4 +797,26 @@ public class BluetoothMapSmsPdu {
        return messageBody;
    }

    private static int[] getTableFromByteArray(byte[] data) {
        ByteArrayInputStream inStream = new ByteArrayInputStream(data);
        /** tableValue[0]: languageTable
         *  tableValue[1]: languageShiftTable */
        int[] tableValue = new int[2];
        while (inStream.available() > 0) {
            int id = inStream.read();
            int length = inStream.read();
            switch (id) {
                case ELT_ID_NATIONAL_LANGUAGE_SINGLE_SHIFT:
                    tableValue[1] = inStream.read();
                    break;
                case ELT_ID_NATIONAL_LANGUAGE_LOCKING_SHIFT:
                    tableValue[0] = inStream.read();
                    break;
                default:
                    inStream.skip(length);
            }
        }
        return tableValue;
    }

}