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

Commit 46bcd661 authored by Hwangoo Park's avatar Hwangoo Park
Browse files

Add interworking with EmergencyStateTracker for sending emergency SMS

This adds the interworking implementation for emergency SMS with the
EmergencyStateTracker. When an emergency SMS is being sent, the
SmsDispatchersController calls the startEmergencySms, then the
EmergencyStateTracker sets the emergency mode to the modem and if the
emergency SMS completely sends regardless of the success or failure, it
should call the endSms, then the EmergencyStateTracker exits the
emergency mode or enters the emergency SMS callback mode if needed.

Bug: 262804071
Test: atest SmsDispatchersControllerTest, EmergencyStateTrackerTest
Test: manual (verify emergency SMS using test number on device when
domain selection disabled)
Test: manual (verify emergency SMS using test number/equipment on device
when domain selection enabled)
Test: manual (verify normal MO SMS on device when domain selection
disabled)
Test: manual (verify normal MO SMS on device when domain selection
enabled)

Change-Id: I7310c1affa3d8e474de7f3f9f81a9af56a17c2c9
parent 3536e852
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -6,3 +6,10 @@ flag {
  description: "Previously, the DB allows insertion of a random sub Id, but doesn't allow query it. This change rejects such interaction."
  bug: "294125411"
}

flag {
  name: "sms_domain_selection_enabled"
  namespace: "telephony"
  description: "This flag controls AP domain selection support for normal/emergency SMS."
  bug: "262804071"
}
+1 −1
Original line number Diff line number Diff line
@@ -463,7 +463,7 @@ public class GsmCdmaPhone extends Phone {
        mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, LOG_TAG);
        mIccSmsInterfaceManager = mTelephonyComponentFactory
                .inject(IccSmsInterfaceManager.class.getName())
                .makeIccSmsInterfaceManager(this);
                .makeIccSmsInterfaceManager(this, mFeatureFlags);

        mCi.registerForAvailable(this, EVENT_RADIO_AVAILABLE, null);
        mCi.registerForOffOrNotAvailable(this, EVENT_RADIO_OFF_OR_NOT_AVAILABLE, null);
+4 −2
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.telephony.SmsManager.STATUS_ON_ICC_READ;
import static android.telephony.SmsManager.STATUS_ON_ICC_UNREAD;

import android.Manifest;
import android.annotation.NonNull;
import android.annotation.RequiresPermission;
import android.app.AppOpsManager;
import android.app.PendingIntent;
@@ -47,6 +48,7 @@ import android.util.Log;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.cdma.CdmaSmsBroadcastConfigInfo;
import com.android.internal.telephony.flags.FeatureFlags;
import com.android.internal.telephony.gsm.SmsBroadcastConfigInfo;
import com.android.internal.telephony.uicc.IccConstants;
import com.android.internal.telephony.uicc.IccFileHandler;
@@ -155,11 +157,11 @@ public class IccSmsInterfaceManager {
        }
    };

    protected IccSmsInterfaceManager(Phone phone) {
    protected IccSmsInterfaceManager(Phone phone, @NonNull FeatureFlags featureFlags) {
        this(phone, phone.getContext(),
                (AppOpsManager) phone.getContext().getSystemService(Context.APP_OPS_SERVICE),
                new SmsDispatchersController(
                        phone, phone.mSmsStorageMonitor, phone.mSmsUsageMonitor),
                        phone, phone.mSmsStorageMonitor, phone.mSmsUsageMonitor, featureFlags),
                new SmsPermissions(phone, phone.getContext(),
                        (AppOpsManager) phone.getContext().getSystemService(
                                Context.APP_OPS_SERVICE)));
+4 −0
Original line number Diff line number Diff line
@@ -202,10 +202,13 @@ public class ImsSmsDispatcher extends SMSDispatcher {
                        tracker.onSent(mContext);
                        mTrackers.remove(token);
                        mPhone.notifySmsSent(tracker.mDestAddress);
                        mSmsDispatchersController.notifySmsSentToEmergencyStateTracker(
                                tracker.mDestAddress, tracker.mMessageId);
                        break;
                    case ImsSmsImplBase.SEND_STATUS_ERROR:
                        tracker.onFailed(mContext, reason, networkReasonCode);
                        mTrackers.remove(token);
                        notifySmsSentFailedToEmergencyStateTracker(tracker);
                        break;
                    case ImsSmsImplBase.SEND_STATUS_ERROR_RETRY:
                        int maxRetryCountOverIms = getMaxRetryCountOverIms();
@@ -224,6 +227,7 @@ public class ImsSmsDispatcher extends SMSDispatcher {
                        } else {
                            tracker.onFailed(mContext, reason, networkReasonCode);
                            mTrackers.remove(token);
                            notifySmsSentFailedToEmergencyStateTracker(tracker);
                        }
                        break;
                    case ImsSmsImplBase.SEND_STATUS_ERROR_FALLBACK:
+15 −0
Original line number Diff line number Diff line
@@ -1009,6 +1009,16 @@ public abstract class SMSDispatcher extends Handler {
     */
    protected abstract boolean shouldBlockSmsForEcbm();

    /**
     * Notifies the {@link SmsDispatchersController} that sending MO SMS is failed.
     *
     * @param tracker holds the SMS message to be sent
     */
    protected void notifySmsSentFailedToEmergencyStateTracker(SmsTracker tracker) {
        mSmsDispatchersController.notifySmsSentFailedToEmergencyStateTracker(
                tracker.mDestAddress, tracker.mMessageId);
    }

    /**
     * Called when SMS send completes. Broadcasts a sentIntent on success.
     * On failure, either sets up retries or broadcasts a sentIntent with
@@ -1041,6 +1051,8 @@ public abstract class SMSDispatcher extends Handler {
            }
            tracker.onSent(mContext);
            mPhone.notifySmsSent(tracker.mDestAddress);
            mSmsDispatchersController.notifySmsSentToEmergencyStateTracker(
                    tracker.mDestAddress, tracker.mMessageId);

            mPhone.getSmsStats().onOutgoingSms(
                    tracker.mImsRetry > 0 /* isOverIms */,
@@ -1091,6 +1103,7 @@ public abstract class SMSDispatcher extends Handler {
            // if sms over IMS is not supported on data and voice is not available...
            if (!isIms() && ss != ServiceState.STATE_IN_SERVICE) {
                tracker.onFailed(mContext, getNotInServiceError(ss), NO_ERROR_CODE);
                notifySmsSentFailedToEmergencyStateTracker(tracker);
                mPhone.getSmsStats().onOutgoingSms(
                        tracker.mImsRetry > 0 /* isOverIms */,
                        SmsConstants.FORMAT_3GPP2.equals(getFormat()),
@@ -1151,6 +1164,7 @@ public abstract class SMSDispatcher extends Handler {
            } else {
                int errorCode = (smsResponse != null) ? smsResponse.mErrorCode : NO_ERROR_CODE;
                tracker.onFailed(mContext, error, errorCode);
                notifySmsSentFailedToEmergencyStateTracker(tracker);
                mPhone.getSmsStats().onOutgoingSms(
                        tracker.mImsRetry > 0 /* isOverIms */,
                        SmsConstants.FORMAT_3GPP2.equals(getFormat()),
@@ -2375,6 +2389,7 @@ public abstract class SMSDispatcher extends Handler {
            int errorCode) {
        for (SmsTracker tracker : trackers) {
            tracker.onFailed(mContext, error, errorCode);
            notifySmsSentFailedToEmergencyStateTracker(tracker);
        }
        if (trackers.length > 0) {
            // This error occurs before the SMS is sent. Make an assumption if it would have
Loading