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

Commit 9543d6eb authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes from topic "sms_ready"

* changes:
  Unhide SMS over IMS APIs
  Add and trigger onReady API for SMS over IMS.
parents 3512edbc 9cb476bb
Loading
Loading
Loading
Loading
+42 −0
Original line number Diff line number Diff line
@@ -4788,6 +4788,24 @@ package android.telephony {
  public final class SmsManager {
    method public void sendMultipartTextMessageWithoutPersisting(java.lang.String, java.lang.String, java.util.List<java.lang.String>, java.util.List<android.app.PendingIntent>, java.util.List<android.app.PendingIntent>);
    method public void sendTextMessageWithoutPersisting(java.lang.String, java.lang.String, java.lang.String, android.app.PendingIntent, android.app.PendingIntent);
    field public static final int RESULT_CANCELLED = 23; // 0x17
    field public static final int RESULT_ENCODING_ERROR = 18; // 0x12
    field public static final int RESULT_ERROR_FDN_CHECK_FAILURE = 6; // 0x6
    field public static final int RESULT_ERROR_NONE = 0; // 0x0
    field public static final int RESULT_INTERNAL_ERROR = 21; // 0x15
    field public static final int RESULT_INVALID_ARGUMENTS = 11; // 0xb
    field public static final int RESULT_INVALID_SMSC_ADDRESS = 19; // 0x13
    field public static final int RESULT_INVALID_SMS_FORMAT = 14; // 0xe
    field public static final int RESULT_INVALID_STATE = 12; // 0xc
    field public static final int RESULT_MODEM_ERROR = 16; // 0x10
    field public static final int RESULT_NETWORK_ERROR = 17; // 0x11
    field public static final int RESULT_NETWORK_REJECT = 10; // 0xa
    field public static final int RESULT_NO_MEMORY = 13; // 0xd
    field public static final int RESULT_NO_RESOURCES = 22; // 0x16
    field public static final int RESULT_OPERATION_NOT_ALLOWED = 20; // 0x14
    field public static final int RESULT_RADIO_NOT_AVAILABLE = 9; // 0x9
    field public static final int RESULT_REQUEST_NOT_SUPPORTED = 24; // 0x18
    field public static final int RESULT_SYSTEM_ERROR = 15; // 0xf
  }

  public class SubscriptionManager {
@@ -5048,6 +5066,30 @@ package android.telephony.ims {

}

package android.telephony.ims.internal.stub {

  public class SmsImplBase {
    ctor public SmsImplBase();
    method public void acknowledgeSms(int, int, int);
    method public void acknowledgeSmsReport(int, int, int);
    method public java.lang.String getSmsFormat();
    method public void onReady();
    method public final void onSendSmsResult(int, int, int, int) throws java.lang.RuntimeException;
    method public final void onSmsReceived(int, java.lang.String, byte[]) throws java.lang.RuntimeException;
    method public final void onSmsStatusReportReceived(int, int, java.lang.String, byte[]) throws java.lang.RuntimeException;
    method public void sendSms(int, int, java.lang.String, java.lang.String, boolean, byte[]);
    field public static final int DELIVER_STATUS_ERROR = 2; // 0x2
    field public static final int DELIVER_STATUS_OK = 1; // 0x1
    field public static final int SEND_STATUS_ERROR = 2; // 0x2
    field public static final int SEND_STATUS_ERROR_FALLBACK = 4; // 0x4
    field public static final int SEND_STATUS_ERROR_RETRY = 3; // 0x3
    field public static final int SEND_STATUS_OK = 1; // 0x1
    field public static final int STATUS_REPORT_STATUS_ERROR = 2; // 0x2
    field public static final int STATUS_REPORT_STATUS_OK = 1; // 0x1
  }

}

package android.telephony.mbms {

  public final class DownloadRequest implements android.os.Parcelable {
+107 −2
Original line number Diff line number Diff line
@@ -1134,7 +1134,11 @@ public final class SmsManager {

    // SMS send failure result codes

    /** No error. {@hide}*/
    /**
     * No error.
     * @hide
     */
    @SystemApi
    static public final int RESULT_ERROR_NONE    = 0;
    /** Generic failure cause */
    static public final int RESULT_ERROR_GENERIC_FAILURE    = 1;
@@ -1146,12 +1150,113 @@ public final class SmsManager {
    static public final int RESULT_ERROR_NO_SERVICE         = 4;
    /** Failed because we reached the sending queue limit. */
    static public final int RESULT_ERROR_LIMIT_EXCEEDED     = 5;
    /** Failed because FDN is enabled. {@hide} */
    /**
     * Failed because FDN is enabled.
     * @hide
     */
    @SystemApi
    static public final int RESULT_ERROR_FDN_CHECK_FAILURE  = 6;
    /** Failed because user denied the sending of this short code. */
    static public final int RESULT_ERROR_SHORT_CODE_NOT_ALLOWED = 7;
    /** Failed because the user has denied this app ever send premium short codes. */
    static public final int RESULT_ERROR_SHORT_CODE_NEVER_ALLOWED = 8;
    /**
     * Failed because the radio was not available
     * @hide
     */
    @SystemApi
    static public final int RESULT_RADIO_NOT_AVAILABLE = 9;
    /**
     * Failed because of network rejection
     * @hide
     */
    @SystemApi
    static public final int RESULT_NETWORK_REJECT = 10;
    /**
     * Failed because of invalid arguments
     * @hide
     */
    @SystemApi
    static public final int RESULT_INVALID_ARGUMENTS = 11;
    /**
     * Failed because of an invalid state
     * @hide
     */
    @SystemApi
    static public final int RESULT_INVALID_STATE = 12;
    /**
     * Failed because there is no memory
     * @hide
     */
    @SystemApi
    static public final int RESULT_NO_MEMORY = 13;
    /**
     * Failed because the sms format is not valid
     * @hide
     */
    @SystemApi
    static public final int RESULT_INVALID_SMS_FORMAT = 14;
    /**
     * Failed because of a system error
     * @hide
     */
    @SystemApi
    static public final int RESULT_SYSTEM_ERROR = 15;
    /**
     * Failed because of a modem error
     * @hide
     */
    @SystemApi
    static public final int RESULT_MODEM_ERROR = 16;
    /**
     * Failed because of a network error
     * @hide
     */
    @SystemApi
    static public final int RESULT_NETWORK_ERROR = 17;
    /**
     * Failed because of an encoding error
     * @hide
     */
    @SystemApi
    static public final int RESULT_ENCODING_ERROR = 18;
    /**
     * Failed because of an invalid smsc address
     * @hide
     */
    @SystemApi
    static public final int RESULT_INVALID_SMSC_ADDRESS = 19;
    /**
     * Failed because the operation is not allowed
     * @hide
     */
    @SystemApi
    static public final int RESULT_OPERATION_NOT_ALLOWED = 20;
    /**
     * Failed because of an internal error
     * @hide
     */
    @SystemApi
    static public final int RESULT_INTERNAL_ERROR = 21;
    /**
     * Failed because there are no resources
     * @hide
     */
    @SystemApi
    static public final int RESULT_NO_RESOURCES = 22;
    /**
     * Failed because the operation was cancelled
     * @hide
     */
    @SystemApi
    static public final int RESULT_CANCELLED = 23;
    /**
     * Failed because the request is not supported
     * @hide
     */
    @SystemApi
    static public final int RESULT_REQUEST_NOT_SUPPORTED = 24;


    static private final String PHONE_PACKAGE_NAME = "com.android.phone";

+15 −4
Original line number Diff line number Diff line
@@ -209,6 +209,13 @@ public class MMTelFeature extends ImsFeature {
                return MMTelFeature.this.getSmsFormat();
            }
        }

        @Override
        public void onSmsReady() {
            synchronized (mLock) {
                MMTelFeature.this.onSmsReady();
            }
        }
    };

    /**
@@ -384,25 +391,29 @@ public class MMTelFeature extends ImsFeature {
        return null;
    }

    public void setSmsListener(IImsSmsListener listener) {
    private void setSmsListener(IImsSmsListener listener) {
        getSmsImplementation().registerSmsListener(listener);
    }

    public void sendSms(int token, int messageRef, String format, String smsc, boolean isRetry,
    private void sendSms(int token, int messageRef, String format, String smsc, boolean isRetry,
            byte[] pdu) {
        getSmsImplementation().sendSms(token, messageRef, format, smsc, isRetry, pdu);
    }

    public void acknowledgeSms(int token, int messageRef,
    private void acknowledgeSms(int token, int messageRef,
            @SmsImplBase.DeliverStatusResult int result) {
        getSmsImplementation().acknowledgeSms(token, messageRef, result);
    }

    public void acknowledgeSmsReport(int token, int messageRef,
    private void acknowledgeSmsReport(int token, int messageRef,
            @SmsImplBase.StatusReportResult int result) {
        getSmsImplementation().acknowledgeSmsReport(token, messageRef, result);
    }

    private void onSmsReady() {
        getSmsImplementation().onReady();
    }

    /**
     * Must be overridden by IMS Provider to be able to support SMS over IMS. Otherwise a default
     * non-functional implementation is returned.
+69 −31
Original line number Diff line number Diff line
@@ -17,10 +17,10 @@
package android.telephony.ims.internal.stub;

import android.annotation.IntDef;
import android.annotation.SystemApi;
import android.os.RemoteException;
import android.telephony.SmsManager;
import android.telephony.SmsMessage;
import android.telephony.ims.internal.feature.MmTelFeature;
import android.util.Log;

import com.android.ims.internal.IImsSmsListener;
@@ -33,11 +33,14 @@ import java.lang.annotation.RetentionPolicy;
 *
 * Any service wishing to provide SMS over IMS should extend this class and implement all methods
 * that the service supports.
 *
 * @hide
 */
@SystemApi
public class SmsImplBase {
    private static final String LOG_TAG = "SmsImplBase";

    /** @hide */
    @IntDef({
            SEND_STATUS_OK,
            SEND_STATUS_ERROR,
@@ -58,8 +61,8 @@ public class SmsImplBase {
    public static final int SEND_STATUS_ERROR = 2;

    /**
     * IMS provider failed to send the message and platform should retry again after setting TP-RD bit
     * to high.
     * IMS provider failed to send the message and platform should retry again after setting TP-RD
     * bit to high.
     */
    public static final int SEND_STATUS_ERROR_RETRY = 3;

@@ -69,6 +72,7 @@ public class SmsImplBase {
     */
    public static final int SEND_STATUS_ERROR_FALLBACK = 4;

    /** @hide */
    @IntDef({
            DELIVER_STATUS_OK,
            DELIVER_STATUS_ERROR
@@ -85,6 +89,7 @@ public class SmsImplBase {
     */
    public static final int DELIVER_STATUS_ERROR = 2;

    /** @hide */
    @IntDef({
            STATUS_REPORT_STATUS_OK,
            STATUS_REPORT_STATUS_ERROR
@@ -140,21 +145,23 @@ public class SmsImplBase {
        try {
            onSendSmsResult(token, messageRef, SEND_STATUS_ERROR,
                    SmsManager.RESULT_ERROR_GENERIC_FAILURE);
        } catch (RemoteException e) {
        } catch (RuntimeException e) {
            Log.e(LOG_TAG, "Can not send sms: " + e.getMessage());
        }
    }

    /**
     * This method will be triggered by the platform after {@link #onSmsReceived(int, String, byte[])}
     * has been called to deliver the result to the IMS provider.
     * This method will be triggered by the platform after
     * {@link #onSmsReceived(int, String, byte[])} has been called to deliver the result to the IMS
     * provider.
     *
     * @param token token provided in {@link #onSmsReceived(int, String, byte[])}
     * @param result result of delivering the message. Valid values are defined in
     * {@link DeliverStatusResult}
     * @param result result of delivering the message. Valid values are:
     *  {@link #DELIVER_STATUS_OK},
     *  {@link #DELIVER_STATUS_OK}
     * @param messageRef the message reference
     */
    public void acknowledgeSms(int token, int messageRef, @DeliverStatusResult int result) {
    public void acknowledgeSms(int token, @DeliverStatusResult int messageRef, int result) {
        Log.e(LOG_TAG, "acknowledgeSms() not implemented.");
    }

@@ -164,8 +171,9 @@ public class SmsImplBase {
     * result to the IMS provider.
     *
     * @param token token provided in {@link #sendSms(int, int, String, String, boolean, byte[])}
     * @param result result of delivering the message. Valid values are defined in
     * {@link StatusReportResult}
     * @param result result of delivering the message. Valid values are:
     *  {@link #STATUS_REPORT_STATUS_OK},
     *  {@link #STATUS_REPORT_STATUS_ERROR}
     * @param messageRef the message reference
     */
    public void acknowledgeSmsReport(int token, int messageRef, @StatusReportResult int result) {
@@ -177,20 +185,17 @@ public class SmsImplBase {
     * platform will deliver the message to the messages database and notify the IMS provider of the
     * result by calling {@link #acknowledgeSms(int, int, int)}.
     *
     * This method must not be called before {@link MmTelFeature#onFeatureReady()} is called.
     *
     * @param token unique token generated by IMS providers that the platform will use to trigger
     *              callbacks for this message.
     * @param format the format of the message. Valid values are {@link SmsMessage#FORMAT_3GPP} and
     * {@link SmsMessage#FORMAT_3GPP2}.
     * @param pdu PDUs representing the contents of the message.
     * @throws IllegalStateException if called before {@link MmTelFeature#onFeatureReady()}
     * @throws RuntimeException if called before {@link #onReady()} is triggered.
     */
    public final void onSmsReceived(int token, String format, byte[] pdu)
            throws IllegalStateException {
    public final void onSmsReceived(int token, String format, byte[] pdu) throws RuntimeException {
        synchronized (mLock) {
            if (mListener == null) {
                throw new IllegalStateException("Feature not ready.");
                throw new RuntimeException("Feature not ready.");
            }
            try {
                mListener.onSmsReceived(token, format, pdu);
@@ -205,11 +210,13 @@ public class SmsImplBase {
     * This method should be triggered by the IMS providers to pass the result of the sent message
     * to the platform.
     *
     * This method must not be called before {@link MmTelFeature#onFeatureReady()} is called.
     *
     * @param token token provided in {@link #sendSms(int, int, String, String, boolean, byte[])}
     * @param messageRef the message reference. Should be between 0 and 255 per TS.123.040
     * @param status result of sending the SMS. Valid values are defined in {@link SendStatusResult}
     * @param status result of sending the SMS. Valid values are:
     *  {@link #SEND_STATUS_OK},
     *  {@link #SEND_STATUS_ERROR},
     *  {@link #SEND_STATUS_ERROR_RETRY},
     *  {@link #SEND_STATUS_ERROR_FALLBACK},
     * @param reason reason in case status is failure. Valid values are:
     *  {@link SmsManager#RESULT_ERROR_NONE},
     *  {@link SmsManager#RESULT_ERROR_GENERIC_FAILURE},
@@ -217,19 +224,41 @@ public class SmsImplBase {
     *  {@link SmsManager#RESULT_ERROR_NULL_PDU},
     *  {@link SmsManager#RESULT_ERROR_NO_SERVICE},
     *  {@link SmsManager#RESULT_ERROR_LIMIT_EXCEEDED},
     *  {@link SmsManager#RESULT_ERROR_FDN_CHECK_FAILURE},
     *  {@link SmsManager#RESULT_ERROR_SHORT_CODE_NOT_ALLOWED},
     *  {@link SmsManager#RESULT_ERROR_SHORT_CODE_NEVER_ALLOWED}
     * @throws IllegalStateException if called before {@link MmTelFeature#onFeatureReady()}
     * @throws RemoteException if the connection to the framework is not available. If this happens
     *  attempting to send the SMS should be aborted.
     *  {@link SmsManager#RESULT_ERROR_SHORT_CODE_NEVER_ALLOWED},
     *  {@link SmsManager#RESULT_RADIO_NOT_AVAILABLE},
     *  {@link SmsManager#RESULT_NETWORK_REJECT},
     *  {@link SmsManager#RESULT_INVALID_ARGUMENTS},
     *  {@link SmsManager#RESULT_INVALID_STATE},
     *  {@link SmsManager#RESULT_NO_MEMORY},
     *  {@link SmsManager#RESULT_INVALID_SMS_FORMAT},
     *  {@link SmsManager#RESULT_SYSTEM_ERROR},
     *  {@link SmsManager#RESULT_MODEM_ERROR},
     *  {@link SmsManager#RESULT_NETWORK_ERROR},
     *  {@link SmsManager#RESULT_ENCODING_ERROR},
     *  {@link SmsManager#RESULT_INVALID_SMSC_ADDRESS},
     *  {@link SmsManager#RESULT_OPERATION_NOT_ALLOWED},
     *  {@link SmsManager#RESULT_INTERNAL_ERROR},
     *  {@link SmsManager#RESULT_NO_RESOURCES},
     *  {@link SmsManager#RESULT_CANCELLED},
     *  {@link SmsManager#RESULT_REQUEST_NOT_SUPPORTED}
     *
     * @throws RuntimeException if called before {@link #onReady()} is triggered or if the
     * connection to the framework is not available. If this happens attempting to send the SMS
     * should be aborted.
     */
    public final void onSendSmsResult(int token, int messageRef,  @SendStatusResult int status,
            int reason) throws IllegalStateException, RemoteException {
            int reason) throws RuntimeException {
        synchronized (mLock) {
            if (mListener == null) {
                throw new IllegalStateException("Feature not ready.");
                throw new RuntimeException("Feature not ready.");
            }
            try {
                mListener.onSendSmsResult(token, messageRef, status, reason);
            } catch (RemoteException e) {
                e.rethrowFromSystemServer();
            }
        }
    }

@@ -241,13 +270,13 @@ public class SmsImplBase {
     * @param format the format of the message. Valid values are {@link SmsMessage#FORMAT_3GPP} and
     * {@link SmsMessage#FORMAT_3GPP2}.
     * @param pdu PDUs representing the content of the status report.
     * @throws IllegalStateException if called before {@link MmTelFeature#onFeatureReady()}
     * @throws RuntimeException if called before {@link #onReady()} is triggered
     */
    public final void onSmsStatusReportReceived(int token, int messageRef, String format,
            byte[] pdu) {
            byte[] pdu) throws RuntimeException{
        synchronized (mLock) {
            if (mListener == null) {
                throw new IllegalStateException("Feature not ready.");
                throw new RuntimeException("Feature not ready.");
            }
            try {
                mListener.onSmsStatusReportReceived(token, messageRef, format, pdu);
@@ -268,4 +297,13 @@ public class SmsImplBase {
    public String getSmsFormat() {
      return SmsMessage.FORMAT_3GPP;
    }

    /**
     * Called when SmsImpl has been initialized and communication with the framework is set up.
     * Any attempt by this class to access the framework before this method is called will return
     * with an {@link RuntimeException}.
     */
    public void onReady() {
        // Base Implementation - Should be overridden
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -61,4 +61,5 @@ interface IImsMMTelFeature {
    oneway void acknowledgeSms(int token, int messageRef, int result);
    oneway void acknowledgeSmsReport(int token, int messageRef, int result);
    String getSmsFormat();
    oneway void onSmsReady();
}