Merge "Manual network selection handling when request satellite enable" into main
diff --git a/flags/data.aconfig b/flags/data.aconfig
index ccd5db4..321ac6b 100644
--- a/flags/data.aconfig
+++ b/flags/data.aconfig
@@ -102,12 +102,15 @@
bug:"318519337"
}
-# OWNER=jackyu TARGET=24Q4
+# OWNER=jackyu TARGET=25Q1
flag {
name: "dds_callback"
namespace: "telephony"
description: "Adding new callback when DDS changed"
bug:"353723350"
+ metadata {
+ purpose: PURPOSE_BUGFIX
+ }
}
# OWNER=jackyu TARGET=25Q1
diff --git a/src/java/com/android/internal/telephony/Phone.java b/src/java/com/android/internal/telephony/Phone.java
index 1a8c046..ca82d31 100644
--- a/src/java/com/android/internal/telephony/Phone.java
+++ b/src/java/com/android/internal/telephony/Phone.java
@@ -126,6 +126,7 @@
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -5374,6 +5375,8 @@
*/
public void notifyCarrierRoamingNtnAvailableServicesChanged(
@NetworkRegistrationInfo.ServiceType int[] availableServices) {
+ logd("notifyCarrierRoamingNtnAvailableServicesChanged availableServices:"
+ + Arrays.toString(availableServices));
mNotifier.notifyCarrierRoamingNtnAvailableServicesChanged(this, availableServices);
}
diff --git a/src/java/com/android/internal/telephony/RIL.java b/src/java/com/android/internal/telephony/RIL.java
index 88ead6f..34ac832 100644
--- a/src/java/com/android/internal/telephony/RIL.java
+++ b/src/java/com/android/internal/telephony/RIL.java
@@ -178,6 +178,9 @@
/** @hide */
public static final HalVersion RADIO_HAL_VERSION_2_2 = new HalVersion(2, 2);
+ /** @hide */
+ public static final HalVersion RADIO_HAL_VERSION_2_3 = new HalVersion(2, 3);
+
// Hal version
private final Map<Integer, HalVersion> mHalVersion = new HashMap<>();
@@ -6212,6 +6215,7 @@
case 1: return RADIO_HAL_VERSION_2_0;
case 2: return RADIO_HAL_VERSION_2_1;
case 3: return RADIO_HAL_VERSION_2_2;
+ case 4: return RADIO_HAL_VERSION_2_3;
default: return RADIO_HAL_VERSION_UNKNOWN;
}
}
diff --git a/src/java/com/android/internal/telephony/emergency/EmergencyStateTracker.java b/src/java/com/android/internal/telephony/emergency/EmergencyStateTracker.java
index e5ea0c0..3040c23 100644
--- a/src/java/com/android/internal/telephony/emergency/EmergencyStateTracker.java
+++ b/src/java/com/android/internal/telephony/emergency/EmergencyStateTracker.java
@@ -1738,8 +1738,7 @@
return phone.getServiceStateTracker().isRadioOn()
&& !satelliteController.isSatelliteEnabledOrBeingEnabled();
}
- }, !isTestEmergencyNumber, phone, isTestEmergencyNumber, waitForInServiceTimeout,
- /* forNormalRoutingEmergencyCall */ false);
+ }, !isTestEmergencyNumber, phone, isTestEmergencyNumber, waitForInServiceTimeout);
} else {
switchDdsAndSetEmergencyMode(phone, emergencyType);
}
diff --git a/src/java/com/android/internal/telephony/emergency/RadioOnHelper.java b/src/java/com/android/internal/telephony/emergency/RadioOnHelper.java
index 11162b8..e2291c9 100644
--- a/src/java/com/android/internal/telephony/emergency/RadioOnHelper.java
+++ b/src/java/com/android/internal/telephony/emergency/RadioOnHelper.java
@@ -85,7 +85,7 @@
*/
public void triggerRadioOnAndListen(RadioOnStateListener.Callback callback,
boolean forEmergencyCall, Phone phoneForEmergencyCall, boolean isTestEmergencyNumber,
- int emergencyTimeoutIntervalMillis, boolean forNormalRoutingEmergencyCall) {
+ int emergencyTimeoutIntervalMillis) {
setupListeners();
mCallback = callback;
mInProgressListeners.clear();
@@ -102,8 +102,7 @@
mListeners.get(i).waitForRadioOn(phone, this, forEmergencyCall, forEmergencyCall
&& phone == phoneForEmergencyCall, timeoutCallbackInterval);
}
- powerOnRadio(forEmergencyCall, phoneForEmergencyCall, isTestEmergencyNumber,
- forNormalRoutingEmergencyCall);
+ powerOnRadio(forEmergencyCall, phoneForEmergencyCall, isTestEmergencyNumber);
if (SatelliteController.getInstance().isSatelliteEnabledOrBeingEnabled()) {
powerOffSatellite();
}
@@ -114,25 +113,17 @@
* get an onServiceStateChanged() callback when the radio successfully comes up.
*/
private void powerOnRadio(boolean forEmergencyCall, Phone phoneForEmergencyCall,
- boolean isTestEmergencyNumber, boolean forNormalRoutingEmergencyCall) {
+ boolean isTestEmergencyNumber) {
// Always try to turn on the radio here independent of APM setting - if we got here in the
// first place, the radio is off independent of APM setting.
for (Phone phone : PhoneFactory.getPhones()) {
Rlog.d(TAG, "powerOnRadio, enabling Radio");
if (isTestEmergencyNumber) {
- phone.setRadioPowerOnForTestEmergencyCall(
- (phone == phoneForEmergencyCall) && !forNormalRoutingEmergencyCall);
+ phone.setRadioPowerOnForTestEmergencyCall(phone == phoneForEmergencyCall);
} else {
- if (forNormalRoutingEmergencyCall) {
- if (phone.getServiceStateTracker() != null) {
- // Clear all radio off reasons to ensure that the radio is turned on for
- // normal routing emergency call.
- phone.getServiceStateTracker().clearAllRadioOffReasons();
- }
- }
- phone.setRadioPower(true, forEmergencyCall && !forNormalRoutingEmergencyCall,
- (phone == phoneForEmergencyCall) && !forNormalRoutingEmergencyCall, false);
+ phone.setRadioPower(true, forEmergencyCall, phone == phoneForEmergencyCall,
+ false);
}
}
diff --git a/src/java/com/android/internal/telephony/satellite/SatelliteController.java b/src/java/com/android/internal/telephony/satellite/SatelliteController.java
index 1e56b27..b0a5a0c 100644
--- a/src/java/com/android/internal/telephony/satellite/SatelliteController.java
+++ b/src/java/com/android/internal/telephony/satellite/SatelliteController.java
@@ -427,11 +427,11 @@
@VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
protected boolean mRadioOffRequested = false;
@VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
- protected final Object mSatelliteViaOemProvisionLock = new Object();
+ protected final Object mDeviceProvisionLock = new Object();
@VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
- @GuardedBy("mSatelliteViaOemProvisionLock")
- protected Boolean mIsSatelliteViaOemProvisioned = null;
- @GuardedBy("mSatelliteViaOemProvisionLock")
+ @GuardedBy("mDeviceProvisionLock")
+ protected Boolean mIsDeviceProvisioned = null;
+ @GuardedBy("mDeviceProvisionLock")
private Boolean mOverriddenIsSatelliteViaOemProvisioned = null;
private final Object mSatelliteCapabilitiesLock = new Object();
@GuardedBy("mSatelliteCapabilitiesLock")
@@ -610,6 +610,8 @@
private static final String ACTION_NOTIFICATION_CLICK = "action_notification_click";
private static final String ACTION_NOTIFICATION_DISMISS = "action_notification_dismiss";
private AtomicBoolean mOverrideNtnEligibility;
+ private String mDefaultSmsPackageName = "";
+ private String mSatelliteGatewayServicePackageName = "";
private BroadcastReceiver
mDefaultSmsSubscriptionChangedBroadcastReceiver = new BroadcastReceiver() {
@Override
@@ -622,6 +624,32 @@
}
};
+ private BroadcastReceiver mPackageStateChangedReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ mDefaultSmsPackageName = Telephony.Sms.getDefaultSmsPackage(mContext);
+ mSatelliteGatewayServicePackageName = getConfigSatelliteGatewayServicePackage();
+ String schemeSpecificPart = intent.getData().getSchemeSpecificPart();
+ plogd("packageStateChanged: " + intent.getData().toString()
+ + " DefaultSmsPackageName:" + mDefaultSmsPackageName);
+
+ if (!schemeSpecificPart.equals(mSatelliteGatewayServicePackageName)
+ && !schemeSpecificPart.equals(mDefaultSmsPackageName)) {
+ plogv("Neither SMS or SatelliteGateway package");
+ return;
+ }
+ int[] activeSubIds = mSubscriptionManagerService.getActiveSubIdList(true);
+ if (activeSubIds != null) {
+ for (int activeSubId : activeSubIds) {
+ plogd("mPackageStateChangedReceiver: activeSubId= " + activeSubId);
+ handleCarrierRoamingNtnAvailableServicesChanged(activeSubId);
+ }
+ } else {
+ ploge("mPackageStateChangedReceiver: activeSubIds is null");
+ }
+ }
+ };
+
// List of device states returned from DeviceStateManager to determine if running on a foldable
// device.
private List<DeviceState> mDeviceStates = new ArrayList();
@@ -730,6 +758,7 @@
}
mSatellitePlmnListFromOverlayConfig = readSatellitePlmnsFromOverlayConfig();
+ registerApplicationStateChanged();
updateSupportedSatelliteServicesForActiveSubscriptions();
mCarrierConfigChangeListener =
(slotIndex, subId, carrierId, specificCarrierId) ->
@@ -2288,10 +2317,14 @@
return false;
}
- if (mSatelliteSessionController != null) {
- return mSatelliteSessionController.isInEnablingState();
+ if (mSatelliteSessionController != null
+ && mSatelliteSessionController.isInEnablingState()) {
+ return true;
}
- return false;
+
+ synchronized (mSatelliteEnabledRequestLock) {
+ return (mSatelliteEnabledRequest != null);
+ }
}
/**
@@ -2311,10 +2344,14 @@
* @return {@code true} if the satellite modem is being disabled and {@code false} otherwise.
*/
public boolean isSatelliteBeingDisabled() {
- if (mSatelliteSessionController != null) {
- return mSatelliteSessionController.isInDisablingState();
+ if (mSatelliteSessionController != null
+ && mSatelliteSessionController.isInDisablingState()) {
+ return true;
}
- return false;
+
+ synchronized (mSatelliteEnabledRequestLock) {
+ return (mSatelliteDisabledRequest != null);
+ }
}
/**
@@ -2481,36 +2518,60 @@
@NonNull String token, @NonNull byte[] provisionData,
@NonNull IIntegerConsumer callback) {
Consumer<Integer> result = FunctionalUtils.ignoreRemoteException(callback::accept);
- int error = evaluateOemSatelliteRequestAllowed(false);
- if (error != SATELLITE_RESULT_SUCCESS) {
- result.accept(error);
- return null;
+ if (mFeatureFlags.carrierRoamingNbIotNtn()) {
+ List<SatelliteSubscriberInfo> subscriberInfoList =
+ getNtnOnlySatelliteSubscriberInfoList(result);
+ if (subscriberInfoList == null) {
+ return null;
+ }
+ ResultReceiver internalReceiver = new ResultReceiver(this) {
+ @Override
+ protected void onReceiveResult(int resultCode, Bundle resultData) {
+ plogd("provisionSatelliteService: resultCode=" + resultCode
+ + ", resultData=" + resultData);
+ result.accept(resultCode);
+ }
+ };
+ provisionSatellite(subscriberInfoList, internalReceiver);
+
+ ICancellationSignal cancelTransport = CancellationSignal.createTransport();
+ CancellationSignal.fromTransport(cancelTransport).setOnCancelListener(() -> {
+ deprovisionSatellite(subscriberInfoList, internalReceiver);
+ mProvisionMetricsStats.setIsCanceled(true);
+ });
+ return cancelTransport;
+ } else {
+ int error = evaluateOemSatelliteRequestAllowed(false);
+ if (error != SATELLITE_RESULT_SUCCESS) {
+ result.accept(error);
+ return null;
+ }
+
+ final int validSubId = getSelectedSatelliteSubId();
+ if (mSatelliteProvisionCallbacks.containsKey(validSubId)) {
+ result.accept(SatelliteManager.SATELLITE_RESULT_SERVICE_PROVISION_IN_PROGRESS);
+ return null;
+ }
+
+ Boolean satelliteProvisioned = isDeviceProvisioned();
+ if (satelliteProvisioned != null && satelliteProvisioned) {
+ result.accept(SATELLITE_RESULT_SUCCESS);
+ return null;
+ }
+
+ sendRequestAsync(CMD_PROVISION_SATELLITE_SERVICE,
+ new ProvisionSatelliteServiceArgument(token, provisionData, result, validSubId),
+ null);
+
+ ICancellationSignal cancelTransport = CancellationSignal.createTransport();
+ CancellationSignal.fromTransport(cancelTransport).setOnCancelListener(() -> {
+ sendRequestAsync(CMD_DEPROVISION_SATELLITE_SERVICE,
+ new ProvisionSatelliteServiceArgument(token, provisionData, null,
+ validSubId), null);
+ mProvisionMetricsStats.setIsCanceled(true);
+ });
+ return cancelTransport;
}
-
- final int validSubId = getSelectedSatelliteSubId();
- if (mSatelliteProvisionCallbacks.containsKey(validSubId)) {
- result.accept(SatelliteManager.SATELLITE_RESULT_SERVICE_PROVISION_IN_PROGRESS);
- return null;
- }
-
- Boolean satelliteProvisioned = isSatelliteViaOemProvisioned();
- if (satelliteProvisioned != null && satelliteProvisioned) {
- result.accept(SATELLITE_RESULT_SUCCESS);
- return null;
- }
-
- sendRequestAsync(CMD_PROVISION_SATELLITE_SERVICE,
- new ProvisionSatelliteServiceArgument(token, provisionData, result, validSubId),
- null);
-
- ICancellationSignal cancelTransport = CancellationSignal.createTransport();
- CancellationSignal.fromTransport(cancelTransport).setOnCancelListener(() -> {
- sendRequestAsync(CMD_DEPROVISION_SATELLITE_SERVICE,
- new ProvisionSatelliteServiceArgument(token, provisionData, null,
- validSubId), null);
- mProvisionMetricsStats.setIsCanceled(true);
- });
- return cancelTransport;
}
/**
@@ -2526,21 +2587,38 @@
public void deprovisionSatelliteService(
@NonNull String token, @NonNull IIntegerConsumer callback) {
Consumer<Integer> result = FunctionalUtils.ignoreRemoteException(callback::accept);
- int error = evaluateOemSatelliteRequestAllowed(false);
- if (error != SATELLITE_RESULT_SUCCESS) {
- result.accept(error);
- return;
- }
+ if (mFeatureFlags.carrierRoamingNbIotNtn()) {
+ List<SatelliteSubscriberInfo> subscriberInfoList =
+ getNtnOnlySatelliteSubscriberInfoList(result);
+ if (subscriberInfoList == null) {
+ return;
+ }
+ ResultReceiver internalReceiver = new ResultReceiver(this) {
+ @Override
+ protected void onReceiveResult(int resultCode, Bundle resultData) {
+ plogd("deprovisionSatelliteService: resultCode=" + resultCode
+ + ", resultData=" + resultData);
+ result.accept(resultCode);
+ }
+ };
+ deprovisionSatellite(subscriberInfoList, internalReceiver);
+ } else {
+ int error = evaluateOemSatelliteRequestAllowed(false);
+ if (error != SATELLITE_RESULT_SUCCESS) {
+ result.accept(error);
+ return;
+ }
- if (Boolean.FALSE.equals(isSatelliteViaOemProvisioned())) {
- result.accept(SATELLITE_RESULT_SUCCESS);
- return;
- }
+ if (Boolean.FALSE.equals(isDeviceProvisioned())) {
+ result.accept(SATELLITE_RESULT_SUCCESS);
+ return;
+ }
- sendRequestAsync(CMD_DEPROVISION_SATELLITE_SERVICE,
+ sendRequestAsync(CMD_DEPROVISION_SATELLITE_SERVICE,
new ProvisionSatelliteServiceArgument(token, null,
result, getSelectedSatelliteSubId()),
null);
+ }
}
/**
@@ -2559,13 +2637,13 @@
mSatelliteProvisionStateChangedListeners.put(callback.asBinder(), callback);
- boolean isProvisioned = Boolean.TRUE.equals(isSatelliteViaOemProvisioned());
+ boolean isProvisioned = Boolean.TRUE.equals(isDeviceProvisioned());
try {
callback.onSatelliteProvisionStateChanged(isProvisioned);
} catch (RemoteException ex) {
loge("registerForSatelliteProvisionStateChanged: " + ex);
}
- synchronized (mSatelliteViaOemProvisionLock) {
+ synchronized (mDeviceProvisionLock) {
plogd("registerForSatelliteProvisionStateChanged: report current provisioned "
+ "state, state=" + isProvisioned);
}
@@ -2604,11 +2682,11 @@
return;
}
- synchronized (mSatelliteViaOemProvisionLock) {
- if (mIsSatelliteViaOemProvisioned != null) {
+ synchronized (mDeviceProvisionLock) {
+ if (mIsDeviceProvisioned != null) {
Bundle bundle = new Bundle();
bundle.putBoolean(SatelliteManager.KEY_SATELLITE_PROVISIONED,
- mIsSatelliteViaOemProvisioned);
+ mIsDeviceProvisioned);
result.send(SATELLITE_RESULT_SUCCESS, bundle);
return;
}
@@ -3080,8 +3158,8 @@
synchronized (mIsSatelliteSupportedLock) {
mIsSatelliteSupported = null;
}
- synchronized (mSatelliteViaOemProvisionLock) {
- mIsSatelliteViaOemProvisioned = Optional.ofNullable(provisioned)
+ synchronized (mDeviceProvisionLock) {
+ mIsDeviceProvisioned = Optional.ofNullable(provisioned)
.filter(s -> s.equalsIgnoreCase("true") || s.equalsIgnoreCase("false"))
.map(s -> s.equalsIgnoreCase("true"))
.orElse(null);
@@ -3304,7 +3382,7 @@
ploge("setOemEnabledSatelliteProvisionStatus: mock modem not allowed");
return false;
}
- synchronized (mSatelliteViaOemProvisionLock) {
+ synchronized (mDeviceProvisionLock) {
if (reset) {
mOverriddenIsSatelliteViaOemProvisioned = null;
} else {
@@ -3656,6 +3734,11 @@
}
int subId = phone.getSubId();
+ int carrierRoamingNtnConnectType = getCarrierRoamingNtnConnectType(subId);
+ if (carrierRoamingNtnConnectType == CARRIER_ROAMING_NTN_CONNECT_MANUAL) {
+ return isInCarrierRoamingNbIotNtn(phone);
+ }
+
if (!isSatelliteSupportedViaCarrier(subId)) {
return false;
}
@@ -4007,8 +4090,8 @@
if (result == SATELLITE_RESULT_SUCCESS
|| result == SATELLITE_RESULT_REQUEST_NOT_SUPPORTED) {
persistOemEnabledSatelliteProvisionStatus(true);
- synchronized (mSatelliteViaOemProvisionLock) {
- mIsSatelliteViaOemProvisioned = true;
+ synchronized (mDeviceProvisionLock) {
+ mIsDeviceProvisioned = true;
}
callback.accept(SATELLITE_RESULT_SUCCESS);
handleEventSatelliteProvisionStateChanged(true);
@@ -4035,8 +4118,8 @@
if (result == SATELLITE_RESULT_SUCCESS
|| result == SATELLITE_RESULT_REQUEST_NOT_SUPPORTED) {
persistOemEnabledSatelliteProvisionStatus(false);
- synchronized (mSatelliteViaOemProvisionLock) {
- mIsSatelliteViaOemProvisioned = false;
+ synchronized (mDeviceProvisionLock) {
+ mIsDeviceProvisioned = false;
}
if (arg.callback != null) {
arg.callback.accept(SATELLITE_RESULT_SUCCESS);
@@ -4086,21 +4169,21 @@
}
/**
- * Check if satellite is provisioned for a subscription on the device.
- * @return true if satellite is provisioned on the given subscription else return false.
+ * Check if satellite is provisioned for the device.
+ * @return {@code true} if device is provisioned for satellite else return {@code false}.
*/
@VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
@Nullable
- protected Boolean isSatelliteViaOemProvisioned() {
- synchronized (mSatelliteViaOemProvisionLock) {
+ protected Boolean isDeviceProvisioned() {
+ synchronized (mDeviceProvisionLock) {
if (mOverriddenIsSatelliteViaOemProvisioned != null) {
return mOverriddenIsSatelliteViaOemProvisioned;
}
- if (mIsSatelliteViaOemProvisioned == null) {
- mIsSatelliteViaOemProvisioned = getPersistedOemEnabledSatelliteProvisionStatus();
+ if (mIsDeviceProvisioned == null) {
+ mIsDeviceProvisioned = getPersistedDeviceProvisionStatus();
}
- return mIsSatelliteViaOemProvisioned;
+ return mIsDeviceProvisioned;
}
}
@@ -4328,11 +4411,14 @@
private void handleEventSatelliteProvisionStateChanged(boolean provisioned) {
plogd("handleSatelliteProvisionStateChangedEvent: provisioned=" + provisioned);
- synchronized (mSatelliteViaOemProvisionLock) {
+ synchronized (mDeviceProvisionLock) {
persistOemEnabledSatelliteProvisionStatus(provisioned);
- mIsSatelliteViaOemProvisioned = provisioned;
+ mIsDeviceProvisioned = provisioned;
}
+ notifyDeviceProvisionStateChanged(provisioned);
+ }
+ private void notifyDeviceProvisionStateChanged(boolean provisioned) {
List<ISatelliteProvisionStateCallback> deadCallersList = new ArrayList<>();
mSatelliteProvisionStateChangedListeners.values().forEach(listener -> {
try {
@@ -4354,14 +4440,14 @@
boolean provisionChanged = false;
synchronized (mSatelliteTokenProvisionedLock) {
for (SatelliteSubscriberInfo subscriberInfo : newList) {
- if (mProvisionedSubscriberId.getOrDefault(subscriberInfo.getSubscriberId(), false)
- == provisioned) {
+ Boolean currentProvisioned =
+ mProvisionedSubscriberId.get(subscriberInfo.getSubscriberId());
+ if (currentProvisioned != null && currentProvisioned == provisioned) {
continue;
}
provisionChanged = true;
mProvisionedSubscriberId.put(subscriberInfo.getSubscriberId(), provisioned);
- int subId = mSubscriberIdPerSub.getOrDefault(subscriberInfo.getSubscriberId(),
- SubscriptionManager.INVALID_SUBSCRIPTION_ID);
+ int subId = subscriberInfo.getSubId();
try {
mSubscriptionManagerService.setIsSatelliteProvisionedForNonIpDatagram(subId,
provisioned);
@@ -4381,7 +4467,8 @@
getPrioritizedSatelliteSubscriberProvisionStatusList();
plogd("handleEventSatelliteSubscriptionProvisionStateChanged: " + informList);
notifySatelliteSubscriptionProvisionStateChanged(informList);
- // Report updated provisioned status
+ updateDeviceProvisionStatus();
+ // Report updated provisioned status to metrics.
synchronized (mSatelliteTokenProvisionedLock) {
boolean isProvisioned = !mProvisionedSubscriberId.isEmpty()
&& mProvisionedSubscriberId.containsValue(Boolean.TRUE);
@@ -4391,6 +4478,17 @@
handleStateChangedForCarrierRoamingNtnEligibility();
}
+ private void updateDeviceProvisionStatus() {
+ boolean isProvisioned = getPersistedDeviceProvisionStatus();
+ plogd("updateDeviceProvisionStatus: isProvisioned=" + isProvisioned);
+ synchronized (mDeviceProvisionLock) {
+ if (mIsDeviceProvisioned == null || mIsDeviceProvisioned != isProvisioned) {
+ mIsDeviceProvisioned = isProvisioned;
+ notifyDeviceProvisionStateChanged(isProvisioned);
+ }
+ }
+ }
+
private void notifySatelliteSubscriptionProvisionStateChanged(
@NonNull List<SatelliteSubscriberProvisionStatus> list) {
List<ISatelliteProvisionStateCallback> deadCallersList = new ArrayList<>();
@@ -4717,6 +4815,9 @@
sendRequestAsync(CMD_UPDATE_SATELLITE_ENABLE_ATTRIBUTES,
mSatelliteEnableAttributesUpdateRequest, null);
}
+ synchronized (mSatellitePhoneLock) {
+ updateLastNotifiedNtnModeAndNotify(mSatellitePhone);
+ }
}
}
}
@@ -4764,6 +4865,9 @@
false, "moveSatelliteToOffStateAndCleanUpResources");
}
selectBindingSatelliteSubscription();
+ synchronized (mSatellitePhoneLock) {
+ updateLastNotifiedNtnModeAndNotify(mSatellitePhone);
+ }
}
private void setDemoModeEnabled(boolean enabled) {
@@ -5102,6 +5206,8 @@
}
}
}
+ // Need to update the provision status of the device
+ updateDeviceProvisionStatus();
}
@NonNull
@@ -5415,7 +5521,7 @@
}
if (isProvisionRequired) {
- Boolean satelliteProvisioned = isSatelliteViaOemProvisioned();
+ Boolean satelliteProvisioned = isDeviceProvisioned();
if (satelliteProvisioned == null) {
plogd("evaluateOemSatelliteRequestAllowed: satelliteProvisioned is null");
return SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE;
@@ -5687,10 +5793,10 @@
}
private void persistOemEnabledSatelliteProvisionStatus(boolean isProvisioned) {
- synchronized (mSatelliteViaOemProvisionLock) {
+ synchronized (mDeviceProvisionLock) {
plogd("persistOemEnabledSatelliteProvisionStatus: isProvisioned=" + isProvisioned);
if (mFeatureFlags.carrierRoamingNbIotNtn()) {
- int subId = SatelliteServiceUtils.getNtnOnlySubscriptionId(mContext);
+ int subId = getNtnOnlySubscriptionId();
if (subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
try {
mSubscriptionManagerService.setIsSatelliteProvisionedForNonIpDatagram(subId,
@@ -5717,24 +5823,34 @@
}
@Nullable
- private Boolean getPersistedOemEnabledSatelliteProvisionStatus() {
- plogd("getPersistedOemEnabledSatelliteProvisionStatus:");
- synchronized (mSatelliteViaOemProvisionLock) {
+ private boolean getPersistedDeviceProvisionStatus() {
+ plogd("getPersistedDeviceProvisionStatus");
+ synchronized (mDeviceProvisionLock) {
if (mFeatureFlags.carrierRoamingNbIotNtn()) {
- int subId = SatelliteServiceUtils.getNtnOnlySubscriptionId(mContext);
+ int subId = getNtnOnlySubscriptionId();
if (subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
- return mSubscriptionManagerService.isSatelliteProvisionedForNonIpDatagram(
- subId);
- } else {
- plogd("getPersistedOemEnabledSatelliteProvisionStatus: "
- + "subId=INVALID_SUBSCRIPTION_ID, return null");
- return null;
+ if (mSubscriptionManagerService.isSatelliteProvisionedForNonIpDatagram(subId)) {
+ return true;
+ }
}
+
+ List<SubscriptionInfo> activeSubscriptionInfoList =
+ mSubscriptionManagerService.getActiveSubscriptionInfoList(
+ mContext.getOpPackageName(), mContext.getAttributionTag(), true);
+ for (SubscriptionInfo info : activeSubscriptionInfoList) {
+ if (info.isSatelliteESOSSupported()) {
+ if (mSubscriptionManagerService.isSatelliteProvisionedForNonIpDatagram(
+ info.getSubscriptionId())) {
+ return true;
+ }
+ }
+ }
+ return false;
} else {
if (!loadSatelliteSharedPreferences()) return false;
if (mSharedPreferences == null) {
- ploge("getPersistedOemEnabledSatelliteProvisionStatus: mSharedPreferences is "
+ ploge("getPersistedDeviceProvisionStatus: mSharedPreferences is "
+ "null");
return false;
} else {
@@ -5766,7 +5882,7 @@
Bundle bundle = new Bundle();
bundle.putBoolean(SatelliteManager.KEY_SATELLITE_PROVISIONED,
- Boolean.TRUE.equals(isSatelliteViaOemProvisioned()));
+ Boolean.TRUE.equals(isDeviceProvisioned()));
((ResultReceiver) request.argument).send(SATELLITE_RESULT_SUCCESS, bundle);
}
@@ -6410,6 +6526,13 @@
}
}
+ private void plogv(@NonNull String log) {
+ Rlog.v(TAG, log);
+ if (mPersistentLogger != null) {
+ mPersistentLogger.debug(TAG, log);
+ }
+ }
+
private void handlePersistentLoggingOnSessionStart(RequestSatelliteEnabledArgument argument) {
if (mPersistentLogger == null) {
return;
@@ -6504,6 +6627,9 @@
if (!isNtnOnly && !isESOSSupported) {
continue;
}
+ if (!isActive && !isNtnOnly) {
+ continue;
+ }
int keyPriority = (isESOSSupported && isActive && isDefaultSmsSubId) ? 0
: (isESOSSupported && isActive) ? 1
@@ -6529,6 +6655,9 @@
logd("Old phone number is removed: id = " + subId);
isChanged = true;
}
+ if (!newSubscriberId.isEmpty()) {
+ mSubscriberIdPerSub.put(newSubscriberId, subId);
+ }
}
}
plogd("evaluateESOSProfilesPrioritization: newSubsInfoListPerPriority.size()="
@@ -6553,16 +6682,19 @@
// The subscriberId for ntnOnly SIMs is the Iccid, whereas for ESOS supported SIMs, the
// subscriberId is the Imsi prefix 6 digit + phone number.
- private Pair<String, Integer> getSubscriberIdAndType(SubscriptionInfo info) {
+ private Pair<String, Integer> getSubscriberIdAndType(@Nullable SubscriptionInfo info) {
String subscriberId = "";
@SatelliteSubscriberInfo.SubscriberIdType int subscriberIdType =
SatelliteSubscriberInfo.ICCID;
- if (info.isSatelliteESOSSupported()) {
- subscriberId = getPhoneNumberBasedCarrier(info.getSubscriptionId());
- subscriberIdType = SatelliteSubscriberInfo.IMSI_MSISDN;
+ if (info == null) {
+ logd("getSubscriberIdAndType: subscription info is null");
+ return new Pair<>(subscriberId, subscriberIdType);
}
if (info.isOnlyNonTerrestrialNetwork()) {
subscriberId = info.getIccId();
+ } else if (info.isSatelliteESOSSupported()) {
+ subscriberId = getPhoneNumberBasedCarrier(info.getSubscriptionId());
+ subscriberIdType = SatelliteSubscriberInfo.IMSI_MSISDN;
}
logd("getSubscriberIdAndType: subscriberId=" + subscriberId + ", subscriberIdType="
+ subscriberIdType);
@@ -6735,7 +6867,7 @@
synchronized (mSatelliteTokenProvisionedLock) {
if (selectedSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID
&& isSatelliteSupportedViaOem()) {
- selectedSubId = SatelliteServiceUtils.getNtnOnlySubscriptionId(mContext);
+ selectedSubId = getNtnOnlySubscriptionId();
}
mSelectedSatelliteSubId = selectedSubId;
setSatellitePhone(selectedSubId);
@@ -6752,7 +6884,12 @@
}
private boolean isActiveSubId(int subId) {
- return mSubscriptionManagerService.getSubscriptionInfo(subId).isActive();
+ SubscriptionInfo subInfo = mSubscriptionManagerService.getSubscriptionInfo(subId);
+ if (subInfo == null) {
+ logd("isActiveSubId: subscription associated with subId=" + subId + " not found");
+ return false;
+ }
+ return subInfo.isActive();
}
@VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
@@ -6832,7 +6969,8 @@
if (mSatellitePhone == null) {
mSatellitePhone = SatelliteServiceUtils.getPhone();
}
- plogd("mSatellitePhone:" + (mSatellitePhone != null) + ", subId=" + subId);
+ plogd("mSatellitePhone: phoneId=" + (mSatellitePhone != null
+ ? mSatellitePhone.getPhoneId() : "null") + ", subId=" + subId);
int carrierId = mSatellitePhone.getCarrierId();
if (carrierId != UNKNOWN_CARRIER_ID) {
mControllerMetricsStats.setCarrierId(carrierId);
@@ -7231,7 +7369,69 @@
}
}
- private void handleCarrierRoamingNtnAvailableServicesChanged(int subId) {
+ private int getNtnOnlySubscriptionId() {
+ List<SubscriptionInfo> infoList = mSubscriptionManagerService.getAllSubInfoList(
+ mContext.getOpPackageName(), mContext.getAttributionTag());
+ int subId = infoList.stream()
+ .filter(info -> info.isOnlyNonTerrestrialNetwork())
+ .mapToInt(SubscriptionInfo::getSubscriptionId)
+ .findFirst()
+ .orElse(SubscriptionManager.INVALID_SUBSCRIPTION_ID);
+ logd("getNtnOnlySubscriptionId: subId=" + subId);
+ return subId;
+ }
+
+ @Nullable
+ private List<SatelliteSubscriberInfo> getNtnOnlySatelliteSubscriberInfoList(
+ Consumer<Integer> result) {
+ SatelliteSubscriberInfo satelliteSubscriberInfo = getNtnOnlySatelliteSubscriberInfo();
+ if (satelliteSubscriberInfo == null) {
+ result.accept(SatelliteManager.SATELLITE_RESULT_REQUEST_NOT_SUPPORTED);
+ return null;
+ }
+ List<SatelliteSubscriberInfo> satelliteSubscriberInfoList = new ArrayList<>();
+ satelliteSubscriberInfoList.add(satelliteSubscriberInfo);
+
+ return satelliteSubscriberInfoList;
+ }
+
+ @Nullable private SatelliteSubscriberInfo getNtnOnlySatelliteSubscriberInfo() {
+ int ntnOnlySubId = getNtnOnlySubscriptionId();
+ if (ntnOnlySubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+ logw("getNtnOnlySatelliteSubscriberInfo: no ntn only subscription found");
+ return null;
+ }
+ SubscriptionInfo subInfo = mSubscriptionManagerService.getSubscriptionInfo(ntnOnlySubId);
+ if (subInfo == null) {
+ logw("getNtnOnlySatelliteSubscriberInfo: no subscription info found for subId="
+ + ntnOnlySubId);
+ return null;
+ }
+ return getSatelliteSubscriberInfo(subInfo);
+ }
+
+ @Nullable private SatelliteSubscriberInfo getSatelliteSubscriberInfo(
+ @NonNull SubscriptionInfo subInfo) {
+ Pair<String, Integer> subscriberIdPair = getSubscriberIdAndType(subInfo);
+ String subscriberId = subscriberIdPair.first;
+ int carrierId = subInfo.getCarrierId();
+ String apn = getConfigForSubId(subInfo.getSubscriptionId())
+ .getString(KEY_SATELLITE_NIDD_APN_NAME_STRING, "");
+ logd("getSatelliteSubscriberInfo: subInfo: " + subInfo + ", subscriberId:"
+ + subscriberId + " , carrierId=" + carrierId + " , apn=" + apn);
+ if (subscriberId.isEmpty()) {
+ logw("getSatelliteSubscriberInfo: not a satellite subscription.");
+ return null;
+ }
+ return new SatelliteSubscriberInfo.Builder().setSubscriberId(subscriberId)
+ .setCarrierId(carrierId).setNiddApn(apn)
+ .setSubId(subInfo.getSubscriptionId())
+ .setSubscriberIdType(subscriberIdPair.second)
+ .build();
+ }
+
+ @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
+ protected void handleCarrierRoamingNtnAvailableServicesChanged(int subId) {
if (!mFeatureFlags.carrierRoamingNbIotNtn()) {
plogd("handleCarrierRoamingNtnAvailableServicesChanged: "
+ "carrierRoamingNbIotNtn flag is disabled");
@@ -7245,48 +7445,46 @@
plogd("notifyNtnAvailableServices: carrierRoamingNbIotNtn flag is disabled");
return;
}
- synchronized (mSatellitePhoneLock) {
- if (mSatellitePhone == null) {
- plogd("updateLastNotifiedNtnAvailableServicesAndNotify: phone is null");
- return;
+ Phone phone = SatelliteServiceUtils.getPhone(subId);
+ if (phone == null) {
+ plogd("notifyNtnAvailableServices: phone is null.");
+ return;
+ }
+ plogd("updateLastNotifiedNtnAvailableServicesAndNotify: phoneId= " + phone.getPhoneId());
+
+ if (isSatelliteSupportedViaCarrier(subId)) {
+ // TODO: Invoke SatelliteManager#getSatelliteDisallowedReasons() NOT EMPTY.
+ int[] services = getSupportedSatelliteServicesForCarrier(subId);
+ if (isP2PSmsDisallowedOnCarrierRoamingNtn(subId)) {
+ services = Arrays.stream(services).filter(
+ value -> value != NetworkRegistrationInfo.SERVICE_TYPE_SMS).toArray();
}
- if (isSatelliteSupportedViaCarrier(subId)) {
- int[] services = getSupportedSatelliteServicesForCarrier(subId);
- if (isP2PSmsDisallowedOnCarrierRoamingNtn(mSatellitePhone)) {
- services = Arrays.stream(services).filter(
- value -> value != NetworkRegistrationInfo.SERVICE_TYPE_SMS).toArray();
- }
- mSatellitePhone.notifyCarrierRoamingNtnAvailableServicesChanged(services);
- } else {
- mSatellitePhone.notifyCarrierRoamingNtnAvailableServicesChanged(new int[0]);
- }
+ phone.notifyCarrierRoamingNtnAvailableServicesChanged(services);
+ } else {
+ phone.notifyCarrierRoamingNtnAvailableServicesChanged(new int[0]);
}
}
/**
* Whether the P2P SMS over carrier roaming satellite is disallowed or not.
*
- * @param phone phone object
+ * @param subId Associated subscription ID
* return {@code true} when the phone does not support P2P SMS over carrier roaming satellite
* {@code false} otherwise
*/
@VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
- public boolean isP2PSmsDisallowedOnCarrierRoamingNtn(@NonNull Phone phone) {
- int subId = phone.getSubId();
+ public boolean isP2PSmsDisallowedOnCarrierRoamingNtn(int subId) {
int carrierRoamingNtnConnectType = getCarrierRoamingNtnConnectType(subId);
if (carrierRoamingNtnConnectType == CARRIER_ROAMING_NTN_CONNECT_MANUAL) {
// Manual Connected
plogd("isP2PSmsDisallowedOnCarrierRoamingNtn: manual connect");
- String msgPackageName = Telephony.Sms.getDefaultSmsPackage(mContext);
- String sgPackageName = getConfigSatelliteGatewayServicePackage();
- if (!isApplicationSupportsP2P(msgPackageName)
- || !isApplicationSupportsP2P(sgPackageName)) {
- plogd("isP2PSmsSupportedOnCarrierRoamingNtn APKs do not supports P2P");
+ if (!isApplicationSupportsP2P(mDefaultSmsPackageName)
+ || !isApplicationSupportsP2P(mSatelliteGatewayServicePackageName)) {
+ plogd("isP2PSmsDisallowedOnCarrierRoamingNtn: APKs do not supports P2P");
return true;
}
}
- plogd("isP2PSmsDisallowedOnCarrierRoamingNtn [phoneId="
- + phone.getPhoneId() + "]: P2P is supported");
+ plogd("isP2PSmsDisallowedOnCarrierRoamingNtn: P2P is supported");
return false;
}
@@ -7304,12 +7502,13 @@
return availableServices;
}
-/**
- * Whether application supports the P2P SMS to connect to carrier roaming non-terrestrial network.
- *
- * @param packageName application's default package name
- * return {@code true} when the application supports P2P SMS over the roaming satellite
- */
+ /**
+ * Whether application supports the P2P SMS to connect to carrier roaming non-terrestrial
+ * network.
+ *
+ * @param packageName application's default package name
+ * return {@code true} when the application supports P2P SMS over the roaming satellite
+ */
@VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
public boolean isApplicationSupportsP2P(String packageName) {
PackageManager pm = mContext.getPackageManager();
@@ -7318,6 +7517,7 @@
applicationInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA);
} catch (PackageManager.NameNotFoundException e) {
logd("isApplicationSupportsP2P pkgName: " + packageName + " is not installed.");
+ return false;
}
if (applicationInfo == null || applicationInfo.metaData == null) {
logd("isApplicationSupportsP2P pkgName: " + packageName + " meta-data info is empty.");
@@ -7326,4 +7526,21 @@
return applicationInfo.metaData.getBoolean(
SatelliteManager.METADATA_SATELLITE_MANUAL_CONNECT_P2P_SUPPORT);
}
+
+ /**
+ * Registers for the applications state changed.
+ */
+ @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
+ public void registerApplicationStateChanged() {
+ mDefaultSmsPackageName = Telephony.Sms.getDefaultSmsPackage(mContext);
+ mSatelliteGatewayServicePackageName = getConfigSatelliteGatewayServicePackage();
+
+ IntentFilter packageFilter = new IntentFilter();
+ packageFilter.addAction(Telephony.Sms.Intents.ACTION_DEFAULT_SMS_PACKAGE_CHANGED);
+ packageFilter.addAction(Intent.ACTION_PACKAGE_REPLACED);
+ packageFilter.addAction(Intent.ACTION_PACKAGE_CHANGED);
+ packageFilter.addDataScheme("package");
+ mContext.registerReceiver(mPackageStateChangedReceiver, packageFilter,
+ mContext.RECEIVER_EXPORTED);
+ }
}
diff --git a/src/java/com/android/internal/telephony/satellite/SatelliteSOSMessageRecommender.java b/src/java/com/android/internal/telephony/satellite/SatelliteSOSMessageRecommender.java
index 50732fa..182f667 100644
--- a/src/java/com/android/internal/telephony/satellite/SatelliteSOSMessageRecommender.java
+++ b/src/java/com/android/internal/telephony/satellite/SatelliteSOSMessageRecommender.java
@@ -321,7 +321,7 @@
boolean isCellularAvailable = SatelliteServiceUtils.isCellularAvailable();
if (!isCellularAvailable
&& isSatelliteAllowed()
- && (isSatelliteViaOemAvailable()
+ && (isDeviceProvisioned()
|| isSatelliteConnectedViaCarrierWithinHysteresisTime())
&& shouldTrackCall(mEmergencyConnection.getState())) {
plogd("handleTimeoutEvent: Sent EVENT_DISPLAY_EMERGENCY_MESSAGE to Dialer");
@@ -359,8 +359,8 @@
* @return {@code true} if satellite is provisioned via OEM else return {@code false}
*/
@VisibleForTesting
- public boolean isSatelliteViaOemAvailable() {
- Boolean satelliteProvisioned = mSatelliteController.isSatelliteViaOemProvisioned();
+ public boolean isDeviceProvisioned() {
+ Boolean satelliteProvisioned = mSatelliteController.isDeviceProvisioned();
return satelliteProvisioned != null ? satelliteProvisioned : false;
}
@@ -737,7 +737,7 @@
@VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
public int getEmergencyCallToSatelliteHandoverType() {
- if (Flags.carrierRoamingNbIotNtn() && isSatelliteViaOemAvailable()
+ if (Flags.carrierRoamingNbIotNtn() && isDeviceProvisioned()
&& isSatelliteConnectedViaCarrierWithinHysteresisTime()) {
int satelliteSubId = mSatelliteController.getSelectedSatelliteSubId();
return mSatelliteController.getCarrierRoamingNtnEmergencyCallToSatelliteHandoverType(
@@ -799,7 +799,7 @@
}
private boolean isSatelliteViaOemProvisioned() {
- Boolean provisioned = mSatelliteController.isSatelliteViaOemProvisioned();
+ Boolean provisioned = mSatelliteController.isDeviceProvisioned();
return (provisioned != null) && provisioned;
}
diff --git a/src/java/com/android/internal/telephony/satellite/SatelliteSessionController.java b/src/java/com/android/internal/telephony/satellite/SatelliteSessionController.java
index 3d92e2a..1b6f9f1 100644
--- a/src/java/com/android/internal/telephony/satellite/SatelliteSessionController.java
+++ b/src/java/com/android/internal/telephony/satellite/SatelliteSessionController.java
@@ -309,20 +309,6 @@
mSessionMetricsStats = SessionMetricsStats.getInstance();
mAlarmManager = mContext.getSystemService(AlarmManager.class);
- if (mFeatureFlags.carrierRoamingNbIotNtn()) {
- // Register to received Cellular service state
- for (Phone phone : PhoneFactory.getPhones()) {
- if (phone == null) continue;
-
- phone.registerForServiceStateChanged(
- getHandler(), EVENT_SERVICE_STATE_CHANGED, null);
- if (DBG) {
- plogd("SatelliteSessionController: registerForServiceStateChanged phoneId "
- + phone.getPhoneId());
- }
- }
- }
-
addState(mUnavailableState);
addState(mPowerOffState);
addState(mEnablingState);
@@ -924,12 +910,7 @@
handleSatelliteModemStateChanged(msg);
break;
case EVENT_ENABLE_CELLULAR_MODEM_WHILE_SATELLITE_MODE_IS_ON_DONE:
- if (!mIgnoreCellularServiceState) {
- handleEventEnableCellularModemWhileSatelliteModeIsOnDone();
- } else {
- plogd("IdleState: processing: ignore "
- + "EVENT_ENABLE_CELLULAR_MODEM_WHILE_SATELLITE_MODE_IS_ON_DONE");
- }
+ plogd("EVENT_ENABLE_CELLULAR_MODEM_WHILE_SATELLITE_MODE_IS_ON_DONE");
break;
case EVENT_SERVICE_STATE_CHANGED:
if (!mIgnoreCellularServiceState) {
@@ -971,22 +952,6 @@
}
}
- private void handleEventEnableCellularModemWhileSatelliteModeIsOnDone() {
- if (!mFeatureFlags.carrierRoamingNbIotNtn()) {
- Rlog.d(TAG, "handleEventEnableCellularModemWhileSatelliteModeIsOnDone: "
- + "carrierRoamingNbIotNtn is disabled");
- return;
- }
-
- ServiceState serviceState = mSatelliteController.getSatellitePhone().getServiceState();
- if (serviceState == null) {
- plogd("handleEventEnableCellularModemWhileSatelliteModeIsOnDone: "
- + "can't access ServiceState");
- return;
- }
- handleEventServiceStateChanged(serviceState);
- }
-
private void handleEventServiceStateChanged(ServiceState serviceState) {
boolean isInServiceOrEmergency =
serviceState.getVoiceRegState() == ServiceState.STATE_IN_SERVICE
diff --git a/tests/telephonytests/src/com/android/internal/telephony/SmsMessageBodyTest.java b/tests/telephonytests/src/com/android/internal/telephony/SmsMessageBodyTest.java
index dc1ee63..1846bae 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/SmsMessageBodyTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/SmsMessageBodyTest.java
@@ -16,13 +16,17 @@
package com.android.internal.telephony;
-import android.telephony.TelephonyManager;
-import android.test.AndroidTestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
-import androidx.test.filters.SmallTest;
+import android.telephony.TelephonyManager;
import com.android.telephony.Rlog;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+
/**
* Test cases to verify selection of the optimal 7 bit encoding tables
* (for all combinations of enabled national language tables) for messages
@@ -33,7 +37,7 @@
* Tests both encoding variations: unsupported characters mapped to space,
* and unsupported characters force entire message to UCS-2.
*/
-public class SmsMessageBodyTest extends AndroidTestCase {
+public class SmsMessageBodyTest extends TelephonyTest {
private static final String TAG = "SmsMessageBodyTest";
// ASCII chars in the GSM 7 bit default alphabet
@@ -250,7 +254,12 @@
*/
private static final int UDH_SEPTET_COST_CONCATENATED_MESSAGE = 6;
- @SmallTest
+ @Before
+ public void setUp() {
+ TelephonyManager.setupISmsForTest(Mockito.mock(ISms.class));
+ }
+
+ @Test
public void testCalcLengthAscii() throws Exception {
StringBuilder sb = new StringBuilder(320);
int[] values = {0, 0, 0, SmsConstants.ENCODING_7BIT, 0, 0};
@@ -282,7 +291,7 @@
}
}
- @SmallTest
+ @Test
public void testCalcLengthUnicode() throws Exception {
StringBuilder sb = new StringBuilder(160);
int[] values = {0, 0, 0, SmsConstants.ENCODING_16BIT, 0, 0};
@@ -482,7 +491,7 @@
}
}
- //@LargeTest
+ //@Test
/*public void testCalcLengthMixed7bit() throws Exception {
StringBuilder sb = new StringBuilder(320);
CounterHelper ch = new CounterHelper();
diff --git a/tests/telephonytests/src/com/android/internal/telephony/emergency/EmergencyStateTrackerTest.java b/tests/telephonytests/src/com/android/internal/telephony/emergency/EmergencyStateTrackerTest.java
index 6694e98..62c2010 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/emergency/EmergencyStateTrackerTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/emergency/EmergencyStateTrackerTest.java
@@ -184,7 +184,7 @@
ArgumentCaptor<RadioOnStateListener.Callback> callback = ArgumentCaptor
.forClass(RadioOnStateListener.Callback.class);
verify(mRadioOnHelper).triggerRadioOnAndListen(callback.capture(), eq(true), eq(testPhone),
- eq(false), eq(DEFAULT_WAIT_FOR_IN_SERVICE_TIMEOUT_MS), eq(false));
+ eq(false), eq(DEFAULT_WAIT_FOR_IN_SERVICE_TIMEOUT_MS));
// isOkToCall() should return true when IN_SERVICE state
assertFalse(callback.getValue()
.isOkToCall(testPhone, ServiceState.STATE_OUT_OF_SERVICE, false));
@@ -243,7 +243,7 @@
ArgumentCaptor<RadioOnStateListener.Callback> callback = ArgumentCaptor
.forClass(RadioOnStateListener.Callback.class);
verify(mRadioOnHelper).triggerRadioOnAndListen(callback.capture(), eq(true), eq(testPhone),
- eq(false), eq(DEFAULT_WAIT_FOR_IN_SERVICE_TIMEOUT_MS), eq(false));
+ eq(false), eq(DEFAULT_WAIT_FOR_IN_SERVICE_TIMEOUT_MS));
// onTimeout should return true when radion on
assertFalse(callback.getValue()
.isOkToCall(testPhone, ServiceState.STATE_OUT_OF_SERVICE, false));
@@ -291,7 +291,7 @@
ArgumentCaptor<RadioOnStateListener.Callback> callback = ArgumentCaptor
.forClass(RadioOnStateListener.Callback.class);
verify(mRadioOnHelper).triggerRadioOnAndListen(callback.capture(), eq(true), eq(testPhone),
- eq(false), eq(DEFAULT_WAIT_FOR_IN_SERVICE_TIMEOUT_MS), eq(false));
+ eq(false), eq(DEFAULT_WAIT_FOR_IN_SERVICE_TIMEOUT_MS));
// Hangup the call
emergencyStateTracker.endCall(mTestConnection1);
@@ -327,7 +327,7 @@
ArgumentCaptor<RadioOnStateListener.Callback> callback = ArgumentCaptor
.forClass(RadioOnStateListener.Callback.class);
verify(mRadioOnHelper).triggerRadioOnAndListen(callback.capture(), eq(true), eq(testPhone),
- eq(false), eq(DEFAULT_WAIT_FOR_IN_SERVICE_TIMEOUT_MS), eq(false));
+ eq(false), eq(DEFAULT_WAIT_FOR_IN_SERVICE_TIMEOUT_MS));
// Verify future completes with DisconnectCause.POWER_OFF if radio not ready
CompletableFuture<Void> unused = future.thenAccept((result) -> {
assertEquals((Integer) result, (Integer) DisconnectCause.POWER_OFF);
@@ -363,7 +363,7 @@
ArgumentCaptor<RadioOnStateListener.Callback> callback = ArgumentCaptor
.forClass(RadioOnStateListener.Callback.class);
verify(mRadioOnHelper).triggerRadioOnAndListen(callback.capture(), eq(true), eq(testPhone),
- eq(false), eq(0), eq(false));
+ eq(false), eq(0));
// isOkToCall() should return true once satellite modem is off
assertFalse(callback.getValue()
.isOkToCall(testPhone, ServiceState.STATE_IN_SERVICE, false));
@@ -404,7 +404,7 @@
ArgumentCaptor<RadioOnStateListener.Callback> callback = ArgumentCaptor
.forClass(RadioOnStateListener.Callback.class);
verify(mRadioOnHelper).triggerRadioOnAndListen(callback.capture(), eq(true), eq(testPhone),
- eq(false), eq(0), eq(false));
+ eq(false), eq(0));
// Verify future completes with DisconnectCause.POWER_OFF if radio not ready
CompletableFuture<Void> unused = future.thenAccept((result) -> {
assertEquals((Integer) result, (Integer) DisconnectCause.SATELLITE_ENABLED);
@@ -432,7 +432,7 @@
// Radio already on so shouldn't trigger this
verify(mRadioOnHelper, never()).triggerRadioOnAndListen(any(), anyBoolean(), any(),
- anyBoolean(), eq(0), eq(false));
+ anyBoolean(), eq(0));
// Carrier supports control-plane fallback, so no DDS switch
verify(mPhoneSwitcher, never()).overrideDefaultDataForEmergency(anyInt(), anyInt(), any());
}
@@ -3198,7 +3198,7 @@
// Wait for the radio off for all phones
verify(mSST, times(2)).registerForVoiceRegStateOrRatChanged(any(), anyInt(), any());
verify(mRadioOnHelper, never()).triggerRadioOnAndListen(any(), anyBoolean(), any(),
- anyBoolean(), eq(0), eq(false));
+ anyBoolean(), eq(0));
}
/**
diff --git a/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java b/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java
index c043074..46252a2 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java
@@ -16,12 +16,12 @@
package com.android.internal.telephony.satellite;
-import static android.telephony.CarrierConfigManager.CARRIER_ROAMING_NTN_CONNECT_AUTOMATIC;
import static android.hardware.devicestate.DeviceState.PROPERTY_FOLDABLE_DISPLAY_CONFIGURATION_INNER_PRIMARY;
import static android.hardware.devicestate.DeviceState.PROPERTY_FOLDABLE_DISPLAY_CONFIGURATION_OUTER_PRIMARY;
import static android.hardware.devicestate.DeviceState.PROPERTY_FOLDABLE_HARDWARE_CONFIGURATION_FOLD_IN_CLOSED;
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.KEY_CARRIER_ROAMING_NTN_CONNECT_TYPE_INT;
import static android.telephony.CarrierConfigManager.KEY_CARRIER_SUPPORTED_SATELLITE_NOTIFICATION_HYSTERESIS_SEC_INT;
import static android.telephony.CarrierConfigManager.KEY_EMERGENCY_CALL_TO_SATELLITE_T911_HANDOVER_TIMEOUT_MILLIS_INT;
@@ -84,12 +84,13 @@
import static com.android.internal.telephony.satellite.SatelliteController.SATELLITE_MODE_ENABLED_TRUE;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
@@ -113,13 +114,16 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.NotificationManager;
+import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
+import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.hardware.devicestate.DeviceState;
+import android.net.Uri;
import android.os.AsyncResult;
import android.os.Bundle;
import android.os.CancellationSignal;
@@ -198,6 +202,7 @@
import java.util.Map;
import java.util.Optional;
import java.util.Set;
+import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
@@ -644,7 +649,7 @@
doNothing().when(mMockProvisionMetricsStats).reportProvisionMetrics();
doNothing().when(mMockControllerMetricsStats).reportDeprovisionCount(anyInt());
when(mFeatureFlags.oemEnabledSatelliteFlag()).thenReturn(true);
- when(mFeatureFlags.carrierRoamingNbIotNtn()).thenReturn(false);
+ when(mFeatureFlags.carrierRoamingNbIotNtn()).thenReturn(true);
doReturn(mSST).when(mPhone).getServiceStateTracker();
doReturn(mSST).when(mPhone2).getServiceStateTracker();
doReturn(mServiceState).when(mSST).getServiceState();
@@ -1029,7 +1034,7 @@
clearInvocations(mMockSatelliteSessionController);
clearInvocations(mMockDatagramController);
mSatelliteControllerUT.setSatelliteSessionController(mMockSatelliteSessionController);
- when(mMockSatelliteSessionController.isInDisablingState()).thenReturn(true);
+ mSatelliteControllerUT.isSatelliteBeingDisabled = true;
mSatelliteControllerUT.setSettingsKeyForSatelliteModeCalled = false;
mSatelliteControllerUT.setSettingsKeyToAllowDeviceRotationCalled = false;
setUpResponseForRequestSatelliteEnabled(false, false, false, SATELLITE_RESULT_SUCCESS);
@@ -1048,7 +1053,7 @@
verify(mMockSatelliteSessionController, times(2)).setDemoMode(eq(false));
verify(mMockDatagramController, times(2)).setDemoMode(eq(false));
verify(mMockControllerMetricsStats, times(1)).onSatelliteDisabled();
- when(mMockSatelliteSessionController.isInDisablingState()).thenReturn(false);
+ mSatelliteControllerUT.isSatelliteBeingDisabled = false;
// Fail to enable satellite when radio is off.
mIIntegerConsumerResults.clear();
@@ -1196,7 +1201,7 @@
mIIntegerConsumerResults.clear();
mIIntegerConsumerSemaphore.drainPermits();
mSatelliteControllerUT.setSatelliteSessionController(mMockSatelliteSessionController);
- when(mMockSatelliteSessionController.isInDisablingState()).thenReturn(true);
+ mSatelliteControllerUT.isSatelliteBeingDisabled = true;
mSatelliteControllerUT.requestSatelliteEnabled(true, false, false, mIIntegerConsumer);
processAllMessages();
assertTrue(waitForIIntegerConsumerResult(1));
@@ -1205,7 +1210,7 @@
mIIntegerConsumerResults.clear();
mIIntegerConsumerSemaphore.drainPermits();
resetSatelliteControllerUTToOffAndProvisionedState();
- when(mMockSatelliteSessionController.isInDisablingState()).thenReturn(false);
+ mSatelliteControllerUT.isSatelliteBeingDisabled = false;
/**
* Make areAllRadiosDisabled return false and move mWaitingForRadioDisabled to true, which
@@ -1719,6 +1724,14 @@
semaphore, 1, "testRegisterForSatelliteProvisionStateChanged"));
assertEquals(SATELLITE_RESULT_SUCCESS, errorCode);
+ try {
+ setSatelliteSubscriberTesting();
+ } catch (Exception ex) {
+ fail("provisionSatelliteService.setSatelliteSubscriberTesting: ex=" + ex);
+ }
+ doReturn(true).when(mMockSubscriptionManagerService).isSatelliteProvisionedForNonIpDatagram(
+ anyInt());
+
String mText = "This is test provision data.";
byte[] testProvisionData = mText.getBytes();
CancellationSignal cancellationSignal = new CancellationSignal();
@@ -1865,6 +1878,8 @@
@Test
public void testProvisionSatelliteService() {
+ when(mFeatureFlags.carrierRoamingNbIotNtn()).thenReturn(false);
+
String mText = "This is test provision data.";
byte[] testProvisionData = mText.getBytes();
CancellationSignal cancellationSignal = new CancellationSignal();
@@ -1949,6 +1964,7 @@
@Test
public void testDeprovisionSatelliteService() {
+ when(mFeatureFlags.carrierRoamingNbIotNtn()).thenReturn(false);
mIIntegerConsumerSemaphore.drainPermits();
mIIntegerConsumerResults.clear();
setUpResponseForRequestIsSatelliteSupported(false, SATELLITE_RESULT_SUCCESS);
@@ -2553,14 +2569,14 @@
clearInvocations(mMockSatelliteSessionController);
clearInvocations(mMockDatagramController);
- when(mMockSatelliteSessionController.isInDisablingState()).thenReturn(true);
+ mSatelliteControllerUT.isSatelliteBeingDisabled = true;
sendSatelliteModemStateChangedEvent(SATELLITE_MODEM_STATE_NOT_CONNECTED, null);
processAllMessages();
verify(mMockSatelliteSessionController, times(1)).onSatelliteModemStateChanged(
SATELLITE_MODEM_STATE_NOT_CONNECTED);
clearInvocations(mMockSatelliteSessionController);
- when(mMockSatelliteSessionController.isInDisablingState()).thenReturn(false);
+ mSatelliteControllerUT.isSatelliteBeingDisabled = false;
sendSatelliteModemStateChangedEvent(SATELLITE_MODEM_STATE_NOT_CONNECTED, null);
processAllMessages();
verify(mMockSatelliteSessionController, never()).onSatelliteModemStateChanged(
@@ -2570,7 +2586,6 @@
@Test
public void testRequestNtnSignalStrengthWithFeatureFlagEnabled() {
when(mFeatureFlags.oemEnabledSatelliteFlag()).thenReturn(true);
-
resetSatelliteControllerUT();
mRequestNtnSignalStrengthSemaphore.drainPermits();
@@ -4759,6 +4774,7 @@
.thenReturn(allSubInfos);
when(mSubscriptionInfo.isSatelliteESOSSupported()).thenReturn(true);
+ when(mSubscriptionInfo.isActive()).thenReturn(true);
when(mMockSubscriptionManagerService.getSubscriptionInfoInternal(SUB_ID))
.thenReturn(subInfoInternal);
@@ -4831,7 +4847,7 @@
logd("NameNotFoundException");
}
assertTrue(mSatelliteControllerUT
- .isP2PSmsDisallowedOnCarrierRoamingNtn(mPhone));
+ .isP2PSmsDisallowedOnCarrierRoamingNtn(/*subId*/ SUB_ID));
}
@Test
@@ -4853,7 +4869,7 @@
}
// If it is automatic connection case, it is not support the callback.
assertFalse(mSatelliteControllerUT
- .isP2PSmsDisallowedOnCarrierRoamingNtn(mPhone));
+ .isP2PSmsDisallowedOnCarrierRoamingNtn(/*subId*/ SUB_ID));
}
ApplicationInfo getApplicationInfo() {
@@ -4863,6 +4879,84 @@
METADATA_SATELLITE_MANUAL_CONNECT_P2P_SUPPORT, true);
return applicationInfo;
}
+
+ @Test
+ public void testRegisterApplicationStateChanged() {
+ when(mFeatureFlags.carrierRoamingNbIotNtn()).thenReturn(true);
+ mCarrierConfigBundle.putBoolean(KEY_SATELLITE_ATTACH_SUPPORTED_BOOL, false);
+ when(mMockSubscriptionManagerService.getActiveSubIdList(true))
+ .thenReturn(new int[]{SUB_ID1});
+
+ ArgumentCaptor<IntentFilter> intentFilterCaptor =
+ ArgumentCaptor.forClass(IntentFilter.class);
+ ArgumentCaptor<BroadcastReceiver> receiverCaptor =
+ ArgumentCaptor.forClass(BroadcastReceiver.class);
+ verify(mContext).registerReceiver(receiverCaptor.capture(), intentFilterCaptor.capture(),
+ anyInt());
+
+ BroadcastReceiver receiver = receiverCaptor.getValue();
+ mSatelliteControllerUT =
+ new TestSatelliteController(mContext, Looper.myLooper(), mFeatureFlags);
+ assertFalse(mSatelliteControllerUT.isApplicationUpdated);
+ Intent intent = new Intent(Intent.ACTION_PACKAGE_ADDED);
+ intent.setData(Uri.parse("com.example.app"));
+ receiver.onReceive(mContext, intent);
+ CountDownLatch latch1 = new CountDownLatch(1);
+ new Handler(Looper.getMainLooper()).postDelayed(() -> {
+ latch1.countDown();
+ }, 100);
+ try {
+ latch1.await();
+ } catch (InterruptedException e) {
+ }
+ assertTrue(mSatelliteControllerUT.isApplicationUpdated);
+ mSatelliteControllerUT =
+ new TestSatelliteController(mContext, Looper.myLooper(), mFeatureFlags);
+ assertFalse(mSatelliteControllerUT.isApplicationUpdated);
+ intent = new Intent(Intent.ACTION_PACKAGE_REPLACED);
+ intent.setData(Uri.parse("com.example.app"));
+ receiver.onReceive(mContext, intent);
+ CountDownLatch latch2 = new CountDownLatch(1);
+ new Handler(Looper.getMainLooper()).postDelayed(() -> {
+ latch2.countDown();
+ }, 100);
+ try {
+ latch2.await();
+ } catch (InterruptedException e) {
+ }
+ assertTrue(mSatelliteControllerUT.isApplicationUpdated);
+ mSatelliteControllerUT =
+ new TestSatelliteController(mContext, Looper.myLooper(), mFeatureFlags);
+ assertFalse(mSatelliteControllerUT.isApplicationUpdated);
+ intent = new Intent(Intent.ACTION_PACKAGE_REMOVED);
+ intent.setData(Uri.parse("com.example.app"));
+ receiver.onReceive(mContext, intent);
+ CountDownLatch latch3 = new CountDownLatch(1);
+ new Handler(Looper.getMainLooper()).postDelayed(() -> {
+ latch3.countDown();
+ }, 100);
+ try {
+ latch3.await();
+ } catch (InterruptedException e) {
+ }
+ assertTrue(mSatelliteControllerUT.isApplicationUpdated);
+ mSatelliteControllerUT =
+ new TestSatelliteController(mContext, Looper.myLooper(), mFeatureFlags);
+ assertFalse(mSatelliteControllerUT.isApplicationUpdated);
+ intent = new Intent(Intent.ACTION_PACKAGE_ADDED);
+ intent.setData(Uri.parse("com.example.different"));
+ receiver.onReceive(mContext, intent);
+ CountDownLatch latch4 = new CountDownLatch(1);
+ new Handler(Looper.getMainLooper()).postDelayed(() -> {
+ latch4.countDown();
+ }, 100);
+ try {
+ latch4.await();
+ } catch (InterruptedException e) {
+ }
+ assertFalse(mSatelliteControllerUT.isApplicationUpdated);
+ }
+
private void verifyProvisionStatusPerSubscriberIdGetFromDb(boolean provision) {
doReturn(provision).when(
mMockSubscriptionManagerService).isSatelliteProvisionedForNonIpDatagram(anyInt());
@@ -5449,6 +5543,15 @@
setUpResponseForRequestIsSatelliteProvisioned(false, SATELLITE_RESULT_SUCCESS);
verifySatelliteSupported(true, SATELLITE_RESULT_SUCCESS);
verifySatelliteProvisioned(false, SATELLITE_RESULT_SUCCESS);
+
+ try {
+ setSatelliteSubscriberTesting();
+ } catch (Exception ex) {
+ fail("provisionSatelliteService.setSatelliteSubscriberTesting: ex=" + ex);
+ }
+ doReturn(true).when(mMockSubscriptionManagerService).isSatelliteProvisionedForNonIpDatagram(
+ anyInt());
+
cancelRemote = mSatelliteControllerUT.provisionSatelliteService(
TEST_SATELLITE_TOKEN,
testProvisionData, mIIntegerConsumer);
@@ -5620,12 +5723,15 @@
public int satelliteModeSettingValue = SATELLITE_MODE_ENABLED_FALSE;
public boolean setSettingsKeyToAllowDeviceRotationCalled = false;
public OutcomeReceiver<Boolean, SatelliteException> isSatelliteAllowedCallback = null;
+ public static boolean isApplicationUpdated;
public String packageName = "com.example.app";
+ public boolean isSatelliteBeingDisabled = false;
TestSatelliteController(
Context context, Looper looper, @NonNull FeatureFlags featureFlags) {
super(context, looper, featureFlags);
logd("Constructing TestSatelliteController");
+ isApplicationUpdated = false;
}
@Override
@@ -5701,13 +5807,23 @@
}
@Override
+ public boolean isSatelliteBeingDisabled() {
+ return isSatelliteBeingDisabled;
+ }
+
protected String getConfigSatelliteGatewayServicePackage() {
+ String packageName = "com.example.app";
return packageName;
}
+ @Override
+ protected void handleCarrierRoamingNtnAvailableServicesChanged(int subId) {
+ isApplicationUpdated = true;
+ }
+
void setSatelliteProvisioned(@Nullable Boolean isProvisioned) {
- synchronized (mSatelliteViaOemProvisionLock) {
- mIsSatelliteViaOemProvisioned = isProvisioned;
+ synchronized (mDeviceProvisionLock) {
+ mIsDeviceProvisioned = isProvisioned;
}
}
diff --git a/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteSOSMessageRecommenderTest.java b/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteSOSMessageRecommenderTest.java
index f15ffbd..2609ffc 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteSOSMessageRecommenderTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteSOSMessageRecommenderTest.java
@@ -266,7 +266,7 @@
@Test
public void testTimeoutBeforeEmergencyCallEnd_EventDisplayEmergencyMessageNotSent() {
mTestSatelliteController.setSatelliteConnectedViaCarrierWithinHysteresisTime(false);
- mTestSatelliteController.setIsSatelliteViaOemProvisioned(false);
+ mTestSatelliteController.setDeviceProvisioned(false);
mTestSOSMessageRecommender.isSatelliteAllowedCallback = null;
mTestSOSMessageRecommender.onEmergencyCallStarted(mTestConnection, false);
processAllMessages();
@@ -568,20 +568,20 @@
}
@Test
- public void testIsSatelliteViaOemAvailable() {
+ public void testIsDeviceProvisioned() {
Boolean originalIsSatelliteViaOemProvisioned =
- mTestSatelliteController.mIsSatelliteViaOemProvisioned;
+ mTestSatelliteController.mIsDeviceProvisionedForTest;
- mTestSatelliteController.mIsSatelliteViaOemProvisioned = null;
- assertFalse(mTestSOSMessageRecommender.isSatelliteViaOemAvailable());
+ mTestSatelliteController.mIsDeviceProvisionedForTest = null;
+ assertFalse(mTestSOSMessageRecommender.isDeviceProvisioned());
- mTestSatelliteController.mIsSatelliteViaOemProvisioned = true;
- assertTrue(mTestSOSMessageRecommender.isSatelliteViaOemAvailable());
+ mTestSatelliteController.mIsDeviceProvisionedForTest = true;
+ assertTrue(mTestSOSMessageRecommender.isDeviceProvisioned());
- mTestSatelliteController.mIsSatelliteViaOemProvisioned = false;
- assertFalse(mTestSOSMessageRecommender.isSatelliteViaOemAvailable());
+ mTestSatelliteController.mIsDeviceProvisionedForTest = false;
+ assertFalse(mTestSOSMessageRecommender.isDeviceProvisioned());
- mTestSatelliteController.mIsSatelliteViaOemProvisioned =
+ mTestSatelliteController.mIsDeviceProvisionedForTest =
originalIsSatelliteViaOemProvisioned;
}
@@ -632,7 +632,7 @@
mSetFlagsRule.enableFlags(Flags.FLAG_CARRIER_ROAMING_NB_IOT_NTN);
mTestSatelliteController.setSatelliteConnectedViaCarrierWithinHysteresisTime(true);
- mTestSatelliteController.mIsSatelliteViaOemProvisioned = true;
+ mTestSatelliteController.mIsDeviceProvisionedForTest = true;
mTestSOSMessageRecommender.onEmergencyCallStarted(mTestConnection, false);
assertEquals(EMERGENCY_CALL_TO_SATELLITE_HANDOVER_TYPE_T911,
mTestSOSMessageRecommender.getEmergencyCallToSatelliteHandoverType());
@@ -646,7 +646,7 @@
mSetFlagsRule.enableFlags(Flags.FLAG_CARRIER_ROAMING_NB_IOT_NTN);
mTestSatelliteController.setSatelliteConnectedViaCarrierWithinHysteresisTime(true);
- mTestSatelliteController.mIsSatelliteViaOemProvisioned = false;
+ mTestSatelliteController.mIsDeviceProvisionedForTest = false;
mTestSOSMessageRecommender.onEmergencyCallStarted(mTestConnection, false);
assertEquals(EMERGENCY_CALL_TO_SATELLITE_HANDOVER_TYPE_T911,
mTestSOSMessageRecommender.getEmergencyCallToSatelliteHandoverType());
@@ -660,13 +660,13 @@
mSetFlagsRule.enableFlags(Flags.FLAG_CARRIER_ROAMING_NB_IOT_NTN);
mTestSatelliteController.setSatelliteConnectedViaCarrierWithinHysteresisTime(false);
- mTestSatelliteController.mIsSatelliteViaOemProvisioned = true;
+ mTestSatelliteController.mIsDeviceProvisionedForTest = true;
mTestSOSMessageRecommender.onEmergencyCallStarted(mTestConnection, false);
assertEquals(EMERGENCY_CALL_TO_SATELLITE_HANDOVER_TYPE_SOS,
mTestSOSMessageRecommender.getEmergencyCallToSatelliteHandoverType());
mTestSatelliteController.setSatelliteConnectedViaCarrierWithinHysteresisTime(false);
- mTestSatelliteController.mIsSatelliteViaOemProvisioned = false;
+ mTestSatelliteController.mIsDeviceProvisionedForTest = false;
mTestSOSMessageRecommender.onEmergencyCallStarted(mTestConnection, false);
assertEquals(EMERGENCY_CALL_TO_SATELLITE_HANDOVER_TYPE_SOS,
mTestSOSMessageRecommender.getEmergencyCallToSatelliteHandoverType());
@@ -771,7 +771,7 @@
mProvisionStateChangedCallbacks;
private int mRegisterForSatelliteProvisionStateChangedCalls = 0;
private int mUnregisterForSatelliteProvisionStateChangedCalls = 0;
- private Boolean mIsSatelliteViaOemProvisioned = true;
+ private Boolean mIsDeviceProvisionedForTest = true;
private boolean mIsSatelliteConnectedViaCarrierWithinHysteresisTime = true;
public boolean isOemEnabledSatelliteSupported = true;
public boolean isCarrierEnabledSatelliteSupported = true;
@@ -792,8 +792,8 @@
}
@Override
- public Boolean isSatelliteViaOemProvisioned() {
- return mIsSatelliteViaOemProvisioned;
+ public Boolean isDeviceProvisioned() {
+ return mIsDeviceProvisionedForTest;
}
@Override
@@ -867,12 +867,12 @@
return mUnregisterForSatelliteProvisionStateChangedCalls;
}
- public void setIsSatelliteViaOemProvisioned(boolean provisioned) {
- mIsSatelliteViaOemProvisioned = provisioned;
+ public void setDeviceProvisioned(boolean provisioned) {
+ mIsDeviceProvisionedForTest = provisioned;
}
public void sendProvisionStateChangedEvent(int subId, boolean provisioned) {
- mIsSatelliteViaOemProvisioned = provisioned;
+ mIsDeviceProvisionedForTest = provisioned;
Set<ISatelliteProvisionStateCallback> perSubscriptionCallbacks =
mProvisionStateChangedCallbacks.get(SUB_ID);
if (perSubscriptionCallbacks != null) {
diff --git a/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteSessionControllerTest.java b/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteSessionControllerTest.java
index eb9103a..96c50b6 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteSessionControllerTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteSessionControllerTest.java
@@ -60,7 +60,6 @@
import android.os.Looper;
import android.os.Message;
import android.os.PersistableBundle;
-import android.os.RemoteException;
import android.telephony.ServiceState;
import android.telephony.satellite.ISatelliteModemStateCallback;
import android.telephony.satellite.SatelliteManager;
@@ -694,14 +693,6 @@
// Time shift to cause P2P_SMS timeout
moveTimeForward(P2P_SMS_INACTIVITY_TIMEOUT_SEC * 1000);
processAllMessages();
-
- // Verify that expired P2P_SMS timer
- // reported IDLE state, called satellite disabling.
- verifyEsosP2pSmsInactivityTimer(false, false);
- assertSuccessfulModemStateChangedCallback(
- mTestSatelliteModemStateCallback, SatelliteManager.SATELLITE_MODEM_STATE_IDLE);
- verify(mMockSatelliteController, times(1)).requestSatelliteEnabled(
- eq(false), eq(false), eq(false), any(IIntegerConsumer.Stub.class));
}
@Test
diff --git a/tests/telephonytests/src/com/android/internal/telephony/subscription/SubscriptionManagerServiceTest.java b/tests/telephonytests/src/com/android/internal/telephony/subscription/SubscriptionManagerServiceTest.java
index 65790f8..66b2eb8 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/subscription/SubscriptionManagerServiceTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/subscription/SubscriptionManagerServiceTest.java
@@ -70,6 +70,7 @@
import android.Manifest;
import android.annotation.NonNull;
+import android.app.ActivityManager;
import android.app.AppOpsManager;
import android.app.PropertyInvalidatedCache;
import android.compat.testing.PlatformCompatChangeRule;
@@ -1123,9 +1124,12 @@
public void testGetAccessibleSubscriptionInfoList() {
doReturn(true).when(mEuiccManager).isEnabled();
insertSubscription(FAKE_SUBSCRIPTION_INFO2);
+ UserHandle user = UserHandle.of(ActivityManager.getCurrentUser());
doReturn(true).when(mSubscriptionManager).canManageSubscription(
any(SubscriptionInfo.class), eq(CALLING_PACKAGE));
+ doReturn(true).when(mSubscriptionManager).canManageSubscriptionAsUser(
+ any(SubscriptionInfo.class), eq(CALLING_PACKAGE), any(UserHandle.class));
// FAKE_SUBSCRIPTION_INFO2 is a not eSIM. So the list should be empty.
assertThat(mSubscriptionManagerServiceUT.getAccessibleSubscriptionInfoList(
CALLING_PACKAGE)).isEmpty();
@@ -1138,6 +1142,8 @@
doReturn(false).when(mSubscriptionManager).canManageSubscription(
any(SubscriptionInfo.class), eq(CALLING_PACKAGE));
+ doReturn(false).when(mSubscriptionManager).canManageSubscriptionAsUser(
+ any(SubscriptionInfo.class), eq(CALLING_PACKAGE), eq(user));
doReturn(true).when(mEuiccManager).isEnabled();
assertThat(mSubscriptionManagerServiceUT.getAccessibleSubscriptionInfoList(
@@ -1145,6 +1151,8 @@
doReturn(true).when(mSubscriptionManager).canManageSubscription(
any(SubscriptionInfo.class), eq(CALLING_PACKAGE));
+ doReturn(true).when(mSubscriptionManager).canManageSubscriptionAsUser(
+ any(SubscriptionInfo.class), eq(CALLING_PACKAGE), eq(user));
assertThat(mSubscriptionManagerServiceUT.getAccessibleSubscriptionInfoList(
CALLING_PACKAGE)).isEqualTo(List.of(new SubscriptionInfoInternal.Builder(
FAKE_SUBSCRIPTION_INFO1).setId(2).build().toSubscriptionInfo()));
@@ -1363,6 +1371,9 @@
doReturn(true).when(mEuiccManager).isEnabled();
doReturn(true).when(mSubscriptionManager).canManageSubscription(
any(SubscriptionInfo.class), eq(CALLING_PACKAGE));
+ UserHandle user = UserHandle.of(ActivityManager.getCurrentUser());
+ doReturn(true).when(mSubscriptionManager).canManageSubscriptionAsUser(
+ any(SubscriptionInfo.class), eq(CALLING_PACKAGE), eq(user));
assertThat(mSubscriptionManagerServiceUT.getAccessibleSubscriptionInfoList(
CALLING_PACKAGE)).isEqualTo(List.of(FAKE_SUBSCRIPTION_INFO1.toSubscriptionInfo()));
// Test getActiveSubIdList, System
@@ -1499,6 +1510,9 @@
doReturn(true).when(mEuiccManager).isEnabled();
doReturn(true).when(mSubscriptionManager).canManageSubscription(
any(SubscriptionInfo.class), eq(CALLING_PACKAGE));
+ UserHandle user = UserHandle.of(ActivityManager.getCurrentUser());
+ doReturn(true).when(mSubscriptionManager).canManageSubscriptionAsUser(
+ any(SubscriptionInfo.class), eq(CALLING_PACKAGE), eq(user));
assertThat(mSubscriptionManagerServiceUT.getAccessibleSubscriptionInfoList(
CALLING_PACKAGE)).isEqualTo(List.of(FAKE_SUBSCRIPTION_INFO1.toSubscriptionInfo()));
// Test getActiveSubIdList, System