Loading src/java/android/telephony/SmsManager.java +49 −0 Original line number Diff line number Diff line /* * Copyright (C) 2008 The Android Open Source Project * Copyright (c) 2012, The Linux Foundation. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading Loading @@ -518,6 +519,54 @@ public final class SmsManager { return messages; } /** * SMS over IMS is supported if IMS is registered and SMS is supported * on IMS. * * @return true if SMS over IMS is supported, false otherwise * * @see #getImsSmsFormat() * * @hide */ boolean isImsSmsSupported() { boolean boSupported = false; try { ISms iccISms = ISms.Stub.asInterface(ServiceManager.getService("isms")); if (iccISms != null) { boSupported = iccISms.isImsSmsSupported(); } } catch (RemoteException ex) { // ignore it } return boSupported; } /** * Gets SMS format supported on IMS. SMS over IMS format is * either 3GPP or 3GPP2. * * @return SmsMessage.FORMAT_3GPP, * SmsMessage.FORMAT_3GPP2 * or SmsMessage.FORMAT_UNKNOWN * * @see #isImsSmsSupported() * * @hide */ String getImsSmsFormat() { String format = com.android.internal.telephony.SmsConstants.FORMAT_UNKNOWN; try { ISms iccISms = ISms.Stub.asInterface(ServiceManager.getService("isms")); if (iccISms != null) { format = iccISms.getImsSmsFormat(); } } catch (RemoteException ex) { // ignore it } return format; } // see SmsMessage.getStatusOnIcc /** Free space (TS 51.011 10.5.3 / 3GPP2 C.S0023 3.4.27). */ Loading src/java/android/telephony/SmsMessage.java +51 −16 Original line number Diff line number Diff line /* * Copyright (C) 2008 The Android Open Source Project * Copyright (c) 2012, The Linux Foundation. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading Loading @@ -131,13 +132,26 @@ public class SmsMessage { * into the new method {@code createFromPdu(byte[], String)} which takes an * extra format parameter. This is required in order to correctly decode the PDU on * devices that require support for both 3GPP and 3GPP2 formats at the same time, * such as dual-mode GSM/CDMA and CDMA/LTE phones. * such as dual-mode GSM/CDMA and CDMA/LTE phones. Guess format based on Voice * technology first, if it fails use other format. */ public static SmsMessage createFromPdu(byte[] pdu) { SmsMessage message = null; // cdma(3gpp2) vs gsm(3gpp) format info was not given, // guess from active voice phone type int activePhone = TelephonyManager.getDefault().getCurrentPhoneType(); String format = (PHONE_TYPE_CDMA == activePhone) ? SmsConstants.FORMAT_3GPP2 : SmsConstants.FORMAT_3GPP; return createFromPdu(pdu, format); message = createFromPdu(pdu, format); if (null == message || null == message.mWrappedSmsMessage) { // decoding pdu failed based on activePhone type, must be other format format = (PHONE_TYPE_CDMA == activePhone) ? SmsConstants.FORMAT_3GPP : SmsConstants.FORMAT_3GPP2; message = createFromPdu(pdu, format); } return message; } /** Loading Loading @@ -203,9 +217,8 @@ public class SmsMessage { */ public static SmsMessage createFromEfRecord(int index, byte[] data) { SmsMessageBase wrappedMessage; int activePhone = TelephonyManager.getDefault().getCurrentPhoneType(); if (PHONE_TYPE_CDMA == activePhone) { if (isCdmaVoice()) { wrappedMessage = com.android.internal.telephony.cdma.SmsMessage.createFromEfRecord( index, data); } else { Loading @@ -224,9 +237,7 @@ public class SmsMessage { * We should probably deprecate it and remove the obsolete test case. */ public static int getTPLayerLengthForPDU(String pdu) { int activePhone = TelephonyManager.getDefault().getCurrentPhoneType(); if (PHONE_TYPE_CDMA == activePhone) { if (isCdmaVoice()) { return com.android.internal.telephony.cdma.SmsMessage.getTPLayerLengthForPDU(pdu); } else { return com.android.internal.telephony.gsm.SmsMessage.getTPLayerLengthForPDU(pdu); Loading Loading @@ -259,8 +270,8 @@ public class SmsMessage { * code unit size (see the ENCODING_* definitions in SmsConstants) */ public static int[] calculateLength(CharSequence msgBody, boolean use7bitOnly) { int activePhone = TelephonyManager.getDefault().getCurrentPhoneType(); TextEncodingDetails ted = (PHONE_TYPE_CDMA == activePhone) ? // this function is for MO SMS TextEncodingDetails ted = (useCdmaFormatForMoSms()) ? com.android.internal.telephony.cdma.SmsMessage.calculateLength(msgBody, use7bitOnly) : com.android.internal.telephony.gsm.SmsMessage.calculateLength(msgBody, use7bitOnly); int ret[] = new int[4]; Loading @@ -282,8 +293,8 @@ public class SmsMessage { * @hide */ public static ArrayList<String> fragmentText(String text) { int activePhone = TelephonyManager.getDefault().getCurrentPhoneType(); TextEncodingDetails ted = (PHONE_TYPE_CDMA == activePhone) ? // This function is for MO SMS TextEncodingDetails ted = (useCdmaFormatForMoSms()) ? com.android.internal.telephony.cdma.SmsMessage.calculateLength(text, false) : com.android.internal.telephony.gsm.SmsMessage.calculateLength(text, false); Loading Loading @@ -325,7 +336,7 @@ public class SmsMessage { while (pos < textLen) { int nextPos = 0; // Counts code units. if (ted.codeUnitSize == SmsConstants.ENCODING_7BIT) { if (activePhone == PHONE_TYPE_CDMA && ted.msgCount == 1) { if (useCdmaFormatForMoSms() && ted.msgCount == 1) { // For a singleton CDMA message, the encoding must be ASCII... nextPos = pos + Math.min(limit, textLen - pos); } else { Loading Loading @@ -398,9 +409,8 @@ public class SmsMessage { public static SubmitPdu getSubmitPdu(String scAddress, String destinationAddress, String message, boolean statusReportRequested) { SubmitPduBase spb; int activePhone = TelephonyManager.getDefault().getCurrentPhoneType(); if (PHONE_TYPE_CDMA == activePhone) { if (useCdmaFormatForMoSms()) { spb = com.android.internal.telephony.cdma.SmsMessage.getSubmitPdu(scAddress, destinationAddress, message, statusReportRequested, null); } else { Loading Loading @@ -428,9 +438,8 @@ public class SmsMessage { String destinationAddress, short destinationPort, byte[] data, boolean statusReportRequested) { SubmitPduBase spb; int activePhone = TelephonyManager.getDefault().getCurrentPhoneType(); if (PHONE_TYPE_CDMA == activePhone) { if (useCdmaFormatForMoSms()) { spb = com.android.internal.telephony.cdma.SmsMessage.getSubmitPdu(scAddress, destinationAddress, destinationPort, data, statusReportRequested); } else { Loading Loading @@ -685,4 +694,30 @@ public class SmsMessage { public boolean isReplyPathPresent() { return mWrappedSmsMessage.isReplyPathPresent(); } /** * Determines whether or not to use CDMA format for MO SMS. * If SMS over IMS is supported, then format is based on IMS SMS format, * otherwise format is based on current phone type. * * @return true if Cdma format should be used for MO SMS, false otherwise. */ private static boolean useCdmaFormatForMoSms() { if (!SmsManager.getDefault().isImsSmsSupported()) { // use Voice technology to determine SMS format. return isCdmaVoice(); } // IMS is registered with SMS support, check the SMS format supported return (SmsConstants.FORMAT_3GPP2.equals(SmsManager.getDefault().getImsSmsFormat())); } /** * Determines whether or not to current phone type is cdma. * * @return true if current phone type is cdma, false otherwise. */ private static boolean isCdmaVoice() { int activePhone = TelephonyManager.getDefault().getCurrentPhoneType(); return (PHONE_TYPE_CDMA == activePhone); } } src/java/com/android/internal/telephony/BaseCommands.java +11 −0 Original line number Diff line number Diff line /* * Copyright (C) 2006 The Android Open Source Project * Copyright (c) 2012, The Linux Foundation. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading Loading @@ -42,6 +43,7 @@ public abstract class BaseCommands implements CommandsInterface { protected RegistrantList mVoiceNetworkStateRegistrants = new RegistrantList(); protected RegistrantList mDataNetworkStateRegistrants = new RegistrantList(); protected RegistrantList mVoiceRadioTechChangedRegistrants = new RegistrantList(); protected RegistrantList mImsNetworkStateChangedRegistrants = new RegistrantList(); protected RegistrantList mIccStatusChangedRegistrants = new RegistrantList(); protected RegistrantList mVoicePrivacyOnRegistrants = new RegistrantList(); protected RegistrantList mVoicePrivacyOffRegistrants = new RegistrantList(); Loading Loading @@ -121,6 +123,15 @@ public abstract class BaseCommands implements CommandsInterface { } } public void registerForImsNetworkStateChanged(Handler h, int what, Object obj) { Registrant r = new Registrant (h, what, obj); mImsNetworkStateChangedRegistrants.add(r); } public void unregisterForImsNetworkStateChanged(Handler h) { mImsNetworkStateChangedRegistrants.remove(h); } @Override public void registerForOn(Handler h, int what, Object obj) { Registrant r = new Registrant (h, what, obj); Loading src/java/com/android/internal/telephony/CommandsInterface.java +39 −0 Original line number Diff line number Diff line /* * Copyright (C) 2006 The Android Open Source Project * Copyright (c) 2012, The Linux Foundation. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading Loading @@ -109,6 +110,17 @@ public interface CommandsInterface { //***** Methods RadioState getRadioState(); /** * response.obj.result is an int[2] * * response.obj.result[0] is registration state * 0 - Not registered * 1 - Registered * response.obj.result[1] is of type const RIL_IMS_SMS_Format, * corresponds to sms format used for SMS over IMS. */ void getImsRegistrationState(Message result); /** * Fires on any RadioState transition * Always fires immediately as well Loading @@ -122,6 +134,8 @@ public interface CommandsInterface { void registerForVoiceRadioTechChanged(Handler h, int what, Object obj); void unregisterForVoiceRadioTechChanged(Handler h); void registerForImsNetworkStateChanged(Handler h, int what, Object obj); void unregisterForImsNetworkStateChanged(Handler h); /** * Fires on any transition into RadioState.isOn() Loading Loading @@ -999,6 +1013,31 @@ public interface CommandsInterface { */ void sendCdmaSms(byte[] pdu, Message response); /** * send SMS over IMS with 3GPP/GSM SMS format * @param smscPDU is smsc address in PDU form GSM BCD format prefixed * by a length byte (as expected by TS 27.005) or NULL for default SMSC * @param pdu is SMS in PDU format as an ASCII hex string * less the SMSC address * @param retry indicates if this is a retry; 0 == not retry, nonzero = retry * @param messageRef valid field if retry is set to nonzero. * Contains messageRef from RIL_SMS_Response corresponding to failed MO SMS * @param response sent when operation completes */ void sendImsGsmSms (String smscPDU, String pdu, int retry, int messageRef, Message response); /** * send SMS over IMS with 3GPP2/CDMA SMS format * @param pdu is CDMA-SMS in internal pseudo-PDU format * @param response sent when operation completes * @param retry indicates if this is a retry; 0 == not retry, nonzero = retry * @param messageRef valid field if retry is set to nonzero. * Contains messageRef from RIL_SMS_Response corresponding to failed MO SMS * @param response sent when operation completes */ void sendImsCdmaSms(byte[] pdu, int retry, int messageRef, Message response); /** * Deletes the specified SMS record from SIM memory (EF_SMS). * Loading src/java/com/android/internal/telephony/IccSmsInterfaceManager.java +236 −21 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
src/java/android/telephony/SmsManager.java +49 −0 Original line number Diff line number Diff line /* * Copyright (C) 2008 The Android Open Source Project * Copyright (c) 2012, The Linux Foundation. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading Loading @@ -518,6 +519,54 @@ public final class SmsManager { return messages; } /** * SMS over IMS is supported if IMS is registered and SMS is supported * on IMS. * * @return true if SMS over IMS is supported, false otherwise * * @see #getImsSmsFormat() * * @hide */ boolean isImsSmsSupported() { boolean boSupported = false; try { ISms iccISms = ISms.Stub.asInterface(ServiceManager.getService("isms")); if (iccISms != null) { boSupported = iccISms.isImsSmsSupported(); } } catch (RemoteException ex) { // ignore it } return boSupported; } /** * Gets SMS format supported on IMS. SMS over IMS format is * either 3GPP or 3GPP2. * * @return SmsMessage.FORMAT_3GPP, * SmsMessage.FORMAT_3GPP2 * or SmsMessage.FORMAT_UNKNOWN * * @see #isImsSmsSupported() * * @hide */ String getImsSmsFormat() { String format = com.android.internal.telephony.SmsConstants.FORMAT_UNKNOWN; try { ISms iccISms = ISms.Stub.asInterface(ServiceManager.getService("isms")); if (iccISms != null) { format = iccISms.getImsSmsFormat(); } } catch (RemoteException ex) { // ignore it } return format; } // see SmsMessage.getStatusOnIcc /** Free space (TS 51.011 10.5.3 / 3GPP2 C.S0023 3.4.27). */ Loading
src/java/android/telephony/SmsMessage.java +51 −16 Original line number Diff line number Diff line /* * Copyright (C) 2008 The Android Open Source Project * Copyright (c) 2012, The Linux Foundation. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading Loading @@ -131,13 +132,26 @@ public class SmsMessage { * into the new method {@code createFromPdu(byte[], String)} which takes an * extra format parameter. This is required in order to correctly decode the PDU on * devices that require support for both 3GPP and 3GPP2 formats at the same time, * such as dual-mode GSM/CDMA and CDMA/LTE phones. * such as dual-mode GSM/CDMA and CDMA/LTE phones. Guess format based on Voice * technology first, if it fails use other format. */ public static SmsMessage createFromPdu(byte[] pdu) { SmsMessage message = null; // cdma(3gpp2) vs gsm(3gpp) format info was not given, // guess from active voice phone type int activePhone = TelephonyManager.getDefault().getCurrentPhoneType(); String format = (PHONE_TYPE_CDMA == activePhone) ? SmsConstants.FORMAT_3GPP2 : SmsConstants.FORMAT_3GPP; return createFromPdu(pdu, format); message = createFromPdu(pdu, format); if (null == message || null == message.mWrappedSmsMessage) { // decoding pdu failed based on activePhone type, must be other format format = (PHONE_TYPE_CDMA == activePhone) ? SmsConstants.FORMAT_3GPP : SmsConstants.FORMAT_3GPP2; message = createFromPdu(pdu, format); } return message; } /** Loading Loading @@ -203,9 +217,8 @@ public class SmsMessage { */ public static SmsMessage createFromEfRecord(int index, byte[] data) { SmsMessageBase wrappedMessage; int activePhone = TelephonyManager.getDefault().getCurrentPhoneType(); if (PHONE_TYPE_CDMA == activePhone) { if (isCdmaVoice()) { wrappedMessage = com.android.internal.telephony.cdma.SmsMessage.createFromEfRecord( index, data); } else { Loading @@ -224,9 +237,7 @@ public class SmsMessage { * We should probably deprecate it and remove the obsolete test case. */ public static int getTPLayerLengthForPDU(String pdu) { int activePhone = TelephonyManager.getDefault().getCurrentPhoneType(); if (PHONE_TYPE_CDMA == activePhone) { if (isCdmaVoice()) { return com.android.internal.telephony.cdma.SmsMessage.getTPLayerLengthForPDU(pdu); } else { return com.android.internal.telephony.gsm.SmsMessage.getTPLayerLengthForPDU(pdu); Loading Loading @@ -259,8 +270,8 @@ public class SmsMessage { * code unit size (see the ENCODING_* definitions in SmsConstants) */ public static int[] calculateLength(CharSequence msgBody, boolean use7bitOnly) { int activePhone = TelephonyManager.getDefault().getCurrentPhoneType(); TextEncodingDetails ted = (PHONE_TYPE_CDMA == activePhone) ? // this function is for MO SMS TextEncodingDetails ted = (useCdmaFormatForMoSms()) ? com.android.internal.telephony.cdma.SmsMessage.calculateLength(msgBody, use7bitOnly) : com.android.internal.telephony.gsm.SmsMessage.calculateLength(msgBody, use7bitOnly); int ret[] = new int[4]; Loading @@ -282,8 +293,8 @@ public class SmsMessage { * @hide */ public static ArrayList<String> fragmentText(String text) { int activePhone = TelephonyManager.getDefault().getCurrentPhoneType(); TextEncodingDetails ted = (PHONE_TYPE_CDMA == activePhone) ? // This function is for MO SMS TextEncodingDetails ted = (useCdmaFormatForMoSms()) ? com.android.internal.telephony.cdma.SmsMessage.calculateLength(text, false) : com.android.internal.telephony.gsm.SmsMessage.calculateLength(text, false); Loading Loading @@ -325,7 +336,7 @@ public class SmsMessage { while (pos < textLen) { int nextPos = 0; // Counts code units. if (ted.codeUnitSize == SmsConstants.ENCODING_7BIT) { if (activePhone == PHONE_TYPE_CDMA && ted.msgCount == 1) { if (useCdmaFormatForMoSms() && ted.msgCount == 1) { // For a singleton CDMA message, the encoding must be ASCII... nextPos = pos + Math.min(limit, textLen - pos); } else { Loading Loading @@ -398,9 +409,8 @@ public class SmsMessage { public static SubmitPdu getSubmitPdu(String scAddress, String destinationAddress, String message, boolean statusReportRequested) { SubmitPduBase spb; int activePhone = TelephonyManager.getDefault().getCurrentPhoneType(); if (PHONE_TYPE_CDMA == activePhone) { if (useCdmaFormatForMoSms()) { spb = com.android.internal.telephony.cdma.SmsMessage.getSubmitPdu(scAddress, destinationAddress, message, statusReportRequested, null); } else { Loading Loading @@ -428,9 +438,8 @@ public class SmsMessage { String destinationAddress, short destinationPort, byte[] data, boolean statusReportRequested) { SubmitPduBase spb; int activePhone = TelephonyManager.getDefault().getCurrentPhoneType(); if (PHONE_TYPE_CDMA == activePhone) { if (useCdmaFormatForMoSms()) { spb = com.android.internal.telephony.cdma.SmsMessage.getSubmitPdu(scAddress, destinationAddress, destinationPort, data, statusReportRequested); } else { Loading Loading @@ -685,4 +694,30 @@ public class SmsMessage { public boolean isReplyPathPresent() { return mWrappedSmsMessage.isReplyPathPresent(); } /** * Determines whether or not to use CDMA format for MO SMS. * If SMS over IMS is supported, then format is based on IMS SMS format, * otherwise format is based on current phone type. * * @return true if Cdma format should be used for MO SMS, false otherwise. */ private static boolean useCdmaFormatForMoSms() { if (!SmsManager.getDefault().isImsSmsSupported()) { // use Voice technology to determine SMS format. return isCdmaVoice(); } // IMS is registered with SMS support, check the SMS format supported return (SmsConstants.FORMAT_3GPP2.equals(SmsManager.getDefault().getImsSmsFormat())); } /** * Determines whether or not to current phone type is cdma. * * @return true if current phone type is cdma, false otherwise. */ private static boolean isCdmaVoice() { int activePhone = TelephonyManager.getDefault().getCurrentPhoneType(); return (PHONE_TYPE_CDMA == activePhone); } }
src/java/com/android/internal/telephony/BaseCommands.java +11 −0 Original line number Diff line number Diff line /* * Copyright (C) 2006 The Android Open Source Project * Copyright (c) 2012, The Linux Foundation. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading Loading @@ -42,6 +43,7 @@ public abstract class BaseCommands implements CommandsInterface { protected RegistrantList mVoiceNetworkStateRegistrants = new RegistrantList(); protected RegistrantList mDataNetworkStateRegistrants = new RegistrantList(); protected RegistrantList mVoiceRadioTechChangedRegistrants = new RegistrantList(); protected RegistrantList mImsNetworkStateChangedRegistrants = new RegistrantList(); protected RegistrantList mIccStatusChangedRegistrants = new RegistrantList(); protected RegistrantList mVoicePrivacyOnRegistrants = new RegistrantList(); protected RegistrantList mVoicePrivacyOffRegistrants = new RegistrantList(); Loading Loading @@ -121,6 +123,15 @@ public abstract class BaseCommands implements CommandsInterface { } } public void registerForImsNetworkStateChanged(Handler h, int what, Object obj) { Registrant r = new Registrant (h, what, obj); mImsNetworkStateChangedRegistrants.add(r); } public void unregisterForImsNetworkStateChanged(Handler h) { mImsNetworkStateChangedRegistrants.remove(h); } @Override public void registerForOn(Handler h, int what, Object obj) { Registrant r = new Registrant (h, what, obj); Loading
src/java/com/android/internal/telephony/CommandsInterface.java +39 −0 Original line number Diff line number Diff line /* * Copyright (C) 2006 The Android Open Source Project * Copyright (c) 2012, The Linux Foundation. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading Loading @@ -109,6 +110,17 @@ public interface CommandsInterface { //***** Methods RadioState getRadioState(); /** * response.obj.result is an int[2] * * response.obj.result[0] is registration state * 0 - Not registered * 1 - Registered * response.obj.result[1] is of type const RIL_IMS_SMS_Format, * corresponds to sms format used for SMS over IMS. */ void getImsRegistrationState(Message result); /** * Fires on any RadioState transition * Always fires immediately as well Loading @@ -122,6 +134,8 @@ public interface CommandsInterface { void registerForVoiceRadioTechChanged(Handler h, int what, Object obj); void unregisterForVoiceRadioTechChanged(Handler h); void registerForImsNetworkStateChanged(Handler h, int what, Object obj); void unregisterForImsNetworkStateChanged(Handler h); /** * Fires on any transition into RadioState.isOn() Loading Loading @@ -999,6 +1013,31 @@ public interface CommandsInterface { */ void sendCdmaSms(byte[] pdu, Message response); /** * send SMS over IMS with 3GPP/GSM SMS format * @param smscPDU is smsc address in PDU form GSM BCD format prefixed * by a length byte (as expected by TS 27.005) or NULL for default SMSC * @param pdu is SMS in PDU format as an ASCII hex string * less the SMSC address * @param retry indicates if this is a retry; 0 == not retry, nonzero = retry * @param messageRef valid field if retry is set to nonzero. * Contains messageRef from RIL_SMS_Response corresponding to failed MO SMS * @param response sent when operation completes */ void sendImsGsmSms (String smscPDU, String pdu, int retry, int messageRef, Message response); /** * send SMS over IMS with 3GPP2/CDMA SMS format * @param pdu is CDMA-SMS in internal pseudo-PDU format * @param response sent when operation completes * @param retry indicates if this is a retry; 0 == not retry, nonzero = retry * @param messageRef valid field if retry is set to nonzero. * Contains messageRef from RIL_SMS_Response corresponding to failed MO SMS * @param response sent when operation completes */ void sendImsCdmaSms(byte[] pdu, int retry, int messageRef, Message response); /** * Deletes the specified SMS record from SIM memory (EF_SMS). * Loading
src/java/com/android/internal/telephony/IccSmsInterfaceManager.java +236 −21 File changed.Preview size limit exceeded, changes collapsed. Show changes