Loading src/com/android/server/telecom/voip/VoipCallMonitor.java +11 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,12 @@ package com.android.server.telecom.voip; import static android.app.ForegroundServiceDelegationOptions.DELEGATION_SERVICE_PHONE_CALL; import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_CAMERA; import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE; import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE; import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_PHONE_CALL; import android.app.ActivityManager; import android.app.ActivityManagerInternal; import android.app.ForegroundServiceDelegationOptions; Loading Loading @@ -199,8 +205,11 @@ public class VoipCallMonitor extends CallsManagerListenerBase { ForegroundServiceDelegationOptions options = new ForegroundServiceDelegationOptions(pid, uid, handle.getComponentName().getPackageName(), null /* clientAppThread */, false /* isSticky */, String.valueOf(handle.hashCode()), 0 /* foregroundServiceType */, ForegroundServiceDelegationOptions.DELEGATION_SERVICE_PHONE_CALL); FOREGROUND_SERVICE_TYPE_PHONE_CALL | FOREGROUND_SERVICE_TYPE_MICROPHONE | FOREGROUND_SERVICE_TYPE_CAMERA | FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE /* foregroundServiceTypes */, DELEGATION_SERVICE_PHONE_CALL /* delegationService */); ServiceConnection fgsConnection = new ServiceConnection() { @Override public void onServiceConnected(ComponentName name, IBinder service) { Loading tests/src/com/android/server/telecom/tests/VoipCallMonitorTest.java +31 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,12 @@ package com.android.server.telecom.tests; import static android.app.ForegroundServiceDelegationOptions.DELEGATION_SERVICE_PHONE_CALL; import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_CAMERA; import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE; import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE; import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_PHONE_CALL; import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; Loading Loading @@ -86,6 +92,31 @@ public class VoipCallMonitorTest extends TelecomTestCase { .thenReturn(true); } /** * This test ensures VoipCallMonitor is passing the correct foregroundServiceTypes when starting * foreground service delegation on behalf of a client. */ @SmallTest @Test public void testVerifyForegroundServiceTypesBeingPassedToActivityManager() { Call call = createTestCall("testCall", mHandle1User1); ArgumentCaptor<ForegroundServiceDelegationOptions> optionsCaptor = ArgumentCaptor.forClass(ForegroundServiceDelegationOptions.class); mMonitor.onCallAdded(call); verify(mActivityManagerInternal, timeout(TIMEOUT)).startForegroundServiceDelegate( optionsCaptor.capture(), any(ServiceConnection.class)); assertEquals( FOREGROUND_SERVICE_TYPE_PHONE_CALL | FOREGROUND_SERVICE_TYPE_MICROPHONE | FOREGROUND_SERVICE_TYPE_CAMERA | FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE, optionsCaptor.getValue().mForegroundServiceTypes); mMonitor.onCallRemoved(call); } @SmallTest @Test public void testStartMonitorForOneCall() { Loading Loading
src/com/android/server/telecom/voip/VoipCallMonitor.java +11 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,12 @@ package com.android.server.telecom.voip; import static android.app.ForegroundServiceDelegationOptions.DELEGATION_SERVICE_PHONE_CALL; import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_CAMERA; import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE; import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE; import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_PHONE_CALL; import android.app.ActivityManager; import android.app.ActivityManagerInternal; import android.app.ForegroundServiceDelegationOptions; Loading Loading @@ -199,8 +205,11 @@ public class VoipCallMonitor extends CallsManagerListenerBase { ForegroundServiceDelegationOptions options = new ForegroundServiceDelegationOptions(pid, uid, handle.getComponentName().getPackageName(), null /* clientAppThread */, false /* isSticky */, String.valueOf(handle.hashCode()), 0 /* foregroundServiceType */, ForegroundServiceDelegationOptions.DELEGATION_SERVICE_PHONE_CALL); FOREGROUND_SERVICE_TYPE_PHONE_CALL | FOREGROUND_SERVICE_TYPE_MICROPHONE | FOREGROUND_SERVICE_TYPE_CAMERA | FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE /* foregroundServiceTypes */, DELEGATION_SERVICE_PHONE_CALL /* delegationService */); ServiceConnection fgsConnection = new ServiceConnection() { @Override public void onServiceConnected(ComponentName name, IBinder service) { Loading
tests/src/com/android/server/telecom/tests/VoipCallMonitorTest.java +31 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,12 @@ package com.android.server.telecom.tests; import static android.app.ForegroundServiceDelegationOptions.DELEGATION_SERVICE_PHONE_CALL; import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_CAMERA; import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE; import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE; import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_PHONE_CALL; import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; Loading Loading @@ -86,6 +92,31 @@ public class VoipCallMonitorTest extends TelecomTestCase { .thenReturn(true); } /** * This test ensures VoipCallMonitor is passing the correct foregroundServiceTypes when starting * foreground service delegation on behalf of a client. */ @SmallTest @Test public void testVerifyForegroundServiceTypesBeingPassedToActivityManager() { Call call = createTestCall("testCall", mHandle1User1); ArgumentCaptor<ForegroundServiceDelegationOptions> optionsCaptor = ArgumentCaptor.forClass(ForegroundServiceDelegationOptions.class); mMonitor.onCallAdded(call); verify(mActivityManagerInternal, timeout(TIMEOUT)).startForegroundServiceDelegate( optionsCaptor.capture(), any(ServiceConnection.class)); assertEquals( FOREGROUND_SERVICE_TYPE_PHONE_CALL | FOREGROUND_SERVICE_TYPE_MICROPHONE | FOREGROUND_SERVICE_TYPE_CAMERA | FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE, optionsCaptor.getValue().mForegroundServiceTypes); mMonitor.onCallRemoved(call); } @SmallTest @Test public void testStartMonitorForOneCall() { Loading