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

Commit 99d738e4 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 11367679 from e033ee86 to 24Q2-release

Change-Id: Ie99c715e3da021c5d1297813430fdbe550429b08
parents fec8309a e033ee86
Loading
Loading
Loading
Loading
+5 −14
Original line number Diff line number Diff line
@@ -420,23 +420,14 @@ public class MultiSimSettingController extends Handler {
            return;
        }

        // b/153860050 Occasionally we receive carrier config change broadcast without subId
        // being specified in it. So here we do additional check to make sur we don't miss the
        // subId.
        if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
            subId = SubscriptionManager.getSubscriptionId(phoneId);
            if (SubscriptionManager.isValidSubscriptionId(subId)) {
        CarrierConfigManager cm = mContext.getSystemService(CarrierConfigManager.class);
                if (cm != null && cm.getConfigForSubId(subId) != null) {
                    loge("onCarrierConfigChanged with invalid subId while subId "
                            + subId + " is active and its config is loaded");
                }
            }
        }

        if (cm != null) {
            if (CarrierConfigManager.isConfigForIdentifiedCarrier(cm.getConfigForSubId(subId))) {
                mCarrierConfigLoadedSubIds[phoneId] = subId;
                reEvaluateAll();
            }
        }
    }

    /**
     * Check whether carrier config loaded for all subs
+100 −40
Original line number Diff line number Diff line
@@ -318,9 +318,23 @@ public class SatelliteController extends Handler {
    private int mEnforcedEmergencyCallToSatelliteHandoverType =
            INVALID_EMERGENCY_CALL_TO_SATELLITE_HANDOVER_TYPE;
    private int mDelayInSendingEventDisplayEmergencyMessage = 0;
    private boolean mCarrierSatelliteEnabled;
    @NonNull private SharedPreferences mSharedPreferences = null;

    /**
     * Key : Subscription ID, Value: {@code true} if the EntitlementStatus is enabled,
     * {@code false} otherwise.
     */
    @GuardedBy("mSupportedSatelliteServicesLock")
    private SparseBooleanArray mSatelliteEntitlementStatusPerCarrier = new SparseBooleanArray();
    /** Key Subscription ID, value : PLMN allowed list from entitlement. */
    @GuardedBy("mSupportedSatelliteServicesLock")
    private SparseArray<List<String>> mEntitlementPlmnListPerCarrier = new SparseArray<>();
    /**
     * Key : Subscription ID, Value : If there is an entitlementPlmnList, use it. Otherwise, use the
     * carrierPlmnList. */
    @GuardedBy("mSupportedSatelliteServicesLock")
    private final SparseArray<List<String>> mMergedPlmnListPerCarrier = new SparseArray<>();

    /**
     * @return The singleton instance of SatelliteController.
     */
@@ -784,13 +798,6 @@ public class SatelliteController extends Handler {
                            mWaitingForRadioDisabled = true;
                        }
                        setSettingsKeyForSatelliteMode(SATELLITE_MODE_ENABLED_TRUE);

                        /**
                         * TODO for NTN-based satellites: Check if satellite is acquired.
                         */
                        if (mNeedsSatellitePointing) {
                            mPointingAppController.startPointingUI(false);
                        }
                        evaluateToSendSatelliteEnabledSuccess();
                    } else {
                        /**
@@ -908,7 +915,7 @@ public class SatelliteController extends Handler {
                        error = SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE;
                    } else {
                        boolean supported = (boolean) ar.result;
                        if (DBG) logd("isSatelliteSupported: " + supported);
                        logd("isSatelliteSupported: " + supported);
                        bundle.putBoolean(SatelliteManager.KEY_SATELLITE_SUPPORTED, supported);
                        updateSatelliteSupportedStateWhenSatelliteServiceConnected(supported);
                    }
@@ -1020,6 +1027,24 @@ public class SatelliteController extends Handler {
                if (mCi.getRadioState() == TelephonyManager.RADIO_POWER_ON) {
                    mIsRadioOn = true;
                }
                if (mCi.getRadioState() != TelephonyManager.RADIO_POWER_UNAVAILABLE) {
                    if (mSatelliteModemInterface.isSatelliteServiceConnected()) {
                        synchronized (mIsSatelliteSupportedLock) {
                            if (mIsSatelliteSupported == null || !mIsSatelliteSupported) {
                                ResultReceiver receiver = new ResultReceiver(this) {
                                    @Override
                                    protected void onReceiveResult(
                                            int resultCode, Bundle resultData) {
                                        logd("onRadioStateChanged.requestIsSatelliteSupported: "
                                                + "resultCode=" + resultCode
                                                + ", resultData=" + resultData);
                                    }
                                };
                                sendRequestAsync(CMD_IS_SATELLITE_SUPPORTED, receiver, null);
                            }
                        }
                    }
                }
                break;
            }

@@ -2323,11 +2348,7 @@ public class SatelliteController extends Handler {
            return new ArrayList<>();
        }
        synchronized (mSupportedSatelliteServicesLock) {
            if (mSatelliteServicesSupportedByCarriers.containsKey(subId)) {
                return new ArrayList<>(mSatelliteServicesSupportedByCarriers.get(subId).keySet());
            } else {
                return new ArrayList<>();
            }
            return mMergedPlmnListPerCarrier.get(subId, new ArrayList<>()).stream().toList();
        }
    }

@@ -2469,22 +2490,21 @@ public class SatelliteController extends Handler {
    }

    /**
     * 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.
     * To use the satellite service, update the EntitlementStatus and the PlmnAllowedList after
     * receiving the satellite configuration from the entitlement server. If satellite
     * entitlement is enabled, enable satellite for the carrier. Otherwise, disable satellite.
     *
     * @param subId              subId
     * @param entitlementEnabled {@code true} Satellite service enabled
     * @param allowedPlmnList    plmn allowed list to use the satellite service
     * @param callback           callback for accept
     */
    public void updateSatelliteEntitlementStatus(int subId, boolean satelliteEnabled,
            List<String> plmnAllowed, IIntegerConsumer callback) {
    public void onSatelliteEntitlementStatusUpdated(int subId, boolean entitlementEnabled,
            List<String> allowedPlmnList, @Nullable 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
@@ -2494,7 +2514,19 @@ public class SatelliteController extends Handler {
            };
        }

        if (mCarrierSatelliteEnabled) {
        synchronized (mSupportedSatelliteServicesLock) {
            if (mSatelliteEntitlementStatusPerCarrier.get(subId, false) != entitlementEnabled) {
                logd("update the carrier satellite enabled to " + entitlementEnabled);
                mSatelliteEntitlementStatusPerCarrier.put(subId, entitlementEnabled);
            }
            mMergedPlmnListPerCarrier.remove(subId);

            mEntitlementPlmnListPerCarrier.put(subId, allowedPlmnList);
            updatePlmnListPerCarrier(subId);
            configureSatellitePlmnForCarrier(subId);

            // TODO b/322143408 store entitlement status in telephony db.
            if (mSatelliteEntitlementStatusPerCarrier.get(subId, false)) {
                removeSatelliteAttachRestrictionForCarrier(subId,
                        SATELLITE_COMMUNICATION_RESTRICTION_REASON_ENTITLEMENT, callback);
            } else {
@@ -2502,6 +2534,7 @@ public class SatelliteController extends Handler {
                        SATELLITE_COMMUNICATION_RESTRICTION_REASON_ENTITLEMENT, callback);
            }
        }
    }

    /**
     * If we have not successfully queried the satellite modem for its satellite service support,
@@ -2727,7 +2760,8 @@ public class SatelliteController extends Handler {
                    new ResultReceiver(this) {
                        @Override
                        protected void onReceiveResult(int resultCode, Bundle resultData) {
                            logd("requestIsSatelliteProvisioned: resultCode=" + resultCode);
                            logd("requestIsSatelliteProvisioned: resultCode=" + resultCode
                                    + ", resultData=" + resultData);
                            requestSatelliteEnabled(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID,
                                    false, false,
                                    new IIntegerConsumer.Stub() {
@@ -2742,7 +2776,8 @@ public class SatelliteController extends Handler {
                    new ResultReceiver(this) {
                        @Override
                        protected void onReceiveResult(int resultCode, Bundle resultData) {
                            logd("requestSatelliteCapabilities: resultCode=" + resultCode);
                            logd("requestSatelliteCapabilities: resultCode=" + resultCode
                                    + ", resultData=" + resultData);
                        }
                    });
        }
@@ -3008,13 +3043,8 @@ public class SatelliteController extends Handler {
            return;
        }
        synchronized (mSupportedSatelliteServicesLock) {
            List<String> carrierPlmnList;
            if (mSatelliteServicesSupportedByCarriers.containsKey(subId)) {
                carrierPlmnList =
                        mSatelliteServicesSupportedByCarriers.get(subId).keySet().stream().toList();
            } else {
                carrierPlmnList = new ArrayList<>();
            }
            List<String> carrierPlmnList = mMergedPlmnListPerCarrier.get(subId,
                    new ArrayList<>()).stream().toList();
            int slotId = SubscriptionManager.getSlotIndex(subId);
            mSatelliteModemInterface.setSatellitePlmn(slotId, carrierPlmnList,
                    SatelliteServiceUtils.mergeStrLists(
@@ -3037,6 +3067,7 @@ public class SatelliteController extends Handler {

        synchronized (mSupportedSatelliteServicesLock) {
            mSatelliteServicesSupportedByCarriers.clear();
            mMergedPlmnListPerCarrier.clear();
            int[] activeSubIds = mSubscriptionManagerService.getActiveSubIdList(true);
            if (activeSubIds != null) {
                for (int subId : activeSubIds) {
@@ -3049,10 +3080,37 @@ public class SatelliteController extends Handler {
        }
    }

    /**
     * If the entitlementPlmnList exist then used it.
     * Otherwise, If the carrierPlmnList exist then used it.
     */
    private void updatePlmnListPerCarrier(int subId) {
        synchronized (mSupportedSatelliteServicesLock) {
            List<String> carrierPlmnList, entitlementPlmnList;
            entitlementPlmnList = mEntitlementPlmnListPerCarrier.get(subId,
                    new ArrayList<>()).stream().toList();
            if (!entitlementPlmnList.isEmpty()) {
                mMergedPlmnListPerCarrier.put(subId, entitlementPlmnList);
                logd("update it using entitlementPlmnList=" + entitlementPlmnList);
                return;
            }

            if (mSatelliteServicesSupportedByCarriers.containsKey(subId)) {
                carrierPlmnList =
                        mSatelliteServicesSupportedByCarriers.get(subId).keySet().stream().toList();
            } else {
                carrierPlmnList = new ArrayList<>();
            }
            mMergedPlmnListPerCarrier.put(subId, carrierPlmnList);
            logd("update it using carrierPlmnList=" + carrierPlmnList);
        }
    }

    private void updateSupportedSatelliteServices(int subId) {
        synchronized (mSupportedSatelliteServicesLock) {
            mSatelliteServicesSupportedByCarriers.put(
                    subId, readSupportedSatelliteServicesFromCarrierConfig(subId));
            updatePlmnListPerCarrier(subId);
        }
    }

@@ -3103,6 +3161,8 @@ public class SatelliteController extends Handler {
        }

        updateCarrierConfig(subId);
        // TODO b/322143408 read the telephony db to get the entitlementStatus and update the
        //  restriction
        updateSupportedSatelliteServicesForActiveSubscriptions();
        configureSatellitePlmnForCarrier(subId);

+13 −3
Original line number Diff line number Diff line
@@ -1236,10 +1236,13 @@ public class SatelliteModemInterface {
                            }
                        }, new INtnSignalStrengthConsumer.Stub() {
                            @Override
                            public void accept(NtnSignalStrength result) {
                                logd("requestNtnSignalStrength: " + result);
                            public void accept(
                                    android.telephony.satellite.stub.NtnSignalStrength result) {
                                NtnSignalStrength ntnSignalStrength =
                                        SatelliteServiceUtils.fromNtnSignalStrength(result);
                                logd("requestNtnSignalStrength: " + ntnSignalStrength);
                                Binder.withCleanCallingIdentity(() -> sendMessageWithResult(
                                        message, result,
                                        message, ntnSignalStrength,
                                        SatelliteManager.SATELLITE_RESULT_SUCCESS));
                            }
                        });
@@ -1318,6 +1321,13 @@ public class SatelliteModemInterface {
        return mIsSatelliteServiceSupported;
    }

    /** Check if vendor satellite service is connected */
    public boolean isSatelliteServiceConnected() {
        synchronized (mLock) {
            return (mSatelliteService != null);
        }
    }

    /**
     * This API can be used by only CTS to update satellite vendor service package name.
     *
+14 −7
Original line number Diff line number Diff line
@@ -247,6 +247,10 @@ public class MultiSimSettingControllerTest extends TelephonyTest {
            return SubscriptionManager.INVALID_SUBSCRIPTION_ID;
        }).when(mPhoneMock2).getSubId();

        PersistableBundle bundle = new PersistableBundle();
        bundle.putBoolean(CarrierConfigManager.KEY_CARRIER_CONFIG_APPLIED_BOOL, true);
        doReturn(bundle).when(mCarrierConfigManager).getConfigForSubId(anyInt());

        replaceInstance(PhoneFactory.class, "sPhones", null, mPhones);
        // Capture listener to emulate the carrier config change notification used later
        ArgumentCaptor<CarrierConfigManager.CarrierConfigChangeListener> listenerArgumentCaptor =
@@ -885,6 +889,13 @@ public class MultiSimSettingControllerTest extends TelephonyTest {
        doReturn(true).when(mPhoneMock2).isUserDataEnabled();
        mMultiSimSettingControllerUT.notifyAllSubscriptionLoaded();
        processAllMessages();

        PersistableBundle bundle = new PersistableBundle();
        bundle.putBoolean(CarrierConfigManager.KEY_CARRIER_CONFIG_APPLIED_BOOL, true);
        doReturn(bundle).when(mCarrierConfigManager).getConfigForSubId(eq(1));
        PersistableBundle bundle2 = new PersistableBundle();
        doReturn(bundle).when(mCarrierConfigManager).getConfigForSubId(eq(2));

        sendCarrierConfigChanged(0, 1);
        // Notify carrier config change on phone1 without specifying subId.
        sendCarrierConfigChanged(1, SubscriptionManager.INVALID_SUBSCRIPTION_ID);
@@ -893,13 +904,9 @@ public class MultiSimSettingControllerTest extends TelephonyTest {
        verify(mDataSettingsManagerMock2, never()).setDataEnabled(
                TelephonyManager.DATA_ENABLED_REASON_USER, false, PHONE_PACKAGE);

        // Still notify carrier config without specifying subId2, but this time subController
        // and CarrierConfigManager have subId 2 active and ready.
        doReturn(2).when(mSubscriptionManagerService).getSubId(1);
        CarrierConfigManager cm = (CarrierConfigManager) mContext.getSystemService(
                mContext.CARRIER_CONFIG_SERVICE);
        doReturn(new PersistableBundle()).when(cm).getConfigForSubId(2);
        sendCarrierConfigChanged(1, SubscriptionManager.INVALID_SUBSCRIPTION_ID);
        logd("Sending the correct phone id and sub id");
        bundle2.putBoolean(CarrierConfigManager.KEY_CARRIER_CONFIG_APPLIED_BOOL, true);
        sendCarrierConfigChanged(1, 2);
        processAllMessages();
        // This time user data should be disabled on phone1.
        verify(mDataSettingsManagerMock2).setDataEnabled(
+260 −6

File changed.

Preview size limit exceeded, changes collapsed.