Loading src/com/android/server/telecom/Call.java +12 −1 Original line number Diff line number Diff line Loading @@ -1092,11 +1092,22 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, return mDisconnectCause; } /** * @return {@code true} if this is an outgoing call to emergency services. An outgoing call is * identified as an emergency call by the dialer phone number. */ @VisibleForTesting public boolean isEmergencyCall() { return mIsEmergencyCall; } /** * @return {@code true} if the network has identified this call as an emergency call. */ public boolean isNetworkIdentifiedEmergencyCall() { return hasProperty(Connection.PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL); } /** * @return The original handle this call is associated with. In-call services should use this * handle when indicating in their UI the handle that is being called. Loading Loading @@ -1454,7 +1465,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, } } void setConnectionProperties(int connectionProperties) { public void setConnectionProperties(int connectionProperties) { Log.v(this, "setConnectionProperties: %s", Connection.propertiesToString( connectionProperties)); Loading src/com/android/server/telecom/CallsManager.java +10 −0 Original line number Diff line number Diff line Loading @@ -3979,4 +3979,14 @@ public class CallsManager extends Call.ListenerBase } } } /** * Determines if there is an ongoing emergency call. This can be either an outgoing emergency * call, or a number which has been identified by the number as an emergency call. * @return {@code true} if there is an ongoing emergency call, {@code false} otherwise. */ public boolean isInEmergencyCall() { return mCalls.stream().filter(c -> c.isEmergencyCall() || c.isNetworkIdentifiedEmergencyCall()).count() > 0; } } src/com/android/server/telecom/ParcelableCallUtils.java +4 −1 Original line number Diff line number Diff line Loading @@ -347,7 +347,10 @@ public class ParcelableCallUtils { android.telecom.Call.Details.PROPERTY_ASSISTED_DIALING_USED, Connection.PROPERTY_IS_RTT, android.telecom.Call.Details.PROPERTY_RTT android.telecom.Call.Details.PROPERTY_RTT, Connection.PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL, android.telecom.Call.Details.PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL }; private static int convertConnectionToCallProperties(int connectionProperties) { Loading src/com/android/server/telecom/TelecomServiceImpl.java +23 −0 Original line number Diff line number Diff line Loading @@ -1449,6 +1449,29 @@ public class TelecomServiceImpl { Log.endSession(); } } /** * See {@link TelecomManager#isInEmergencyCall()} */ @Override public boolean isInEmergencyCall() { try { Log.startSession("TSI.iIEC"); enforceModifyPermission(); synchronized (mLock) { long token = Binder.clearCallingIdentity(); try { boolean isInEmergencyCall = mCallsManager.isInEmergencyCall(); Log.i(this, "isInEmergencyCall: %b", isInEmergencyCall); return isInEmergencyCall; } finally { Binder.restoreCallingIdentity(token); } } } finally { Log.endSession(); } } }; /** Loading tests/src/com/android/server/telecom/tests/CallsManagerTest.java +28 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.telecom.tests; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; Loading @@ -37,6 +38,7 @@ import android.os.SystemClock; import android.telecom.Connection; import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; import android.telecom.TelecomManager; import android.telecom.VideoProfile; import android.telephony.TelephonyManager; import android.test.suitebuilder.annotation.MediumTest; Loading Loading @@ -868,6 +870,32 @@ public class CallsManagerTest extends TelecomTestCase { verify(incomingCall).setIsUsingCallFiltering(eq(false)); } @SmallTest @Test public void testIsInEmergencyCallNetwork() { // Setup a call which the network identified as an emergency call. Call ongoingCall = addSpyCall(); ongoingCall.setConnectionProperties(Connection.PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL); assertFalse(ongoingCall.isEmergencyCall()); assertTrue(ongoingCall.isNetworkIdentifiedEmergencyCall()); assertTrue(mCallsManager.isInEmergencyCall()); } @SmallTest @Test public void testIsInEmergencyCallLocal() { // Setup a call which is considered emergency based on its phone number. Call ongoingCall = addSpyCall(); when(mPhoneNumberUtilsAdapter.isLocalEmergencyNumber(any(), any())).thenReturn(true); ongoingCall.setHandle(Uri.fromParts("tel", "5551212", null), TelecomManager.PRESENTATION_ALLOWED); assertTrue(ongoingCall.isEmergencyCall()); assertFalse(ongoingCall.isNetworkIdentifiedEmergencyCall()); assertTrue(mCallsManager.isInEmergencyCall()); } private Call addSpyCallWithConnectionService(ConnectionServiceWrapper connSvr) { Call call = addSpyCall(); doReturn(connSvr).when(call).getConnectionService(); Loading Loading
src/com/android/server/telecom/Call.java +12 −1 Original line number Diff line number Diff line Loading @@ -1092,11 +1092,22 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, return mDisconnectCause; } /** * @return {@code true} if this is an outgoing call to emergency services. An outgoing call is * identified as an emergency call by the dialer phone number. */ @VisibleForTesting public boolean isEmergencyCall() { return mIsEmergencyCall; } /** * @return {@code true} if the network has identified this call as an emergency call. */ public boolean isNetworkIdentifiedEmergencyCall() { return hasProperty(Connection.PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL); } /** * @return The original handle this call is associated with. In-call services should use this * handle when indicating in their UI the handle that is being called. Loading Loading @@ -1454,7 +1465,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, } } void setConnectionProperties(int connectionProperties) { public void setConnectionProperties(int connectionProperties) { Log.v(this, "setConnectionProperties: %s", Connection.propertiesToString( connectionProperties)); Loading
src/com/android/server/telecom/CallsManager.java +10 −0 Original line number Diff line number Diff line Loading @@ -3979,4 +3979,14 @@ public class CallsManager extends Call.ListenerBase } } } /** * Determines if there is an ongoing emergency call. This can be either an outgoing emergency * call, or a number which has been identified by the number as an emergency call. * @return {@code true} if there is an ongoing emergency call, {@code false} otherwise. */ public boolean isInEmergencyCall() { return mCalls.stream().filter(c -> c.isEmergencyCall() || c.isNetworkIdentifiedEmergencyCall()).count() > 0; } }
src/com/android/server/telecom/ParcelableCallUtils.java +4 −1 Original line number Diff line number Diff line Loading @@ -347,7 +347,10 @@ public class ParcelableCallUtils { android.telecom.Call.Details.PROPERTY_ASSISTED_DIALING_USED, Connection.PROPERTY_IS_RTT, android.telecom.Call.Details.PROPERTY_RTT android.telecom.Call.Details.PROPERTY_RTT, Connection.PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL, android.telecom.Call.Details.PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL }; private static int convertConnectionToCallProperties(int connectionProperties) { Loading
src/com/android/server/telecom/TelecomServiceImpl.java +23 −0 Original line number Diff line number Diff line Loading @@ -1449,6 +1449,29 @@ public class TelecomServiceImpl { Log.endSession(); } } /** * See {@link TelecomManager#isInEmergencyCall()} */ @Override public boolean isInEmergencyCall() { try { Log.startSession("TSI.iIEC"); enforceModifyPermission(); synchronized (mLock) { long token = Binder.clearCallingIdentity(); try { boolean isInEmergencyCall = mCallsManager.isInEmergencyCall(); Log.i(this, "isInEmergencyCall: %b", isInEmergencyCall); return isInEmergencyCall; } finally { Binder.restoreCallingIdentity(token); } } } finally { Log.endSession(); } } }; /** Loading
tests/src/com/android/server/telecom/tests/CallsManagerTest.java +28 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.telecom.tests; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; Loading @@ -37,6 +38,7 @@ import android.os.SystemClock; import android.telecom.Connection; import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; import android.telecom.TelecomManager; import android.telecom.VideoProfile; import android.telephony.TelephonyManager; import android.test.suitebuilder.annotation.MediumTest; Loading Loading @@ -868,6 +870,32 @@ public class CallsManagerTest extends TelecomTestCase { verify(incomingCall).setIsUsingCallFiltering(eq(false)); } @SmallTest @Test public void testIsInEmergencyCallNetwork() { // Setup a call which the network identified as an emergency call. Call ongoingCall = addSpyCall(); ongoingCall.setConnectionProperties(Connection.PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL); assertFalse(ongoingCall.isEmergencyCall()); assertTrue(ongoingCall.isNetworkIdentifiedEmergencyCall()); assertTrue(mCallsManager.isInEmergencyCall()); } @SmallTest @Test public void testIsInEmergencyCallLocal() { // Setup a call which is considered emergency based on its phone number. Call ongoingCall = addSpyCall(); when(mPhoneNumberUtilsAdapter.isLocalEmergencyNumber(any(), any())).thenReturn(true); ongoingCall.setHandle(Uri.fromParts("tel", "5551212", null), TelecomManager.PRESENTATION_ALLOWED); assertTrue(ongoingCall.isEmergencyCall()); assertFalse(ongoingCall.isNetworkIdentifiedEmergencyCall()); assertTrue(mCallsManager.isInEmergencyCall()); } private Call addSpyCallWithConnectionService(ConnectionServiceWrapper connSvr) { Call call = addSpyCall(); doReturn(connSvr).when(call).getConnectionService(); Loading