Loading src/java/com/android/internal/telephony/satellite/SatelliteController.java +102 −129 Original line number Diff line number Diff line Loading @@ -387,6 +387,7 @@ public class SatelliteController extends Handler { private AtomicBoolean mNeedsSatellitePointing = new AtomicBoolean(false); private AtomicBoolean mIsDemoModeEnabled = new AtomicBoolean(false); private AtomicBoolean mIsEmergency = new AtomicBoolean(false); private AtomicBoolean mIsSatelliteEnabled = null; private final Object mSatelliteEnabledRequestLock = new Object(); /* This variable is used to store the first enable request that framework has received in the Loading Loading @@ -479,9 +480,6 @@ public class SatelliteController extends Handler { private final ConcurrentHashMap<IBinder, ISelectedNbIotSatelliteSubscriptionCallback> mSelectedNbIotSatelliteSubscriptionChangedListeners = new ConcurrentHashMap<>(); private final Object mIsSatelliteEnabledLock = new Object(); @GuardedBy("mIsSatelliteEnabledLock") private Boolean mIsSatelliteEnabled = null; @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE) protected final Object mIsRadioOnLock = new Object(); @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE) Loading Loading @@ -520,15 +518,14 @@ public class SatelliteController extends Handler { private final SubscriptionManager.OnSubscriptionsChangedListener mSubscriptionsChangedListener; @GuardedBy("mCarrierConfigArrayLock") @NonNull private final SparseArray<PersistableBundle> mCarrierConfigArray = new SparseArray<>(); @GuardedBy("mIsSatelliteEnabledLock") /** Key: Subscription ID, value: set of restriction reasons for satellite communication.*/ @NonNull private final Map<Integer, Set<Integer>> mSatelliteAttachRestrictionForCarrierArray = new HashMap<>(); @GuardedBy("mIsSatelliteEnabledLock") @NonNull private final ConcurrentHashMap<Integer, Set<Integer>> mSatelliteAttachRestrictionForCarrierArray = new ConcurrentHashMap<>(); /** Key: Subscription ID, value: the actual satellite enabled state in the modem - * {@code true} for enabled and {@code false} for disabled. */ @NonNull private final Map<Integer, Boolean> mIsSatelliteAttachEnabledForCarrierArrayPerSub = new HashMap<>(); @NonNull private final ConcurrentHashMap<Integer, Boolean> mIsSatelliteAttachEnabledForCarrierArrayPerSub = new ConcurrentHashMap<>(); /** Key: subId, value: (key: Regional satellite config Id string, value: Integer * arrays of earfcns in the corresponding regions.) */ Loading Loading @@ -1933,7 +1930,6 @@ public class SatelliteController extends Handler { plogd("EVENT_EVALUATE_SATELLITE_ATTACH_RESTRICTION_CHANGE_DONE: subId=" + subId + " error:" + error); synchronized (mIsSatelliteEnabledLock) { if (error == SATELLITE_RESULT_SUCCESS) { boolean enableSatellite = mSatelliteAttachRestrictionForCarrierArray .getOrDefault(argument.subId, Collections.emptySet()).isEmpty(); Loading @@ -1943,8 +1939,6 @@ public class SatelliteController extends Handler { } else { mIsSatelliteAttachEnabledForCarrierArrayPerSub.remove(subId); } } argument.callback.accept(error); break; } Loading Loading @@ -2319,10 +2313,8 @@ public class SatelliteController extends Handler { + " error=" + error + " satelliteEnabled=" + satelliteEnabled); if (error == SATELLITE_RESULT_SUCCESS) { synchronized (mIsSatelliteEnabledLock) { mIsSatelliteAttachEnabledForCarrierArrayPerSub.put( subId, satelliteEnabled); } evaluateEnablingSatelliteForCarrier(subId, SATELLITE_COMMUNICATION_RESTRICTION_REASON_USER, null); } Loading Loading @@ -3032,10 +3024,8 @@ public class SatelliteController extends Handler { * @return {@code true} if the satellite modem is enabled and {@code false} otherwise. */ public boolean isSatelliteEnabled() { synchronized (mIsSatelliteEnabledLock) { if (mIsSatelliteEnabled == null) return false; return mIsSatelliteEnabled; } return mIsSatelliteEnabled.get(); } /** Loading Loading @@ -3746,7 +3736,6 @@ public class SatelliteController extends Handler { plogd("handleRequestAddAttachRestrictionForCarrier: subId=" + subId + " reason=" + reason); Consumer<Integer> result = FunctionalUtils.ignoreRemoteException(callback::accept); synchronized (mIsSatelliteEnabledLock) { if (mSatelliteAttachRestrictionForCarrierArray.getOrDefault( subId, Collections.emptySet()).isEmpty()) { mSatelliteAttachRestrictionForCarrierArray.put(subId, new HashSet<>()); Loading @@ -3755,7 +3744,7 @@ public class SatelliteController extends Handler { return; } mSatelliteAttachRestrictionForCarrierArray.get(subId).add(reason); } RequestHandleSatelliteAttachRestrictionForCarrierArgument request = new RequestHandleSatelliteAttachRestrictionForCarrierArgument(subId, reason, result); Loading Loading @@ -3796,7 +3785,6 @@ public class SatelliteController extends Handler { + " reason=" + reason); Consumer<Integer> result = FunctionalUtils.ignoreRemoteException(callback::accept); synchronized (mIsSatelliteEnabledLock) { if (mSatelliteAttachRestrictionForCarrierArray.getOrDefault( subId, Collections.emptySet()).isEmpty() || !mSatelliteAttachRestrictionForCarrierArray.get(subId).contains(reason)) { Loading @@ -3804,7 +3792,7 @@ public class SatelliteController extends Handler { return; } mSatelliteAttachRestrictionForCarrierArray.get(subId).remove(reason); } RequestHandleSatelliteAttachRestrictionForCarrierArgument request = new RequestHandleSatelliteAttachRestrictionForCarrierArgument(subId, reason, result); Loading @@ -3821,7 +3809,6 @@ public class SatelliteController extends Handler { * @return Set of reasons for disallowing satellite attach for carrier. */ @NonNull public Set<Integer> getAttachRestrictionReasonsForCarrier(int subId) { synchronized (mIsSatelliteEnabledLock) { Set<Integer> resultSet = mSatelliteAttachRestrictionForCarrierArray.get(subId); if (resultSet == null) { Loading @@ -3829,7 +3816,6 @@ public class SatelliteController extends Handler { } return new HashSet<>(resultSet); } } /** * Request to get the signal strength of the satellite connection. Loading Loading @@ -4051,9 +4037,7 @@ public class SatelliteController extends Handler { plogd("setSatelliteServicePackageName: Resetting cached states, provisioned=" + provisioned); mIsSatelliteSupported = null; synchronized (mIsSatelliteEnabledLock) { mIsSatelliteEnabled = null; } synchronized (mSatelliteCapabilitiesLock) { mSatelliteCapabilities = null; } Loading Loading @@ -5324,9 +5308,7 @@ public class SatelliteController extends Handler { } private void updateSatelliteEnabledState(boolean enabled, String caller) { synchronized (mIsSatelliteEnabledLock) { mIsSatelliteEnabled = enabled; } setIsSatelliteEnabled(enabled); if (mSatelliteSessionController != null) { mSatelliteSessionController.onSatelliteEnabledStateChanged(enabled); mSatelliteSessionController.setDemoMode(mIsDemoModeEnabled.get()); Loading Loading @@ -5819,9 +5801,7 @@ public class SatelliteController extends Handler { if (areAllRadiosDisabled() && (mSatelliteEnabledRequest != null) && mWaitingForRadioDisabled) { plogd("Sending success to callback that sent enable satellite request"); synchronized (mIsSatelliteEnabledLock) { mIsSatelliteEnabled = mSatelliteEnabledRequest.enableSatellite; } setIsSatelliteEnabled(mSatelliteEnabledRequest.enableSatellite); mSatelliteEnabledRequest.callback.accept(SATELLITE_RESULT_SUCCESS); updateSatelliteEnabledState( mSatelliteEnabledRequest.enableSatellite, Loading Loading @@ -5879,9 +5859,7 @@ public class SatelliteController extends Handler { setDemoModeEnabled(false); handlePersistentLoggingOnSessionEnd(mIsEmergency.get()); setEmergencyMode(false); synchronized (mIsSatelliteEnabledLock) { mIsSatelliteEnabled = false; } setIsSatelliteEnabled(false); setSettingsKeyForSatelliteMode(SATELLITE_MODE_ENABLED_FALSE); setSettingsKeyToAllowDeviceRotation(SATELLITE_MODE_ENABLED_FALSE); abortSatelliteDisableRequest(resultCode); Loading Loading @@ -6215,13 +6193,11 @@ public class SatelliteController extends Handler { private void getSatelliteEnabledForCarrierAtModem(int subId) { Phone phone = SatelliteServiceUtils.getPhone(subId); synchronized (mIsSatelliteEnabledLock) { if (!mIsSatelliteAttachEnabledForCarrierArrayPerSub.containsKey(subId)) { // Get enabled status from modem for new subscription sendRequestAsync(CMD_GET_SATELLITE_ENABLED_FOR_CARRIER, null, phone); } } } // imsi, msisdn, default sms subId change private void handleSubscriptionsChanged() { Loading Loading @@ -6483,7 +6459,6 @@ public class SatelliteController extends Handler { * {@code false} otherwise. */ private boolean isSatelliteAttachEnabledForCarrierByUser(int subId) { synchronized (mIsSatelliteEnabledLock) { Set<Integer> cachedRestrictionSet = mSatelliteAttachRestrictionForCarrierArray.get(subId); if (cachedRestrictionSet != null) { Loading @@ -6510,7 +6485,6 @@ public class SatelliteController extends Handler { return false; } synchronized (mIsSatelliteEnabledLock) { boolean result = enabled.equals("1"); if (!result) { mSatelliteAttachRestrictionForCarrierArray.put(subId, new HashSet<>()); Loading @@ -6518,14 +6492,12 @@ public class SatelliteController extends Handler { SATELLITE_COMMUNICATION_RESTRICTION_REASON_USER); } return result; } } catch (IllegalArgumentException | SecurityException ex) { ploge("isSatelliteAttachEnabledForCarrierByUser: ex=" + ex); return false; } } } } /** * Check whether there is any reason to restrict satellite communication for the carrier Loading @@ -6535,11 +6507,9 @@ public class SatelliteController extends Handler { * @return {@code true} when there is at least on reason, {@code false} otherwise. */ private boolean hasReasonToRestrictSatelliteCommunicationForCarrier(int subId) { synchronized (mIsSatelliteEnabledLock) { return !mSatelliteAttachRestrictionForCarrierArray .getOrDefault(subId, Collections.emptySet()).isEmpty(); } } private void updateRestrictReasonForEntitlementPerCarrier(int subId) { if (!getConfigForSubId(subId).getBoolean(KEY_SATELLITE_ENTITLEMENT_SUPPORTED_BOOL, false)) { Loading Loading @@ -6613,7 +6583,6 @@ public class SatelliteController extends Handler { return false; } synchronized (mIsSatelliteEnabledLock) { try { mSubscriptionManagerService.setSubscriptionProperty(subId, SATELLITE_ATTACH_ENABLED_FOR_CARRIER, Loading @@ -6624,7 +6593,6 @@ public class SatelliteController extends Handler { ploge("persistSatelliteAttachEnabledForCarrierSetting, ex=" + ex); return false; } } return true; } Loading @@ -6647,10 +6615,8 @@ public class SatelliteController extends Handler { */ @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE) public boolean isSatelliteEnabledForCarrierAtModem(int subId) { synchronized (mIsSatelliteEnabledLock) { return mIsSatelliteAttachEnabledForCarrierArrayPerSub.getOrDefault(subId, false); } } /** * Evaluate whether satellite modem for carrier should be enabled or not. Loading Loading @@ -9211,9 +9177,7 @@ public class SatelliteController extends Handler { } private boolean isSatelliteDisabled() { synchronized (mIsSatelliteEnabledLock) { return ((mIsSatelliteEnabled != null) && !mIsSatelliteEnabled); } return ((mIsSatelliteEnabled != null) && !mIsSatelliteEnabled.get()); } private boolean shouldStopWaitForEnableResponseTimer( Loading Loading @@ -9689,11 +9653,20 @@ public class SatelliteController extends Handler { } } private void setIsSatelliteEnabled(boolean enabled) { if (mIsSatelliteEnabled == null) { mIsSatelliteEnabled = new AtomicBoolean(enabled); } else { mIsSatelliteEnabled.set(enabled); } } @Nullable private Boolean getIsSatelliteEnabled() { synchronized (mIsSatelliteEnabledLock) { return mIsSatelliteEnabled; if (mIsSatelliteEnabled == null) { return null; } return mIsSatelliteEnabled.get(); } @Nullable Loading tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java +5 −2 Original line number Diff line number Diff line Loading @@ -222,6 +222,7 @@ import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executor; import java.util.concurrent.Semaphore; Loading Loading @@ -2932,7 +2933,8 @@ public class SatelliteControllerTest extends TelephonyTest { reset(mMockSatelliteModemInterface); setUpResponseForRequestSetSatelliteEnabledForCarrier(true, SATELLITE_RESULT_SUCCESS); doReturn(true).when(mMockSatelliteModemInterface).isSatelliteServiceSupported(); Map<Integer, Set<Integer>> satelliteAttachRestrictionForCarrierArray = new HashMap<>(); ConcurrentHashMap<Integer, Set<Integer>> satelliteAttachRestrictionForCarrierArray = new ConcurrentHashMap<>(); satelliteAttachRestrictionForCarrierArray.put(SUB_ID, new HashSet<>()); satelliteAttachRestrictionForCarrierArray.get(SUB_ID).add( SATELLITE_COMMUNICATION_RESTRICTION_REASON_ENTITLEMENT); Loading @@ -2956,7 +2958,8 @@ public class SatelliteControllerTest extends TelephonyTest { mIIntegerConsumerResults.clear(); reset(mMockSatelliteModemInterface); reset(mPhone); Map<Integer, Boolean> enabledForCarrierArrayPerSub = new HashMap<>(); ConcurrentHashMap<Integer, Boolean> enabledForCarrierArrayPerSub = new ConcurrentHashMap<>(); enabledForCarrierArrayPerSub.put(SUB_ID, true); replaceInstance(SatelliteController.class, "mIsSatelliteAttachEnabledForCarrierArrayPerSub", mSatelliteControllerUT, enabledForCarrierArrayPerSub); Loading Loading
src/java/com/android/internal/telephony/satellite/SatelliteController.java +102 −129 Original line number Diff line number Diff line Loading @@ -387,6 +387,7 @@ public class SatelliteController extends Handler { private AtomicBoolean mNeedsSatellitePointing = new AtomicBoolean(false); private AtomicBoolean mIsDemoModeEnabled = new AtomicBoolean(false); private AtomicBoolean mIsEmergency = new AtomicBoolean(false); private AtomicBoolean mIsSatelliteEnabled = null; private final Object mSatelliteEnabledRequestLock = new Object(); /* This variable is used to store the first enable request that framework has received in the Loading Loading @@ -479,9 +480,6 @@ public class SatelliteController extends Handler { private final ConcurrentHashMap<IBinder, ISelectedNbIotSatelliteSubscriptionCallback> mSelectedNbIotSatelliteSubscriptionChangedListeners = new ConcurrentHashMap<>(); private final Object mIsSatelliteEnabledLock = new Object(); @GuardedBy("mIsSatelliteEnabledLock") private Boolean mIsSatelliteEnabled = null; @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE) protected final Object mIsRadioOnLock = new Object(); @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE) Loading Loading @@ -520,15 +518,14 @@ public class SatelliteController extends Handler { private final SubscriptionManager.OnSubscriptionsChangedListener mSubscriptionsChangedListener; @GuardedBy("mCarrierConfigArrayLock") @NonNull private final SparseArray<PersistableBundle> mCarrierConfigArray = new SparseArray<>(); @GuardedBy("mIsSatelliteEnabledLock") /** Key: Subscription ID, value: set of restriction reasons for satellite communication.*/ @NonNull private final Map<Integer, Set<Integer>> mSatelliteAttachRestrictionForCarrierArray = new HashMap<>(); @GuardedBy("mIsSatelliteEnabledLock") @NonNull private final ConcurrentHashMap<Integer, Set<Integer>> mSatelliteAttachRestrictionForCarrierArray = new ConcurrentHashMap<>(); /** Key: Subscription ID, value: the actual satellite enabled state in the modem - * {@code true} for enabled and {@code false} for disabled. */ @NonNull private final Map<Integer, Boolean> mIsSatelliteAttachEnabledForCarrierArrayPerSub = new HashMap<>(); @NonNull private final ConcurrentHashMap<Integer, Boolean> mIsSatelliteAttachEnabledForCarrierArrayPerSub = new ConcurrentHashMap<>(); /** Key: subId, value: (key: Regional satellite config Id string, value: Integer * arrays of earfcns in the corresponding regions.) */ Loading Loading @@ -1933,7 +1930,6 @@ public class SatelliteController extends Handler { plogd("EVENT_EVALUATE_SATELLITE_ATTACH_RESTRICTION_CHANGE_DONE: subId=" + subId + " error:" + error); synchronized (mIsSatelliteEnabledLock) { if (error == SATELLITE_RESULT_SUCCESS) { boolean enableSatellite = mSatelliteAttachRestrictionForCarrierArray .getOrDefault(argument.subId, Collections.emptySet()).isEmpty(); Loading @@ -1943,8 +1939,6 @@ public class SatelliteController extends Handler { } else { mIsSatelliteAttachEnabledForCarrierArrayPerSub.remove(subId); } } argument.callback.accept(error); break; } Loading Loading @@ -2319,10 +2313,8 @@ public class SatelliteController extends Handler { + " error=" + error + " satelliteEnabled=" + satelliteEnabled); if (error == SATELLITE_RESULT_SUCCESS) { synchronized (mIsSatelliteEnabledLock) { mIsSatelliteAttachEnabledForCarrierArrayPerSub.put( subId, satelliteEnabled); } evaluateEnablingSatelliteForCarrier(subId, SATELLITE_COMMUNICATION_RESTRICTION_REASON_USER, null); } Loading Loading @@ -3032,10 +3024,8 @@ public class SatelliteController extends Handler { * @return {@code true} if the satellite modem is enabled and {@code false} otherwise. */ public boolean isSatelliteEnabled() { synchronized (mIsSatelliteEnabledLock) { if (mIsSatelliteEnabled == null) return false; return mIsSatelliteEnabled; } return mIsSatelliteEnabled.get(); } /** Loading Loading @@ -3746,7 +3736,6 @@ public class SatelliteController extends Handler { plogd("handleRequestAddAttachRestrictionForCarrier: subId=" + subId + " reason=" + reason); Consumer<Integer> result = FunctionalUtils.ignoreRemoteException(callback::accept); synchronized (mIsSatelliteEnabledLock) { if (mSatelliteAttachRestrictionForCarrierArray.getOrDefault( subId, Collections.emptySet()).isEmpty()) { mSatelliteAttachRestrictionForCarrierArray.put(subId, new HashSet<>()); Loading @@ -3755,7 +3744,7 @@ public class SatelliteController extends Handler { return; } mSatelliteAttachRestrictionForCarrierArray.get(subId).add(reason); } RequestHandleSatelliteAttachRestrictionForCarrierArgument request = new RequestHandleSatelliteAttachRestrictionForCarrierArgument(subId, reason, result); Loading Loading @@ -3796,7 +3785,6 @@ public class SatelliteController extends Handler { + " reason=" + reason); Consumer<Integer> result = FunctionalUtils.ignoreRemoteException(callback::accept); synchronized (mIsSatelliteEnabledLock) { if (mSatelliteAttachRestrictionForCarrierArray.getOrDefault( subId, Collections.emptySet()).isEmpty() || !mSatelliteAttachRestrictionForCarrierArray.get(subId).contains(reason)) { Loading @@ -3804,7 +3792,7 @@ public class SatelliteController extends Handler { return; } mSatelliteAttachRestrictionForCarrierArray.get(subId).remove(reason); } RequestHandleSatelliteAttachRestrictionForCarrierArgument request = new RequestHandleSatelliteAttachRestrictionForCarrierArgument(subId, reason, result); Loading @@ -3821,7 +3809,6 @@ public class SatelliteController extends Handler { * @return Set of reasons for disallowing satellite attach for carrier. */ @NonNull public Set<Integer> getAttachRestrictionReasonsForCarrier(int subId) { synchronized (mIsSatelliteEnabledLock) { Set<Integer> resultSet = mSatelliteAttachRestrictionForCarrierArray.get(subId); if (resultSet == null) { Loading @@ -3829,7 +3816,6 @@ public class SatelliteController extends Handler { } return new HashSet<>(resultSet); } } /** * Request to get the signal strength of the satellite connection. Loading Loading @@ -4051,9 +4037,7 @@ public class SatelliteController extends Handler { plogd("setSatelliteServicePackageName: Resetting cached states, provisioned=" + provisioned); mIsSatelliteSupported = null; synchronized (mIsSatelliteEnabledLock) { mIsSatelliteEnabled = null; } synchronized (mSatelliteCapabilitiesLock) { mSatelliteCapabilities = null; } Loading Loading @@ -5324,9 +5308,7 @@ public class SatelliteController extends Handler { } private void updateSatelliteEnabledState(boolean enabled, String caller) { synchronized (mIsSatelliteEnabledLock) { mIsSatelliteEnabled = enabled; } setIsSatelliteEnabled(enabled); if (mSatelliteSessionController != null) { mSatelliteSessionController.onSatelliteEnabledStateChanged(enabled); mSatelliteSessionController.setDemoMode(mIsDemoModeEnabled.get()); Loading Loading @@ -5819,9 +5801,7 @@ public class SatelliteController extends Handler { if (areAllRadiosDisabled() && (mSatelliteEnabledRequest != null) && mWaitingForRadioDisabled) { plogd("Sending success to callback that sent enable satellite request"); synchronized (mIsSatelliteEnabledLock) { mIsSatelliteEnabled = mSatelliteEnabledRequest.enableSatellite; } setIsSatelliteEnabled(mSatelliteEnabledRequest.enableSatellite); mSatelliteEnabledRequest.callback.accept(SATELLITE_RESULT_SUCCESS); updateSatelliteEnabledState( mSatelliteEnabledRequest.enableSatellite, Loading Loading @@ -5879,9 +5859,7 @@ public class SatelliteController extends Handler { setDemoModeEnabled(false); handlePersistentLoggingOnSessionEnd(mIsEmergency.get()); setEmergencyMode(false); synchronized (mIsSatelliteEnabledLock) { mIsSatelliteEnabled = false; } setIsSatelliteEnabled(false); setSettingsKeyForSatelliteMode(SATELLITE_MODE_ENABLED_FALSE); setSettingsKeyToAllowDeviceRotation(SATELLITE_MODE_ENABLED_FALSE); abortSatelliteDisableRequest(resultCode); Loading Loading @@ -6215,13 +6193,11 @@ public class SatelliteController extends Handler { private void getSatelliteEnabledForCarrierAtModem(int subId) { Phone phone = SatelliteServiceUtils.getPhone(subId); synchronized (mIsSatelliteEnabledLock) { if (!mIsSatelliteAttachEnabledForCarrierArrayPerSub.containsKey(subId)) { // Get enabled status from modem for new subscription sendRequestAsync(CMD_GET_SATELLITE_ENABLED_FOR_CARRIER, null, phone); } } } // imsi, msisdn, default sms subId change private void handleSubscriptionsChanged() { Loading Loading @@ -6483,7 +6459,6 @@ public class SatelliteController extends Handler { * {@code false} otherwise. */ private boolean isSatelliteAttachEnabledForCarrierByUser(int subId) { synchronized (mIsSatelliteEnabledLock) { Set<Integer> cachedRestrictionSet = mSatelliteAttachRestrictionForCarrierArray.get(subId); if (cachedRestrictionSet != null) { Loading @@ -6510,7 +6485,6 @@ public class SatelliteController extends Handler { return false; } synchronized (mIsSatelliteEnabledLock) { boolean result = enabled.equals("1"); if (!result) { mSatelliteAttachRestrictionForCarrierArray.put(subId, new HashSet<>()); Loading @@ -6518,14 +6492,12 @@ public class SatelliteController extends Handler { SATELLITE_COMMUNICATION_RESTRICTION_REASON_USER); } return result; } } catch (IllegalArgumentException | SecurityException ex) { ploge("isSatelliteAttachEnabledForCarrierByUser: ex=" + ex); return false; } } } } /** * Check whether there is any reason to restrict satellite communication for the carrier Loading @@ -6535,11 +6507,9 @@ public class SatelliteController extends Handler { * @return {@code true} when there is at least on reason, {@code false} otherwise. */ private boolean hasReasonToRestrictSatelliteCommunicationForCarrier(int subId) { synchronized (mIsSatelliteEnabledLock) { return !mSatelliteAttachRestrictionForCarrierArray .getOrDefault(subId, Collections.emptySet()).isEmpty(); } } private void updateRestrictReasonForEntitlementPerCarrier(int subId) { if (!getConfigForSubId(subId).getBoolean(KEY_SATELLITE_ENTITLEMENT_SUPPORTED_BOOL, false)) { Loading Loading @@ -6613,7 +6583,6 @@ public class SatelliteController extends Handler { return false; } synchronized (mIsSatelliteEnabledLock) { try { mSubscriptionManagerService.setSubscriptionProperty(subId, SATELLITE_ATTACH_ENABLED_FOR_CARRIER, Loading @@ -6624,7 +6593,6 @@ public class SatelliteController extends Handler { ploge("persistSatelliteAttachEnabledForCarrierSetting, ex=" + ex); return false; } } return true; } Loading @@ -6647,10 +6615,8 @@ public class SatelliteController extends Handler { */ @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE) public boolean isSatelliteEnabledForCarrierAtModem(int subId) { synchronized (mIsSatelliteEnabledLock) { return mIsSatelliteAttachEnabledForCarrierArrayPerSub.getOrDefault(subId, false); } } /** * Evaluate whether satellite modem for carrier should be enabled or not. Loading Loading @@ -9211,9 +9177,7 @@ public class SatelliteController extends Handler { } private boolean isSatelliteDisabled() { synchronized (mIsSatelliteEnabledLock) { return ((mIsSatelliteEnabled != null) && !mIsSatelliteEnabled); } return ((mIsSatelliteEnabled != null) && !mIsSatelliteEnabled.get()); } private boolean shouldStopWaitForEnableResponseTimer( Loading Loading @@ -9689,11 +9653,20 @@ public class SatelliteController extends Handler { } } private void setIsSatelliteEnabled(boolean enabled) { if (mIsSatelliteEnabled == null) { mIsSatelliteEnabled = new AtomicBoolean(enabled); } else { mIsSatelliteEnabled.set(enabled); } } @Nullable private Boolean getIsSatelliteEnabled() { synchronized (mIsSatelliteEnabledLock) { return mIsSatelliteEnabled; if (mIsSatelliteEnabled == null) { return null; } return mIsSatelliteEnabled.get(); } @Nullable Loading
tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java +5 −2 Original line number Diff line number Diff line Loading @@ -222,6 +222,7 @@ import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executor; import java.util.concurrent.Semaphore; Loading Loading @@ -2932,7 +2933,8 @@ public class SatelliteControllerTest extends TelephonyTest { reset(mMockSatelliteModemInterface); setUpResponseForRequestSetSatelliteEnabledForCarrier(true, SATELLITE_RESULT_SUCCESS); doReturn(true).when(mMockSatelliteModemInterface).isSatelliteServiceSupported(); Map<Integer, Set<Integer>> satelliteAttachRestrictionForCarrierArray = new HashMap<>(); ConcurrentHashMap<Integer, Set<Integer>> satelliteAttachRestrictionForCarrierArray = new ConcurrentHashMap<>(); satelliteAttachRestrictionForCarrierArray.put(SUB_ID, new HashSet<>()); satelliteAttachRestrictionForCarrierArray.get(SUB_ID).add( SATELLITE_COMMUNICATION_RESTRICTION_REASON_ENTITLEMENT); Loading @@ -2956,7 +2958,8 @@ public class SatelliteControllerTest extends TelephonyTest { mIIntegerConsumerResults.clear(); reset(mMockSatelliteModemInterface); reset(mPhone); Map<Integer, Boolean> enabledForCarrierArrayPerSub = new HashMap<>(); ConcurrentHashMap<Integer, Boolean> enabledForCarrierArrayPerSub = new ConcurrentHashMap<>(); enabledForCarrierArrayPerSub.put(SUB_ID, true); replaceInstance(SatelliteController.class, "mIsSatelliteAttachEnabledForCarrierArrayPerSub", mSatelliteControllerUT, enabledForCarrierArrayPerSub); Loading