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

Commit 076b637f authored by Duke Lee's avatar Duke Lee Committed by Sungcheol Ahn
Browse files

Add notification when satellite availability changes



When satellite availaibility changes, we need to notify the state to users so that they're aware of it.
Specifically, when the satellite connectivity is not available, we need to show users the reason so that
they can act accordingly. For example, if we show that satellite connectivity is not available because
location settings is disabled, users can enable location settings and check availability again.

Add getSupportedMsgApps() and change access modifier of isSatelliteServiceSupportedByCarrier() from private to public.

Test: Manual
Bug: 376694756
Flag: EXEMPT bugfix

Change-Id: Ifc70aacf8a6797e9a269715620bb7a85ed98ae20
Signed-off-by: default avatarDuke Lee <deukmo.lee@samsung.corp-partner.google.com>
parent 6688de78
Loading
Loading
Loading
Loading
+32 −5
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import static android.telephony.CarrierConfigManager.KEY_SATELLITE_CONNECTION_HY
import static android.telephony.CarrierConfigManager.KEY_SATELLITE_ENTITLEMENT_SUPPORTED_BOOL;
import static android.telephony.CarrierConfigManager.KEY_SATELLITE_ESOS_SUPPORTED_BOOL;
import static android.telephony.CarrierConfigManager.KEY_SATELLITE_SOS_MAX_DATAGRAM_SIZE;
import static android.telephony.CarrierConfigManager.KEY_SATELLITE_SUPPORTED_MSG_APPS_STRING_ARRAY;
import static android.telephony.CarrierConfigManager.KEY_SATELLITE_NIDD_APN_NAME_STRING;
import static android.telephony.CarrierConfigManager.KEY_SATELLITE_ROAMING_ESOS_INACTIVITY_TIMEOUT_SEC_INT;
import static android.telephony.CarrierConfigManager.KEY_SATELLITE_ROAMING_P2P_SMS_INACTIVITY_TIMEOUT_SEC_INT;
@@ -108,7 +109,6 @@ import android.os.ServiceSpecificException;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.provider.Telephony;
import android.telecom.TelecomManager;
@@ -5068,7 +5068,8 @@ public class SatelliteController extends Handler {
                        KEY_SATELLITE_ROAMING_SCREEN_OFF_INACTIVITY_TIMEOUT_SEC_INT,
                        KEY_SATELLITE_ROAMING_P2P_SMS_INACTIVITY_TIMEOUT_SEC_INT,
                        KEY_SATELLITE_ROAMING_ESOS_INACTIVITY_TIMEOUT_SEC_INT,
                        KEY_SATELLITE_SOS_MAX_DATAGRAM_SIZE
                        KEY_SATELLITE_SOS_MAX_DATAGRAM_SIZE,
                        KEY_SATELLITE_SUPPORTED_MSG_APPS_STRING_ARRAY
                );
            } catch (Exception e) {
                logw("getConfigForSubId: " + e);
@@ -5554,6 +5555,17 @@ public class SatelliteController extends Handler {
        }
    }

    /**
     * Returns a list of messaging apps that support satellite.
     */
    @NonNull public List<String> getSatelliteSupportedMsgApps(int subId) {
        String[] satelliteSupportedMsgApps = getConfigForSubId(subId)
                .getStringArray(KEY_SATELLITE_SUPPORTED_MSG_APPS_STRING_ARRAY);

        return satelliteSupportedMsgApps != null
                ? List.of(satelliteSupportedMsgApps) : Collections.emptyList();
    }

    private void sendErrorAndReportSessionMetrics(@SatelliteManager.SatelliteResult int error,
            Consumer<Integer> result) {
        result.accept(error);
@@ -7078,7 +7090,15 @@ public class SatelliteController extends Handler {
        return true;
    }

    private boolean isSatelliteServiceSupportedByCarrier(int subId,

    /**
     * Checks if the satellite service is supported by the carrier for the specified
     * subscription ID and servicetype.
     *
     * @param subId The subscription id.
     * @param serviceType The type of service to check
     */
    public boolean isSatelliteServiceSupportedByCarrier(int subId,
            @NetworkRegistrationInfo.ServiceType int serviceType) {
        List<String> satellitePlmnList = getSatellitePlmnsForCarrier(subId);
        for (String satellitePlmn : satellitePlmnList) {
@@ -7456,8 +7476,15 @@ public class SatelliteController extends Handler {
        }
        plogd("updateLastNotifiedNtnAvailableServicesAndNotify: phoneId= " + phone.getPhoneId());

        if (isSatelliteSupportedViaCarrier(subId)) {
            // TODO: Invoke SatelliteManager#getSatelliteDisallowedReasons() NOT EMPTY.
        SatelliteManager satelliteManager = mContext.getSystemService(SatelliteManager.class);
        if (satelliteManager == null) {
            plogd("updateLastNotifiedNtnAvailableServicesAndNotify: satelliteManager is null");
            phone.notifyCarrierRoamingNtnAvailableServicesChanged(new int[0]);
            return;
        }
        List<Integer> satelliteDisallowedReasons = satelliteManager.getSatelliteDisallowedReasons();
        if (isSatelliteSupportedViaCarrier(subId)
                && (satelliteDisallowedReasons != null && !satelliteDisallowedReasons.isEmpty())) {
            int[] services = getSupportedSatelliteServicesForCarrier(subId);
            if (isP2PSmsDisallowedOnCarrierRoamingNtn(subId)) {
                services = Arrays.stream(services).filter(