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

Commit 71df0c35 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 13283428 from 8bf025c5 to 25Q3-release

Change-Id: I31e6309d085506d1338c4d5817ec99787be15d90
parents 38974f95 8bf025c5
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -357,7 +357,7 @@ public class ServiceStateTracker extends Handler {
    private final LocalLog mRadioPowerLog = new LocalLog(16);
    private final LocalLog mCdnrLogs = new LocalLog(64);

    private Pattern mOperatorNameStringPattern;
    @Nullable private Pattern mOperatorNameStringPattern;
    private PersistableBundle mCarrierConfig;

    @NonNull
@@ -5842,8 +5842,10 @@ public class ServiceStateTracker extends Handler {
        if (!TextUtils.isEmpty(operatorNamePattern)) {
            mOperatorNameStringPattern = Pattern.compile(operatorNamePattern);
            if (DBG) {
                log("mOperatorNameStringPattern: " + mOperatorNameStringPattern.toString());
                log("mOperatorNameStringPattern: " + mOperatorNameStringPattern);
            }
        } else {
            mOperatorNameStringPattern = null;
        }
    }

+32 −7
Original line number Diff line number Diff line
@@ -1307,7 +1307,8 @@ public class SatelliteController extends Handler {
        }
    }

    private static final class SatelliteControllerHandlerRequest {
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
    public static final class SatelliteControllerHandlerRequest {
        /** The argument to use for the request */
        public @NonNull Object argument;
        /** The caller needs to specify the phone to be used for the request */
@@ -1315,7 +1316,7 @@ public class SatelliteController extends Handler {
        /** The result of the request that is run on the main thread */
        public @Nullable Object result;

        SatelliteControllerHandlerRequest(Object argument, Phone phone) {
        public SatelliteControllerHandlerRequest(Object argument, Phone phone) {
            this.argument = argument;
            this.phone = phone;
        }
@@ -2302,7 +2303,7 @@ public class SatelliteController extends Handler {
                    int subId = (int) ar.userObj;
                    int error = SatelliteServiceUtils.getSatelliteError(
                            ar, "isSatelliteEnabledForCarrier");
                    boolean satelliteEnabled = (boolean) ar.result;
                    boolean satelliteEnabled = (Boolean) ar.result;
                    plogd("EVENT_GET_SATELLITE_ENABLED_FOR_CARRIER_DONE: subId=" + subId
                            + " error=" + error + " satelliteEnabled=" + satelliteEnabled);

@@ -6129,7 +6130,8 @@ public class SatelliteController extends Handler {
     * @param subId subscription ID
     * @return {@code true} if satellite modem is enabled, {@code false} otherwise.
     */
    private boolean isSatelliteEnabledForCarrierAtModem(int subId) {
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
    public boolean isSatelliteEnabledForCarrierAtModem(int subId) {
        synchronized (mIsSatelliteEnabledLock) {
            return mIsSatelliteAttachEnabledForCarrierArrayPerSub.getOrDefault(subId, false);
        }
@@ -7925,14 +7927,37 @@ public class SatelliteController extends Handler {
        }

        if(carrierTagIds == null) {
            plogd("isSatelliteAvailableAtCurrentLocation: tagids for carrier satellite enabled " +
                    "are not available");
            String satelliteAccessConfigFile =
                getSatelliteAccessConfigurationFileFromOverlayConfig();
            if (TextUtils.isEmpty(satelliteAccessConfigFile)) {
                plogd("isSatelliteAvailableAtCurrentLocation: device does not support"
                          + " custom satellite access configuration per location");
                return true;
            } else {
                plogd("isSatelliteAvailableAtCurrentLocation: tagids for carrier "
                          + info.getCarrierName() + ", subId=" + info.getSubscriptionId()
                          + " are not available");
                return false;
            }
        }

        return isCarrierSatelliteAvailableAtCurrentLocation(carrierTagIds);
    }

    @Nullable
    private String getSatelliteAccessConfigurationFileFromOverlayConfig() {
        String satelliteAccessConfigFile = null;
        try {
            satelliteAccessConfigFile = mContext.getResources().getString(
                    com.android.internal.R.string.satellite_access_config_file);
        } catch (Resources.NotFoundException ex) {
            loge("getSatelliteAccessConfigurationFileFromOverlayConfig: got ex=" + ex);
        }

        logd("satelliteAccessConfigFile =" + satelliteAccessConfigFile);
        return satelliteAccessConfigFile;
    }

    /**
     * Compares tagIds and determine if
     * carrier satellite is available at current location while selecting highest priority profile.
+2 −6
Original line number Diff line number Diff line
@@ -1160,13 +1160,9 @@ public class SatelliteModemInterface {
                        }, new IBooleanConsumer.Stub() {
                            @Override
                            public void accept(boolean result) {
                                // Convert for compatibility with SatelliteResponse
                                // TODO: This should just report result instead.
                                int[] enabled = new int[] {result ? 1 : 0};
                                plogd("requestIsSatelliteEnabledForCarrier: "
                                        + Arrays.toString(enabled));
                                plogd("requestIsSatelliteEnabledForCarrier: " + result);
                                Binder.withCleanCallingIdentity(() -> sendMessageWithResult(
                                        message, enabled,
                                        message, result,
                                        SatelliteManager.SATELLITE_RESULT_SUCCESS));
                            }
                        });
+99 −0
Original line number Diff line number Diff line
@@ -5693,6 +5693,22 @@ public class SatelliteControllerTest extends TelephonyTest {
                61 /* CMD_EVALUATE_CARRIER_ROAMING_NTN_ELIGIBILITY_CHANGE */).sendToTarget();
    }

    private void sendCmdGetSatelliteEnabledForCarrier(Phone phone) {
        SatelliteController.SatelliteControllerHandlerRequest request =
                new SatelliteController.SatelliteControllerHandlerRequest(null, phone);
        Message msg = mSatelliteControllerUT.obtainMessage(
                64 /* CMD_GET_SATELLITE_ENABLED_FOR_CARRIER */, request);
        msg.sendToTarget();
    }

    private void sendEventGetSatelliteEnabledForCarrierDone(int subId, Boolean result,
            Throwable exception) {
        Message msg = mSatelliteControllerUT.obtainMessage(
                65 /* EVENT_GET_SATELLITE_ENABLED_FOR_CARRIER_DONE */, subId);
        msg.obj = new AsyncResult(subId, result, exception);
        msg.sendToTarget();
    }

    private void setRadioPower(boolean on) {
        mSimulatedCommands.setRadioPower(on, false, false, null);
    }
@@ -6040,6 +6056,11 @@ public class SatelliteControllerTest extends TelephonyTest {
            return mLocationServiceEnabled;
        }

        @Override
        protected boolean isSatelliteAvailableAtCurrentLocation(@Nullable SubscriptionInfo info) {
            return super.isSatelliteAvailableAtCurrentLocation(info);
        }

        void setSatelliteProvisioned(@Nullable Boolean isProvisioned) {
            synchronized (mDeviceProvisionLock) {
                mIsDeviceProvisioned = isProvisioned;
@@ -6950,6 +6971,61 @@ public class SatelliteControllerTest extends TelephonyTest {
        assertTrue(mSatelliteControllerUT.isCarrierRoamingNtnEligible(mPhone));
    }

    @Test
    public void testIsSatelliteAvailableAtCurrentLocation() throws Exception {
        SubscriptionInfo ntnOnlySubscriptionInfo = new SubscriptionInfo.Builder()
                .setOnlyNonTerrestrialNetwork(true)
                .build();
        SubscriptionInfo esosSubscriptionInfo = new SubscriptionInfo.Builder()
                .setSatelliteESOSSupported(true)
                .build();
        Field currentLocationTagIdsField = SatelliteController.class.getDeclaredField(
                "mCurrentLocationTagIds");
        currentLocationTagIdsField.setAccessible(true);

        // Null subscription info
        assertFalse(mSatelliteControllerUT.isSatelliteAvailableAtCurrentLocation(null));

        // Satellite is not allowed
        mSatelliteControllerUT.setIsSatelliteAllowedState(false);
        assertFalse(mSatelliteControllerUT.isSatelliteAvailableAtCurrentLocation(
                ntnOnlySubscriptionInfo));
        assertFalse(mSatelliteControllerUT.isSatelliteAvailableAtCurrentLocation(
                esosSubscriptionInfo));

        // Satellite is allowed
        mSatelliteControllerUT.setIsSatelliteAllowedState(true);
        assertTrue(mSatelliteControllerUT.isSatelliteAvailableAtCurrentLocation(
                ntnOnlySubscriptionInfo));

        // Both config_verizon_satellite_enabled_tagids and satellite_access_config_file
        // are not configured
        assertTrue(mSatelliteControllerUT.isSatelliteAvailableAtCurrentLocation(
                esosSubscriptionInfo));

        // config_verizon_satellite_enabled_tagids is not configured whereas
        // satellite_access_config_file is configured
        mContextFixture.putResource(
                com.android.internal.R.string.satellite_access_config_file,
                "test_satellite_access_config_file");
        assertFalse(mSatelliteControllerUT.isSatelliteAvailableAtCurrentLocation(
                esosSubscriptionInfo));

        // Both config_verizon_satellite_enabled_tagids and satellite_access_config_file
        // are configured, but mCurrentLocationTagIds is empty
        mContextFixture.putIntArrayResource(
                R.array.config_verizon_satellite_enabled_tagids,
                new int[]{1001});
        assertFalse(mSatelliteControllerUT.isSatelliteAvailableAtCurrentLocation(
                esosSubscriptionInfo));

        // Both config_verizon_satellite_enabled_tagids and satellite_access_config_file
        // are configured, and mCurrentLocationTagIds contains the carrier tag id
        currentLocationTagIdsField.set(mSatelliteControllerUT, Arrays.asList(1001));
        assertTrue(mSatelliteControllerUT.isSatelliteAvailableAtCurrentLocation(
                esosSubscriptionInfo));
    }

    public void testNotifyNtnEligibilityLocationServiceStatusChanged() {
        // Enable CarrierRoamingNtn
        mContextFixture.putBooleanResource(
@@ -7009,4 +7085,27 @@ public class SatelliteControllerTest extends TelephonyTest {

        verify(mPhone, times(1)).notifyCarrierRoamingNtnEligibleStateChanged(eq(true));
    }

    @Test
    public void testGetSatelliteEnabledForCarrier() {
        reset(mPhone);
        sendCmdGetSatelliteEnabledForCarrier(mPhone);
        processAllMessages();
        verify(mPhone, times(1)).isSatelliteEnabledForCarrier(anyInt(), any());
        reset(mPhone);

        sendEventGetSatelliteEnabledForCarrierDone(mPhone.getSubId(), false,
                new SatelliteException(SATELLITE_RESULT_ERROR));
        processAllMessages();
        assertFalse(mSatelliteControllerUT.isSatelliteEnabledForCarrierAtModem(mPhone.getSubId()));

        sendEventGetSatelliteEnabledForCarrierDone(mPhone.getSubId(), true, null);
        processAllMessages();
        assertTrue(mSatelliteControllerUT.isSatelliteEnabledForCarrierAtModem(mPhone.getSubId()));

        sendEventGetSatelliteEnabledForCarrierDone(mPhone.getSubId(), false, null);
        processAllMessages();
        assertFalse(mSatelliteControllerUT.isSatelliteEnabledForCarrierAtModem(mPhone.getSubId()));
    }

}