summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsangyun <sangyun@google.com>2023-03-29 04:39:07 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-03-29 04:39:07 +0000
commitd1f737efc1d6f664f5dbaa36f09774d61d25c7e8 (patch)
tree8f2ca2ac232f94e9ecc5368d46c4cb93867f615c
parent7ae0c2576f91d2f590ae6b136dbfe9921538bfd5 (diff)
parent27d15968aa33335e73cb95f59f62e2aa452d3381 (diff)
downloadTelephony-d1f737efc1d6f664f5dbaa36f09774d61d25c7e8.tar.gz
[QNS] Remove AlternativeEventListener & Provider am: 27d15968aa
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Telephony/+/22215374 Change-Id: I8b4c375b226688002cacb9c8dada582754f177a9 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--services/QualifiedNetworksService/src/com/android/telephony/qns/AccessNetworkEvaluator.java3
-rw-r--r--services/QualifiedNetworksService/src/com/android/telephony/qns/AlternativeEventListener.java501
-rw-r--r--services/QualifiedNetworksService/src/com/android/telephony/qns/AlternativeEventProvider.java159
-rw-r--r--services/QualifiedNetworksService/src/com/android/telephony/qns/QnsComponents.java17
-rw-r--r--services/QualifiedNetworksService/tests/src/com/android/telephony/qns/AlternativeEventListenerTest.java490
-rw-r--r--services/QualifiedNetworksService/tests/src/com/android/telephony/qns/QnsComponentsTest.java6
-rw-r--r--services/QualifiedNetworksService/tests/src/com/android/telephony/qns/QnsTest.java3
-rw-r--r--services/QualifiedNetworksService/tests/src/com/android/telephony/qns/QualifiedNetworksServiceImplTest.java1
-rw-r--r--services/QualifiedNetworksService/tests/src/com/android/telephony/qns/RestrictManagerTest.java5
9 files changed, 0 insertions, 1185 deletions
diff --git a/services/QualifiedNetworksService/src/com/android/telephony/qns/AccessNetworkEvaluator.java b/services/QualifiedNetworksService/src/com/android/telephony/qns/AccessNetworkEvaluator.java
index e8a742d..098820a 100644
--- a/services/QualifiedNetworksService/src/com/android/telephony/qns/AccessNetworkEvaluator.java
+++ b/services/QualifiedNetworksService/src/com/android/telephony/qns/AccessNetworkEvaluator.java
@@ -85,7 +85,6 @@ class AccessNetworkEvaluator {
protected IwlanNetworkStatusTracker mIwlanNetworkStatusTracker;
protected DataConnectionStatusTracker mDataConnectionStatusTracker;
protected QnsEventDispatcher mQnsEventDispatcher;
- protected AlternativeEventListener mAltEventListener;
protected QnsCallStatusTracker mCallStatusTracker;
protected QnsProvisioningListener mQnsProvisioningListener;
protected QnsImsManager mQnsImsManager;
@@ -149,7 +148,6 @@ class AccessNetworkEvaluator {
Executor executor = new QnsUtils.QnsExecutor(mHandler);
mConfigManager = mQnsComponents.getQnsCarrierConfigManager(mSlotIndex);
- mAltEventListener = mQnsComponents.getAlternativeEventListener(mSlotIndex);
mCallStatusTracker = mQnsComponents.getQnsCallStatusTracker(mSlotIndex);
mQnsProvisioningListener = mQnsComponents.getQnsProvisioningListener(mSlotIndex);
mIwlanNetworkStatusTracker = mQnsComponents.getIwlanNetworkStatusTracker();
@@ -216,7 +214,6 @@ class AccessNetworkEvaluator {
mIwlanNetworkStatusTracker = mQnsComponents.getIwlanNetworkStatusTracker();
mDataConnectionStatusTracker = dataConnectionStatusTracker;
mQnsEventDispatcher = mQnsComponents.getQnsEventDispatcher(mSlotIndex);
- mAltEventListener = mQnsComponents.getAlternativeEventListener(mSlotIndex);
mCallStatusTracker = mQnsComponents.getQnsCallStatusTracker(mSlotIndex);
mQnsProvisioningListener = mQnsComponents.getQnsProvisioningListener(mSlotIndex);
mQnsImsManager = mQnsComponents.getQnsImsManager(mSlotIndex);
diff --git a/services/QualifiedNetworksService/src/com/android/telephony/qns/AlternativeEventListener.java b/services/QualifiedNetworksService/src/com/android/telephony/qns/AlternativeEventListener.java
deleted file mode 100644
index 36fdaa4..0000000
--- a/services/QualifiedNetworksService/src/com/android/telephony/qns/AlternativeEventListener.java
+++ /dev/null
@@ -1,501 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.telephony.qns;
-
-import static android.telephony.PreciseCallState.PRECISE_CALL_STATE_ACTIVE;
-import static android.telephony.PreciseCallState.PRECISE_CALL_STATE_ALERTING;
-import static android.telephony.PreciseCallState.PRECISE_CALL_STATE_DIALING;
-import static android.telephony.PreciseCallState.PRECISE_CALL_STATE_DISCONNECTED;
-import static android.telephony.PreciseCallState.PRECISE_CALL_STATE_HOLDING;
-import static android.telephony.PreciseCallState.PRECISE_CALL_STATE_IDLE;
-
-import android.annotation.NonNull;
-import android.annotation.Nullable;
-import android.content.Context;
-import android.net.NetworkCapabilities;
-import android.os.Handler;
-import android.os.Looper;
-import android.os.Message;
-import android.telephony.Annotation;
-import android.telephony.PreciseDataConnectionState;
-import android.telephony.TelephonyManager;
-import android.util.Log;
-import android.util.SparseArray;
-
-import com.android.internal.annotations.VisibleForTesting;
-
-class AlternativeEventListener {
- private static final int EVENT_SRVCC_STATE_CHANGED = 13001;
- private static final SparseArray<AlternativeEventListener> sAlternativeInterfaceManager =
- new SparseArray<>();
- private final String mLogTag;
- private Context mContext;
- private int mSlotIndex;
- private QnsTelephonyListener mQnsTelephonyListener;
- private QnsRegistrant mCallTypeChangedEventListener;
- private QnsRegistrant mEmergencyCallTypeChangedEventListener;
- private QnsRegistrant mEmergencyPreferredTransportTypeChanged;
- private QnsRegistrant mTryWfcConnectionState;
- private QnsRegistrant mLowRtpQuallityListener;
- private QnsRegistrant mEmcLowRtpQuallityListener;
- private AlternativeEventCb mEventCb;
- private AlternativeEventProvider mEventProvider;
- private Handler mHandler;
- private CallInfoManager mCallInfoManager = new CallInfoManager();
-
- class CallInfo {
- int mId;
- int mType;
- int mState;
-
- CallInfo(int id, int type, int state) {
- mId = id;
- mType = type;
- mState = state;
- }
- }
-
- /** Manager of CallInfo list. */
- private class CallInfoManager {
- private SparseArray<CallInfo> mCallInfos = new SparseArray<>();
- QnsCarrierConfigManager.RtpMetricsConfig mRtpMetricsConfig;
- int mEmergencyCallState = PRECISE_CALL_STATE_IDLE;
- int mLastReportedCallType = QnsConstants.CALL_TYPE_IDLE;
-
- CallInfoManager() {
- mRtpMetricsConfig = null;
- }
-
- void updateCallInfo(
- int id,
- @QnsConstants.QnsCallType int type,
- @Annotation.PreciseCallStates int state) {
- if (mRtpMetricsConfig != null && state == PRECISE_CALL_STATE_ACTIVE) {
- requestRtpThreshold(mRtpMetricsConfig);
- }
- if (type == QnsConstants.CALL_TYPE_EMERGENCY) {
- mEmergencyCallState = state;
- return;
- }
- if (type == QnsConstants.CALL_TYPE_VIDEO || type == QnsConstants.CALL_TYPE_VOICE) {
- CallInfo info = mCallInfos.get(id);
- if (info == null) {
- if (state == PRECISE_CALL_STATE_ACTIVE) {
- mCallInfos.put(id, new CallInfo(id, type, state));
- log("add callinfo with id " + id);
- }
- } else {
- if (info.mType != type) {
- log("CallId[" + info.mId + "] type changed " + info.mType + " > " + id);
- info.mType = type;
- }
- if (state == PRECISE_CALL_STATE_HOLDING) {
- log("CallId[" + info.mId + "] changed to HOLDING ");
- info.mState = state;
- } else if (state == PRECISE_CALL_STATE_ACTIVE) {
- log("CallId[" + info.mId + "] changed to ACTIVE ");
- info.mState = state;
- } else if (state == PRECISE_CALL_STATE_DISCONNECTED) {
- log("delete callInfo callId:" + id);
- mCallInfos.remove(id);
- }
- }
- }
- }
-
- boolean isCallIdle() {
- return mCallInfos.size() == 0;
- }
-
- CallInfo getActiveCallInfo() {
- for (int i = 0; i < mCallInfos.size(); i++) {
- int key = mCallInfos.keyAt(i);
- if (mCallInfos.get(key).mState == PRECISE_CALL_STATE_ACTIVE) {
- return mCallInfos.get(key);
- }
- }
- return null;
- }
-
- void clearCallInfo() {
- mCallInfos.clear();
- }
-
- boolean hasVideoCall() {
- for (int i = 0; i < mCallInfos.size(); i++) {
- int key = mCallInfos.keyAt(i);
- if (mCallInfos.get(key).mType == QnsConstants.CALL_TYPE_VIDEO) {
- return true;
- }
- }
- return false;
- }
-
- void requestRtpThreshold(QnsCarrierConfigManager.RtpMetricsConfig config) {
- if (config != null) {
- mRtpMetricsConfig =
- new QnsCarrierConfigManager.RtpMetricsConfig(
- config.mJitter,
- config.mPktLossRate,
- config.mPktLossTime,
- config.mNoRtpInterval);
- }
- CallInfo info = getActiveCallInfo();
- if (mEventProvider != null && info != null) {
- log("requestRtpThreshold callId:" + info.mId + " " + config.toString());
- mEventProvider.requestRtpThreshold(
- info.mId,
- mRtpMetricsConfig.mJitter,
- mRtpMetricsConfig.mPktLossRate,
- mRtpMetricsConfig.mPktLossTime,
- mRtpMetricsConfig.mNoRtpInterval);
- }
- }
- }
-
- class MessageHandler extends Handler {
- MessageHandler(Looper l) {
- super(l);
- }
-
- @Override
- public void handleMessage(Message message) {
- Log.d(mLogTag, "handleMessage msg=" + message.what);
- QnsAsyncResult ar = (QnsAsyncResult) message.obj;
- int state = (int) ar.mResult;
- switch (message.what) {
- case EVENT_SRVCC_STATE_CHANGED:
- onSrvccStateChanged(state);
- break;
- default:
- Log.d(mLogTag, "Unknown message received!");
- break;
- }
- }
- }
-
- /**
- * AlternativeEventListener constructor.
- */
- AlternativeEventListener(
- Context context, QnsTelephonyListener qnsTelephonyListener, int slotId) {
- mSlotIndex = slotId;
- mLogTag =
- QnsConstants.QNS_TAG
- + "_"
- + AlternativeEventListener.class.getSimpleName()
- + "_"
- + mSlotIndex;
- mContext = context;
- mQnsTelephonyListener = qnsTelephonyListener;
- mHandler = new AlternativeEventListener.MessageHandler(mContext.getMainLooper());
- mEventCb = new AlternativeEventCb();
- }
-
- /**
- * register emergency preferred transport type changed event.
- *
- * @param h Handler want to receive event.
- * @param what event Id to receive
- * @param userObj user object
- */
- void registerEmergencyPreferredTransportTypeChanged(
- @NonNull Handler h, int what, Object userObj) {
- mEmergencyPreferredTransportTypeChanged = new QnsRegistrant(h, what, userObj);
- }
-
- /** Unregister emergency preferred transport type changed event. */
- void unregisterEmergencyPreferredTransportTypeChanged() {
- mEmergencyPreferredTransportTypeChanged = null;
- }
-
- /**
- * register try WFC connection state change event.
- *
- * @param h Handler want to receive event
- * @param what event Id to receive
- * @param userObj user object
- */
- void registerTryWfcConnectionStateListener(@NonNull Handler h, int what, Object userObj) {
- mTryWfcConnectionState = new QnsRegistrant(h, what, userObj);
- }
-
- /**
- * Register low RTP quality event.
- *
- * @param netCapability Network Capability
- * @param h Handler want to receive event.
- * @param what event Id to receive
- * @param userObj user object
- */
- void registerLowRtpQualityEvent(
- int netCapability,
- @NonNull Handler h,
- int what,
- Object userObj,
- QnsCarrierConfigManager.RtpMetricsConfig config) {
- if (h != null) {
- QnsRegistrant r = new QnsRegistrant(h, what, userObj);
- if (netCapability == NetworkCapabilities.NET_CAPABILITY_IMS) {
- mLowRtpQuallityListener = r;
- } else if (netCapability == NetworkCapabilities.NET_CAPABILITY_EIMS) {
- mEmcLowRtpQuallityListener = r;
- }
- if (mEventProvider != null) {
- mCallInfoManager.requestRtpThreshold(config);
- }
- }
- }
-
- /**
- * Unregister low RTP quality event.
- *
- * @param netCapability Network Capability
- * @param h Handler want to receive event.
- */
- void unregisterLowRtpQualityEvent(int netCapability, @NonNull Handler h) {
- if (netCapability == NetworkCapabilities.NET_CAPABILITY_IMS) {
- mLowRtpQuallityListener = null;
- } else if (netCapability == NetworkCapabilities.NET_CAPABILITY_EIMS) {
- mEmcLowRtpQuallityListener = null;
- }
- mCallInfoManager.mRtpMetricsConfig = null;
- }
-
- /**
- * register call type changed event.
- *
- * @param netCapability Network Capability of caller
- * @param h Handler want to receive event.
- * @param what event Id to receive
- * @param userObj user object
- */
- void registerCallTypeChangedListener(
- int netCapability, @NonNull Handler h, int what, Object userObj) {
- if (netCapability != NetworkCapabilities.NET_CAPABILITY_IMS
- && netCapability != NetworkCapabilities.NET_CAPABILITY_EIMS) {
- log("registerCallTypeChangedListener : wrong netCapability");
- return;
- }
- if (h != null) {
- QnsRegistrant r = new QnsRegistrant(h, what, userObj);
- if (netCapability == NetworkCapabilities.NET_CAPABILITY_IMS) {
- mCallTypeChangedEventListener = r;
- mQnsTelephonyListener.registerSrvccStateListener(
- mHandler, EVENT_SRVCC_STATE_CHANGED, null);
- } else if (netCapability == NetworkCapabilities.NET_CAPABILITY_EIMS) {
- mEmergencyCallTypeChangedEventListener = r;
- }
- } else {
- log("registerCallTypeChangedListener : Handler is Null");
- }
- }
-
- /**
- * Unregister call type changed event.
- *
- * @param netCapability Network Capability of caller
- * @param h Handler want to receive event.
- */
- void unregisterCallTypeChangedListener(int netCapability, @NonNull Handler h) {
- if (netCapability != NetworkCapabilities.NET_CAPABILITY_IMS
- && netCapability != NetworkCapabilities.NET_CAPABILITY_EIMS) {
- log("unregisterCallTypeChangedListener : wrong netCapability");
- return;
- }
- if (h != null) {
- if (netCapability == NetworkCapabilities.NET_CAPABILITY_IMS) {
- mCallTypeChangedEventListener = null;
- mQnsTelephonyListener.unregisterSrvccStateChanged(mHandler);
- } else if (netCapability == NetworkCapabilities.NET_CAPABILITY_EIMS) {
- mEmergencyCallTypeChangedEventListener = null;
- }
- } else {
- log("unregisterCallTypeChangedListener : Handler is Null");
- }
- }
-
- /**
- * register EventProvider to EventListener
- *
- * @param provider extends of AlternativeEventProvider
- */
- void setEventProvider(AlternativeEventProvider provider) {
- log("setEventProvider provider " + provider);
- mEventProvider = provider;
- provider.registerCallBack(mEventCb);
- }
-
- @VisibleForTesting
- void onSrvccStateChanged(int srvccState) {
- if (srvccState == TelephonyManager.SRVCC_STATE_HANDOVER_COMPLETED) {
- mCallInfoManager.clearCallInfo();
- int callType = QnsConstants.CALL_TYPE_IDLE;
- mCallTypeChangedEventListener.notifyResult(callType);
- }
- }
-
- void clearNormalCallInfo() {
- mCallInfoManager.clearCallInfo();
- mCallInfoManager.mLastReportedCallType = QnsConstants.CALL_TYPE_IDLE;
- unregisterLowRtpQualityEvent(NetworkCapabilities.NET_CAPABILITY_IMS, null);
- }
-
- @VisibleForTesting
- void notifyRtpLowQuality(int callType, int reason) {
- if (callType == QnsConstants.CALL_TYPE_VOICE) {
- if (mLowRtpQuallityListener != null) {
- mLowRtpQuallityListener.notifyResult(reason);
- } else {
- log("notifyRtpLowQuality mLowRtpQuallityListener is null.");
- }
- } else if (callType == QnsConstants.CALL_TYPE_EMERGENCY) {
- if (mEmcLowRtpQuallityListener != null) {
- mEmcLowRtpQuallityListener.notifyResult(reason);
- } else {
- log("notifyRtpLowQuality mEmcLowRtpQuallityListener is null.");
- }
- if (mCallInfoManager.mLastReportedCallType == QnsConstants.CALL_TYPE_EMERGENCY) {
- if (mLowRtpQuallityListener != null) {
- log("notifyRtpLowQuality for emergency call to IMS ANE");
- mLowRtpQuallityListener.notifyResult(reason);
- } else {
- log("notifyRtpLowQuality mLowRtpQuallityListener is null.");
- }
- }
- }
- }
-
- class AlternativeEventCb implements AlternativeEventProvider.EventCallback {
- @Override
- public void onCallInfoChanged(
- int id,
- @QnsConstants.QnsCallType int type,
- @Annotation.PreciseCallStates int state) {
- log("onCallInfoChanged callId" + id + " type" + type + " state" + state);
-
- mCallInfoManager.updateCallInfo(id, type, state);
- if (type == QnsConstants.CALL_TYPE_EMERGENCY) {
- if (mEmergencyCallTypeChangedEventListener != null) {
- if (state == PRECISE_CALL_STATE_DISCONNECTED) {
- mEmergencyCallTypeChangedEventListener.notifyResult(
- QnsConstants.CALL_TYPE_IDLE);
- } else if (state == PRECISE_CALL_STATE_ACTIVE) {
- mEmergencyCallTypeChangedEventListener.notifyResult(
- QnsConstants.CALL_TYPE_EMERGENCY);
- }
- }
- if (mCallTypeChangedEventListener != null) {
- if ((state == PRECISE_CALL_STATE_ACTIVE
- || state == PRECISE_CALL_STATE_DIALING
- || state == PRECISE_CALL_STATE_ALERTING)
- && !isDataNetworkConnected(NetworkCapabilities.NET_CAPABILITY_EIMS)
- && isDataNetworkConnected(NetworkCapabilities.NET_CAPABILITY_IMS)) {
- log("Emergency call is progressing without emergency PDN");
- if (mCallInfoManager.mLastReportedCallType
- != QnsConstants.CALL_TYPE_EMERGENCY) {
- mCallTypeChangedEventListener.notifyResult(
- QnsConstants.CALL_TYPE_EMERGENCY);
- mCallInfoManager.mLastReportedCallType =
- QnsConstants.CALL_TYPE_EMERGENCY;
- }
- } else if (state == PRECISE_CALL_STATE_DISCONNECTED) {
- log("Emergency call disconnected");
- if (mCallInfoManager.mLastReportedCallType
- == QnsConstants.CALL_TYPE_EMERGENCY) {
- mCallTypeChangedEventListener.notifyResult(QnsConstants.CALL_TYPE_IDLE);
- mCallInfoManager.mLastReportedCallType = QnsConstants.CALL_TYPE_IDLE;
- }
- }
- }
- return;
- }
- if (mCallTypeChangedEventListener != null) {
- int callType = QnsConstants.CALL_TYPE_IDLE;
- if (mCallInfoManager.isCallIdle()) {
- callType = QnsConstants.CALL_TYPE_IDLE;
- } else if (mCallInfoManager.hasVideoCall()) {
- callType = QnsConstants.CALL_TYPE_VIDEO;
- } else {
- callType = QnsConstants.CALL_TYPE_VOICE;
- }
- if (mCallTypeChangedEventListener != null
- && mCallInfoManager.mLastReportedCallType != callType) {
- mCallTypeChangedEventListener.notifyResult(callType);
- mCallInfoManager.mLastReportedCallType = callType;
- }
- }
- }
-
- @Override
- public void onVoiceRtpLowQuality(@QnsConstants.RtpLowQualityReason int reason) {
- if (mCallInfoManager.mEmergencyCallState == PRECISE_CALL_STATE_ACTIVE) {
- notifyRtpLowQuality(QnsConstants.CALL_TYPE_EMERGENCY, reason);
- } else if (!mCallInfoManager.isCallIdle() && !mCallInfoManager.hasVideoCall()) {
- notifyRtpLowQuality(QnsConstants.CALL_TYPE_VOICE, reason);
- }
- }
-
- @Override
- public void onEmergencyPreferenceChanged(int preferredTransportType) {
- if (mEmergencyPreferredTransportTypeChanged != null) {
- mEmergencyPreferredTransportTypeChanged.notifyResult(preferredTransportType);
- }
- }
-
- @Override
- public void onTryWfcConnectionStateChanged(boolean isEnabled) {
- mTryWfcConnectionState.notifyResult(isEnabled);
- }
- }
-
- protected boolean isIdleState() {
- return mCallInfoManager.isCallIdle();
- }
-
- protected void setEcnoSignalThreshold(@Nullable int[] threshold) {
- if (mEventProvider != null) {
- mEventProvider.setEcnoSignalThreshold(threshold);
- }
- }
-
- private boolean isDataNetworkConnected(int netCapability) {
- PreciseDataConnectionState preciseDataStatus =
- mQnsTelephonyListener.getLastPreciseDataConnectionState(netCapability);
-
- if (preciseDataStatus == null) return false;
- int state = preciseDataStatus.getState();
- return (state == TelephonyManager.DATA_CONNECTED
- || state == TelephonyManager.DATA_HANDOVER_IN_PROGRESS
- || state == TelephonyManager.DATA_SUSPENDED);
- }
-
- @VisibleForTesting
- protected void close() {
- mCallTypeChangedEventListener = null;
- mEmergencyCallTypeChangedEventListener = null;
- mEmergencyPreferredTransportTypeChanged = null;
- mTryWfcConnectionState = null;
- mLowRtpQuallityListener = null;
- mEmcLowRtpQuallityListener = null;
- sAlternativeInterfaceManager.remove(mSlotIndex);
- }
-
- protected void log(String s) {
- Log.d(mLogTag, s);
- }
-}
diff --git a/services/QualifiedNetworksService/src/com/android/telephony/qns/AlternativeEventProvider.java b/services/QualifiedNetworksService/src/com/android/telephony/qns/AlternativeEventProvider.java
deleted file mode 100644
index b2ef78d..0000000
--- a/services/QualifiedNetworksService/src/com/android/telephony/qns/AlternativeEventProvider.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.telephony.qns;
-
-import android.annotation.NonNull;
-import android.annotation.Nullable;
-import android.telephony.AccessNetworkConstants;
-import android.telephony.Annotation;
-import android.util.Log;
-
-/** AlternativeEventProvider class */
-public abstract class AlternativeEventProvider {
- private EventCallback mEventCb;
- private final String mLogTag;
-
- public AlternativeEventProvider(AlternativeEventListener altEventListener, int slotId) {
- mLogTag =
- QnsConstants.QNS_TAG
- + "_"
- + AlternativeEventProvider.class.getSimpleName()
- + "_"
- + slotId;
- altEventListener.setEventProvider(this);
- }
-
- /**
- * Thins is to register RTP threshold.
- *
- * @param callId CallId
- * @param jitter RTP jitter value
- * @param packetLossRate RTP packet loss rate
- * @param packetLossTimeInMilliSec timer for RTP packet loss
- * @param noRtpTimeInMilliSec time for no incoming RTP
- */
- public abstract void requestRtpThreshold(
- int callId,
- int jitter,
- int packetLossRate,
- int packetLossTimeInMilliSec,
- int noRtpTimeInMilliSec);
-
- /**
- * This is to set signal strength threshold.
- *
- * @param threshold signal strength threshold values
- */
- public abstract void setEcnoSignalThreshold(@Nullable int[] threshold);
-
- /**
- * Event provider calls this to notify call info changed.
- *
- * @param id CallId
- * @param type CallType
- * @param state CallState
- */
- public void notifyCallInfo(int id, int type, int state) {
- if (mEventCb != null) {
- mEventCb.onCallInfoChanged(id, type, state);
- }
- }
-
- /**
- * Event provider calls this to notify RTP low quality
- *
- * @param reason RTP low quality reason.
- */
- public void notifyRtpLowQuality(@QnsConstants.RtpLowQualityReason int reason) {
- if (mEventCb != null) {
- mEventCb.onVoiceRtpLowQuality(reason);
- }
- }
-
- /**
- * Event provider needs to call this to notify Emergency preference change
- *
- * @param type Emergency transport type preference for initial data connection.
- */
- public void notifyEmergencyPreferredTransportType(
- @AccessNetworkConstants.TransportType int type) {
- if (mEventCb != null) {
- mEventCb.onEmergencyPreferenceChanged(type);
- }
- }
-
- /**
- * Event provider needs to call this to notify try WFC connection state change
- *
- * @param isEnabled try WFC connection
- */
- public void notifyTryWfcConnectionState(boolean isEnabled) {
- if (mEventCb != null) {
- mEventCb.onTryWfcConnectionStateChanged(isEnabled);
- }
- }
-
- /**
- * Listener need to register CallBack with implements of EventCallback.
- *
- * @param eventCb implements of EventCallback.
- */
- public void registerCallBack(@NonNull EventCallback eventCb) {
- log("registerCallBack" + eventCb);
- mEventCb = eventCb;
- }
-
- /** Event callback for call related item */
- public interface EventCallback {
- /**
- * call type event notification.
- *
- * @param id CallId
- * @param type CallType
- * @param state CallState
- */
- void onCallInfoChanged(
- int id,
- @QnsConstants.QnsCallType int type,
- @Annotation.PreciseCallStates int state);
-
- /**
- * RTP event notification.
- *
- * @param reason reason for RTP low quality
- */
- void onVoiceRtpLowQuality(@QnsConstants.RtpLowQualityReason int reason);
-
- /**
- * Notify Emergency Transport Type Preference for initial connect.
- *
- * @param transport Transport Type
- */
- void onEmergencyPreferenceChanged(@AccessNetworkConstants.TransportType int transport);
-
- /**
- * Try WFC connection state change notification.
- *
- * @param isEnabled flag value for WFC connection state change notification
- */
- void onTryWfcConnectionStateChanged(boolean isEnabled);
- }
-
- protected void log(String s) {
- Log.d(mLogTag, s);
- }
-}
diff --git a/services/QualifiedNetworksService/src/com/android/telephony/qns/QnsComponents.java b/services/QualifiedNetworksService/src/com/android/telephony/qns/QnsComponents.java
index 74809f7..04780e7 100644
--- a/services/QualifiedNetworksService/src/com/android/telephony/qns/QnsComponents.java
+++ b/services/QualifiedNetworksService/src/com/android/telephony/qns/QnsComponents.java
@@ -33,7 +33,6 @@ class QnsComponents {
private final String mLogTag = QnsComponents.class.getSimpleName();
private final Context mContext;
- private final SparseArray<AlternativeEventListener> mAlternativeEventListeners;
private final SparseArray<CellularNetworkStatusTracker> mCellularNetworkStatusTrackers;
private final SparseArray<CellularQualityMonitor> mCellularQualityMonitors;
private final SparseArray<QnsImsManager> mQnsImsManagers;
@@ -51,7 +50,6 @@ class QnsComponents {
/** Constructor to instantiate QnsComponents class. */
QnsComponents(Context context) {
mContext = context;
- mAlternativeEventListeners = new SparseArray<>();
mCellularNetworkStatusTrackers = new SparseArray<>();
mCellularQualityMonitors = new SparseArray<>();
mQnsImsManagers = new SparseArray<>();
@@ -69,9 +67,6 @@ class QnsComponents {
mSlotIds.add(slotId);
mQnsTelephonyListeners.put(slotId, new QnsTelephonyListener(mContext, slotId));
mQnsImsManagers.put(slotId, new QnsImsManager(mContext, slotId));
- mAlternativeEventListeners.put(
- slotId,
- new AlternativeEventListener(mContext, mQnsTelephonyListeners.get(slotId), slotId));
mCellularNetworkStatusTrackers.put(
slotId,
new CellularNetworkStatusTracker(mQnsTelephonyListeners.get(slotId), slotId));
@@ -127,7 +122,6 @@ class QnsComponents {
@VisibleForTesting
QnsComponents(
Context context,
- AlternativeEventListener alternativeEventListener,
CellularNetworkStatusTracker cellularNetworkStatusTracker,
CellularQualityMonitor cellularQualityMonitor,
IwlanNetworkStatusTracker iwlanNetworkStatusTracker,
@@ -145,7 +139,6 @@ class QnsComponents {
mSlotIds.add(slotId);
mQnsTelephonyListeners.put(slotId, qnsTelephonyListener);
mQnsImsManagers.put(slotId, qnsImsManager);
- mAlternativeEventListeners.put(slotId, alternativeEventListener);
mCellularNetworkStatusTrackers.put(slotId, cellularNetworkStatusTracker);
mCellularQualityMonitors.put(slotId, cellularQualityMonitor);
mQnsCallStatusTracker.put(slotId, qnsCallStatusTracker);
@@ -166,11 +159,6 @@ class QnsComponents {
mQnsMetrics = qnsMetrics;
}
- /** Returns instance of AlternativeEventListener for given slotId. */
- AlternativeEventListener getAlternativeEventListener(int slotId) {
- return mAlternativeEventListeners.get(slotId);
- }
-
/** Returns instance of CellularNetworkStatusTracker for given slotId. */
CellularNetworkStatusTracker getCellularNetworkStatusTracker(int slotId) {
return mCellularNetworkStatusTrackers.get(slotId);
@@ -284,11 +272,6 @@ class QnsComponents {
mCellularNetworkStatusTrackers.remove(slotId);
cellularTracker.close();
}
- AlternativeEventListener alternativeEventListener = mAlternativeEventListeners.get(slotId);
- if (alternativeEventListener != null) {
- mAlternativeEventListeners.remove(slotId);
- alternativeEventListener.close();
- }
QnsImsManager qnsImsManager = mQnsImsManagers.get(slotId);
if (qnsImsManager != null) {
mQnsImsManagers.remove(slotId);
diff --git a/services/QualifiedNetworksService/tests/src/com/android/telephony/qns/AlternativeEventListenerTest.java b/services/QualifiedNetworksService/tests/src/com/android/telephony/qns/AlternativeEventListenerTest.java
deleted file mode 100644
index f3583a3..0000000
--- a/services/QualifiedNetworksService/tests/src/com/android/telephony/qns/AlternativeEventListenerTest.java
+++ /dev/null
@@ -1,490 +0,0 @@
-/*
- * Copyright (C) 2022 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.telephony.qns;
-
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.when;
-
-import android.net.LinkProperties;
-import android.net.NetworkCapabilities;
-import android.os.Handler;
-import android.os.Message;
-import android.os.test.TestLooper;
-import android.telephony.AccessNetworkConstants;
-import android.telephony.PreciseCallState;
-import android.telephony.PreciseDataConnectionState;
-import android.telephony.TelephonyManager;
-import android.telephony.data.ApnSetting;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-@RunWith(JUnit4.class)
-public class AlternativeEventListenerTest extends QnsTest {
-
- AlternativeEventListener mListener;
- AltEventProvider mAltEventProvider;
- TestLooper mTestLooper;
- private static final int SLOT_INDEX = 0;
- private Handler mHandler;
- CountDownLatch mLatch;
- int[] mThresholds;
- // QnsTelephonyListener mQtListener;
-
- class AltEventProvider extends AlternativeEventProvider {
-
- AltEventProvider(AlternativeEventListener altEventListener, int slotId) {
- super(altEventListener, slotId);
- }
-
- @Override
- public void requestRtpThreshold(
- int callId,
- int jitter,
- int packetLossRate,
- int packetLossTimeInMilliSec,
- int noRtpTimeInMilliSec) {}
-
- @Override
- public void setEcnoSignalThreshold(int[] threshold) {
- if (mLatch != null) {
- mThresholds = threshold;
- mLatch.countDown();
- }
- }
- }
-
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
- super.setUp();
- mTestLooper = new TestLooper();
- Mockito.when(sMockContext.getMainLooper()).thenReturn(mTestLooper.getLooper());
- mHandler = new Handler(mTestLooper.getLooper());
- mListener = new AlternativeEventListener(sMockContext, mMockQnsTelephonyListener, 0);
- mAltEventProvider = new AltEventProvider(mMockAltEventListener, SLOT_INDEX);
- mListener.setEventProvider(mAltEventProvider);
- }
-
- @After
- public void tearDown() {
- mListener.close();
- }
-
- @Test
- public void testRegisterEmergencyPreferredTransportTypeChanged() {
- int[] expectedTransports =
- new int[] {
- AccessNetworkConstants.TRANSPORT_TYPE_WLAN,
- AccessNetworkConstants.TRANSPORT_TYPE_WWAN
- };
-
- mListener.registerEmergencyPreferredTransportTypeChanged(mHandler, 1, null);
-
- for (int expectedTransport : expectedTransports) {
- mAltEventProvider.notifyEmergencyPreferredTransportType(expectedTransport);
- Message msg = mTestLooper.nextMessage();
- assertNotNull(msg);
- QnsAsyncResult result = (QnsAsyncResult) msg.obj;
- assertNotNull(result.mResult);
- int actualTransport = (int) result.mResult;
- assertEquals(expectedTransport, actualTransport);
- }
- }
-
- @Test
- public void testUnregisterEmergencyPreferredTransportTypeChanged() {
- mListener.registerEmergencyPreferredTransportTypeChanged(mHandler, 1, null);
- mAltEventProvider.notifyEmergencyPreferredTransportType(
- AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
- Message msg = mTestLooper.nextMessage();
- assertNotNull(msg);
-
- mListener.unregisterEmergencyPreferredTransportTypeChanged();
- mAltEventProvider.notifyEmergencyPreferredTransportType(
- AccessNetworkConstants.TRANSPORT_TYPE_WLAN);
- msg = mTestLooper.nextMessage();
- assertNull(msg);
-
- mAltEventProvider.notifyEmergencyPreferredTransportType(
- AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
- msg = mTestLooper.nextMessage();
- assertNull(msg);
- }
-
- @Test
- public void testRegisterTryWfcConnectionStateListener() {
- mListener.registerTryWfcConnectionStateListener(mHandler, 1, null);
- boolean[] expectedStates = new boolean[] {false, true, false};
-
- for (boolean expectedState : expectedStates) {
- mAltEventProvider.notifyTryWfcConnectionState(expectedState);
- Message msg = mTestLooper.nextMessage();
- assertNotNull(msg);
- QnsAsyncResult result = (QnsAsyncResult) msg.obj;
- assertNotNull(result.mResult);
- boolean actualState = (boolean) result.mResult;
- assertEquals(expectedState, actualState);
- }
- }
-
- @Test
- public void testForRtpQualityScenarios() {
- QnsCarrierConfigManager.RtpMetricsConfig rtpConfig =
- new QnsCarrierConfigManager.RtpMetricsConfig(0, 0, 0, 0);
- int expectedReason = QnsConstants.RTP_LOW_QUALITY_REASON_JITTER;
-
- // register to IMS, Emergency:
- mListener.registerLowRtpQualityEvent(
- NetworkCapabilities.NET_CAPABILITY_IMS, mHandler, 1, null, rtpConfig);
- mListener.registerLowRtpQualityEvent(
- NetworkCapabilities.NET_CAPABILITY_EIMS, mHandler, 2, null, rtpConfig);
-
- mAltEventProvider.notifyCallInfo(
- 1, QnsConstants.CALL_TYPE_VOICE, PreciseCallState.PRECISE_CALL_STATE_ACTIVE);
- mAltEventProvider.notifyRtpLowQuality(expectedReason);
- Message msg = mTestLooper.nextMessage();
- assertNotNull(msg);
- QnsAsyncResult result = (QnsAsyncResult) msg.obj;
- assertNotNull(result.mResult);
- int actualReason = (int) result.mResult;
- assertEquals(expectedReason, actualReason);
-
- // Do not notify when call is disconnected:
- mAltEventProvider.notifyCallInfo(
- 1, QnsConstants.CALL_TYPE_VOICE, PreciseCallState.PRECISE_CALL_STATE_DISCONNECTED);
- mAltEventProvider.notifyRtpLowQuality(expectedReason);
- msg = mTestLooper.nextMessage();
- assertNull(msg);
-
- mAltEventProvider.notifyCallInfo(
- 2, QnsConstants.CALL_TYPE_EMERGENCY, PreciseCallState.PRECISE_CALL_STATE_ACTIVE);
- mAltEventProvider.notifyRtpLowQuality(expectedReason);
- msg = mTestLooper.nextMessage();
- assertNotNull(msg);
- result = (QnsAsyncResult) msg.obj;
- assertNotNull(result.mResult);
- actualReason = (int) result.mResult;
- assertEquals(expectedReason, actualReason);
-
- // Do not notify when call is disconnected:
- mAltEventProvider.notifyCallInfo(
- 1,
- QnsConstants.CALL_TYPE_EMERGENCY,
- PreciseCallState.PRECISE_CALL_STATE_DISCONNECTED);
- mAltEventProvider.notifyRtpLowQuality(expectedReason);
- msg = mTestLooper.nextMessage();
- assertNull(msg);
- }
-
- @Test
- public void testUnregisterLowRtpQualityEvent() {
- QnsCarrierConfigManager.RtpMetricsConfig rtpConfig =
- new QnsCarrierConfigManager.RtpMetricsConfig(0, 0, 0, 0);
- int expectedReason = QnsConstants.RTP_LOW_QUALITY_REASON_JITTER;
- mAltEventProvider.notifyCallInfo(
- 1, QnsConstants.CALL_TYPE_VOICE, PreciseCallState.PRECISE_CALL_STATE_ACTIVE);
-
- // register to IMS, Emergency:
- mListener.registerLowRtpQualityEvent(
- NetworkCapabilities.NET_CAPABILITY_IMS, mHandler, 1, null, rtpConfig);
- mListener.registerLowRtpQualityEvent(
- NetworkCapabilities.NET_CAPABILITY_EIMS, mHandler, 2, null, rtpConfig);
- mAltEventProvider.notifyRtpLowQuality(expectedReason);
- Message msg = mTestLooper.nextMessage();
- assertNotNull(msg);
-
- // unregister for IMS
- mListener.unregisterLowRtpQualityEvent(NetworkCapabilities.NET_CAPABILITY_IMS, mHandler);
- mAltEventProvider.notifyRtpLowQuality(expectedReason);
- msg = mTestLooper.nextMessage();
- assertNull(msg);
-
- // Event still registered for emergency, hence it should be notified:
- mAltEventProvider.notifyCallInfo(
- 1, QnsConstants.CALL_TYPE_EMERGENCY, PreciseCallState.PRECISE_CALL_STATE_ACTIVE);
- mAltEventProvider.notifyRtpLowQuality(expectedReason);
- msg = mTestLooper.nextMessage();
- assertNotNull(msg);
-
- // unregister for Emergency:
- mListener.unregisterLowRtpQualityEvent(NetworkCapabilities.NET_CAPABILITY_EIMS, mHandler);
- mAltEventProvider.notifyRtpLowQuality(expectedReason);
- msg = mTestLooper.nextMessage();
- assertNull(msg);
- }
-
- @Test
- public void testForCallTypeChangedScenarios() {
- mListener.registerCallTypeChangedListener(
- NetworkCapabilities.NET_CAPABILITY_IMS, null, 1, null);
- mListener.registerCallTypeChangedListener(
- NetworkCapabilities.NET_CAPABILITY_IMS, mHandler, 1, null);
- mListener.registerCallTypeChangedListener(
- NetworkCapabilities.NET_CAPABILITY_EIMS, mHandler, 1, null);
- mListener.registerCallTypeChangedListener(
- NetworkCapabilities.NET_CAPABILITY_MMS, mHandler, 1, null);
-
- // Test1:
- mAltEventProvider.notifyCallInfo(
- 1, QnsConstants.CALL_TYPE_VOICE, PreciseCallState.PRECISE_CALL_STATE_ACTIVE);
-
- Message msg = mTestLooper.nextMessage();
- assertNotNull(msg);
- QnsAsyncResult result = (QnsAsyncResult) msg.obj;
- assertNotNull(result.mResult);
- assertEquals(QnsConstants.CALL_TYPE_VOICE, (int) result.mResult);
- assertFalse(mListener.isIdleState()); // for IMS calls only
-
- // Test2:
- mAltEventProvider.notifyCallInfo(
- 1, QnsConstants.CALL_TYPE_VOICE, PreciseCallState.PRECISE_CALL_STATE_ACTIVE);
- msg = mTestLooper.nextMessage();
-
- // Should not notify if call type is not changed
- assertNull(msg);
-
- // Test3:
- mAltEventProvider.notifyCallInfo(
- 1, QnsConstants.CALL_TYPE_VOICE, PreciseCallState.PRECISE_CALL_STATE_DISCONNECTED);
- msg = mTestLooper.nextMessage();
- assertNotNull(msg);
- result = (QnsAsyncResult) msg.obj;
- assertNotNull(result.mResult);
- assertEquals(QnsConstants.CALL_TYPE_IDLE, (int) result.mResult);
- assertTrue(mListener.isIdleState()); // for IMS calls only
-
- // Test4:
- mAltEventProvider.notifyCallInfo(
- 2, QnsConstants.CALL_TYPE_EMERGENCY, PreciseCallState.PRECISE_CALL_STATE_ACTIVE);
- msg = mTestLooper.nextMessage();
- assertNotNull(msg);
- result = (QnsAsyncResult) msg.obj;
- assertNotNull(result.mResult);
- assertEquals(QnsConstants.CALL_TYPE_EMERGENCY, (int) result.mResult);
-
- // Test5:
- mAltEventProvider.notifyCallInfo(
- 2,
- QnsConstants.CALL_TYPE_EMERGENCY,
- PreciseCallState.PRECISE_CALL_STATE_DISCONNECTED);
- msg = mTestLooper.nextMessage();
- assertNotNull(msg);
- result = (QnsAsyncResult) msg.obj;
- assertNotNull(result.mResult);
- assertEquals(QnsConstants.CALL_TYPE_IDLE, (int) result.mResult);
- }
-
- @Test
- public void testUnregisterCallTypeChangedListener() {
- mListener.registerCallTypeChangedListener(
- NetworkCapabilities.NET_CAPABILITY_IMS, null, 1, null);
- mListener.registerCallTypeChangedListener(
- NetworkCapabilities.NET_CAPABILITY_IMS, mHandler, 1, null);
- mListener.registerCallTypeChangedListener(
- NetworkCapabilities.NET_CAPABILITY_EIMS, mHandler, 1, null);
- mListener.registerCallTypeChangedListener(
- NetworkCapabilities.NET_CAPABILITY_MMS, mHandler, 1, null);
-
- mAltEventProvider.notifyCallInfo(
- 1, QnsConstants.CALL_TYPE_VOICE, PreciseCallState.PRECISE_CALL_STATE_ACTIVE);
- Message msg = mTestLooper.nextMessage();
- assertNotNull(msg);
-
- mListener.unregisterCallTypeChangedListener(
- NetworkCapabilities.NET_CAPABILITY_IMS, mHandler);
- mAltEventProvider.notifyCallInfo(
- 1, QnsConstants.CALL_TYPE_VOICE, PreciseCallState.PRECISE_CALL_STATE_DISCONNECTED);
- msg = mTestLooper.nextMessage();
- assertNull(msg);
-
- mAltEventProvider.notifyCallInfo(
- 1, QnsConstants.CALL_TYPE_EMERGENCY, PreciseCallState.PRECISE_CALL_STATE_ACTIVE);
- msg = mTestLooper.nextMessage();
- assertNotNull(msg);
-
- mListener.unregisterCallTypeChangedListener(
- NetworkCapabilities.NET_CAPABILITY_EIMS, mHandler);
- mAltEventProvider.notifyCallInfo(
- 1,
- QnsConstants.CALL_TYPE_EMERGENCY,
- PreciseCallState.PRECISE_CALL_STATE_DISCONNECTED);
- msg = mTestLooper.nextMessage();
- assertNull(msg);
- }
-
- @Test
- public void testEmergencyOverImsCallTypeChangedScenarios() {
- mListener.registerCallTypeChangedListener(
- NetworkCapabilities.NET_CAPABILITY_IMS, mHandler, 1, null);
- PreciseDataConnectionState emergencyDataStatus =
- new PreciseDataConnectionState.Builder()
- .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_INVALID)
- .setState(TelephonyManager.DATA_DISCONNECTED)
- .setNetworkType(AccessNetworkConstants.AccessNetworkType.EUTRAN)
- .setApnSetting(
- new ApnSetting.Builder()
- .setApnTypeBitmask(ApnSetting.TYPE_EMERGENCY)
- .setApnName("sos")
- .setEntryName("sos")
- .build())
- .setLinkProperties(new LinkProperties())
- .build();
- PreciseDataConnectionState imsDataStatus =
- new PreciseDataConnectionState.Builder()
- .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WLAN)
- .setState(TelephonyManager.DATA_CONNECTED)
- .setNetworkType(AccessNetworkConstants.AccessNetworkType.IWLAN)
- .setApnSetting(
- new ApnSetting.Builder()
- .setApnTypeBitmask(ApnSetting.TYPE_IMS)
- .setApnName("ims")
- .setEntryName("ims")
- .build())
- .build();
-
- when(mMockQnsTelephonyListener.getLastPreciseDataConnectionState(
- NetworkCapabilities.NET_CAPABILITY_EIMS))
- .thenReturn(emergencyDataStatus);
- when(mMockQnsTelephonyListener.getLastPreciseDataConnectionState(
- NetworkCapabilities.NET_CAPABILITY_IMS))
- .thenReturn(imsDataStatus);
- // Test1:
- mAltEventProvider.notifyCallInfo(
- 1, QnsConstants.CALL_TYPE_EMERGENCY, PreciseCallState.PRECISE_CALL_STATE_DIALING);
-
- Message msg = mTestLooper.nextMessage();
- assertNotNull(msg);
- QnsAsyncResult result = (QnsAsyncResult) msg.obj;
- assertNotNull(result.mResult);
- assertEquals(QnsConstants.CALL_TYPE_EMERGENCY, (int) result.mResult);
-
- // Test2:
- mAltEventProvider.notifyCallInfo(
- 1, QnsConstants.CALL_TYPE_EMERGENCY, PreciseCallState.PRECISE_CALL_STATE_ACTIVE);
- msg = mTestLooper.nextMessage();
-
- // Should not notify if call type is not changed
- assertNull(msg);
-
- // Test3:
- imsDataStatus =
- new PreciseDataConnectionState.Builder()
- .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_INVALID)
- .setState(TelephonyManager.DATA_DISCONNECTED)
- .setNetworkType(AccessNetworkConstants.AccessNetworkType.EUTRAN)
- .setApnSetting(
- new ApnSetting.Builder()
- .setApnTypeBitmask(ApnSetting.TYPE_IMS)
- .setApnName("ims")
- .setEntryName("ims")
- .build())
- .build();
- Mockito.clearInvocations(mMockQnsTelephonyListener);
- when(mMockQnsTelephonyListener.getLastPreciseDataConnectionState(
- NetworkCapabilities.NET_CAPABILITY_IMS))
- .thenReturn(imsDataStatus);
-
- mAltEventProvider.notifyCallInfo(
- 1,
- QnsConstants.CALL_TYPE_EMERGENCY,
- PreciseCallState.PRECISE_CALL_STATE_DISCONNECTED);
- msg = mTestLooper.nextMessage();
- assertNotNull(msg);
- result = (QnsAsyncResult) msg.obj;
- assertNotNull(result.mResult);
- assertEquals(QnsConstants.CALL_TYPE_IDLE, (int) result.mResult);
-
- // Test4:
- emergencyDataStatus =
- new PreciseDataConnectionState.Builder()
- .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WLAN)
- .setState(TelephonyManager.DATA_CONNECTED)
- .setNetworkType(AccessNetworkConstants.AccessNetworkType.IWLAN)
- .setApnSetting(
- new ApnSetting.Builder()
- .setApnTypeBitmask(ApnSetting.TYPE_EMERGENCY)
- .setApnName("sos")
- .setEntryName("sos")
- .build())
- .build();
- Mockito.clearInvocations(mMockQnsTelephonyListener);
- when(mMockQnsTelephonyListener.getLastPreciseDataConnectionState(
- NetworkCapabilities.NET_CAPABILITY_EIMS))
- .thenReturn(emergencyDataStatus);
- imsDataStatus =
- new PreciseDataConnectionState.Builder()
- .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WLAN)
- .setState(TelephonyManager.DATA_CONNECTED)
- .setNetworkType(AccessNetworkConstants.AccessNetworkType.IWLAN)
- .setApnSetting(
- new ApnSetting.Builder()
- .setApnTypeBitmask(ApnSetting.TYPE_IMS)
- .setApnName("ims")
- .setEntryName("ims")
- .build())
- .build();
- Mockito.clearInvocations(mMockQnsTelephonyListener);
- when(mMockQnsTelephonyListener.getLastPreciseDataConnectionState(
- NetworkCapabilities.NET_CAPABILITY_IMS))
- .thenReturn(imsDataStatus);
- mAltEventProvider.notifyCallInfo(
- 2, QnsConstants.CALL_TYPE_EMERGENCY, PreciseCallState.PRECISE_CALL_STATE_ACTIVE);
- msg = mTestLooper.nextMessage();
- assertNull(msg);
- }
-
- @Test
- public void testOnSrvccStateChanged() {
- mListener.registerCallTypeChangedListener(
- NetworkCapabilities.NET_CAPABILITY_IMS, mHandler, 1, null);
-
- mListener.onSrvccStateChanged(TelephonyManager.SRVCC_STATE_HANDOVER_COMPLETED);
- Message msg = mTestLooper.nextMessage();
- assertNotNull(msg);
- QnsAsyncResult result = (QnsAsyncResult) msg.obj;
- assertNotNull(result.mResult);
- assertEquals(QnsConstants.CALL_TYPE_IDLE, (int) result.mResult);
-
- mListener.onSrvccStateChanged(TelephonyManager.SRVCC_STATE_HANDOVER_STARTED);
- msg = mTestLooper.nextMessage();
- assertNull(msg);
- }
-
- @Test
- public void isIdleState() {
- mListener.isIdleState();
- }
-
- @Test
- public void setEcnoSignalThreshold() throws InterruptedException {
- mLatch = new CountDownLatch(1);
- int[] ecnoThresholds = new int[] {-85, -90, -95};
- mListener.setEcnoSignalThreshold(ecnoThresholds);
- assertTrue(mLatch.await(100, TimeUnit.MILLISECONDS));
- assertNotNull(mThresholds);
- assertArrayEquals(ecnoThresholds, mThresholds);
- }
-}
diff --git a/services/QualifiedNetworksService/tests/src/com/android/telephony/qns/QnsComponentsTest.java b/services/QualifiedNetworksService/tests/src/com/android/telephony/qns/QnsComponentsTest.java
index 8b7bff3..8d88d75 100644
--- a/services/QualifiedNetworksService/tests/src/com/android/telephony/qns/QnsComponentsTest.java
+++ b/services/QualifiedNetworksService/tests/src/com/android/telephony/qns/QnsComponentsTest.java
@@ -42,7 +42,6 @@ public class QnsComponentsTest extends QnsTest {
assertNull(qnsComponents.getQnsTelephonyListener(slotId));
assertNull(qnsComponents.getQnsImsManager(slotId));
- assertNull(qnsComponents.getAlternativeEventListener(slotId));
assertNull(qnsComponents.getCellularNetworkStatusTracker(slotId));
assertNull(qnsComponents.getCellularQualityMonitor(slotId));
assertNull(qnsComponents.getQnsProvisioningListener(slotId));
@@ -57,7 +56,6 @@ public class QnsComponentsTest extends QnsTest {
assertNotNull(qnsComponents.getQnsTelephonyListener(slotId));
assertNotNull(qnsComponents.getQnsImsManager(slotId));
- assertNotNull(qnsComponents.getAlternativeEventListener(slotId));
assertNotNull(qnsComponents.getCellularNetworkStatusTracker(slotId));
assertNotNull(qnsComponents.getCellularQualityMonitor(slotId));
assertNotNull(qnsComponents.getQnsProvisioningListener(slotId));
@@ -75,7 +73,6 @@ public class QnsComponentsTest extends QnsTest {
int slotId = 0;
QnsComponents qnsComponents = new QnsComponents(
sMockContext,
- mMockAltEventListener,
mMockCellNetStatusTracker,
mMockCellularQm,
mMockIwlanNetworkStatusTracker,
@@ -92,7 +89,6 @@ public class QnsComponentsTest extends QnsTest {
assertNotNull(qnsComponents.getQnsTelephonyListener(slotId));
assertNotNull(qnsComponents.getQnsImsManager(slotId));
- assertNotNull(qnsComponents.getAlternativeEventListener(slotId));
assertNotNull(qnsComponents.getCellularNetworkStatusTracker(slotId));
assertNotNull(qnsComponents.getCellularQualityMonitor(slotId));
assertNotNull(qnsComponents.getQnsProvisioningListener(slotId));
@@ -108,7 +104,6 @@ public class QnsComponentsTest extends QnsTest {
assertNull(qnsComponents.getQnsTelephonyListener(slotId));
assertNull(qnsComponents.getQnsImsManager(slotId));
- assertNull(qnsComponents.getAlternativeEventListener(slotId));
assertNull(qnsComponents.getCellularNetworkStatusTracker(slotId));
assertNull(qnsComponents.getCellularQualityMonitor(slotId));
assertNull(qnsComponents.getQnsProvisioningListener(slotId));
@@ -122,7 +117,6 @@ public class QnsComponentsTest extends QnsTest {
verify(mMockQnsTelephonyListener).close();
verify(mMockQnsImsManager).close();
- verify(mMockAltEventListener).close();
verify(mMockCellNetStatusTracker).close();
verify(mMockCellularQm).close();
verify(mMockQnsProvisioningListener).close();
diff --git a/services/QualifiedNetworksService/tests/src/com/android/telephony/qns/QnsTest.java b/services/QualifiedNetworksService/tests/src/com/android/telephony/qns/QnsTest.java
index d535d97..c973a25 100644
--- a/services/QualifiedNetworksService/tests/src/com/android/telephony/qns/QnsTest.java
+++ b/services/QualifiedNetworksService/tests/src/com/android/telephony/qns/QnsTest.java
@@ -69,7 +69,6 @@ public abstract class QnsTest {
@Mock protected Resources mMockResources;
// qns mocks
- @Mock AlternativeEventListener mMockAltEventListener;
@Mock protected IwlanNetworkStatusTracker mMockIwlanNetworkStatusTracker;
@Mock protected WifiQualityMonitor mMockWifiQm;
@Mock protected CellularNetworkStatusTracker mMockCellNetStatusTracker;
@@ -101,7 +100,6 @@ public abstract class QnsTest {
mQnsComponents[0] =
new QnsComponents(
sMockContext,
- mMockAltEventListener,
mMockCellNetStatusTracker,
mMockCellularQm,
mMockIwlanNetworkStatusTracker,
@@ -119,7 +117,6 @@ public abstract class QnsTest {
mQnsComponents[1] =
new QnsComponents(
sMockContext,
- mMockAltEventListener,
mMockCellNetStatusTracker,
mMockCellularQm,
mMockIwlanNetworkStatusTracker,
diff --git a/services/QualifiedNetworksService/tests/src/com/android/telephony/qns/QualifiedNetworksServiceImplTest.java b/services/QualifiedNetworksService/tests/src/com/android/telephony/qns/QualifiedNetworksServiceImplTest.java
index 9e08cfa..87eb761 100644
--- a/services/QualifiedNetworksService/tests/src/com/android/telephony/qns/QualifiedNetworksServiceImplTest.java
+++ b/services/QualifiedNetworksService/tests/src/com/android/telephony/qns/QualifiedNetworksServiceImplTest.java
@@ -81,7 +81,6 @@ public class QualifiedNetworksServiceImplTest extends QnsTest {
TestQnsComponents(int slotId) {
super(
sMockContext,
- mMockAltEventListener,
mMockCellNetStatusTracker,
mMockCellularQm,
mMockIwlanNetworkStatusTracker,
diff --git a/services/QualifiedNetworksService/tests/src/com/android/telephony/qns/RestrictManagerTest.java b/services/QualifiedNetworksService/tests/src/com/android/telephony/qns/RestrictManagerTest.java
index 67d1382..f897366 100644
--- a/services/QualifiedNetworksService/tests/src/com/android/telephony/qns/RestrictManagerTest.java
+++ b/services/QualifiedNetworksService/tests/src/com/android/telephony/qns/RestrictManagerTest.java
@@ -84,7 +84,6 @@ public class RestrictManagerTest extends QnsTest {
@Mock DataConnectionStatusTracker mMockDcst;
private MockitoSession mMockSession;
- private AlternativeEventListener mAltListener;
private QnsTelephonyListener mTelephonyListener;
private static final int DEFAULT_GUARDING_TIME = 30000;
@@ -100,9 +99,6 @@ public class RestrictManagerTest extends QnsTest {
@Override
protected void onLooperPrepared() {
super.onLooperPrepared();
- mAltListener =
- new AlternativeEventListener(
- sMockContext, mMockQnsTelephonyListener, 0);
mTelephonyListener = new QnsTelephonyListener(sMockContext, 0);
mQnsImsManager = new QnsImsManager(sMockContext, 0);
setReady(true);
@@ -135,7 +131,6 @@ public class RestrictManagerTest extends QnsTest {
mQnsComponents[0] =
new QnsComponents(
sMockContext,
- mAltListener,
mMockCellNetStatusTracker,
mMockCellularQm,
mMockIwlanNetworkStatusTracker,