diff options
8 files changed, 162 insertions, 12 deletions
diff --git a/api/system-current.txt b/api/system-current.txt index f3b1302597f9..d84830fedd93 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -6109,6 +6109,7 @@ package android.telephony.ims { } public class ImsCallSessionListener { + method public void callQualityChanged(android.telephony.CallQuality); method public void callSessionConferenceExtendFailed(android.telephony.ims.ImsReasonInfo); method public void callSessionConferenceExtendReceived(android.telephony.ims.stub.ImsCallSessionImplBase, android.telephony.ims.ImsCallProfile); method public void callSessionConferenceExtended(android.telephony.ims.stub.ImsCallSessionImplBase, android.telephony.ims.ImsCallProfile); diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java index ead9cab86f7f..122112b7a7d4 100644 --- a/services/core/java/com/android/server/TelephonyRegistry.java +++ b/services/core/java/com/android/server/TelephonyRegistry.java @@ -32,6 +32,8 @@ import android.os.IBinder; import android.os.Message; import android.os.RemoteException; import android.os.UserHandle; +import android.telephony.CallAttributes; +import android.telephony.CallQuality; import android.telephony.CellInfo; import android.telephony.CellLocation; import android.telephony.DataFailCause; @@ -173,6 +175,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { private ServiceState[] mServiceState; + private int[] mNetworkType; + private int[] mVoiceActivationState; private int[] mDataActivationState; @@ -202,6 +206,10 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { private Map<Integer, List<EmergencyNumber>> mEmergencyNumberList; + private CallQuality mCallQuality; + + private CallAttributes mCallAttributes; + private int[] mSrvccState; private int mDefaultSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; @@ -358,6 +366,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { mDataConnectionNetworkType = new int[numPhones]; mCallIncomingNumber = new String[numPhones]; mServiceState = new ServiceState[numPhones]; + mNetworkType = new int[numPhones]; mVoiceActivationState = new int[numPhones]; mDataActivationState = new int[numPhones]; mUserMobileDataState = new boolean[numPhones]; @@ -377,6 +386,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { mDataActivationState[i] = TelephonyManager.SIM_ACTIVATION_STATE_UNKNOWN; mCallIncomingNumber[i] = ""; mServiceState[i] = new ServiceState(); + mNetworkType[i] = mServiceState[i].getVoiceNetworkType(); mSignalStrength[i] = new SignalStrength(); mUserMobileDataState[i] = false; mMessageWaiting[i] = false; @@ -807,6 +817,13 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { remove(r.binder); } } + if ((events & PhoneStateListener.LISTEN_CALL_ATTRIBUTES_CHANGED) != 0) { + try { + r.callback.onCallAttributesChanged(mCallAttributes); + } catch (RemoteException ex) { + remove(r.binder); + } + } } } } else { @@ -957,6 +974,21 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { if (validatePhoneId(phoneId)) { mServiceState[phoneId] = state; + boolean notifyCallAttributes = true; + if (mNetworkType[phoneId] != mServiceState[phoneId].getVoiceNetworkType()) { + mNetworkType[phoneId] = state.getVoiceNetworkType(); + mCallAttributes = new CallAttributes(mPreciseCallState, mNetworkType[phoneId], + mCallQuality); + } else { + // No change to network type, so no need to notify call attributes + notifyCallAttributes = false; + } + + if (mCallQuality == null) { + // No call quality reported yet, so no need to notify call attributes + notifyCallAttributes = false; + } + for (Record r : mRecords) { if (VDBG) { log("notifyServiceStateForSubscriber: r=" + r + " subId=" + subId @@ -975,6 +1007,14 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { mRemoveList.add(r.binder); } } + if (notifyCallAttributes && r.matchPhoneStateListenerEvent( + PhoneStateListener.LISTEN_CALL_ATTRIBUTES_CHANGED)) { + try { + r.callback.onCallAttributesChanged(mCallAttributes); + } catch (RemoteException ex) { + mRemoveList.add(r.binder); + } + } } } else { log("notifyServiceStateForSubscriber: INVALID phoneId=" + phoneId); @@ -1484,7 +1524,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { } public void notifyPreciseCallState(int ringingCallState, int foregroundCallState, - int backgroundCallState) { + int backgroundCallState, int phoneId) { if (!checkNotifyPermission("notifyPreciseCallState()")) { return; } @@ -1496,6 +1536,15 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { backgroundCallState, DisconnectCause.NOT_VALID, PreciseDisconnectCause.NOT_VALID); + boolean notifyCallAttributes = true; + if (mCallQuality == null) { + log("notifyPreciseCallState: mCallQuality is null, skipping call attributes"); + notifyCallAttributes = false; + } else { + mCallAttributes = new CallAttributes(mPreciseCallState, mNetworkType[phoneId], + mCallQuality); + } + for (Record r : mRecords) { if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_PRECISE_CALL_STATE)) { try { @@ -1504,6 +1553,14 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { mRemoveList.add(r.binder); } } + if (notifyCallAttributes && r.matchPhoneStateListenerEvent( + PhoneStateListener.LISTEN_CALL_ATTRIBUTES_CHANGED)) { + try { + r.callback.onCallAttributesChanged(mCallAttributes); + } catch (RemoteException ex) { + mRemoveList.add(r.binder); + } + } } handleRemoveListLocked(); } @@ -1722,6 +1779,36 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { } } + @Override + public void notifyCallQualityChanged(CallQuality callQuality, int phoneId) { + if (!checkNotifyPermission("notifyCallQualityChanged()")) { + return; + } + + // merge CallQuality with PreciseCallState and network type + mCallQuality = callQuality; + mCallAttributes = new CallAttributes(mPreciseCallState, + mNetworkType[phoneId], + callQuality); + + synchronized (mRecords) { + TelephonyManager tm = (TelephonyManager) mContext.getSystemService( + Context.TELEPHONY_SERVICE); + + for (Record r : mRecords) { + if (r.matchPhoneStateListenerEvent( + PhoneStateListener.LISTEN_CALL_ATTRIBUTES_CHANGED)) { + try { + r.callback.onCallAttributesChanged(mCallAttributes); + } catch (RemoteException ex) { + mRemoveList.add(r.binder); + } + } + } + handleRemoveListLocked(); + } + } + @Override public void dump(FileDescriptor fd, PrintWriter writer, String[] args) { @@ -1739,6 +1826,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { pw.println("mCallState=" + mCallState[i]); pw.println("mCallIncomingNumber=" + mCallIncomingNumber[i]); pw.println("mServiceState=" + mServiceState[i]); + pw.println("mNetworkType=" + mNetworkType[i]); pw.println("mVoiceActivationState= " + mVoiceActivationState[i]); pw.println("mDataActivationState= " + mDataActivationState[i]); pw.println("mUserMobileDataState= " + mUserMobileDataState[i]); @@ -1764,6 +1852,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { pw.println("mPreferredDataSubId=" + mPreferredDataSubId); pw.println("mRadioPowerState=" + mRadioPowerState); pw.println("mEmergencyNumberList=" + mEmergencyNumberList); + pw.println("mCallQuality=" + mCallQuality); + pw.println("mCallAttributes=" + mCallAttributes); pw.decreaseIndent(); @@ -2021,6 +2111,11 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { android.Manifest.permission.READ_PRECISE_PHONE_STATE, null); } + if ((events & PhoneStateListener.LISTEN_CALL_ATTRIBUTES_CHANGED) != 0) { + mContext.enforceCallingOrSelfPermission( + android.Manifest.permission.READ_PRECISE_PHONE_STATE, null); + } + return true; } diff --git a/telephony/java/android/telephony/ims/ImsCallSession.java b/telephony/java/android/telephony/ims/ImsCallSession.java index 397d5d9b4eb5..47c468121484 100644 --- a/telephony/java/android/telephony/ims/ImsCallSession.java +++ b/telephony/java/android/telephony/ims/ImsCallSession.java @@ -18,6 +18,7 @@ package android.telephony.ims; import android.os.Message; import android.os.RemoteException; +import android.telephony.CallQuality; import android.telephony.ims.aidl.IImsCallSessionListener; import android.util.Log; @@ -450,6 +451,13 @@ public class ImsCallSession { public void callSessionRttAudioIndicatorChanged(ImsStreamMediaProfile profile) { // no-op } + + /** + * Called when the IMS service reports a change to the call quality. + */ + public void callQualityChanged(CallQuality callQuality) { + // no-op + } } private final IImsCallSession miSession; @@ -1414,6 +1422,16 @@ public class ImsCallSession { mListener.callSessionRttAudioIndicatorChanged(profile); } } + + /** + * Call quality updated + */ + @Override + public void callQualityChanged(CallQuality callQuality) { + if (mListener != null) { + mListener.callQualityChanged(callQuality); + } + } } /** diff --git a/telephony/java/android/telephony/ims/ImsCallSessionListener.java b/telephony/java/android/telephony/ims/ImsCallSessionListener.java index a4696a3f93aa..337375ac51c3 100644 --- a/telephony/java/android/telephony/ims/ImsCallSessionListener.java +++ b/telephony/java/android/telephony/ims/ImsCallSessionListener.java @@ -18,6 +18,7 @@ package android.telephony.ims; import android.annotation.SystemApi; import android.os.RemoteException; +import android.telephony.CallQuality; import android.telephony.ims.aidl.IImsCallSessionListener; import android.telephony.ims.stub.ImsCallSessionImplBase; @@ -612,5 +613,18 @@ public class ImsCallSessionListener { throw new RuntimeException(e); } } + + /** + * The call quality has changed. + * + * @param callQuality The new call quality + */ + public void callQualityChanged(CallQuality callQuality) { + try { + mListener.callQualityChanged(callQuality); + } catch (RemoteException e) { + throw new RuntimeException(e); + } + } } diff --git a/telephony/java/android/telephony/ims/aidl/IImsCallSessionListener.aidl b/telephony/java/android/telephony/ims/aidl/IImsCallSessionListener.aidl index d0b31e16a4f0..d64e67a40201 100644 --- a/telephony/java/android/telephony/ims/aidl/IImsCallSessionListener.aidl +++ b/telephony/java/android/telephony/ims/aidl/IImsCallSessionListener.aidl @@ -16,6 +16,7 @@ package android.telephony.ims.aidl; +import android.telephony.CallQuality; import android.telephony.ims.ImsStreamMediaProfile; import android.telephony.ims.ImsCallProfile; import android.telephony.ims.ImsReasonInfo; @@ -126,22 +127,29 @@ oneway interface IImsCallSessionListener { */ void callSessionRttModifyRequestReceived(in ImsCallProfile callProfile); - /* Device issued RTT modify request and inturn received response + /** + * Device issued RTT modify request and inturn received response * from Remote UE * @param status Will be one of the following values from: * - {@link Connection.RttModifyStatus} */ void callSessionRttModifyResponseReceived(int status); - /* + /** * While in call, device received RTT message from Remote UE * @param rttMessage Received RTT message */ void callSessionRttMessageReceived(in String rttMessage); - /* + /** * While in call, there has been a change in RTT audio indicator. * @param profile updated ImsStreamMediaProfile */ void callSessionRttAudioIndicatorChanged(in ImsStreamMediaProfile profile); + + /** + * Notifies of a change to the call quality. + * @param callQuality then updated call quality + */ + void callQualityChanged(in CallQuality callQuality); } diff --git a/telephony/java/android/telephony/ims/compat/stub/ImsCallSessionImplBase.java b/telephony/java/android/telephony/ims/compat/stub/ImsCallSessionImplBase.java index bc58e46806c2..38566fe6d811 100644 --- a/telephony/java/android/telephony/ims/compat/stub/ImsCallSessionImplBase.java +++ b/telephony/java/android/telephony/ims/compat/stub/ImsCallSessionImplBase.java @@ -18,19 +18,18 @@ package android.telephony.ims.compat.stub; import android.os.Message; import android.os.RemoteException; - +import android.telephony.CallQuality; import android.telephony.ims.ImsCallProfile; +import android.telephony.ims.ImsCallSession; import android.telephony.ims.ImsConferenceState; import android.telephony.ims.ImsReasonInfo; import android.telephony.ims.ImsStreamMediaProfile; import android.telephony.ims.ImsSuppServiceNotification; import android.telephony.ims.aidl.IImsCallSessionListener; + import com.android.ims.internal.IImsCallSession; import com.android.ims.internal.IImsVideoCallProvider; -import android.annotation.UnsupportedAppUsage; -import android.telephony.ims.ImsCallSession; - /** * Compat implementation of ImsCallSessionImplBase for older implementations. * @@ -597,5 +596,10 @@ public class ImsCallSessionImplBase extends IImsCallSession.Stub { throws RemoteException { mNewListener.callSessionRttAudioIndicatorChanged(profile); } + + @Override + public void callQualityChanged(CallQuality callQuality) throws RemoteException { + mNewListener.callQualityChanged(callQuality); + } } } diff --git a/telephony/java/com/android/ims/internal/IImsCallSessionListener.aidl b/telephony/java/com/android/ims/internal/IImsCallSessionListener.aidl index bbb27af1ba36..579369f4b549 100644 --- a/telephony/java/com/android/ims/internal/IImsCallSessionListener.aidl +++ b/telephony/java/com/android/ims/internal/IImsCallSessionListener.aidl @@ -16,6 +16,7 @@ package com.android.ims.internal; +import android.telephony.CallQuality; import android.telephony.ims.ImsStreamMediaProfile; import android.telephony.ims.ImsCallProfile; import android.telephony.ims.ImsReasonInfo; @@ -140,22 +141,29 @@ oneway interface IImsCallSessionListener { void callSessionRttModifyRequestReceived(in IImsCallSession session, in ImsCallProfile callProfile); - /* Device issued RTT modify request and inturn received response + /** + * Device issued RTT modify request and inturn received response * from Remote UE * @param status Will be one of the following values from: * - {@link Connection.RttModifyStatus} */ void callSessionRttModifyResponseReceived(in int status); - /* + /** * While in call, device received RTT message from Remote UE * @param rttMessage Received RTT message */ void callSessionRttMessageReceived(in String rttMessage); - /* + /** * While in call, there has been a change in RTT audio indicator. * @param profile updated ImsStreamMediaProfile */ void callSessionRttAudioIndicatorChanged(in ImsStreamMediaProfile profile); + + /** + * Notifies of a change to the call quality. + * @param callQuality then updated call quality + */ + void callQualityChanged(in CallQuality callQuality); } diff --git a/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl b/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl index 5632c630999b..2be1f419db4d 100644 --- a/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl @@ -20,6 +20,7 @@ import android.content.Intent; import android.net.LinkProperties; import android.net.NetworkCapabilities; import android.os.Bundle; +import android.telephony.CallQuality; import android.telephony.CellInfo; import android.telephony.PhoneCapability; import android.telephony.PhysicalChannelConfig; @@ -65,7 +66,7 @@ interface ITelephonyRegistry { void notifyPhysicalChannelConfigurationForSubscriber(in int subId, in List<PhysicalChannelConfig> configs); void notifyPreciseCallState(int ringingCallState, int foregroundCallState, - int backgroundCallState); + int backgroundCallState, int phoneId); void notifyDisconnectCause(int disconnectCause, int preciseDisconnectCause); void notifyPreciseDataConnectionFailed(String apnType, String apn, int failCause); @@ -82,4 +83,5 @@ interface ITelephonyRegistry { void notifyPreferredDataSubIdChanged(int preferredSubId); void notifyRadioPowerStateChanged(in int state); void notifyEmergencyNumberList(); + void notifyCallQualityChanged(in CallQuality callQuality, int phoneId); } |