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

Commit 703103dc authored by Hyosun Kim's avatar Hyosun Kim
Browse files

To use the carrier satellite service, get the EntitlementStatus and...

To use the carrier satellite service,  get the EntitlementStatus and PlmnAllowedList after receiving the HTTP  response from the satellite entitlement server.

If the satellite service is enabled then trigger internal satellite enabled for carrier, otherwise trigger internal satellite disabled for carrier.

Bug: 306670992
Test: atest SatelliteControllerTest
Test: atest TeleServiceTests
Test: Manually test with mock entitlement server for satellite (ag/25356673).
1. Check if a query is triggered when data is connected or CarrierConfigChanged is received.
2. Check if the first query's response with a satellite service enabled triggers internally satellite enabled.
3. Check if a query is not made before the refresh time.
4. Check if the next query's response with a satellite service disabled triggers internally satellite disabled.

Change-Id: I4c8881a57087c8f469feaf8a332ad4066ffd150d
parent c200ba47
Loading
Loading
Loading
Loading
+37 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import static android.telephony.satellite.NtnSignalStrength.NTN_SIGNAL_STRENGTH_
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.KEY_NTN_SIGNAL_STRENGTH;
import static android.telephony.satellite.SatelliteManager.SATELLITE_COMMUNICATION_RESTRICTION_REASON_ENTITLEMENT;
import static android.telephony.satellite.SatelliteManager.SATELLITE_COMMUNICATION_RESTRICTION_REASON_USER;
import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_SUCCESS;

@@ -309,7 +310,7 @@ public class SatelliteController extends Handler {
    private int mEnforcedEmergencyCallToSatelliteHandoverType =
            INVALID_EMERGENCY_CALL_TO_SATELLITE_HANDOVER_TYPE;
    private int mDelayInSendingEventDisplayEmergencyMessage = 0;

    private boolean mCarrierSatelliteEnabled;
    /**
     * @return The singleton instance of SatelliteController.
     */
@@ -2471,6 +2472,41 @@ public class SatelliteController extends Handler {
        return SystemClock.elapsedRealtime();
    }

    /**
     * Update the satellite EntitlementStatus and PlmnAllowedList after receiving the HTTP response
     * from the satellite entitlement server.
     * If the satellite service is enabled then trigger internal satellite enabled for carrier,
     * otherwise trigger internal satellite disabled for carrier.
     */
    public void updateSatelliteEntitlementStatus(int subId, boolean satelliteEnabled,
            List<String> plmnAllowed, IIntegerConsumer callback) {
        if (!mFeatureFlags.carrierEnabledSatelliteFlag()) {
            return;
        }

        if (mCarrierSatelliteEnabled != satelliteEnabled) {
            logd("update the carrier satellite enabled to " + satelliteEnabled);
            mCarrierSatelliteEnabled = satelliteEnabled;
        }

        if (callback == null) {
            callback = new IIntegerConsumer.Stub() {
                @Override
                public void accept(int result) {
                    logd("updateSatelliteEntitlementStatus:" + result);
                }
            };
        }

        if (mCarrierSatelliteEnabled) {
            removeSatelliteAttachRestrictionForCarrier(subId,
                    SATELLITE_COMMUNICATION_RESTRICTION_REASON_ENTITLEMENT, callback);
        } else {
            addSatelliteAttachRestrictionForCarrier(subId,
                    SATELLITE_COMMUNICATION_RESTRICTION_REASON_ENTITLEMENT, callback);
        }
    }

    /**
     * If we have not successfully queried the satellite modem for its satellite service support,
     * we will retry the query one more time. Otherwise, we will return the cached result.
+36 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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 com.android.internal.telephony.satellite;

/**
 * Data class of the satellite configuration received from the entitlement server.
 */
public class SatelliteNetworkInfo {
    /** Stored the allowed plmn for using the satellite service. */
    public String mPlmn;
    /** Stored the DataPlanType. It is an optional value that can be one of the following three
     * values.
     * 1. "unmetered"
     * 2. "metered"
     * 3. empty string. */
    public String mDataPlanType;

    public SatelliteNetworkInfo(String plmn, String dataPlanType) {
        mPlmn = plmn;
        mDataPlanType = dataPlanType;
    }
}
+53 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import static android.telephony.satellite.SatelliteManager.NT_RADIO_TECHNOLOGY_E
import static android.telephony.satellite.SatelliteManager.NT_RADIO_TECHNOLOGY_NB_IOT_NTN;
import static android.telephony.satellite.SatelliteManager.NT_RADIO_TECHNOLOGY_NR_NTN;
import static android.telephony.satellite.SatelliteManager.NT_RADIO_TECHNOLOGY_PROPRIETARY;
import static android.telephony.satellite.SatelliteManager.SATELLITE_COMMUNICATION_RESTRICTION_REASON_ENTITLEMENT;
import static android.telephony.satellite.SatelliteManager.SATELLITE_COMMUNICATION_RESTRICTION_REASON_GEOLOCATION;
import static android.telephony.satellite.SatelliteManager.SATELLITE_COMMUNICATION_RESTRICTION_REASON_USER;
import static android.telephony.satellite.SatelliteManager.SATELLITE_MODEM_STATE_CONNECTED;
@@ -2549,6 +2550,58 @@ public class SatelliteControllerTest extends TelephonyTest {
                semaphore, 0, "testRegisterForSatelliteCapabilitiesChanged"));
    }

    @Test
    public void testSatelliteCommunicationRestrictionForEntitlement() throws Exception {
        when(mFeatureFlags.carrierEnabledSatelliteFlag()).thenReturn(true);

        mCarrierConfigBundle.putBoolean(CarrierConfigManager.KEY_SATELLITE_ATTACH_SUPPORTED_BOOL,
                true);
        replaceInstance(SatelliteController.class, "mCarrierSatelliteEnabled",
                mSatelliteControllerUT, false);

        mIIntegerConsumerResults.clear();
        reset(mMockSatelliteModemInterface);
        setUpResponseForRequestSetSatelliteEnabledForCarrier(true, SATELLITE_RESULT_SUCCESS);
        doReturn(true).when(mMockSatelliteModemInterface).isSatelliteServiceSupported();
        Map<Integer, Set<Integer>> satelliteAttachRestrictionForCarrierArray = new HashMap<>();
        satelliteAttachRestrictionForCarrierArray.put(SUB_ID, new HashSet<>());
        satelliteAttachRestrictionForCarrierArray.get(SUB_ID).add(
                SATELLITE_COMMUNICATION_RESTRICTION_REASON_ENTITLEMENT);
        replaceInstance(SatelliteController.class, "mSatelliteAttachRestrictionForCarrierArray",
                mSatelliteControllerUT, satelliteAttachRestrictionForCarrierArray);

        // Verify call the requestSetSatelliteEnabledForCarrier to enable the satellite when
        // satellite service is enabled by entitlement server.
        mSatelliteControllerUT.updateSatelliteEntitlementStatus(SUB_ID, true, new ArrayList<>(),
                mIIntegerConsumer);
        processAllMessages();

        assertTrue(waitForIIntegerConsumerResult(1));
        assertEquals(SATELLITE_RESULT_SUCCESS, (long) mIIntegerConsumerResults.get(0));
        verify(mMockSatelliteModemInterface, times(1))
                .requestSetSatelliteEnabledForCarrier(anyInt(), eq(true), any(Message.class));

        // Verify call the requestSetSatelliteEnabledForCarrier to disable the satellite when
        // satellite service is disabled by entitlement server.
        mIIntegerConsumerResults.clear();
        reset(mMockSatelliteModemInterface);
        Map<Integer, Boolean> enabledForCarrierArrayPerSub = new HashMap<>();
        enabledForCarrierArrayPerSub.put(SUB_ID, true);
        replaceInstance(SatelliteController.class, "mIsSatelliteAttachEnabledForCarrierArrayPerSub",
                mSatelliteControllerUT, enabledForCarrierArrayPerSub);
        doReturn(mIsSatelliteServiceSupported)
                .when(mMockSatelliteModemInterface).isSatelliteServiceSupported();
        setUpResponseForRequestSetSatelliteEnabledForCarrier(false, SATELLITE_RESULT_SUCCESS);
        mSatelliteControllerUT.updateSatelliteEntitlementStatus(SUB_ID, false, new ArrayList<>(),
                mIIntegerConsumer);
        processAllMessages();

        assertTrue(waitForIIntegerConsumerResult(1));
        assertEquals(SATELLITE_RESULT_SUCCESS, (long) mIIntegerConsumerResults.get(0));
        verify(mMockSatelliteModemInterface, times(1))
                .requestSetSatelliteEnabledForCarrier(anyInt(), eq(false), any(Message.class));
    }

    private void resetSatelliteControllerUTEnabledState() {
        logd("resetSatelliteControllerUTEnabledState");
        setUpResponseForRequestIsSatelliteSupported(false, SATELLITE_RESULT_RADIO_NOT_AVAILABLE);