Loading src/java/com/android/internal/telephony/satellite/SatelliteController.java +54 −74 Original line number Diff line number Diff line Loading @@ -203,6 +203,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; import java.util.function.Consumer; import java.util.stream.Collectors; Loading Loading @@ -396,6 +397,12 @@ public class SatelliteController extends Handler { protected AtomicBoolean mIsDeviceProvisioned = null; private AtomicBoolean mOverriddenIsSatelliteViaOemProvisioned = null; private AtomicBoolean mIgnorePlmnListFromStorage = new AtomicBoolean(false); private AtomicBoolean mNtnSmsSupportedByMessagesApp = null; private AtomicBoolean mIsWifiConnected = new AtomicBoolean(false); private AtomicBoolean mHasSentBroadcast = new AtomicBoolean(false); @SatelliteManager.SatelliteModemState private AtomicInteger mSatelliteModemState = new AtomicInteger( SatelliteManager.SATELLITE_MODEM_STATE_UNKNOWN); private final Object mSatelliteEnabledRequestLock = new Object(); /* This variable is used to store the first enable request that framework has received in the Loading Loading @@ -523,10 +530,8 @@ public class SatelliteController extends Handler { /** Key: subId, value: (key: Regional satellite config Id string, value: Integer * arrays of earfcns in the corresponding regions.) */ @GuardedBy("mRegionalSatelliteEarfcnsLock") @NonNull private final Map<Integer, Map<String, Set<Integer>>> mRegionalSatelliteEarfcns = new HashMap<>(); @NonNull private final Object mRegionalSatelliteEarfcnsLock = new Object(); @NonNull private final ConcurrentHashMap<Integer, Map<String, Set<Integer>>> mRegionalSatelliteEarfcns = new ConcurrentHashMap<>(); @NonNull private final FeatureFlags mFeatureFlags; @NonNull private final Object mSatelliteConnectedLock = new Object(); /** Key: Subscription ID; Value: Last satellite connected time */ Loading Loading @@ -680,10 +685,6 @@ public class SatelliteController extends Handler { // mocked. Using this to inject a mock SubscriptionManager to work around this limitation. private SubscriptionManager mInjectSubscriptionManager = null; private final Object mIsWifiConnectedLock = new Object(); @GuardedBy("mIsWifiConnectedLock") private boolean mIsWifiConnected = false; private boolean mHasSentBroadcast = false; // For satellite CTS test which to configure intent component with the necessary values. private boolean mChangeIntentComponent = false; private String mConfigSatelliteGatewayServicePackage = ""; Loading @@ -700,19 +701,11 @@ public class SatelliteController extends Handler { private String mOverriddenSatelliteGatewayServicePackageName = ""; private Boolean mOverriddenDisableSatelliteWhileEnableInProgressSupported = null; private final Object mNtnSmsSupportedByMessagesAppLock = new Object(); @GuardedBy("mNtnSmsSupportedByMessagesAppLock") private Boolean mNtnSmsSupportedByMessagesApp = null; private final Object mCarrierRoamingNtnAllSatellitePlmnSetLock = new Object(); @GuardedBy("mCarrierRoamingNtnAllSatellitePlmnSetLock") private Set<String> mCarrierRoamingNtnAllSatellitePlmnSet = null; private final Object mSatelliteModemStateLock = new Object(); @GuardedBy("mSatelliteModemStateLock") @SatelliteManager.SatelliteModemState private int mSatelliteModemState = SatelliteManager.SATELLITE_MODEM_STATE_UNKNOWN; // Data Plan types at entitlement for the plmn allowed public static final int SATELLITE_DATA_PLAN_METERED = 0; public static final int SATELLITE_DATA_PLAN_UNMETERED = 1; Loading Loading @@ -993,10 +986,8 @@ public class SatelliteController extends Handler { loadSatelliteSharedPreferences(); if (mSharedPreferences != null) { try { synchronized (mNtnSmsSupportedByMessagesAppLock) { mNtnSmsSupportedByMessagesApp = mSharedPreferences.getBoolean( NTN_SMS_SUPPORTED_BY_MESSAGES_APP_KEY, false); } setNtnSmsSupportedByMessagesAppCache(mSharedPreferences.getBoolean( NTN_SMS_SUPPORTED_BY_MESSAGES_APP_KEY, false)); synchronized (mCarrierRoamingNtnAllSatellitePlmnSetLock) { mCarrierRoamingNtnAllSatellitePlmnSet = mSharedPreferences.getStringSet( Loading Loading @@ -2140,12 +2131,10 @@ public class SatelliteController extends Handler { } case EVENT_WIFI_CONNECTIVITY_STATE_CHANGED: { synchronized (mIsWifiConnectedLock) { ar = (AsyncResult) msg.obj; mIsWifiConnected = (boolean) ar.result; mIsWifiConnected.set((boolean) ar.result); plogd("EVENT_WIFI_CONNECTIVITY_STATE_CHANGED: mIsWifiConnected=" + mIsWifiConnected); } + mIsWifiConnected.get()); evaluateCarrierRoamingNtnEligibilityChange(); break; } Loading Loading @@ -5474,11 +5463,7 @@ public class SatelliteController extends Handler { private void handleEventSatelliteModemStateChanged( @SatelliteManager.SatelliteModemState int state) { plogd("handleEventSatelliteModemStateChanged: state=" + state); synchronized (mSatelliteModemStateLock) { mSatelliteModemState = state; } mSatelliteModemState.set(state); if (state == SatelliteManager.SATELLITE_MODEM_STATE_UNAVAILABLE || state == SatelliteManager.SATELLITE_MODEM_STATE_OFF) { if (!isWaitingForDisableSatelliteModemResponse()) { Loading Loading @@ -8041,7 +8026,7 @@ public class SatelliteController extends Handler { plogd("evaluateESOSProfilesPrioritization: newSubsInfoListPerPriority.size()=" + newSubsInfoListPerPriority.size()); if (!mHasSentBroadcast && newSubsInfoListPerPriority.size() == 0) { if (!mHasSentBroadcast.get() && newSubsInfoListPerPriority.size() == 0) { logd("evaluateESOSProfilesPrioritization: no satellite subscription available"); return; } Loading @@ -8058,7 +8043,7 @@ public class SatelliteController extends Handler { mSubsInfoListPerPriority = newSubsInfoListPerPriority; mLastEvaluatedSubscriberProvisionStatus = newEvaluatedSubscriberProvisionStatus; sendBroadCastForProvisionedESOSSubs(); mHasSentBroadcast = true; mHasSentBroadcast.set(true); selectBindingSatelliteSubscription(false); } } Loading Loading @@ -8620,7 +8605,7 @@ public class SatelliteController extends Handler { logd("getRegionalSatelliteEarfcns: carrierRoamingNbIotNtnFlag is disabled"); return new HashMap<>(); } synchronized (mRegionalSatelliteEarfcnsLock) { if (mRegionalSatelliteEarfcns.containsKey(subId)) { return mRegionalSatelliteEarfcns.get(subId); } else { Loading @@ -8628,7 +8613,6 @@ public class SatelliteController extends Handler { return new HashMap<>(); } } } /** * Update regional satellite earfcn information from carrier config. Loading @@ -8641,11 +8625,9 @@ public class SatelliteController extends Handler { return; } synchronized (mRegionalSatelliteEarfcnsLock) { mRegionalSatelliteEarfcns.put(subId, readRegionalSatelliteEarfcnsFromCarrierConfig(subId)); } } /** * Deliver the list of deprovisioned satellite subscriber ids. Loading Loading @@ -8721,18 +8703,22 @@ public class SatelliteController extends Handler { } else { mSharedPreferences.edit().putBoolean( NTN_SMS_SUPPORTED_BY_MESSAGES_APP_KEY, ntnSmsSupported).apply(); synchronized (mNtnSmsSupportedByMessagesAppLock) { mNtnSmsSupportedByMessagesApp = ntnSmsSupported; setNtnSmsSupportedByMessagesAppCache(ntnSmsSupported); } } private void setNtnSmsSupportedByMessagesAppCache(boolean ntnSmsSupported) { if (mNtnSmsSupportedByMessagesApp == null) { mNtnSmsSupportedByMessagesApp = new AtomicBoolean(ntnSmsSupported); } else { mNtnSmsSupportedByMessagesApp.set(ntnSmsSupported); } } private boolean isNtnSmsSupportedByMessagesApp() { synchronized (mNtnSmsSupportedByMessagesAppLock) { if (mNtnSmsSupportedByMessagesApp != null) { plogd("isNtnSmsSupportedByMessagesApp:" + mNtnSmsSupportedByMessagesApp); return mNtnSmsSupportedByMessagesApp; } plogd("isNtnSmsSupportedByMessagesApp:" + mNtnSmsSupportedByMessagesApp.get()); return mNtnSmsSupportedByMessagesApp.get(); } if (!loadSatelliteSharedPreferences()) return false; Loading @@ -8743,10 +8729,8 @@ public class SatelliteController extends Handler { } else { boolean ntnSmsSupported = mSharedPreferences.getBoolean( NTN_SMS_SUPPORTED_BY_MESSAGES_APP_KEY, false); synchronized (mNtnSmsSupportedByMessagesAppLock) { mNtnSmsSupportedByMessagesApp = ntnSmsSupported; plogd("isNtnSmsSupportedByMessagesApp:" + mNtnSmsSupportedByMessagesApp); } setNtnSmsSupportedByMessagesAppCache(ntnSmsSupported); plogd("isNtnSmsSupportedByMessagesApp:" + ntnSmsSupported); return ntnSmsSupported; } } Loading Loading @@ -8866,13 +8850,11 @@ public class SatelliteController extends Handler { return false; } synchronized (mIsWifiConnectedLock) { if (mIsWifiConnected) { if (mIsWifiConnected.get()) { plogd("isCarrierRoamingNtnEligible[phoneId=" + phone.getPhoneId() + "]: Wi-Fi is connected"); return false; } } return true; } Loading Loading @@ -9579,8 +9561,7 @@ public class SatelliteController extends Handler { * Returns satellite connected state from modem, return true if connected. */ public boolean isInConnectedState() { synchronized (mSatelliteModemStateLock) { switch (mSatelliteModemState) { switch (mSatelliteModemState.get()) { case SatelliteManager.SATELLITE_MODEM_STATE_CONNECTED: //fallthrough case SatelliteManager.SATELLITE_MODEM_STATE_DATAGRAM_TRANSFERRING: //fallthrough case SatelliteManager.SATELLITE_MODEM_STATE_DATAGRAM_RETRYING: //fallthrough Loading @@ -9592,7 +9573,6 @@ public class SatelliteController extends Handler { return false; } } } protected void updateLastNotifiedCarrierRoamingNtnSignalStrengthAndNotify( @Nullable Phone phone) { Loading Loading
src/java/com/android/internal/telephony/satellite/SatelliteController.java +54 −74 Original line number Diff line number Diff line Loading @@ -203,6 +203,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; import java.util.function.Consumer; import java.util.stream.Collectors; Loading Loading @@ -396,6 +397,12 @@ public class SatelliteController extends Handler { protected AtomicBoolean mIsDeviceProvisioned = null; private AtomicBoolean mOverriddenIsSatelliteViaOemProvisioned = null; private AtomicBoolean mIgnorePlmnListFromStorage = new AtomicBoolean(false); private AtomicBoolean mNtnSmsSupportedByMessagesApp = null; private AtomicBoolean mIsWifiConnected = new AtomicBoolean(false); private AtomicBoolean mHasSentBroadcast = new AtomicBoolean(false); @SatelliteManager.SatelliteModemState private AtomicInteger mSatelliteModemState = new AtomicInteger( SatelliteManager.SATELLITE_MODEM_STATE_UNKNOWN); private final Object mSatelliteEnabledRequestLock = new Object(); /* This variable is used to store the first enable request that framework has received in the Loading Loading @@ -523,10 +530,8 @@ public class SatelliteController extends Handler { /** Key: subId, value: (key: Regional satellite config Id string, value: Integer * arrays of earfcns in the corresponding regions.) */ @GuardedBy("mRegionalSatelliteEarfcnsLock") @NonNull private final Map<Integer, Map<String, Set<Integer>>> mRegionalSatelliteEarfcns = new HashMap<>(); @NonNull private final Object mRegionalSatelliteEarfcnsLock = new Object(); @NonNull private final ConcurrentHashMap<Integer, Map<String, Set<Integer>>> mRegionalSatelliteEarfcns = new ConcurrentHashMap<>(); @NonNull private final FeatureFlags mFeatureFlags; @NonNull private final Object mSatelliteConnectedLock = new Object(); /** Key: Subscription ID; Value: Last satellite connected time */ Loading Loading @@ -680,10 +685,6 @@ public class SatelliteController extends Handler { // mocked. Using this to inject a mock SubscriptionManager to work around this limitation. private SubscriptionManager mInjectSubscriptionManager = null; private final Object mIsWifiConnectedLock = new Object(); @GuardedBy("mIsWifiConnectedLock") private boolean mIsWifiConnected = false; private boolean mHasSentBroadcast = false; // For satellite CTS test which to configure intent component with the necessary values. private boolean mChangeIntentComponent = false; private String mConfigSatelliteGatewayServicePackage = ""; Loading @@ -700,19 +701,11 @@ public class SatelliteController extends Handler { private String mOverriddenSatelliteGatewayServicePackageName = ""; private Boolean mOverriddenDisableSatelliteWhileEnableInProgressSupported = null; private final Object mNtnSmsSupportedByMessagesAppLock = new Object(); @GuardedBy("mNtnSmsSupportedByMessagesAppLock") private Boolean mNtnSmsSupportedByMessagesApp = null; private final Object mCarrierRoamingNtnAllSatellitePlmnSetLock = new Object(); @GuardedBy("mCarrierRoamingNtnAllSatellitePlmnSetLock") private Set<String> mCarrierRoamingNtnAllSatellitePlmnSet = null; private final Object mSatelliteModemStateLock = new Object(); @GuardedBy("mSatelliteModemStateLock") @SatelliteManager.SatelliteModemState private int mSatelliteModemState = SatelliteManager.SATELLITE_MODEM_STATE_UNKNOWN; // Data Plan types at entitlement for the plmn allowed public static final int SATELLITE_DATA_PLAN_METERED = 0; public static final int SATELLITE_DATA_PLAN_UNMETERED = 1; Loading Loading @@ -993,10 +986,8 @@ public class SatelliteController extends Handler { loadSatelliteSharedPreferences(); if (mSharedPreferences != null) { try { synchronized (mNtnSmsSupportedByMessagesAppLock) { mNtnSmsSupportedByMessagesApp = mSharedPreferences.getBoolean( NTN_SMS_SUPPORTED_BY_MESSAGES_APP_KEY, false); } setNtnSmsSupportedByMessagesAppCache(mSharedPreferences.getBoolean( NTN_SMS_SUPPORTED_BY_MESSAGES_APP_KEY, false)); synchronized (mCarrierRoamingNtnAllSatellitePlmnSetLock) { mCarrierRoamingNtnAllSatellitePlmnSet = mSharedPreferences.getStringSet( Loading Loading @@ -2140,12 +2131,10 @@ public class SatelliteController extends Handler { } case EVENT_WIFI_CONNECTIVITY_STATE_CHANGED: { synchronized (mIsWifiConnectedLock) { ar = (AsyncResult) msg.obj; mIsWifiConnected = (boolean) ar.result; mIsWifiConnected.set((boolean) ar.result); plogd("EVENT_WIFI_CONNECTIVITY_STATE_CHANGED: mIsWifiConnected=" + mIsWifiConnected); } + mIsWifiConnected.get()); evaluateCarrierRoamingNtnEligibilityChange(); break; } Loading Loading @@ -5474,11 +5463,7 @@ public class SatelliteController extends Handler { private void handleEventSatelliteModemStateChanged( @SatelliteManager.SatelliteModemState int state) { plogd("handleEventSatelliteModemStateChanged: state=" + state); synchronized (mSatelliteModemStateLock) { mSatelliteModemState = state; } mSatelliteModemState.set(state); if (state == SatelliteManager.SATELLITE_MODEM_STATE_UNAVAILABLE || state == SatelliteManager.SATELLITE_MODEM_STATE_OFF) { if (!isWaitingForDisableSatelliteModemResponse()) { Loading Loading @@ -8041,7 +8026,7 @@ public class SatelliteController extends Handler { plogd("evaluateESOSProfilesPrioritization: newSubsInfoListPerPriority.size()=" + newSubsInfoListPerPriority.size()); if (!mHasSentBroadcast && newSubsInfoListPerPriority.size() == 0) { if (!mHasSentBroadcast.get() && newSubsInfoListPerPriority.size() == 0) { logd("evaluateESOSProfilesPrioritization: no satellite subscription available"); return; } Loading @@ -8058,7 +8043,7 @@ public class SatelliteController extends Handler { mSubsInfoListPerPriority = newSubsInfoListPerPriority; mLastEvaluatedSubscriberProvisionStatus = newEvaluatedSubscriberProvisionStatus; sendBroadCastForProvisionedESOSSubs(); mHasSentBroadcast = true; mHasSentBroadcast.set(true); selectBindingSatelliteSubscription(false); } } Loading Loading @@ -8620,7 +8605,7 @@ public class SatelliteController extends Handler { logd("getRegionalSatelliteEarfcns: carrierRoamingNbIotNtnFlag is disabled"); return new HashMap<>(); } synchronized (mRegionalSatelliteEarfcnsLock) { if (mRegionalSatelliteEarfcns.containsKey(subId)) { return mRegionalSatelliteEarfcns.get(subId); } else { Loading @@ -8628,7 +8613,6 @@ public class SatelliteController extends Handler { return new HashMap<>(); } } } /** * Update regional satellite earfcn information from carrier config. Loading @@ -8641,11 +8625,9 @@ public class SatelliteController extends Handler { return; } synchronized (mRegionalSatelliteEarfcnsLock) { mRegionalSatelliteEarfcns.put(subId, readRegionalSatelliteEarfcnsFromCarrierConfig(subId)); } } /** * Deliver the list of deprovisioned satellite subscriber ids. Loading Loading @@ -8721,18 +8703,22 @@ public class SatelliteController extends Handler { } else { mSharedPreferences.edit().putBoolean( NTN_SMS_SUPPORTED_BY_MESSAGES_APP_KEY, ntnSmsSupported).apply(); synchronized (mNtnSmsSupportedByMessagesAppLock) { mNtnSmsSupportedByMessagesApp = ntnSmsSupported; setNtnSmsSupportedByMessagesAppCache(ntnSmsSupported); } } private void setNtnSmsSupportedByMessagesAppCache(boolean ntnSmsSupported) { if (mNtnSmsSupportedByMessagesApp == null) { mNtnSmsSupportedByMessagesApp = new AtomicBoolean(ntnSmsSupported); } else { mNtnSmsSupportedByMessagesApp.set(ntnSmsSupported); } } private boolean isNtnSmsSupportedByMessagesApp() { synchronized (mNtnSmsSupportedByMessagesAppLock) { if (mNtnSmsSupportedByMessagesApp != null) { plogd("isNtnSmsSupportedByMessagesApp:" + mNtnSmsSupportedByMessagesApp); return mNtnSmsSupportedByMessagesApp; } plogd("isNtnSmsSupportedByMessagesApp:" + mNtnSmsSupportedByMessagesApp.get()); return mNtnSmsSupportedByMessagesApp.get(); } if (!loadSatelliteSharedPreferences()) return false; Loading @@ -8743,10 +8729,8 @@ public class SatelliteController extends Handler { } else { boolean ntnSmsSupported = mSharedPreferences.getBoolean( NTN_SMS_SUPPORTED_BY_MESSAGES_APP_KEY, false); synchronized (mNtnSmsSupportedByMessagesAppLock) { mNtnSmsSupportedByMessagesApp = ntnSmsSupported; plogd("isNtnSmsSupportedByMessagesApp:" + mNtnSmsSupportedByMessagesApp); } setNtnSmsSupportedByMessagesAppCache(ntnSmsSupported); plogd("isNtnSmsSupportedByMessagesApp:" + ntnSmsSupported); return ntnSmsSupported; } } Loading Loading @@ -8866,13 +8850,11 @@ public class SatelliteController extends Handler { return false; } synchronized (mIsWifiConnectedLock) { if (mIsWifiConnected) { if (mIsWifiConnected.get()) { plogd("isCarrierRoamingNtnEligible[phoneId=" + phone.getPhoneId() + "]: Wi-Fi is connected"); return false; } } return true; } Loading Loading @@ -9579,8 +9561,7 @@ public class SatelliteController extends Handler { * Returns satellite connected state from modem, return true if connected. */ public boolean isInConnectedState() { synchronized (mSatelliteModemStateLock) { switch (mSatelliteModemState) { switch (mSatelliteModemState.get()) { case SatelliteManager.SATELLITE_MODEM_STATE_CONNECTED: //fallthrough case SatelliteManager.SATELLITE_MODEM_STATE_DATAGRAM_TRANSFERRING: //fallthrough case SatelliteManager.SATELLITE_MODEM_STATE_DATAGRAM_RETRYING: //fallthrough Loading @@ -9592,7 +9573,6 @@ public class SatelliteController extends Handler { return false; } } } protected void updateLastNotifiedCarrierRoamingNtnSignalStrengthAndNotify( @Nullable Phone phone) { Loading