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

Commit fd74f50a authored by Aishwarya Mallampati's avatar Aishwarya Mallampati
Browse files

Update the logic of calling setSatelliteEnabledForCarrier HAL API.

The following changes are made in this cl:
- setSatelliteEnabledForCarrier() is called always irrespective of
  satellite enabled state at modem
- setSatelliteEanbledForCarrier(true) will be called only for
  subscriptions with automic connect type

Bug: 406683232
Test: atest SatelliteControllerTest, atest
SatelliteManagerTestOnMockService
Flag: EXEMPT bugfix
Change-Id: I95b0674f86660f45eeb11ceed4ac3a3c7161bb4b

Change-Id: I3354776fd7e71865e2fec9d31f0b05f7649600e7
parent affac042
Loading
Loading
Loading
Loading
+14 −18
Original line number Diff line number Diff line
@@ -6165,17 +6165,16 @@ public class SatelliteController extends Handler {
            return;
        }

        /* Request to enable or disable the satellite in the cellular modem only when the desired
        state and the current state are different. */
        /* Request to enable or disable the satellite in the cellular modem. */
        boolean isSatelliteExpectedToBeEnabled = !isSatelliteRestrictedForCarrier(subId)
                && isSatelliteSupportedViaCarrier(subId);
                && isSatelliteSupportedViaCarrier(subId)
                && getCarrierRoamingNtnConnectType(subId) == CARRIER_ROAMING_NTN_CONNECT_AUTOMATIC;
        boolean isSatelliteEnabledForCarrierAtModem = isSatelliteEnabledForCarrierAtModem(
                phone.getSubId());
        plogd("evaluateEnablingSatelliteForCarrier: subId=" + subId + " reason=" + reason
                + " isSatelliteExpectedToBeEnabled=" + isSatelliteExpectedToBeEnabled
                + " isSatelliteEnabledForCarrierAtModem=" + isSatelliteEnabledForCarrierAtModem);

        if (isSatelliteExpectedToBeEnabled != isSatelliteEnabledForCarrierAtModem) {
        int simSlot = SubscriptionManager.getSlotIndex(subId);
        RequestHandleSatelliteAttachRestrictionForCarrierArgument argument =
                new RequestHandleSatelliteAttachRestrictionForCarrierArgument(subId,
@@ -6187,9 +6186,6 @@ public class SatelliteController extends Handler {
                EVENT_EVALUATE_SATELLITE_ATTACH_RESTRICTION_CHANGE_DONE, request);
        phone.setSatelliteEnabledForCarrier(simSlot,
                isSatelliteExpectedToBeEnabled, onCompleted);
        } else {
            callback.accept(SATELLITE_RESULT_SUCCESS);
        }
    }

    @SatelliteManager.SatelliteResult private int evaluateOemSatelliteRequestAllowed(
+9 −6
Original line number Diff line number Diff line
@@ -2369,14 +2369,15 @@ public class SatelliteControllerTest extends TelephonyTest {
        // Add satellite attach restriction reason by user
        mIIntegerConsumerResults.clear();
        reset(mMockSatelliteModemInterface);
        reset(mPhone);
        setUpResponseForRequestSetSatelliteEnabledForCarrier(false, SATELLITE_RESULT_SUCCESS);
        doReturn(true).when(mMockSatelliteModemInterface).isSatelliteServiceSupported();
        mSatelliteControllerUT.addAttachRestrictionForCarrier(SUB_ID,
                SATELLITE_COMMUNICATION_RESTRICTION_REASON_USER, mIIntegerConsumer);
        processAllMessages();
        assertEquals(SATELLITE_RESULT_SUCCESS, (long) mIIntegerConsumerResults.get(0));
        verify(mPhone, never())
                .setSatelliteEnabledForCarrier(anyInt(), anyBoolean(), any(Message.class));
        verify(mPhone, times(1))
                .setSatelliteEnabledForCarrier(anyInt(), eq(false), any(Message.class));
        assertTrue(waitForIIntegerConsumerResult(1));
        restrictionSet =
                mSatelliteControllerUT.getAttachRestrictionReasonsForCarrier(SUB_ID);
@@ -2385,6 +2386,7 @@ public class SatelliteControllerTest extends TelephonyTest {
        // remove satellite restriction reason by user
        mIIntegerConsumerResults.clear();
        reset(mMockSatelliteModemInterface);
        reset(mPhone);
        setUpResponseForRequestSetSatelliteEnabledForCarrier(true, SATELLITE_RESULT_SUCCESS);
        doReturn(true).when(mMockSatelliteModemInterface).isSatelliteServiceSupported();
        mSatelliteControllerUT.removeAttachRestrictionForCarrier(SUB_ID,
@@ -2428,8 +2430,8 @@ public class SatelliteControllerTest extends TelephonyTest {
        restrictionSet =
                mSatelliteControllerUT.getAttachRestrictionReasonsForCarrier(SUB_ID);
        assertTrue(restrictionSet.contains(SATELLITE_COMMUNICATION_RESTRICTION_REASON_GEOLOCATION));
        verify(mPhone, never())
                .setSatelliteEnabledForCarrier(anyInt(), anyBoolean(), any(Message.class));
        verify(mPhone, times(1))
                .setSatelliteEnabledForCarrier(anyInt(), eq(false), any(Message.class));

        // remove satellite attach restriction reason by geolocation
        mIIntegerConsumerResults.clear();
@@ -2445,8 +2447,8 @@ public class SatelliteControllerTest extends TelephonyTest {
                mSatelliteControllerUT.getAttachRestrictionReasonsForCarrier(SUB_ID);
        assertTrue(!restrictionSet.contains(
                SATELLITE_COMMUNICATION_RESTRICTION_REASON_GEOLOCATION));
        verify(mPhone, never())
                .setSatelliteEnabledForCarrier(anyInt(), anyBoolean(), any(Message.class));
        verify(mPhone, times(2))
                .setSatelliteEnabledForCarrier(anyInt(), eq(false), any(Message.class));

        // remove satellite restriction reason by user
        mIIntegerConsumerResults.clear();
@@ -2941,6 +2943,7 @@ public class SatelliteControllerTest extends TelephonyTest {
        // satellite service is disabled by entitlement server.
        mIIntegerConsumerResults.clear();
        reset(mMockSatelliteModemInterface);
        reset(mPhone);
        Map<Integer, Boolean> enabledForCarrierArrayPerSub = new HashMap<>();
        enabledForCarrierArrayPerSub.put(SUB_ID, true);
        replaceInstance(SatelliteController.class, "mIsSatelliteAttachEnabledForCarrierArrayPerSub",