android9.0 cdma 短信 发不出的问题

/frameworks/base/telephony/java/com/android/internal/telephony/cdma/BearerData.java

87    private static void encodeUserData(BearerData bData, BitwiseOutputStream outStream)
688        throws BitwiseOutputStream.AccessException, CodingException
689    {
690        /*
691         * TODO(cleanup): Do we really need to set userData.payload as
692         * a side effect of encoding?  If not, we could avoid data
693         * copies by passing outStream directly.
694         */
695        encodeUserDataPayload(bData.userData);
696        bData.hasUserDataHeader = bData.userData.userDataHeader != null;
697
698        if (bData.userData.payload.length > SmsConstants.MAX_USER_DATA_BYTES) {
699            throw new CodingException("encoded user data too large (" +
700                                      bData.userData.payload.length +
701                                      " > " + SmsConstants.MAX_USER_DATA_BYTES + " bytes)");
702        }
703
704        /*
705         * TODO(cleanup): figure out what the right answer is WRT paddingBits field
706         *
707         *   userData.paddingBits = (userData.payload.length * 8) - (userData.numFields * 7);
708         *   userData.paddingBits = 0; // XXX this seems better, but why?
709         *
710         */
711        int dataBits = (bData.userData.payload.length * 8) - bData.userData.paddingBits;
712        int paramBits = dataBits + 13;
713        if ((bData.userData.msgEncoding == UserData.ENCODING_IS91_EXTENDED_PROTOCOL) ||
714            (bData.userData.msgEncoding == UserData.ENCODING_GSM_DCS)) {
715            paramBits += 8;
716        }
717        int paramBytes = (paramBits / 8) + ((paramBits % 8) > 0 ? 1 : 0);
718        int paddingBits = (paramBytes * 8) - paramBits;
719        outStream.write(8, paramBytes);
720        outStream.write(5, bData.userData.msgEncoding);
721        if ((bData.userData.msgEncoding == UserData.ENCODING_IS91_EXTENDED_PROTOCOL) ||
722            (bData.userData.msgEncoding == UserData.ENCODING_GSM_DCS)) {
723            outStream.write(8, bData.userData.msgType);
724        }
725        outStream.write(8, bData.userData.numFields);
726        outStream.writeByteArray(dataBits, bData.userData.payload);
727        if (paddingBits > 0) outStream.write(paddingBits, 0);
728    }
这个todo
/*
705         * TODO(cleanup): figure out what the right answer is WRT paddingBits field
706         *
707         *   userData.paddingBits = (userData.payload.length * 8) - (userData.numFields * 7);
708         *   userData.paddingBits = 0; // XXX this seems better, but why?
709         *
710         */

解决方法是如下标红的行

 

private static void encodeUserDataPayload(UserData uData)
630        throws CodingException
631    {
632        if ((uData.payloadStr == null) && (uData.msgEncoding != UserData.ENCODING_OCTET)) {
633            Rlog.e(LOG_TAG, "user data with null payloadStr");
634            uData.payloadStr = "";
635        }
636
637        if (uData.userDataHeader != null) {
638            encodeEmsUserDataPayload(uData);
639            return;
640        }
641
642        if (uData.msgEncodingSet) {
643            if (uData.msgEncoding == UserData.ENCODING_OCTET) {
644                if (uData.payload == null) {
645                    Rlog.e(LOG_TAG, "user data with octet encoding but null payload");
646                    uData.payload = new byte[0];
647                    uData.numFields = 0;
648                } else {
649                    uData.numFields = uData.payload.length;
650                }
651            } else {
652                if (uData.payloadStr == null) {
653                    Rlog.e(LOG_TAG, "non-octet user data with null payloadStr");
654                    uData.payloadStr = "";
655                }
656                if (uData.msgEncoding == UserData.ENCODING_GSM_7BIT_ALPHABET) {
657                    Gsm7bitCodingResult gcr = encode7bitGsm(uData.payloadStr, 0, true);
658                    uData.payload = gcr.data;
659                    uData.numFields = gcr.septets;
660                } else if (uData.msgEncoding == UserData.ENCODING_7BIT_ASCII) {
661                    uData.payload = encode7bitAscii(uData.payloadStr, true);
662                    uData.numFields = uData.payloadStr.length();
663                } else if (uData.msgEncoding == UserData.ENCODING_UNICODE_16) {
664                    uData.payload = encodeUtf16(uData.payloadStr);
665                    uData.numFields = uData.payloadStr.length();
666                } else if (uData.msgEncoding == UserData.ENCODING_SHIFT_JIS) {
667                    uData.payload = encodeShiftJis(uData.payloadStr);
668                    uData.numFields = uData.payload.length;
669                } else {
670                    throw new CodingException("unsupported user data encoding (" +
671                                              uData.msgEncoding + ")");
672                }
673            }
674        } else {
               uData.numFields = uData.payloadStr.length();
675            try {
676                uData.payload = encode7bitAscii(uData.payloadStr, false);
677                uData.msgEncoding = UserData.ENCODING_7BIT_ASCII;
                   uData.paddingBits = (uData.payload.length * 8) - (uData.numFields * 7);
678            } catch (CodingException ex) {
679                uData.payload = encodeUtf16(uData.payloadStr);
680                uData.msgEncoding = UserData.ENCODING_UNICODE_16;
                   uData.paddingBits = 0;
681            }
682            //uData.numFields = uData.payloadStr.length();
683            uData.msgEncodingSet = true;
684        }
685    }

你可能感兴趣的:(android,cdma,BearerData)