Merge "After completing the entitlement query, the barred PLMN list is also passed to the modem." into 24D1-dev am: d33d130e33
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/services/Telephony/+/26817488
Change-Id: Ic7de419f9713496f190da3e6fdcfbfeefcb21a35
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/src/com/android/phone/satellite/entitlement/SatelliteEntitlementApi.java b/src/com/android/phone/satellite/entitlement/SatelliteEntitlementApi.java
index 45482ec..6c55709 100644
--- a/src/com/android/phone/satellite/entitlement/SatelliteEntitlementApi.java
+++ b/src/com/android/phone/satellite/entitlement/SatelliteEntitlementApi.java
@@ -61,7 +61,8 @@
SatelliteEntitlementResponse satelliteEntitlementResponse =
new SatelliteEntitlementResponse(response);
return new SatelliteEntitlementResult(satelliteEntitlementResponse.getEntitlementStatus(),
- satelliteEntitlementResponse.getPlmnAllowed());
+ satelliteEntitlementResponse.getPlmnAllowed(),
+ satelliteEntitlementResponse.getPlmnBarredList());
}
@NonNull
diff --git a/src/com/android/phone/satellite/entitlement/SatelliteEntitlementController.java b/src/com/android/phone/satellite/entitlement/SatelliteEntitlementController.java
index accae32..d193a7d 100644
--- a/src/com/android/phone/satellite/entitlement/SatelliteEntitlementController.java
+++ b/src/com/android/phone/satellite/entitlement/SatelliteEntitlementController.java
@@ -429,7 +429,8 @@
updateSatelliteEntitlementStatus(subId,
mSatelliteEntitlementResultPerSub.get(subId).getEntitlementStatus()
== SATELLITE_ENTITLEMENT_STATUS_ENABLED,
- mSatelliteEntitlementResultPerSub.get(subId).getAllowedPLMNList());
+ mSatelliteEntitlementResultPerSub.get(subId).getAllowedPLMNList(),
+ mSatelliteEntitlementResultPerSub.get(subId).getBarredPLMNList());
stopExponentialBackoff(subId);
mRetryCountPerSub.remove(subId);
}
@@ -528,9 +529,9 @@
*/
@VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
public void updateSatelliteEntitlementStatus(int subId, boolean enabled,
- List<String> plmnAllowedList) {
+ List<String> plmnAllowedList, List<String> plmnBarredList) {
SatelliteController.getInstance().onSatelliteEntitlementStatusUpdated(subId, enabled,
- plmnAllowedList, null);
+ plmnAllowedList, plmnBarredList, null);
}
private static void logd(String log) {
diff --git a/src/com/android/phone/satellite/entitlement/SatelliteEntitlementResponse.java b/src/com/android/phone/satellite/entitlement/SatelliteEntitlementResponse.java
index b877bee..97cb355 100644
--- a/src/com/android/phone/satellite/entitlement/SatelliteEntitlementResponse.java
+++ b/src/com/android/phone/satellite/entitlement/SatelliteEntitlementResponse.java
@@ -97,7 +97,6 @@
* Get the PLMNBarredList from the response
* @return The PLMNs Barred List
*/
- @VisibleForTesting
public List<String> getPlmnBarredList() {
return mPlmnBarredList.stream().map(String::new).collect(Collectors.toList());
}
@@ -137,7 +136,10 @@
mPlmnBarredList = new ArrayList<>();
JSONArray jsonArray = jsonToken.getJSONArray(PLMN_BARRED_KEY);
for (int i = 0; i < jsonArray.length(); i++) {
- mPlmnBarredList.add(jsonArray.getJSONObject(i).getString(PLMN_KEY));
+ String plmn = jsonArray.getJSONObject(i).getString(PLMN_KEY);
+ if (!TextUtils.isEmpty(plmn)) {
+ mPlmnBarredList.add(plmn);
+ }
}
}
} catch (JSONException e) {
diff --git a/src/com/android/phone/satellite/entitlement/SatelliteEntitlementResult.java b/src/com/android/phone/satellite/entitlement/SatelliteEntitlementResult.java
index 3289232..014e28e 100644
--- a/src/com/android/phone/satellite/entitlement/SatelliteEntitlementResult.java
+++ b/src/com/android/phone/satellite/entitlement/SatelliteEntitlementResult.java
@@ -53,17 +53,25 @@
* item of the satellite configuration received from the entitlement server.
*/
private List<SatelliteNetworkInfo> mAllowedSatelliteNetworkInfoList;
+ /**
+ * List consisting of the PLMN in the PLMNBarred item of the satellite configuration received
+ * from the entitlement server
+ */
+ private List<String> mBarredPlmnList;
/**
* Store the result of the satellite entitlement response.
*
* @param entitlementStatus The entitlement status.
* @param allowedSatelliteNetworkInfoList The allowedSatelliteNetworkInfoList
+ * @param barredPlmnList The barred plmn list
*/
public SatelliteEntitlementResult(@SatelliteEntitlementStatus int entitlementStatus,
- List<SatelliteNetworkInfo> allowedSatelliteNetworkInfoList) {
+ List<SatelliteNetworkInfo> allowedSatelliteNetworkInfoList,
+ List<String> barredPlmnList) {
mEntitlementStatus = entitlementStatus;
mAllowedSatelliteNetworkInfoList = allowedSatelliteNetworkInfoList;
+ mBarredPlmnList = barredPlmnList;
}
/**
@@ -86,6 +94,15 @@
}
/**
+ * Get the plmn barred list
+ *
+ * @return The plmn barred list.
+ */
+ public List<String> getBarredPLMNList() {
+ return mBarredPlmnList.stream().map(String::new).collect(Collectors.toList());
+ }
+
+ /**
* Get the default SatelliteEntitlementResult. EntitlementStatus set to
* `SATELLITE_ENTITLEMENT_STATUS_DISABLED` and SatelliteNetworkInfo list set to empty.
*
@@ -93,6 +110,6 @@
*/
public static SatelliteEntitlementResult getDefaultResult() {
return new SatelliteEntitlementResult(SATELLITE_ENTITLEMENT_STATUS_DISABLED,
- new ArrayList<>());
+ new ArrayList<>(), new ArrayList<>());
}
}
diff --git a/tests/src/com/android/phone/satellite/entitlement/SatelliteEntitlementControllerTest.java b/tests/src/com/android/phone/satellite/entitlement/SatelliteEntitlementControllerTest.java
index 18a0284..dd9ea65 100644
--- a/tests/src/com/android/phone/satellite/entitlement/SatelliteEntitlementControllerTest.java
+++ b/tests/src/com/android/phone/satellite/entitlement/SatelliteEntitlementControllerTest.java
@@ -79,6 +79,7 @@
private static final int[] ACTIVE_SUB_ID = {SUB_ID};
private static final int DEFAULT_QUERY_REFRESH_DAY = 30;
private static final List<String> PLMN_ALLOWED_LIST = Arrays.asList("31026", "302820");
+ private static final List<String> PLMN_BARRED_LIST = Arrays.asList("12345", "98765");
@Mock
CarrierConfigManager mCarrierConfigManager;
@Mock
@@ -166,7 +167,7 @@
verify(mSatelliteEntitlementApi, never()).checkEntitlementStatus();
verify(mSatelliteController, never()).onSatelliteEntitlementStatusUpdated(anyInt(),
- anyBoolean(), anyList(), any());
+ anyBoolean(), anyList(), anyList(), any());
mCarrierConfigBundle.putBoolean(
CarrierConfigManager.KEY_SATELLITE_ENTITLEMENT_SUPPORTED_BOOL, true);
@@ -177,7 +178,7 @@
verify(mSatelliteEntitlementApi, never()).checkEntitlementStatus();
verify(mSatelliteController, never()).onSatelliteEntitlementStatusUpdated(anyInt(),
- anyBoolean(), anyList(), any());
+ anyBoolean(), anyList(), anyList(), any());
replaceInstance(SatelliteEntitlementController.class, "mExponentialBackoffPerSub",
mSatelliteEntitlementController, new HashMap<>());
@@ -188,7 +189,7 @@
verify(mSatelliteEntitlementApi, never()).checkEntitlementStatus();
verify(mSatelliteController, never()).onSatelliteEntitlementStatusUpdated(anyInt(),
- anyBoolean(), anyList(), any());
+ anyBoolean(), anyList(), anyList(), any());
setInternetConnected(true);
// Verify don't start the query when last query refresh time is not expired.
@@ -197,18 +198,19 @@
verify(mSatelliteEntitlementApi, never()).checkEntitlementStatus();
verify(mSatelliteController, never()).onSatelliteEntitlementStatusUpdated(anyInt(),
- anyBoolean(), anyList(), any());
+ anyBoolean(), anyList(), anyList(), any());
// Verify start the query when isQueryAvailable return true
setLastQueryTime(0L);
doReturn(mSatelliteEntitlementResult).when(
mSatelliteEntitlementApi).checkEntitlementStatus();
- setSatelliteEntitlementResult(SATELLITE_ENTITLEMENT_STATUS_ENABLED, PLMN_ALLOWED_LIST);
+ setSatelliteEntitlementResult(SATELLITE_ENTITLEMENT_STATUS_ENABLED, PLMN_ALLOWED_LIST,
+ PLMN_BARRED_LIST);
mSatelliteEntitlementController.handleCmdStartQueryEntitlement();
verify(mSatelliteEntitlementApi).checkEntitlementStatus();
verify(mSatelliteController).onSatelliteEntitlementStatusUpdated(anyInt(),
- anyBoolean(), anyList(), any());
+ anyBoolean(), anyList(), anyList(), any());
}
@Test
@@ -221,7 +223,7 @@
verify(mSatelliteEntitlementApi, never()).checkEntitlementStatus();
// Verify don't call the updateSatelliteEntitlementStatus.
verify(mSatelliteController, never()).onSatelliteEntitlementStatusUpdated(anyInt(),
- anyBoolean(), anyList(), any());
+ anyBoolean(), anyList(), anyList(), any());
// Verify call the checkSatelliteEntitlementStatus with invalid response.
setIsQueryAvailableTrue();
@@ -234,26 +236,27 @@
verify(mSatelliteEntitlementApi).checkEntitlementStatus();
// Verify call the updateSatelliteEntitlementStatus with satellite service is disabled
- // and empty PLMNAllowed
+ // , empty PLMNAllowed and empty PLMNBarred.
verify(mSatelliteController).onSatelliteEntitlementStatusUpdated(eq(SUB_ID),
- eq(false), eq(new ArrayList<>()), any());
+ eq(false), eq(new ArrayList<>()), eq(new ArrayList<>()), any());
// Verify call the checkSatelliteEntitlementStatus with the subscribed result.
clearInvocationsForMock();
setIsQueryAvailableTrue();
doReturn(mSatelliteEntitlementResult).when(
mSatelliteEntitlementApi).checkEntitlementStatus();
- setSatelliteEntitlementResult(SATELLITE_ENTITLEMENT_STATUS_ENABLED, PLMN_ALLOWED_LIST);
+ setSatelliteEntitlementResult(SATELLITE_ENTITLEMENT_STATUS_ENABLED, PLMN_ALLOWED_LIST,
+ PLMN_BARRED_LIST);
mSatelliteEntitlementController.handleCmdStartQueryEntitlement();
verify(mSatelliteEntitlementApi).checkEntitlementStatus();
- // Verify call the updateSatelliteEntitlementStatus with satellite service is enable and
- // availablePLMNAllowedList
+ // Verify call the updateSatelliteEntitlementStatus with satellite service is enable,
+ // availablePLMNAllowedList and availablePLMNBarredList.
verify(mSatelliteController).onSatelliteEntitlementStatusUpdated(eq(SUB_ID), eq(true),
- eq(PLMN_ALLOWED_LIST), any());
+ eq(PLMN_ALLOWED_LIST), eq(PLMN_BARRED_LIST), any());
- // Change subId and verify call the updateSatelliteEntitlementStatus with satellite
- // service is enable and availablePLMNAllowedList
+ // Change subId and verify call the updateSatelliteEntitlementStatus with satellite
+ // service is enable, availablePLMNAllowedList and availablePLMNBarredList
clearInvocationsForMock();
doReturn(new int[]{SUB_ID_2}).when(mMockSubscriptionManagerService).getActiveSubIdList(
true);
@@ -261,7 +264,43 @@
verify(mSatelliteEntitlementApi).checkEntitlementStatus();
verify(mSatelliteController).onSatelliteEntitlementStatusUpdated(eq(SUB_ID_2), eq(true),
- eq(PLMN_ALLOWED_LIST), any());
+ eq(PLMN_ALLOWED_LIST), eq(PLMN_BARRED_LIST), any());
+
+ // Verify call the updateSatelliteEntitlementStatus with satellite service is enable,
+ // availablePLMNAllowedList and empty plmn barred list.
+ clearInvocationsForMock();
+ setIsQueryAvailableTrue();
+ setSatelliteEntitlementResult(SATELLITE_ENTITLEMENT_STATUS_ENABLED, PLMN_ALLOWED_LIST,
+ new ArrayList<>());
+ mSatelliteEntitlementController.handleCmdStartQueryEntitlement();
+
+ verify(mSatelliteEntitlementApi).checkEntitlementStatus();
+ verify(mSatelliteController).onSatelliteEntitlementStatusUpdated(eq(SUB_ID), eq(true),
+ eq(PLMN_ALLOWED_LIST), eq(new ArrayList<>()), any());
+
+ // Verify call the updateSatelliteEntitlementStatus with satellite service is enable,
+ // empty PLMNAllowedList and PLMNBarredList.
+ clearInvocationsForMock();
+ setIsQueryAvailableTrue();
+ setSatelliteEntitlementResult(SATELLITE_ENTITLEMENT_STATUS_ENABLED, new ArrayList<>(),
+ new ArrayList<>());
+ mSatelliteEntitlementController.handleCmdStartQueryEntitlement();
+
+ verify(mSatelliteEntitlementApi).checkEntitlementStatus();
+ verify(mSatelliteController).onSatelliteEntitlementStatusUpdated(eq(SUB_ID), eq(true),
+ eq(new ArrayList<>()), eq(new ArrayList<>()), any());
+
+ // Verify call the updateSatelliteEntitlementStatus with satellite service is enable,
+ // empty PLMNAllowedList and availablePLMNBarredList.
+ clearInvocationsForMock();
+ setIsQueryAvailableTrue();
+ setSatelliteEntitlementResult(SATELLITE_ENTITLEMENT_STATUS_ENABLED, new ArrayList<>(),
+ PLMN_BARRED_LIST);
+ mSatelliteEntitlementController.handleCmdStartQueryEntitlement();
+
+ verify(mSatelliteEntitlementApi).checkEntitlementStatus();
+ verify(mSatelliteController).onSatelliteEntitlementStatusUpdated(eq(SUB_ID), eq(true),
+ eq(new ArrayList<>()), eq(PLMN_BARRED_LIST), any());
}
@Test
@@ -277,7 +316,8 @@
// Verify the called the checkSatelliteEntitlementStatus when Internet is connected.
setInternetConnected(true);
setLastQueryTime(0L);
- setSatelliteEntitlementResult(SATELLITE_ENTITLEMENT_STATUS_ENABLED, PLMN_ALLOWED_LIST);
+ setSatelliteEntitlementResult(SATELLITE_ENTITLEMENT_STATUS_ENABLED, PLMN_ALLOWED_LIST,
+ PLMN_BARRED_LIST);
networkCallback.onAvailable(mockNetwork);
mTestableLooper.processAllMessages();
@@ -285,7 +325,7 @@
verify(mSatelliteEntitlementApi).checkEntitlementStatus();
// Verify call the updateSatelliteEntitlementStatus with satellite service is available.
verify(mSatelliteController).onSatelliteEntitlementStatusUpdated(eq(SUB_ID), eq(true),
- eq(PLMN_ALLOWED_LIST), any());
+ eq(PLMN_ALLOWED_LIST), eq(PLMN_BARRED_LIST), any());
}
@Test
@@ -294,13 +334,14 @@
// occurred and Internet is connected.
setInternetConnected(true);
setLastQueryTime(0L);
- setSatelliteEntitlementResult(SATELLITE_ENTITLEMENT_STATUS_ENABLED, PLMN_ALLOWED_LIST);
+ setSatelliteEntitlementResult(SATELLITE_ENTITLEMENT_STATUS_ENABLED, PLMN_ALLOWED_LIST,
+ PLMN_BARRED_LIST);
triggerCarrierConfigChanged();
verify(mSatelliteEntitlementApi).checkEntitlementStatus();
// Verify call the updateSatelliteEntitlementStatus with satellite service is available.
verify(mSatelliteController).onSatelliteEntitlementStatusUpdated(eq(SUB_ID), eq(true),
- eq(PLMN_ALLOWED_LIST), any());
+ eq(PLMN_ALLOWED_LIST), eq(PLMN_BARRED_LIST), any());
}
private void triggerCarrierConfigChanged() {
@@ -344,9 +385,10 @@
}
private void setSatelliteEntitlementResult(int entitlementStatus,
- List<String> plmnAllowedList) {
+ List<String> plmnAllowedList, List<String> plmnBarredList) {
doReturn(entitlementStatus).when(mSatelliteEntitlementResult).getEntitlementStatus();
doReturn(plmnAllowedList).when(mSatelliteEntitlementResult).getAllowedPLMNList();
+ doReturn(plmnBarredList).when(mSatelliteEntitlementResult).getBarredPLMNList();
}
private void setLastQueryTime(Long lastQueryTime) throws Exception {
diff --git a/tests/src/com/android/phone/satellite/entitlement/SatelliteEntitlementResponseTest.java b/tests/src/com/android/phone/satellite/entitlement/SatelliteEntitlementResponseTest.java
index 13d43c8..8e45a73 100644
--- a/tests/src/com/android/phone/satellite/entitlement/SatelliteEntitlementResponseTest.java
+++ b/tests/src/com/android/phone/satellite/entitlement/SatelliteEntitlementResponseTest.java
@@ -136,27 +136,55 @@
assertTrue(response.getPlmnBarredList().size() == 2);
assertEquals(TEST_PLMN_BARRED_LIST, response.getPlmnBarredList());
+ // Received the body without plmn barred key.
+ response = new SatelliteEntitlementResponse(
+ getChangedAllowedPLMNListResponse(TEST_PLMN_DATA_PLAN_TYPE_LIST.get(0).mPlmn,
+ TEST_PLMN_DATA_PLAN_TYPE_LIST.get(1).mPlmn));
+ assertEquals(SATELLITE_ENTITLEMENT_STATUS_ENABLED, response.getEntitlementStatus());
+ assertTrue(response.getPlmnAllowed().size() == 2);
+ assertTrue(response.getPlmnBarredList().size() == 0);
+
String plmn = "123456";
- // Received 123456 and empty string list
+ // Received the allowed plmn list set as 123456, empty string
response = new SatelliteEntitlementResponse(
- getChangedPLMNListResponse(plmn, ""));
+ getChangedAllowedPLMNListResponse(plmn, ""));
assertEquals(SATELLITE_ENTITLEMENT_STATUS_ENABLED, response.getEntitlementStatus());
assertTrue(response.getPlmnAllowed().size() == 1);
assertEquals(plmn, response.getPlmnAllowed().get(0).mPlmn);
- // Received empty string and 123456 list
+ // Received the allowed plmn list set as 123456, empty string
response = new SatelliteEntitlementResponse(
- getChangedPLMNListResponse("", plmn));
+ getChangedAllowedPLMNListResponse("", plmn));
assertEquals(SATELLITE_ENTITLEMENT_STATUS_ENABLED, response.getEntitlementStatus());
assertTrue(response.getPlmnAllowed().size() == 1);
assertEquals(plmn, response.getPlmnAllowed().get(0).mPlmn);
- // Received all empty strings list
+ // RReceived the allowed plmn list set as empty strings
response = new SatelliteEntitlementResponse(
- getChangedPLMNListResponse("", ""));
+ getChangedAllowedPLMNListResponse("", ""));
assertEquals(SATELLITE_ENTITLEMENT_STATUS_ENABLED, response.getEntitlementStatus());
assertTrue(response.getPlmnAllowed().size() == 0);
+ // Received the barred plmn list set as 123456, empty string
+ response = new SatelliteEntitlementResponse(
+ getChangedBarredPLMNListResponse(plmn, ""));
+ assertEquals(SATELLITE_ENTITLEMENT_STATUS_ENABLED, response.getEntitlementStatus());
+ assertTrue(response.getPlmnBarredList().size() == 1);
+ assertEquals(plmn, response.getPlmnBarredList().get(0));
+
+ // Received the barred plmn list set as empty string, 123456
+ response = new SatelliteEntitlementResponse(
+ getChangedBarredPLMNListResponse("", plmn));
+ assertEquals(SATELLITE_ENTITLEMENT_STATUS_ENABLED, response.getEntitlementStatus());
+ assertTrue(response.getPlmnBarredList().size() == 1);
+ assertEquals(plmn, response.getPlmnBarredList().get(0));
+
+ // Received the barred plmn list set as empty strings
+ response = new SatelliteEntitlementResponse(
+ getChangedBarredPLMNListResponse("", ""));
+ assertEquals(SATELLITE_ENTITLEMENT_STATUS_ENABLED, response.getEntitlementStatus());
+ assertTrue(response.getPlmnBarredList().size() == 0);
+
// Received null
response = new SatelliteEntitlementResponse(null);
assertEquals(SATELLITE_ENTITLEMENT_STATUS_DISABLED, response.getEntitlementStatus());
@@ -190,7 +218,12 @@
+ "{\"PLMN\":\"" + secondPlmn + "\",\"DataPlanType\":\"metered\"}]";
}
- private String getChangedPLMNListResponse(String firstPlmn, String secondPlmn) {
+ private String getBarredPlmns(String firstPlmn, String secondPlmn) {
+ return ",\"PLMNBarred\":[{\"PLMN\":\"" + firstPlmn + "\"}," + "{\"PLMN\":\"" + secondPlmn
+ + "\"}]";
+ }
+
+ private String getChangedAllowedPLMNListResponse(String firstPlmn, String secondPlmn) {
return "{\"VERS\":{\"version\":\"1\",\"validity\":\"172800\"},"
+ "\"TOKEN\":{\"token\":\"ASH127AHHA88SF\"},\""
+ ServiceEntitlement.APP_SATELLITE_ENTITLEMENT + "\":{"
@@ -198,4 +231,15 @@
+ getAllowedPlmns(firstPlmn, secondPlmn)
+ "}}";
}
+
+ private String getChangedBarredPLMNListResponse(String firstPlmn, String secondPlmn) {
+ return "{\"VERS\":{\"version\":\"1\",\"validity\":\"172800\"},"
+ + "\"TOKEN\":{\"token\":\"ASH127AHHA88SF\"},\""
+ + ServiceEntitlement.APP_SATELLITE_ENTITLEMENT + "\":{"
+ + "\"EntitlementStatus\":\"" + SATELLITE_ENTITLEMENT_STATUS_ENABLED + "\""
+ + ",\"PLMNAllowed\":[{\"PLMN\":\"31026\",\"DataPlanType\":\"unmetered\"},"
+ + "{\"PLMN\":\"302820\",\"DataPlanType\":\"metered\"}]"
+ + getBarredPlmns(firstPlmn, secondPlmn)
+ + "}}";
+ }
}