Loading src/com/android/server/telecom/CallsManager.java +13 −5 Original line number Diff line number Diff line Loading @@ -20,9 +20,9 @@ import android.app.ActivityManager; import android.app.KeyguardManager; import android.content.BroadcastReceiver; import android.content.Context; import android.content.pm.UserInfo; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.UserInfo; import android.media.AudioManager; import android.media.AudioSystem; import android.media.ToneGenerator; Loading @@ -47,11 +47,11 @@ import android.telecom.Connection; import android.telecom.DisconnectCause; import android.telecom.GatewayInfo; import android.telecom.Log; import android.telecom.Logging.Runnable; import android.telecom.ParcelableConference; import android.telecom.ParcelableConnection; import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; import android.telecom.Logging.Runnable; import android.telecom.TelecomManager; import android.telecom.VideoProfile; import android.telephony.CarrierConfigManager; Loading Loading @@ -521,12 +521,20 @@ public class CallsManager extends Call.ListenerBase @Override public void onSuccessfulIncomingCall(Call incomingCall) { Log.d(this, "onSuccessfulIncomingCall"); PhoneAccount phoneAccount = mPhoneAccountRegistrar.getPhoneAccountUnchecked( incomingCall.getTargetPhoneAccount()); Bundle extras = phoneAccount == null || phoneAccount.getExtras() == null ? new Bundle() : phoneAccount.getExtras(); if (incomingCall.hasProperty(Connection.PROPERTY_EMERGENCY_CALLBACK_MODE) || incomingCall.isSelfManaged()) { Log.i(this, "Skipping call filtering for %s (ecm=%b, selfMgd=%b)", incomingCall.isSelfManaged() || extras.getBoolean(PhoneAccount.EXTRA_SKIP_CALL_FILTERING)) { Log.i(this, "Skipping call filtering for %s (ecm=%b, selfMgd=%b, skipExtra=%b)", incomingCall.getId(), incomingCall.hasProperty(Connection.PROPERTY_EMERGENCY_CALLBACK_MODE), incomingCall.isSelfManaged()); incomingCall.isSelfManaged(), extras.getBoolean(PhoneAccount.EXTRA_SKIP_CALL_FILTERING)); onCallFilteringComplete(incomingCall, new CallFilteringResult(true, false, true, true)); incomingCall.setIsUsingCallFiltering(false); return; Loading src/com/android/server/telecom/TelecomServiceImpl.java +12 −0 Original line number Diff line number Diff line Loading @@ -440,6 +440,11 @@ public class TelecomServiceImpl { if (account.hasCapabilities(PhoneAccount.CAPABILITY_MULTI_USER)) { enforceRegisterMultiUser(); } Bundle extras = account.getExtras(); if (extras != null && extras.getBoolean(PhoneAccount.EXTRA_SKIP_CALL_FILTERING)) { enforceRegisterSkipCallFiltering(); } enforceUserHandleMatchesCaller(account.getAccountHandle()); final long token = Binder.clearCallingIdentity(); try { Loading Loading @@ -1671,6 +1676,13 @@ public class TelecomServiceImpl { } } private void enforceRegisterSkipCallFiltering() { if (!isCallerSystemApp()) { throw new SecurityException( "EXTRA_SKIP_CALL_FILTERING is only available to system apps."); } } private void enforceUserHandleMatchesCaller(PhoneAccountHandle accountHandle) { if (!Binder.getCallingUserHandle().equals(accountHandle.getUserHandle())) { throw new SecurityException("Calling UserHandle does not match PhoneAccountHandle's"); Loading tests/src/com/android/server/telecom/tests/CallsManagerTest.java +30 −1 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import static org.mockito.Mockito.when; import android.content.ComponentName; import android.net.Uri; import android.os.Bundle; import android.os.SystemClock; import android.telecom.Connection; import android.telecom.PhoneAccount; Loading @@ -39,7 +40,6 @@ import android.telecom.PhoneAccountHandle; import android.telecom.VideoProfile; import android.telephony.TelephonyManager; import android.test.suitebuilder.annotation.MediumTest; import android.test.suitebuilder.annotation.SmallTest; import com.android.server.telecom.AsyncRingtonePlayer; import com.android.server.telecom.Call; Loading Loading @@ -839,6 +839,35 @@ public class CallsManagerTest extends TelecomTestCase { verify(ongoingCall).disconnect(); } @SmallTest @Test public void testNoFilteringOfCallsWhenPhoneAccountRequestsSkipped() { ConnectionServiceWrapper connSvr1 = Mockito.mock(ConnectionServiceWrapper.class); // GIVEN an incoming call which is from a PhoneAccount that requested to skip filtering. Call incomingCall = addSpyCallWithConnectionService(connSvr1); Bundle extras = new Bundle(); extras.putBoolean(PhoneAccount.EXTRA_SKIP_CALL_FILTERING, true); PhoneAccount skipRequestedAccount = new PhoneAccount.Builder(SIM_2_HANDLE, "Skipper") .setCapabilities(PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION | PhoneAccount.CAPABILITY_CALL_PROVIDER) .setExtras(extras) .setIsEnabled(true) .build(); when(mPhoneAccountRegistrar.getPhoneAccountUnchecked(SIM_2_HANDLE)) .thenReturn(skipRequestedAccount); doReturn(false).when(incomingCall).can(Connection.CAPABILITY_HOLD); doReturn(false).when(incomingCall).can(Connection.CAPABILITY_SUPPORT_HOLD); doReturn(false).when(incomingCall).isSelfManaged(); doNothing().when(incomingCall).setState(anyInt(), any()); // WHEN the incoming call is successfully added. mCallsManager.onSuccessfulIncomingCall(incomingCall); // THEN the incoming call is not using call filtering verify(incomingCall).setIsUsingCallFiltering(eq(false)); } private Call addSpyCallWithConnectionService(ConnectionServiceWrapper connSvr) { Call call = addSpyCall(); doReturn(connSvr).when(call).getConnectionService(); Loading Loading
src/com/android/server/telecom/CallsManager.java +13 −5 Original line number Diff line number Diff line Loading @@ -20,9 +20,9 @@ import android.app.ActivityManager; import android.app.KeyguardManager; import android.content.BroadcastReceiver; import android.content.Context; import android.content.pm.UserInfo; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.UserInfo; import android.media.AudioManager; import android.media.AudioSystem; import android.media.ToneGenerator; Loading @@ -47,11 +47,11 @@ import android.telecom.Connection; import android.telecom.DisconnectCause; import android.telecom.GatewayInfo; import android.telecom.Log; import android.telecom.Logging.Runnable; import android.telecom.ParcelableConference; import android.telecom.ParcelableConnection; import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; import android.telecom.Logging.Runnable; import android.telecom.TelecomManager; import android.telecom.VideoProfile; import android.telephony.CarrierConfigManager; Loading Loading @@ -521,12 +521,20 @@ public class CallsManager extends Call.ListenerBase @Override public void onSuccessfulIncomingCall(Call incomingCall) { Log.d(this, "onSuccessfulIncomingCall"); PhoneAccount phoneAccount = mPhoneAccountRegistrar.getPhoneAccountUnchecked( incomingCall.getTargetPhoneAccount()); Bundle extras = phoneAccount == null || phoneAccount.getExtras() == null ? new Bundle() : phoneAccount.getExtras(); if (incomingCall.hasProperty(Connection.PROPERTY_EMERGENCY_CALLBACK_MODE) || incomingCall.isSelfManaged()) { Log.i(this, "Skipping call filtering for %s (ecm=%b, selfMgd=%b)", incomingCall.isSelfManaged() || extras.getBoolean(PhoneAccount.EXTRA_SKIP_CALL_FILTERING)) { Log.i(this, "Skipping call filtering for %s (ecm=%b, selfMgd=%b, skipExtra=%b)", incomingCall.getId(), incomingCall.hasProperty(Connection.PROPERTY_EMERGENCY_CALLBACK_MODE), incomingCall.isSelfManaged()); incomingCall.isSelfManaged(), extras.getBoolean(PhoneAccount.EXTRA_SKIP_CALL_FILTERING)); onCallFilteringComplete(incomingCall, new CallFilteringResult(true, false, true, true)); incomingCall.setIsUsingCallFiltering(false); return; Loading
src/com/android/server/telecom/TelecomServiceImpl.java +12 −0 Original line number Diff line number Diff line Loading @@ -440,6 +440,11 @@ public class TelecomServiceImpl { if (account.hasCapabilities(PhoneAccount.CAPABILITY_MULTI_USER)) { enforceRegisterMultiUser(); } Bundle extras = account.getExtras(); if (extras != null && extras.getBoolean(PhoneAccount.EXTRA_SKIP_CALL_FILTERING)) { enforceRegisterSkipCallFiltering(); } enforceUserHandleMatchesCaller(account.getAccountHandle()); final long token = Binder.clearCallingIdentity(); try { Loading Loading @@ -1671,6 +1676,13 @@ public class TelecomServiceImpl { } } private void enforceRegisterSkipCallFiltering() { if (!isCallerSystemApp()) { throw new SecurityException( "EXTRA_SKIP_CALL_FILTERING is only available to system apps."); } } private void enforceUserHandleMatchesCaller(PhoneAccountHandle accountHandle) { if (!Binder.getCallingUserHandle().equals(accountHandle.getUserHandle())) { throw new SecurityException("Calling UserHandle does not match PhoneAccountHandle's"); Loading
tests/src/com/android/server/telecom/tests/CallsManagerTest.java +30 −1 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import static org.mockito.Mockito.when; import android.content.ComponentName; import android.net.Uri; import android.os.Bundle; import android.os.SystemClock; import android.telecom.Connection; import android.telecom.PhoneAccount; Loading @@ -39,7 +40,6 @@ import android.telecom.PhoneAccountHandle; import android.telecom.VideoProfile; import android.telephony.TelephonyManager; import android.test.suitebuilder.annotation.MediumTest; import android.test.suitebuilder.annotation.SmallTest; import com.android.server.telecom.AsyncRingtonePlayer; import com.android.server.telecom.Call; Loading Loading @@ -839,6 +839,35 @@ public class CallsManagerTest extends TelecomTestCase { verify(ongoingCall).disconnect(); } @SmallTest @Test public void testNoFilteringOfCallsWhenPhoneAccountRequestsSkipped() { ConnectionServiceWrapper connSvr1 = Mockito.mock(ConnectionServiceWrapper.class); // GIVEN an incoming call which is from a PhoneAccount that requested to skip filtering. Call incomingCall = addSpyCallWithConnectionService(connSvr1); Bundle extras = new Bundle(); extras.putBoolean(PhoneAccount.EXTRA_SKIP_CALL_FILTERING, true); PhoneAccount skipRequestedAccount = new PhoneAccount.Builder(SIM_2_HANDLE, "Skipper") .setCapabilities(PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION | PhoneAccount.CAPABILITY_CALL_PROVIDER) .setExtras(extras) .setIsEnabled(true) .build(); when(mPhoneAccountRegistrar.getPhoneAccountUnchecked(SIM_2_HANDLE)) .thenReturn(skipRequestedAccount); doReturn(false).when(incomingCall).can(Connection.CAPABILITY_HOLD); doReturn(false).when(incomingCall).can(Connection.CAPABILITY_SUPPORT_HOLD); doReturn(false).when(incomingCall).isSelfManaged(); doNothing().when(incomingCall).setState(anyInt(), any()); // WHEN the incoming call is successfully added. mCallsManager.onSuccessfulIncomingCall(incomingCall); // THEN the incoming call is not using call filtering verify(incomingCall).setIsUsingCallFiltering(eq(false)); } private Call addSpyCallWithConnectionService(ConnectionServiceWrapper connSvr) { Call call = addSpyCall(); doReturn(connSvr).when(call).getConnectionService(); Loading