summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Chow <ktchow@google.com>2023-07-13 12:33:22 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2023-07-13 12:33:22 +0000
commit3f5724ffd1257bbd5d529a56ccdff18413f8d682 (patch)
treef521bd08a6f0e627c2c177a41a6230e444f35329
parente8cfdca2abd0432bb9b0d1b81c1929b6e7764bd0 (diff)
parenta704b7dfb867da582cc2c6dc0aaebfebf3cf84a7 (diff)
downloadIwlan-3f5724ffd1257bbd5d529a56ccdff18413f8d682.tar.gz
Merge "Only report call state to corresponding slot in IwlanEventListener" into udc-qpr-dev
-rw-r--r--src/com/google/android/iwlan/IwlanEventListener.java8
-rw-r--r--test/com/google/android/iwlan/IwlanEventListenerTest.java33
2 files changed, 36 insertions, 5 deletions
diff --git a/src/com/google/android/iwlan/IwlanEventListener.java b/src/com/google/android/iwlan/IwlanEventListener.java
index f76c179..bcc6ca7 100644
--- a/src/com/google/android/iwlan/IwlanEventListener.java
+++ b/src/com/google/android/iwlan/IwlanEventListener.java
@@ -168,11 +168,9 @@ public class IwlanEventListener {
LOG_TAG,
"Call state changed to " + callStateToString(state) + " for slot " + mSlotId);
- for (Map.Entry<Integer, IwlanEventListener> entry : mInstances.entrySet()) {
- IwlanEventListener instance = entry.getValue();
- if (instance != null) {
- instance.updateHandlers(CALL_STATE_CHANGED_EVENT, state);
- }
+ IwlanEventListener instance = mInstances.get(mSlotId);
+ if (instance != null) {
+ instance.updateHandlers(CALL_STATE_CHANGED_EVENT, state);
}
}
}
diff --git a/test/com/google/android/iwlan/IwlanEventListenerTest.java b/test/com/google/android/iwlan/IwlanEventListenerTest.java
index 79d53c0..81a0bbf 100644
--- a/test/com/google/android/iwlan/IwlanEventListenerTest.java
+++ b/test/com/google/android/iwlan/IwlanEventListenerTest.java
@@ -63,6 +63,7 @@ public class IwlanEventListenerTest {
@Mock private TelephonyManager mMockTelephonyManager;
private static final int DEFAULT_SLOT_INDEX = 0;
+ private static final int OTHER_SLOT_INDEX = 1;
private static final int DEFAULT_CARRIER_INDEX = 0;
private static final String WIFI_SSID_1 = "TEST_AP_NAME_1";
private static final String WIFI_SSID_2 = "TEST_AP_NAME_2";
@@ -303,6 +304,38 @@ public class IwlanEventListenerTest {
}
@Test
+ public void testCallStateChangedMultipleSlots() throws Exception {
+ IwlanEventListener otherSlotIwlanEventListener =
+ IwlanEventListener.getInstance(mMockContext, OTHER_SLOT_INDEX);
+
+ when(mMockHandler.obtainMessage(
+ eq(IwlanEventListener.CALL_STATE_CHANGED_EVENT),
+ eq(DEFAULT_SLOT_INDEX),
+ eq(TelephonyManager.CALL_STATE_OFFHOOK)))
+ .thenReturn(mMockMessage);
+ when(mMockHandler.obtainMessage(
+ eq(IwlanEventListener.CALL_STATE_CHANGED_EVENT),
+ eq(OTHER_SLOT_INDEX),
+ eq(TelephonyManager.CALL_STATE_OFFHOOK)))
+ .thenReturn(mMockMessage_2);
+
+ events = new ArrayList<Integer>();
+ events.add(IwlanEventListener.CALL_STATE_CHANGED_EVENT);
+ mIwlanEventListener.addEventListener(events, mMockHandler);
+ otherSlotIwlanEventListener.addEventListener(events, mMockHandler);
+
+ mIwlanEventListener.registerTelephonyCallback();
+ otherSlotIwlanEventListener.registerTelephonyCallback();
+
+ TelephonyCallback.CallStateListener mTelephonyCallback =
+ mIwlanEventListener.getTelephonyCallback();
+ mTelephonyCallback.onCallStateChanged(TelephonyManager.CALL_STATE_OFFHOOK);
+
+ verify(mMockMessage, times(1)).sendToTarget();
+ verify(mMockMessage_2, never()).sendToTarget();
+ }
+
+ @Test
public void testWfcChangeThrowIAE() throws Exception {
when(mMockHandler.obtainMessage(
eq(IwlanEventListener.WIFI_CALLING_DISABLE_EVENT),