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

Commit 7073c075 authored by Mohamed Abdalkader's avatar Mohamed Abdalkader Committed by Brad Ebinger
Browse files

Remove internal version of SMS apis

Test: manual
BUG=69846044
Merged-In: Ie084ea67c460c686bd587e4b36f8c1579517ea7f
Change-Id: Ie084ea67c460c686bd587e4b36f8c1579517ea7f
parent 6e545d58
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -471,7 +471,6 @@ java_library {
        "telephony/java/android/telephony/ims/internal/aidl/IImsRcsFeature.aidl",
        "telephony/java/android/telephony/ims/internal/aidl/IImsServiceController.aidl",
        "telephony/java/android/telephony/ims/internal/aidl/IImsServiceControllerListener.aidl",
	"telephony/java/android/telephony/ims/internal/aidl/IImsSmsListener.aidl",
	"telephony/java/android/telephony/mbms/IMbmsDownloadSessionCallback.aidl",
        "telephony/java/android/telephony/mbms/IMbmsStreamingSessionCallback.aidl",
        "telephony/java/android/telephony/mbms/IDownloadStateCallback.aidl",
+0 −273
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License
 */

package android.telephony.ims.internal;

import android.annotation.IntDef;
import android.os.RemoteException;
import android.telephony.SmsManager;
import android.telephony.SmsMessage;
import android.telephony.ims.internal.aidl.IImsSmsListener;
import android.telephony.ims.internal.feature.MmTelFeature;
import android.util.Log;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
 * Base implementation for SMS over IMS.
 *
 * Any service wishing to provide SMS over IMS should extend this class and implement all methods
 * that the service supports.
 * @hide
 */
public class SmsImplBase {
  private static final String LOG_TAG = "SmsImplBase";

  /** @hide */
  @IntDef({
          SEND_STATUS_OK,
          SEND_STATUS_ERROR,
          SEND_STATUS_ERROR_RETRY,
          SEND_STATUS_ERROR_FALLBACK
      })
  @Retention(RetentionPolicy.SOURCE)
  public @interface SendStatusResult {}
  /**
   * Message was sent successfully.
   */
  public static final int SEND_STATUS_OK = 1;

  /**
   * IMS provider failed to send the message and platform should not retry falling back to sending
   * the message using the radio.
   */
  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.
   */
  public static final int SEND_STATUS_ERROR_RETRY = 3;

  /**
   * IMS provider failed to send the message and platform should retry falling back to sending
   * the message using the radio.
   */
  public static final int SEND_STATUS_ERROR_FALLBACK = 4;

  /** @hide */
  @IntDef({
          DELIVER_STATUS_OK,
          DELIVER_STATUS_ERROR
      })
  @Retention(RetentionPolicy.SOURCE)
  public @interface DeliverStatusResult {}
  /**
   * Message was delivered successfully.
   */
  public static final int DELIVER_STATUS_OK = 1;

  /**
   * Message was not delivered.
   */
  public static final int DELIVER_STATUS_ERROR = 2;

  /** @hide */
  @IntDef({
          STATUS_REPORT_STATUS_OK,
          STATUS_REPORT_STATUS_ERROR
      })
  @Retention(RetentionPolicy.SOURCE)
  public @interface StatusReportResult {}

  /**
   * Status Report was set successfully.
   */
  public static final int STATUS_REPORT_STATUS_OK = 1;

  /**
   * Error while setting status report.
   */
  public static final int STATUS_REPORT_STATUS_ERROR = 2;


  // Lock for feature synchronization
  private final Object mLock = new Object();
  private IImsSmsListener mListener;

  /**
   * Registers a listener responsible for handling tasks like delivering messages.
   *
   * @param listener listener to register.
   *
   * @hide
   */
  public final void registerSmsListener(IImsSmsListener listener) {
      synchronized (mLock) {
          mListener = listener;
      }
  }

  /**
   * This method will be triggered by the platform when the user attempts to send an SMS. This
   * method should be implemented by the IMS providers to provide implementation of sending an SMS
   * over IMS.
   *
   * @param token unique token generated by the platform that should be used when triggering
   *             callbacks for this specific message.
   * @param messageRef the message reference.
   * @param format the format of the message. Valid values are {@link SmsMessage#FORMAT_3GPP} and
   *               {@link SmsMessage#FORMAT_3GPP2}.
   * @param smsc the Short Message Service Center address.
   * @param isRetry whether it is a retry of an already attempted message or not.
   * @param pdu PDUs representing the contents of the message.
   */
  public void sendSms(int token, int messageRef, String format, String smsc, boolean isRetry,
                      byte[] pdu) {
    // Base implementation returns error. Should be overridden.
    try {
      onSendSmsResult(token, messageRef, SEND_STATUS_ERROR,
              SmsManager.RESULT_ERROR_GENERIC_FAILURE);
    } catch (RemoteException 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.
   *
   * @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 messageRef the message reference
   */
  public void acknowledgeSms(int token, int messageRef, @DeliverStatusResult int result) {
    Log.e(LOG_TAG, "acknowledgeSms() not implemented.");
  }

  /**
   * This method will be triggered by the platform after
   * {@link #onSmsStatusReportReceived(int, int, String, byte[])} has been called to provide the
   * 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 messageRef the message reference
   */
  public void acknowledgeSmsReport(int token, int messageRef, @StatusReportResult int result) {
    Log.e(LOG_TAG, "acknowledgeSmsReport() not implemented.");
  }

  /**
   * This method should be triggered by the IMS providers when there is an incoming message. The
   * 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()}
   */
  public final void onSmsReceived(int token, String format, byte[] pdu)
          throws IllegalStateException {
    synchronized (mLock) {
      if (mListener == null) {
        throw new IllegalStateException("Feature not ready.");
      }
      try {
        mListener.onSmsReceived(token, format, pdu);
      } catch (RemoteException e) {
        Log.e(LOG_TAG, "Can not deliver sms: " + e.getMessage());
        acknowledgeSms(token, 0, DELIVER_STATUS_ERROR);
      }
    }
  }

  /**
   * 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 reason reason in case status is failure. Valid values are:
   *  {@link SmsManager#RESULT_ERROR_NONE},
   *  {@link SmsManager#RESULT_ERROR_GENERIC_FAILURE},
   *  {@link SmsManager#RESULT_ERROR_RADIO_OFF},
   *  {@link SmsManager#RESULT_ERROR_NULL_PDU},
   *  {@link SmsManager#RESULT_ERROR_NO_SERVICE},
   *  {@link SmsManager#RESULT_ERROR_LIMIT_EXCEEDED},
   *  {@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.
   */
  public final void onSendSmsResult(int token, int messageRef, @SendStatusResult int status,
      int reason) throws IllegalStateException, RemoteException {
    synchronized (mLock) {
      if (mListener == null) {
        throw new IllegalStateException("Feature not ready.");
      }
      mListener.onSendSmsResult(token, messageRef, status, reason);
    }
  }

  /**
   * Sets the status report of the sent message.
   *
   * @param token token provided in {@link #sendSms(int, int, String, String, boolean, byte[])}
   * @param messageRef the message reference.
   * @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()}
   */
  public final void onSmsStatusReportReceived(int token, int messageRef, String format,
      byte[] pdu) {
    synchronized (mLock) {
      if (mListener == null) {
        throw new IllegalStateException("Feature not ready.");
      }
      try {
        mListener.onSmsStatusReportReceived(token, messageRef, format, pdu);
      } catch (RemoteException e) {
        Log.e(LOG_TAG, "Can not process sms status report: " + e.getMessage());
        acknowledgeSmsReport(token, messageRef, STATUS_REPORT_STATUS_ERROR);
      }
    }
  }

  /**
   * Returns the SMS format. Default is {@link SmsMessage#FORMAT_3GPP} unless overridden by IMS
   * Provider.
   *
   * @return  the format of the message. Valid values are {@link SmsMessage#FORMAT_3GPP} and
   * {@link SmsMessage#FORMAT_3GPP2}.
   */
  public String getSmsFormat() {
    return SmsMessage.FORMAT_3GPP;
  }

}
+0 −8
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package android.telephony.ims.internal.aidl;

import android.os.Message;
import android.telephony.ims.internal.aidl.IImsMmTelListener;
import android.telephony.ims.internal.aidl.IImsSmsListener;
import android.telephony.ims.internal.aidl.IImsCapabilityCallback;
import android.telephony.ims.internal.aidl.IImsCallSessionListener;
import android.telephony.ims.internal.feature.CapabilityChangeRequest;
@@ -50,11 +49,4 @@ interface IImsMmTelFeature {
            IImsCapabilityCallback c);
    oneway void queryCapabilityConfiguration(int capability, int radioTech,
            IImsCapabilityCallback c);
    // SMS APIs
    void setSmsListener(IImsSmsListener l);
    oneway void sendSms(in int token, int messageRef, String format, String smsc, boolean retry,
            in byte[] pdu);
    oneway void acknowledgeSms(int token, int messageRef, int result);
    oneway void acknowledgeSmsReport(int token, int messageRef, int result);
    String getSmsFormat();
}
+0 −28
Original line number Diff line number Diff line
/*
 * Copyright (c) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.telephony.ims.internal.aidl;

/**
 * See MMTelFeature for more information.
 * {@hide}
 */
interface IImsSmsListener {
    void onSendSmsResult(in int token, in int messageRef, in int status, in int reason);
    void onSmsStatusReportReceived(in int token, in int messageRef, in String format,
            in byte[] pdu);
    void onSmsReceived(in int token, in String format, in byte[] pdu);
}
 No newline at end of file
+0 −69
Original line number Diff line number Diff line
@@ -21,14 +21,10 @@ import android.os.Message;
import android.os.RemoteException;
import android.telecom.TelecomManager;
import android.telephony.ims.internal.ImsCallSessionListener;
import android.telephony.ims.internal.SmsImplBase;
import android.telephony.ims.internal.SmsImplBase.DeliverStatusResult;
import android.telephony.ims.internal.SmsImplBase.StatusReportResult;
import android.telephony.ims.internal.aidl.IImsCallSessionListener;
import android.telephony.ims.internal.aidl.IImsCapabilityCallback;
import android.telephony.ims.internal.aidl.IImsMmTelFeature;
import android.telephony.ims.internal.aidl.IImsMmTelListener;
import android.telephony.ims.internal.aidl.IImsSmsListener;
import android.telephony.ims.stub.ImsRegistrationImplBase;
import android.telephony.ims.stub.ImsEcbmImplBase;
import android.telephony.ims.stub.ImsMultiEndpointImplBase;
@@ -67,11 +63,6 @@ public class MmTelFeature extends ImsFeature {
            }
        }

        @Override
        public void setSmsListener(IImsSmsListener l) throws RemoteException {
            MmTelFeature.this.setSmsListener(l);
        }

        @Override
        public int getFeatureState() throws RemoteException {
            synchronized (mLock) {
@@ -152,35 +143,6 @@ public class MmTelFeature extends ImsFeature {
                IImsCapabilityCallback c) {
            queryCapabilityConfigurationInternal(capability, radioTech, c);
        }

        @Override
        public void sendSms(int token, int messageRef, String format, String smsc, boolean retry,
                byte[] pdu) {
            synchronized (mLock) {
                MmTelFeature.this.sendSms(token, messageRef, format, smsc, retry, pdu);
            }
        }

        @Override
        public void acknowledgeSms(int token, int messageRef, int result) {
            synchronized (mLock) {
                MmTelFeature.this.acknowledgeSms(token, messageRef, result);
            }
        }

        @Override
        public void acknowledgeSmsReport(int token, int messageRef, int result) {
            synchronized (mLock) {
                MmTelFeature.this.acknowledgeSmsReport(token, messageRef, result);
            }
        }

        @Override
        public String getSmsFormat() {
            synchronized (mLock) {
                return MmTelFeature.this.getSmsFormat();
            }
        }
    };

    /**
@@ -292,10 +254,6 @@ public class MmTelFeature extends ImsFeature {
        }
    }

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

    private void queryCapabilityConfigurationInternal(int capability, int radioTech,
            IImsCapabilityCallback c) {
        boolean enabled = queryCapabilityConfiguration(capability, radioTech);
@@ -457,33 +415,6 @@ public class MmTelFeature extends ImsFeature {
        // Base Implementation - Should be overridden
    }

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

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

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

    private String getSmsFormat() {
        return getSmsImplementation().getSmsFormat();
    }

    /**
     * Must be overridden by IMS Provider to be able to support SMS over IMS. Otherwise a default
     * non-functional implementation is returned.
     *
     * @return an instance of {@link SmsImplBase} which should be implemented by the IMS Provider.
     */
    protected SmsImplBase getSmsImplementation() {
        return new SmsImplBase();
    }

    /**{@inheritDoc}*/
    @Override
    public void onFeatureRemoved() {