Merge "Fix possible deadlock in incoming call" into rvc-dev

This commit is contained in:
Brad Ebinger
2020-04-28 18:05:08 +00:00
committed by Android (Google) Code Review

View File

@@ -430,7 +430,6 @@ public class MmTelFeature extends ImsFeature {
/** /**
* @param listener A {@link Listener} used when the MmTelFeature receives an incoming call and * @param listener A {@link Listener} used when the MmTelFeature receives an incoming call and
* notifies the framework. * notifies the framework.
* @hide
*/ */
private void setListener(IImsMmTelListener listener) { private void setListener(IImsMmTelListener listener) {
synchronized (mLock) { synchronized (mLock) {
@@ -441,6 +440,16 @@ public class MmTelFeature extends ImsFeature {
} }
} }
/**
* @return the listener associated with this MmTelFeature. May be null if it has not been set
* by the framework yet.
*/
private IImsMmTelListener getListener() {
synchronized (mLock) {
return mListener;
}
}
/** /**
* The current capability status that this MmTelFeature has defined is available. This * The current capability status that this MmTelFeature has defined is available. This
* configuration will be used by the platform to figure out which capabilities are CURRENTLY * configuration will be used by the platform to figure out which capabilities are CURRENTLY
@@ -489,15 +498,14 @@ public class MmTelFeature extends ImsFeature {
throw new IllegalArgumentException("ImsCallSessionImplBase and Bundle can not be " throw new IllegalArgumentException("ImsCallSessionImplBase and Bundle can not be "
+ "null."); + "null.");
} }
synchronized (mLock) { IImsMmTelListener listener = getListener();
if (mListener == null) { if (listener == null) {
throw new IllegalStateException("Session is not available."); throw new IllegalStateException("Session is not available.");
} }
try { try {
mListener.onIncomingCall(c.getServiceImpl(), extras); listener.onIncomingCall(c.getServiceImpl(), extras);
} catch (RemoteException e) { } catch (RemoteException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
}
} }
} }
@@ -516,15 +524,14 @@ public class MmTelFeature extends ImsFeature {
throw new IllegalArgumentException("ImsCallProfile and ImsReasonInfo must not be " throw new IllegalArgumentException("ImsCallProfile and ImsReasonInfo must not be "
+ "null."); + "null.");
} }
synchronized (mLock) { IImsMmTelListener listener = getListener();
if (mListener == null) { if (listener == null) {
throw new IllegalStateException("Session is not available."); throw new IllegalStateException("Session is not available.");
} }
try { try {
mListener.onRejectedCall(callProfile, reason); listener.onRejectedCall(callProfile, reason);
} catch (RemoteException e) { } catch (RemoteException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
}
} }
} }
@@ -533,15 +540,14 @@ public class MmTelFeature extends ImsFeature {
* @hide * @hide
*/ */
public final void notifyIncomingCallSession(IImsCallSession c, Bundle extras) { public final void notifyIncomingCallSession(IImsCallSession c, Bundle extras) {
synchronized (mLock) { IImsMmTelListener listener = getListener();
if (mListener == null) { if (listener == null) {
throw new IllegalStateException("Session is not available."); throw new IllegalStateException("Session is not available.");
} }
try { try {
mListener.onIncomingCall(c, extras); listener.onIncomingCall(c, extras);
} catch (RemoteException e) { } catch (RemoteException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
}
} }
} }
@@ -552,15 +558,14 @@ public class MmTelFeature extends ImsFeature {
*/ */
@SystemApi @TestApi @SystemApi @TestApi
public final void notifyVoiceMessageCountUpdate(int count) { public final void notifyVoiceMessageCountUpdate(int count) {
synchronized (mLock) { IImsMmTelListener listener = getListener();
if (mListener == null) { if (listener == null) {
throw new IllegalStateException("Session is not available."); throw new IllegalStateException("Session is not available.");
} }
try { try {
mListener.onVoiceMessageCountUpdate(count); listener.onVoiceMessageCountUpdate(count);
} catch (RemoteException e) { } catch (RemoteException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
}
} }
} }