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

Commit 2ed72abe authored by Daniel Banta's avatar Daniel Banta
Browse files

Add requestSelectedSatelliteSubscriptionId API to SatelliteController.

Bug: 378557737
Change-Id: I2b7e45aafd6a91c8a25c35275dfe928eb579d2c2
Test: atest SatelliteManagerTest
FLAG: com.android.internal.telephony.flags.carrier_roaming_nb_iot_ntn
parent 61c41ed7
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ import static android.telephony.satellite.SatelliteManager.SATELLITE_COMMUNICATI
import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_INVALID_ARGUMENTS;
import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_MODEM_ERROR;
import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_MODEM_TIMEOUT;
import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_NO_VALID_SATELLITE_SUBSCRIPTION;
import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_REQUEST_ABORTED;
import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_REQUEST_NOT_SUPPORTED;
import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_SUCCESS;
@@ -7051,6 +7052,34 @@ public class SatelliteController extends Handler {
        }
    }

    /**
     * Request to get the currently selected satellite subscription id.
     *
     * @param result The result receiver that returns the currently selected satellite subscription
     *               id if the request is successful or an error code if the request failed.
     */
    public void requestSelectedNbIotSatelliteSubscriptionId(@NonNull ResultReceiver result) {
        if (!mFeatureFlags.carrierRoamingNbIotNtn()) {
            result.send(SATELLITE_RESULT_REQUEST_NOT_SUPPORTED, null);
            logd("requestSelectedNbIotSatelliteSubscriptionId: carrierRoamingNbIotNtn is disabled");
            return;
        }

        int selectedSatelliteSubId = getSelectedSatelliteSubId();
        plogd("requestSelectedNbIotSatelliteSubscriptionId: " + selectedSatelliteSubId);
        if (selectedSatelliteSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
            result.send(SATELLITE_RESULT_NO_VALID_SATELLITE_SUBSCRIPTION, null);
            logd("requestSelectedNbIotSatelliteSubscriptionId: "
                    + "selectedSatelliteSubId is invalid");
            return;
        }

        Bundle bundle = new Bundle();
        bundle.putInt(SatelliteManager.KEY_SELECTED_NB_IOT_SATELLITE_SUBSCRIPTION_ID,
                selectedSatelliteSubId);
        result.send(SATELLITE_RESULT_SUCCESS, bundle);
    }

    private void selectBindingSatelliteSubscription(boolean shouldIgnoreEnabledState) {
        if ((isSatelliteEnabled() || isSatelliteBeingEnabled()) && !shouldIgnoreEnabledState) {
            plogd("selectBindingSatelliteSubscription: satellite subscription will be selected "