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

Commit 00162530 authored by Sangyun Yun's avatar Sangyun Yun Committed by Android (Google) Code Review
Browse files

Merge "Add DefaultMessageAppSupportedCheck for satellite SOS" into main

parents 1c3ad5bb 62cd748c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -5488,7 +5488,7 @@ public class SatelliteController extends Handler {

    /** If the provision state per subscriberId for the cached is not exist, check the database for
     * the corresponding value and use it. */
    private void updateSatelliteProvisionedStatePerSubscriberId() {
    protected void updateSatelliteProvisionedStatePerSubscriberId() {
        if (!mFeatureFlags.carrierRoamingNbIotNtn()) {
            return;
        }
+39 −0
Original line number Diff line number Diff line
@@ -24,6 +24,9 @@ import static android.telephony.TelephonyManager.EXTRA_EMERGENCY_CALL_TO_SATELLI
import static android.telephony.TelephonyManager.EXTRA_EMERGENCY_CALL_TO_SATELLITE_LAUNCH_INTENT;
import static android.telephony.satellite.SatelliteManager.EMERGENCY_CALL_TO_SATELLITE_HANDOVER_TYPE_SOS;
import static android.telephony.satellite.SatelliteManager.EMERGENCY_CALL_TO_SATELLITE_HANDOVER_TYPE_T911;
import static android.telephony.satellite.SatelliteManager.SATELLITE_DISALLOWED_REASON_NOT_PROVISIONED;
import static android.telephony.satellite.SatelliteManager.SATELLITE_DISALLOWED_REASON_NOT_SUPPORTED;
import static android.telephony.satellite.SatelliteManager.SATELLITE_DISALLOWED_REASON_UNSUPPORTED_DEFAULT_MSG_APP;

import static com.android.internal.telephony.flags.Flags.satellitePersistentLogging;
import static com.android.internal.telephony.satellite.SatelliteController.INVALID_EMERGENCY_CALL_TO_SATELLITE_HANDOVER_TYPE;
@@ -262,8 +265,32 @@ public class SatelliteSOSMessageRecommender extends Handler {
        return SmsApplication.getDefaultSendToApplication(mContext, false);
    }

    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
    protected boolean updateAndGetProvisionState() {
        mSatelliteController.updateSatelliteProvisionedStatePerSubscriberId();
        return isDeviceProvisioned();
    }

    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
    protected boolean isSatelliteAllowedByReasons() {
        SatelliteManager satelliteManager = mContext.getSystemService(SatelliteManager.class);
        List<Integer> disallowedReasons = satelliteManager.getSatelliteDisallowedReasons();
        if (disallowedReasons.stream().anyMatch(r ->
                (r == SATELLITE_DISALLOWED_REASON_UNSUPPORTED_DEFAULT_MSG_APP
                        || r == SATELLITE_DISALLOWED_REASON_NOT_PROVISIONED
                        || r == SATELLITE_DISALLOWED_REASON_NOT_SUPPORTED))) {
            plogd("isAllowedForDefaultMessageApp:false, disallowedReasons=" + disallowedReasons);
            return false;
        }
        return true;
    }

    private void handleEmergencyCallStartedEvent(@NonNull Connection connection) {
        plogd("handleEmergencyCallStartedEvent: connection=" + connection);
        if (!updateAndGetProvisionState() || !isSatelliteAllowedByReasons()) {
            plogd("handleEmergencyCallStartedEvent: not ready to handle emergency call start");
            return;
        }
        mSatelliteController.setLastEmergencyCallTime();

        if (sendEventDisplayEmergencyMessageForcefully(connection)) {
@@ -310,6 +337,12 @@ public class SatelliteSOSMessageRecommender extends Handler {
                return;
            }

            if (!updateAndGetProvisionState() || !isSatelliteAllowedByReasons()) {
                plogd("evaluateSendingConnectionEventDisplayEmergencyMessage: "
                        + "not ready to use satellite.");
                return;
            }

            /*
             * The device might be connected to satellite after the emergency call started. Thus, we
             * need to do this check again so that we will have higher chance of sending the event
@@ -376,6 +409,12 @@ public class SatelliteSOSMessageRecommender extends Handler {
            return;
        }

        if (!updateAndGetProvisionState() || !isSatelliteAllowedByReasons()) {
            plogd("handleEmergencyCallConnectionStateChangedEvent: not ready to use satellite.");
            cleanUpResources(false);
            return;
        }

        String callId = arg.first;
        int state = arg.second;
        if (!mEmergencyConnection.getTelecomCallId().equals(callId)) {
+12 −0
Original line number Diff line number Diff line
@@ -983,6 +983,8 @@ public class SatelliteSOSMessageRecommenderTest extends TelephonyTest {
        private ComponentName mSmsAppComponent = new ComponentName(
                DEFAULT_SATELLITE_MESSAGING_PACKAGE, DEFAULT_SATELLITE_MESSAGING_CLASS);
        private boolean mIsDialerNotified;
        private boolean mProvisionState = true;
        private boolean mSatelliteAllowedByReasons = true;

        /**
         * Create an instance of SatelliteSOSMessageRecommender.
@@ -1017,6 +1019,16 @@ public class SatelliteSOSMessageRecommenderTest extends TelephonyTest {
            mIsDialerNotified = isDialerNotified;
        }

        @Override
        protected boolean updateAndGetProvisionState() {
            return mProvisionState;
        }

        @Override
        protected boolean isSatelliteAllowedByReasons() {
            return mSatelliteAllowedByReasons;
        }

        public boolean isTimerStarted() {
            return hasMessages(EVENT_TIME_OUT);
        }