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

Commit 9db557c8 authored by Jack Yu's avatar Jack Yu Committed by Android Git Automerger
Browse files

am 8d69df49: am f4f3b372: Merge "Fixed that the device crashes when users send...

am 8d69df49: am f4f3b372: Merge "Fixed that the device crashes when users send SMS via STK." into mnc-dr-dev

* commit '8d69df49':
  Fixed that the device crashes when users send SMS via STK.
parents 3f019a1b 8d69df49
Loading
Loading
Loading
Loading
+19 −8
Original line number Diff line number Diff line
@@ -117,15 +117,14 @@ class GetInkeyInputResponseData extends ResponseData {
                    // ucs2 is by definition big endian.
                    data = mInData.getBytes("UTF-16BE");
                } else if (mIsPacked) {
                    int size = mInData.length();

                    byte[] tempData = GsmAlphabet
                            .stringToGsm7BitPacked(mInData, 0, 0);
                    data = new byte[size];
                    // Since stringToGsm7BitPacked() set byte 0 in the
                    // returned byte array to the count of septets used...
                    // copy to a new array without byte 0.
                    System.arraycopy(tempData, 1, data, 0, size);
                    // The size of the new buffer will be smaller than the original buffer
                    // since 7-bit GSM packed only requires ((mInData.length * 7) + 7) / 8 bytes.
                    // And we don't need to copy/store the first byte from the returned array
                    // because it is used to store the count of septets used.
                    data = new byte[tempData.length - 1];
                    System.arraycopy(tempData, 1, data, 0, tempData.length - 1);
                } else {
                    data = GsmAlphabet.stringToGsm8BitPacked(mInData);
                }
@@ -139,7 +138,19 @@ class GetInkeyInputResponseData extends ResponseData {
        }

        // length - one more for data coding scheme.

        // ETSI TS 102 223 Annex C (normative): Structure of CAT communications
        // Any length within the APDU limits (up to 255 bytes) can thus be encoded on two bytes.
        // This coding is chosen to remain compatible with TS 101.220.
        // Note that we need to reserve one more byte for coding scheme thus the maximum APDU
        // size would be 254 bytes.
        if (data.length + 1 <= 255) {
            writeLength(buf, data.length + 1);
        }
        else {
            data = new byte[0];
        }


        // data coding scheme
        if (mIsUcs2) {