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

Commit 292c0bf2 authored by Hidayat Khan's avatar Hidayat Khan Committed by Android (Google) Code Review
Browse files

Merge "Added IsSatelliteSystemNotificationsEnabled check" into main

parents 12b6dddf bbda5ee9
Loading
Loading
Loading
Loading
+21 −6
Original line number Diff line number Diff line
@@ -436,9 +436,9 @@ public class SatelliteController extends Handler {
    private final ConcurrentHashMap<IBinder, ISelectedNbIotSatelliteSubscriptionCallback>
            mSelectedNbIotSatelliteSubscriptionChangedListeners = new ConcurrentHashMap<>();

    private final Object mIsSatelliteSupportedLock = new Object();
    protected final Object mIsSatelliteSupportedLock = new Object();
    @GuardedBy("mIsSatelliteSupportedLock")
    private Boolean mIsSatelliteSupported = null;
    protected Boolean mIsSatelliteSupported = null;
    private boolean mIsDemoModeEnabled = false;
    private boolean mIsEmergency = false;
    private final Object mIsSatelliteEnabledLock = new Object();
@@ -5566,7 +5566,7 @@ public class SatelliteController extends Handler {
                KEY_SATELLITE_ROAMING_TURN_OFF_SESSION_FOR_EMERGENCY_CALL_BOOL);
    }

    private int getCarrierRoamingNtnConnectType(int subId) {
    public int getCarrierRoamingNtnConnectType(int subId) {
        return getConfigForSubId(subId).getInt(KEY_CARRIER_ROAMING_NTN_CONNECT_TYPE_INT);
    }

@@ -6479,6 +6479,23 @@ public class SatelliteController extends Handler {
        updateSatelliteSystemNotification(-1, -1,/*visible*/ false);
    }

    public boolean isSatelliteSystemNotificationsEnabled(int carrierRoamingNtnConnectType) {
        if (!mFeatureFlags.carrierRoamingNbIotNtn()) {
            return false;
        }
        if (carrierRoamingNtnConnectType
            != CarrierConfigManager.CARRIER_ROAMING_NTN_CONNECT_MANUAL) {
            return true;
        }
        boolean notifySatelliteAvailabilityEnabled =
            mContext.getResources().getBoolean(R.bool.config_satellite_should_notify_availability);
        Boolean isSatelliteSupported = getIsSatelliteSupported();
        if(isSatelliteSupported == null) {
            return false;
        }
        return notifySatelliteAvailabilityEnabled && isSatelliteSupported;
    }

    /**
     * Update the system notification to reflect the current satellite status, that's either already
     * connected OR needs to be manually enabled. The device should only display one notification
@@ -6492,9 +6509,7 @@ public class SatelliteController extends Handler {
     */
    private void updateSatelliteSystemNotification(int subId,
            @CARRIER_ROAMING_NTN_CONNECT_TYPE int carrierRoamingNtnConnectType, boolean visible) {
        boolean notifySatelliteAvailabilityEnabled =
            mContext.getResources().getBoolean(R.bool.config_satellite_should_notify_availability);
        if (!mFeatureFlags.carrierRoamingNbIotNtn() || !notifySatelliteAvailabilityEnabled) {
        if (!isSatelliteSystemNotificationsEnabled(carrierRoamingNtnConnectType)) {
            plogd("updateSatelliteSystemNotification: satellite notifications are not enabled.");
            return;
        }
+12 −1
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import static android.hardware.devicestate.DeviceState.PROPERTY_FOLDABLE_HARDWAR
import static android.hardware.devicestate.DeviceState.PROPERTY_FOLDABLE_HARDWARE_CONFIGURATION_FOLD_IN_OPEN;
import static android.hardware.devicestate.feature.flags.Flags.FLAG_DEVICE_STATE_PROPERTY_MIGRATION;
import static android.telephony.CarrierConfigManager.CARRIER_ROAMING_NTN_CONNECT_AUTOMATIC;
import static android.telephony.CarrierConfigManager.CARRIER_ROAMING_NTN_CONNECT_MANUAL;
import static android.telephony.CarrierConfigManager.KEY_CARRIER_CONFIG_APPLIED_BOOL;
import static android.telephony.CarrierConfigManager.KEY_CARRIER_ROAMING_NTN_CONNECT_TYPE_INT;
import static android.telephony.CarrierConfigManager.KEY_CARRIER_SUPPORTED_SATELLITE_NOTIFICATION_HYSTERESIS_SEC_INT;
@@ -3687,6 +3688,7 @@ public class SatelliteControllerTest extends TelephonyTest {
        // Do nothing when the satellite is not connected
        doReturn(false).when(mServiceState).isUsingNonTerrestrialNetwork();
        sendServiceStateChangedEvent();
        setUpResponseForRequestIsSatelliteSupported(true, SATELLITE_RESULT_SUCCESS);
        processAllMessages();
        assertFalse(mSharedPreferences.getBoolean(SATELLITE_SYSTEM_NOTIFICATION_DONE_KEY, false));
        verify(mMockNotificationManager, never()).notifyAsUser(anyString(), anyInt(), any(), any());
@@ -4271,8 +4273,10 @@ public class SatelliteControllerTest extends TelephonyTest {
        when(mServiceState2.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
        when(mServiceState.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
        mSatelliteControllerUT.mIsApplicationSupportsP2P = true;
        mSatelliteControllerUT.setIsSatelliteSupported(true);
        mCarrierConfigBundle.putBoolean(KEY_SATELLITE_ATTACH_SUPPORTED_BOOL, true);
        mCarrierConfigBundle.putInt(KEY_CARRIER_ROAMING_NTN_CONNECT_TYPE_INT, 1);
        mCarrierConfigBundle.putInt(KEY_CARRIER_ROAMING_NTN_CONNECT_TYPE_INT,
            CARRIER_ROAMING_NTN_CONNECT_MANUAL);
        mCarrierConfigBundle.putInt(
                KEY_CARRIER_SUPPORTED_SATELLITE_NOTIFICATION_HYSTERESIS_SEC_INT, 1 * 60);
        mCarrierConfigBundle.putBoolean(KEY_SATELLITE_ROAMING_P2P_SMS_SUPPORTED_BOOL, true);
@@ -4294,6 +4298,7 @@ public class SatelliteControllerTest extends TelephonyTest {
        }
        mSatelliteControllerUT.setSatellitePhone(1);
        mSatelliteControllerUT.isSatelliteAllowedCallback = null;
        setUpResponseForRequestIsSatelliteSupported(true, SATELLITE_RESULT_SUCCESS);
        processAllMessages();
        mSatelliteControllerUT.elapsedRealtime = 0;
        assertTrue(mSatelliteControllerUT.isCarrierRoamingNtnEligible(mPhone));
@@ -6212,6 +6217,12 @@ public class SatelliteControllerTest extends TelephonyTest {
            }
        }

        void setIsSatelliteSupported(@Nullable Boolean isSatelliteSupported) {
            synchronized (mIsSatelliteSupportedLock) {
                mIsSatelliteSupported = isSatelliteSupported;
            }
        }

        public boolean isRadioOn() {
            synchronized (mIsRadioOnLock) {
                return mIsRadioOn;