Add CTS test case for DUPLEX_MODE of ServiceStateTable
Bug: 182601774
Test: atest android.telephonyprovider.cts.ServiceStateTest
Change-Id: I40dea148b544c76125e935e5b3bc8cb99637b9a5
diff --git a/tests/tests/telephonyprovider/src/android/telephonyprovider/cts/ServiceStateTest.java b/tests/tests/telephonyprovider/src/android/telephonyprovider/cts/ServiceStateTest.java
index 8fab865..3c32394 100644
--- a/tests/tests/telephonyprovider/src/android/telephonyprovider/cts/ServiceStateTest.java
+++ b/tests/tests/telephonyprovider/src/android/telephonyprovider/cts/ServiceStateTest.java
@@ -17,6 +17,7 @@
package android.telephonyprovider.cts;
import static android.provider.Telephony.ServiceStateTable.DATA_NETWORK_TYPE;
+import static android.provider.Telephony.ServiceStateTable.DUPLEX_MODE;
import static android.provider.Telephony.ServiceStateTable.VOICE_REG_STATE;
import static android.telephony.NetworkRegistrationInfo.REGISTRATION_STATE_HOME;
@@ -215,6 +216,47 @@
}
/**
+ * Verifies that the duplex mode is valid and matches ServiceState#getDuplexMode().
+ */
+ @Test
+ public void testGetDuplexMode_query() {
+ try (Cursor cursor = mContentResolver.query(Telephony.ServiceStateTable.CONTENT_URI,
+ new String[]{DUPLEX_MODE}, null, null)) {
+ assertThat(cursor.getCount()).isEqualTo(1);
+ cursor.moveToNext();
+
+ int duplexMode = cursor.getInt(cursor.getColumnIndex(DUPLEX_MODE));
+ assertThat(duplexMode).isEqualTo(mTelephonyManager.getServiceState().getDuplexMode());
+ }
+ }
+
+ /**
+ * Verifies that even we have duplex mode change, the observer should not receive the
+ * notification (duplex mode is a poll-only field).
+ */
+ @Test
+ public void testGetDuplexMode_noChangeObserved() throws Exception {
+ ServiceState oldSS = new ServiceState();
+ oldSS.setStateOutOfService();
+
+ ServiceState newSS = new ServiceState();
+ newSS.setStateOutOfService();
+
+ // Add NRI to trigger SS with duplex mode updated
+ NetworkRegistrationInfo nri = new NetworkRegistrationInfo.Builder()
+ .setDomain(NetworkRegistrationInfo.DOMAIN_PS)
+ .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
+ .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_LTE)
+ .build();
+ newSS.addNetworkRegistrationInfo(nri);
+ newSS.setChannelNumber(65536); // EutranBand.BAND_65, DUPLEX_MODE_FDD
+
+ verifyNotificationObservedWhenFieldChanged(
+ DUPLEX_MODE, oldSS, newSS, false /*expectChange*/);
+ }
+
+
+ /**
* Insert new ServiceState over the old ServiceState and expect the observer receiving the
* notification over the observed field change.
*/