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

Commit 08c4cacc authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "Add local function to replace SmsHeader.fromByteArray" am: 0919c4f2 am: 0b27ffc1

Change-Id: I0b9a943cc3bdc3cf5c520d61da9b32e57d314adf
parents e4301357 0b27ffc1
Loading
Loading
Loading
Loading
+32 −3
Original line number Original line 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_GSM = 1;
    public static final int SMS_TYPE_CDMA = 2;
    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.
    /* We need to handle the SC-address mentioned in errata 4335.
     * Since the definition could be read in three different ways, I have asked
     * Since the definition could be read in three different ways, I have asked
@@ -343,9 +350,9 @@ public class BluetoothMapSmsPdu {
                    } catch (IOException e) {
                    } catch (IOException e) {
                        Log.w(TAG, "unable to read userDataHeader", e);
                        Log.w(TAG, "unable to read userDataHeader", e);
                    }
                    }
                    SmsHeader userDataHeader = SmsHeader.fromByteArray(udh);
                    int[] tableValue = getTableFromByteArray(udh);
                    mLanguageTable = userDataHeader.languageTable;
                    mLanguageTable = tableValue[0];
                    mLanguageShiftTable = userDataHeader.languageShiftTable;
                    mLanguageShiftTable = tableValue[1];


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

}
}