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

Commit 9b891a30 authored by Thomas Nguyen's avatar Thomas Nguyen
Browse files

Support overriding satellite access state of carriers from CTS

Flag: TEST_ONLY
Bug: 414919132
Test: MultiProviderCoexistSatelliteTest SatelliteManagerTestOnMockService ManualConnectCarrierRoamingSatelliteTest
Change-Id: I0b8cb4290721ab3e025791d539b2c668d3568313
parent 9b5c3e09
Loading
Loading
Loading
Loading
+46 −24
Original line number Diff line number Diff line
@@ -349,6 +349,7 @@ public class SatelliteController extends Handler {
    private static final int REQUEST_SET_NTN_SMS_SUPPORTED_BY_MESSAGES_APP = 85;
    private static final int REQUEST_PROVISION_SATELLITE = 86;
    private static final int REQUEST_DEPROVISION_SATELLITE = 87;
    private static final int EVENT_SATELLITE_ACCESS_ALLOWED_STATE_CHANGED = 88;

    @NonNull private static SatelliteController sInstance;
    @NonNull private final Context mContext;
@@ -676,7 +677,7 @@ public class SatelliteController extends Handler {
    private final RegistrantList mSatelliteSubIdChangedRegistrants = new RegistrantList();
    private final BTWifiNFCStateReceiver mBTWifiNFCSateReceiver;
    private final UwbAdapterStateCallback mUwbAdapterStateCallback;
    private final List<Integer> mCtsSatelliteAccessAllowedSubIds = new ArrayList<>();
    @Nullable private List<Integer> mCtsSatelliteAccessAllowedSubIds = null;

    private long mSessionStartTimeStamp;
    private long mSessionProcessingTimeStamp;
@@ -2568,6 +2569,12 @@ public class SatelliteController extends Handler {
                break;
            }

            case EVENT_SATELLITE_ACCESS_ALLOWED_STATE_CHANGED: {
                plogd("EVENT_SATELLITE_ACCESS_ALLOWED_STATE_CHANGED");
                handleSatelliteAccessAllowedStateChanged((boolean) msg.obj);
                break;
            }

            default:
                Log.w(TAG, "SatelliteControllerHandler: unexpected message code: " +
                        msg.what);
@@ -8411,10 +8418,16 @@ public class SatelliteController extends Handler {
            plogd("isSatelliteAvailableAtCurrentLocation: subscriptionInfo is null");
            return false;
        }
        if (mCtsSatelliteAccessAllowedSubIds != null) {
            if (mCtsSatelliteAccessAllowedSubIds.contains(info.getSubscriptionId())) {
                plogd("isSatelliteAvailableAtCurrentLocation: subscriptionId="
                        + info.getSubscriptionId() + " is allowed for CTS testing");
                return true;
            } else {
                plogd("isSatelliteAvailableAtCurrentLocation: subscriptionId="
                        + info.getSubscriptionId() + " is not allowed for CTS testing");
                return false;
            }
        }
        if (!isSatelliteAccessAllowedAtCurrentLocation()) {
            plogd("isSatelliteAvailableAtCurrentLocation: satellite access is not allowed at " +
@@ -8901,7 +8914,8 @@ public class SatelliteController extends Handler {
                public void onAccessAllowedStateChanged(boolean isAllowed) {
                    plogd("onAccessStateChanged: isAllowed=" + isAllowed);
                    if (mFeatureFlags.satelliteExitP2pSessionOutsideGeofence()) {
                        handleSatelliteAccessAllowedStateChanged(isAllowed);
                        sendMessage(obtainMessage(EVENT_SATELLITE_ACCESS_ALLOWED_STATE_CHANGED,
                            isAllowed));
                    } else {
                        mSatelliteAccessAllowed.set(isAllowed);
                        evaluateESOSProfilesPrioritization();
@@ -9094,36 +9108,44 @@ public class SatelliteController extends Handler {
     * This API can be used by only CTS to override the satellite access allowed state for
     * a list of subscription IDs.
     *
     * @param reset {@code true} mean the overridden configs should not be used, {@code false}
     *              otherwise.
     * @param subIdListStr The string representation of the list of subscription IDs,
     *                     which are numbers separated by comma.
     * @return {@code true} if the satellite access allowed state is set successfully,
     * {@code false} otherwise.
     */
    public boolean setSatelliteAccessAllowedForSubscriptions(@Nullable String subIdListStr) {
    public boolean setSatelliteAccessAllowedForSubscriptions(
        boolean reset, @Nullable String subIdListStr) {
        if (!isMockModemAllowed()) {
            plogd("setSatelliteAccessAllowedForSubscriptions: mock modem not allowed");
            return false;
        }

        plogd("setSatelliteAccessAllowedForSubscriptions: subIdListStr=" + subIdListStr);
        if (subIdListStr == null) {
            mCtsSatelliteAccessAllowedSubIds.clear();
            return true;
        }

        List<Integer> subIdList = new ArrayList<>();
        plogd("setSatelliteAccessAllowedForSubscriptions: subIdListStr=" + subIdListStr
                  + " reset=" + reset);
        boolean result = true;
        if (reset) {
            mCtsSatelliteAccessAllowedSubIds = null;
        } else {
            mCtsSatelliteAccessAllowedSubIds = new ArrayList<>();
            if (!TextUtils.isEmpty(subIdListStr)) {
                for (String subIdStr : subIdListStr.split(",")) {
                    try {
                subIdList.add(Integer.parseInt(subIdStr));
                        mCtsSatelliteAccessAllowedSubIds.add(Integer.parseInt(subIdStr));
                    } catch (NumberFormatException e) {
                plogd("setSatelliteAccessAllowedForSubscriptions: invalid subIdStr=" + subIdStr);
                return false;
                        plogd("setSatelliteAccessAllowedForSubscriptions: invalid subIdStr="
                                + subIdStr);
                        mCtsSatelliteAccessAllowedSubIds = null;
                        result = false;
                    }
                }
        mCtsSatelliteAccessAllowedSubIds.clear();
        mCtsSatelliteAccessAllowedSubIds.addAll(subIdList);
        selectBindingSatelliteSubscription(false);
        return true;
            }
        }
        boolean isAllowed = mSatelliteAccessAllowed.get();
        plogd("setSatelliteAccessAllowedForSubscriptions: isAllowed=" + isAllowed);
        sendMessage(obtainMessage(EVENT_SATELLITE_ACCESS_ALLOWED_STATE_CHANGED, isAllowed));
        return result;
    }

    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)