Loading src/com/android/server/telecom/CallsManager.java +19 −19 Original line number Diff line number Diff line Loading @@ -45,8 +45,8 @@ import android.graphics.Color; import android.graphics.drawable.ColorDrawable; import android.media.AudioManager; import android.media.AudioSystem; import android.media.ToneGenerator; import android.media.MediaPlayer; import android.media.ToneGenerator; import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; Loading @@ -66,6 +66,7 @@ import android.provider.CallLog.Calls; import android.provider.Settings; import android.sysprop.TelephonyProperties; import android.telecom.CallAudioState; import android.telecom.CallerInfo; import android.telecom.Conference; import android.telecom.Connection; import android.telecom.DisconnectCause; Loading @@ -85,14 +86,12 @@ import android.telephony.PhoneNumberUtils; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.Pair; import com.android.internal.annotations.VisibleForTesting; import android.telecom.CallerInfo; import android.view.LayoutInflater; import android.view.View; import android.view.WindowManager; import android.widget.Button; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.IndentingPrintWriter; import com.android.server.telecom.bluetooth.BluetoothRouteManager; import com.android.server.telecom.bluetooth.BluetoothStateReceiver; Loading @@ -101,10 +100,10 @@ import com.android.server.telecom.callfiltering.BlockCheckerFilter; import com.android.server.telecom.callfiltering.CallFilterResultCallback; import com.android.server.telecom.callfiltering.CallFilteringResult; import com.android.server.telecom.callfiltering.CallFilteringResult.Builder; import com.android.server.telecom.callfiltering.CallScreeningServiceFilter; import com.android.server.telecom.callfiltering.DirectToVoicemailFilter; import com.android.server.telecom.callfiltering.IncomingCallFilter; import com.android.server.telecom.callfiltering.IncomingCallFilterGraph; import com.android.server.telecom.callfiltering.CallScreeningServiceFilter; import com.android.server.telecom.callredirection.CallRedirectionProcessor; import com.android.server.telecom.components.ErrorDialogActivity; import com.android.server.telecom.components.TelecomBroadcastReceiver; Loading @@ -116,8 +115,8 @@ import com.android.server.telecom.ui.DisconnectedCallNotifier; import com.android.server.telecom.ui.IncomingCallNotifier; import com.android.server.telecom.ui.ToastFactory; import java.util.Arrays; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; Loading Loading @@ -696,25 +695,26 @@ public class CallsManager extends Call.ListenerBase new CallScreeningServiceFilter(incomingCall, carrierPackageName, CallScreeningServiceFilter.PACKAGE_TYPE_CARRIER, mContext, this, appLabelProxy, converter); CallScreeningServiceFilter defaultDialerCallScreeningServiceFilter = new CallScreeningServiceFilter(incomingCall, defaultDialerPackageName, CallScreeningServiceFilter.PACKAGE_TYPE_DEFAULT_DIALER, mContext, this, appLabelProxy, converter); CallScreeningServiceFilter userChosenCallScreeningServiceFilter = new CallScreeningServiceFilter(incomingCall, userChosenPackageName, CallScreeningServiceFilter.PACKAGE_TYPE_USER_CHOSEN, mContext, this, appLabelProxy, converter); CallScreeningServiceFilter callScreeningServiceFilter; if ((userChosenPackageName != null) && (!userChosenPackageName.equals(defaultDialerPackageName))) { callScreeningServiceFilter = new CallScreeningServiceFilter(incomingCall, userChosenPackageName, CallScreeningServiceFilter.PACKAGE_TYPE_USER_CHOSEN, mContext, this, appLabelProxy, converter); } else { callScreeningServiceFilter = new CallScreeningServiceFilter(incomingCall, defaultDialerPackageName, CallScreeningServiceFilter.PACKAGE_TYPE_DEFAULT_DIALER, mContext, this, appLabelProxy, converter); } graph.addFilter(voicemailFilter); graph.addFilter(blockCheckerFilter); graph.addFilter(carrierCallScreeningServiceFilter); graph.addFilter(defaultDialerCallScreeningServiceFilter); graph.addFilter(userChosenCallScreeningServiceFilter); graph.addFilter(callScreeningServiceFilter); IncomingCallFilterGraph.addEdge(voicemailFilter, carrierCallScreeningServiceFilter); IncomingCallFilterGraph.addEdge(blockCheckerFilter, carrierCallScreeningServiceFilter); IncomingCallFilterGraph.addEdge(carrierCallScreeningServiceFilter, defaultDialerCallScreeningServiceFilter); IncomingCallFilterGraph.addEdge(carrierCallScreeningServiceFilter, userChosenCallScreeningServiceFilter); callScreeningServiceFilter); mGraphHandlerThreads.add(graph.getHandlerThread()); return graph; } Loading src/com/android/server/telecom/callfiltering/CallScreeningServiceFilter.java +9 −3 Original line number Diff line number Diff line Loading @@ -176,7 +176,6 @@ public class CallScreeningServiceFilter extends CallFilter { public void onServiceConnected(ComponentName componentName, IBinder service) { ICallScreeningService callScreeningService = ICallScreeningService.Stub.asInterface(service); try { callScreeningService.screenCall(new CallScreeningAdapter(mResultFuture), mParcelableCallUtilsConverter. Loading Loading @@ -204,6 +203,7 @@ public class CallScreeningServiceFilter extends CallFilter { public void onNullBinding(ComponentName name) { mResultFuture.complete(mPriorStageResult); Log.i(this, "Null binding."); unbindCallScreeningService(); } } Loading Loading @@ -251,6 +251,11 @@ public class CallScreeningServiceFilter extends CallFilter { return resultFuture; } @Override public String toString() { return super.toString() + ": " + mPackageName; } private boolean hasReadContactsPermission() { int permission = PackageManager.PERMISSION_DENIED; if (mPackagetype == PACKAGE_TYPE_CARRIER || mPackagetype == PACKAGE_TYPE_DEFAULT_DIALER) { Loading @@ -272,7 +277,7 @@ public class CallScreeningServiceFilter extends CallFilter { } } private void unbindCallScreeningService() { public void unbindCallScreeningService() { if (mConnection != null) { mContext.unbindService(mConnection); } Loading @@ -283,7 +288,8 @@ public class CallScreeningServiceFilter extends CallFilter { if (mPackagetype != PACKAGE_TYPE_DEFAULT_DIALER) { return false; } else { return mPackageName.equals(TelecomManager.from(mContext).getSystemDialerPackage()); return mPackageName.equals( TelecomManager.from(mContext).getSystemDialerPackage()); } } Loading src/com/android/server/telecom/callfiltering/IncomingCallFilterGraph.java +6 −0 Original line number Diff line number Diff line Loading @@ -126,6 +126,12 @@ public class IncomingCallFilterGraph { mFinished = true; mHandlerThread.quit(); } for (CallFilter filter : mFiltersList) { // unbind timed out call screening service if (filter instanceof CallScreeningServiceFilter) { ((CallScreeningServiceFilter) filter).unbindCallScreeningService(); } } } }.prepare(), mTimeoutsAdapter.getCallScreeningTimeoutMillis(mContext.getContentResolver())); } Loading tests/src/com/android/server/telecom/tests/CallScreeningServiceFilterTest.java +1 −2 Original line number Diff line number Diff line Loading @@ -111,8 +111,7 @@ public class CallScreeningServiceFilterTest extends TelecomTestCase { when(mCallsManager.getCurrentUserHandle()).thenReturn(UserHandle.CURRENT); when(mCall.getId()).thenReturn(CALL_ID); when(mContext.getPackageManager()).thenReturn(mPackageManager); when(mAppLabelProxy.getAppLabel(eq(PKG_NAME))) .thenReturn(APP_NAME); when(mAppLabelProxy.getAppLabel(PKG_NAME)).thenReturn(APP_NAME); when(mParcelableCallUtilsConverter.toParcelableCall( eq(mCall), anyBoolean(), eq(mPhoneAccountRegistrar))).thenReturn(null); when(mContext.bindServiceAsUser(nullable(Intent.class), nullable(ServiceConnection.class), Loading Loading
src/com/android/server/telecom/CallsManager.java +19 −19 Original line number Diff line number Diff line Loading @@ -45,8 +45,8 @@ import android.graphics.Color; import android.graphics.drawable.ColorDrawable; import android.media.AudioManager; import android.media.AudioSystem; import android.media.ToneGenerator; import android.media.MediaPlayer; import android.media.ToneGenerator; import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; Loading @@ -66,6 +66,7 @@ import android.provider.CallLog.Calls; import android.provider.Settings; import android.sysprop.TelephonyProperties; import android.telecom.CallAudioState; import android.telecom.CallerInfo; import android.telecom.Conference; import android.telecom.Connection; import android.telecom.DisconnectCause; Loading @@ -85,14 +86,12 @@ import android.telephony.PhoneNumberUtils; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.Pair; import com.android.internal.annotations.VisibleForTesting; import android.telecom.CallerInfo; import android.view.LayoutInflater; import android.view.View; import android.view.WindowManager; import android.widget.Button; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.IndentingPrintWriter; import com.android.server.telecom.bluetooth.BluetoothRouteManager; import com.android.server.telecom.bluetooth.BluetoothStateReceiver; Loading @@ -101,10 +100,10 @@ import com.android.server.telecom.callfiltering.BlockCheckerFilter; import com.android.server.telecom.callfiltering.CallFilterResultCallback; import com.android.server.telecom.callfiltering.CallFilteringResult; import com.android.server.telecom.callfiltering.CallFilteringResult.Builder; import com.android.server.telecom.callfiltering.CallScreeningServiceFilter; import com.android.server.telecom.callfiltering.DirectToVoicemailFilter; import com.android.server.telecom.callfiltering.IncomingCallFilter; import com.android.server.telecom.callfiltering.IncomingCallFilterGraph; import com.android.server.telecom.callfiltering.CallScreeningServiceFilter; import com.android.server.telecom.callredirection.CallRedirectionProcessor; import com.android.server.telecom.components.ErrorDialogActivity; import com.android.server.telecom.components.TelecomBroadcastReceiver; Loading @@ -116,8 +115,8 @@ import com.android.server.telecom.ui.DisconnectedCallNotifier; import com.android.server.telecom.ui.IncomingCallNotifier; import com.android.server.telecom.ui.ToastFactory; import java.util.Arrays; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; Loading Loading @@ -696,25 +695,26 @@ public class CallsManager extends Call.ListenerBase new CallScreeningServiceFilter(incomingCall, carrierPackageName, CallScreeningServiceFilter.PACKAGE_TYPE_CARRIER, mContext, this, appLabelProxy, converter); CallScreeningServiceFilter defaultDialerCallScreeningServiceFilter = new CallScreeningServiceFilter(incomingCall, defaultDialerPackageName, CallScreeningServiceFilter.PACKAGE_TYPE_DEFAULT_DIALER, mContext, this, appLabelProxy, converter); CallScreeningServiceFilter userChosenCallScreeningServiceFilter = new CallScreeningServiceFilter(incomingCall, userChosenPackageName, CallScreeningServiceFilter.PACKAGE_TYPE_USER_CHOSEN, mContext, this, appLabelProxy, converter); CallScreeningServiceFilter callScreeningServiceFilter; if ((userChosenPackageName != null) && (!userChosenPackageName.equals(defaultDialerPackageName))) { callScreeningServiceFilter = new CallScreeningServiceFilter(incomingCall, userChosenPackageName, CallScreeningServiceFilter.PACKAGE_TYPE_USER_CHOSEN, mContext, this, appLabelProxy, converter); } else { callScreeningServiceFilter = new CallScreeningServiceFilter(incomingCall, defaultDialerPackageName, CallScreeningServiceFilter.PACKAGE_TYPE_DEFAULT_DIALER, mContext, this, appLabelProxy, converter); } graph.addFilter(voicemailFilter); graph.addFilter(blockCheckerFilter); graph.addFilter(carrierCallScreeningServiceFilter); graph.addFilter(defaultDialerCallScreeningServiceFilter); graph.addFilter(userChosenCallScreeningServiceFilter); graph.addFilter(callScreeningServiceFilter); IncomingCallFilterGraph.addEdge(voicemailFilter, carrierCallScreeningServiceFilter); IncomingCallFilterGraph.addEdge(blockCheckerFilter, carrierCallScreeningServiceFilter); IncomingCallFilterGraph.addEdge(carrierCallScreeningServiceFilter, defaultDialerCallScreeningServiceFilter); IncomingCallFilterGraph.addEdge(carrierCallScreeningServiceFilter, userChosenCallScreeningServiceFilter); callScreeningServiceFilter); mGraphHandlerThreads.add(graph.getHandlerThread()); return graph; } Loading
src/com/android/server/telecom/callfiltering/CallScreeningServiceFilter.java +9 −3 Original line number Diff line number Diff line Loading @@ -176,7 +176,6 @@ public class CallScreeningServiceFilter extends CallFilter { public void onServiceConnected(ComponentName componentName, IBinder service) { ICallScreeningService callScreeningService = ICallScreeningService.Stub.asInterface(service); try { callScreeningService.screenCall(new CallScreeningAdapter(mResultFuture), mParcelableCallUtilsConverter. Loading Loading @@ -204,6 +203,7 @@ public class CallScreeningServiceFilter extends CallFilter { public void onNullBinding(ComponentName name) { mResultFuture.complete(mPriorStageResult); Log.i(this, "Null binding."); unbindCallScreeningService(); } } Loading Loading @@ -251,6 +251,11 @@ public class CallScreeningServiceFilter extends CallFilter { return resultFuture; } @Override public String toString() { return super.toString() + ": " + mPackageName; } private boolean hasReadContactsPermission() { int permission = PackageManager.PERMISSION_DENIED; if (mPackagetype == PACKAGE_TYPE_CARRIER || mPackagetype == PACKAGE_TYPE_DEFAULT_DIALER) { Loading @@ -272,7 +277,7 @@ public class CallScreeningServiceFilter extends CallFilter { } } private void unbindCallScreeningService() { public void unbindCallScreeningService() { if (mConnection != null) { mContext.unbindService(mConnection); } Loading @@ -283,7 +288,8 @@ public class CallScreeningServiceFilter extends CallFilter { if (mPackagetype != PACKAGE_TYPE_DEFAULT_DIALER) { return false; } else { return mPackageName.equals(TelecomManager.from(mContext).getSystemDialerPackage()); return mPackageName.equals( TelecomManager.from(mContext).getSystemDialerPackage()); } } Loading
src/com/android/server/telecom/callfiltering/IncomingCallFilterGraph.java +6 −0 Original line number Diff line number Diff line Loading @@ -126,6 +126,12 @@ public class IncomingCallFilterGraph { mFinished = true; mHandlerThread.quit(); } for (CallFilter filter : mFiltersList) { // unbind timed out call screening service if (filter instanceof CallScreeningServiceFilter) { ((CallScreeningServiceFilter) filter).unbindCallScreeningService(); } } } }.prepare(), mTimeoutsAdapter.getCallScreeningTimeoutMillis(mContext.getContentResolver())); } Loading
tests/src/com/android/server/telecom/tests/CallScreeningServiceFilterTest.java +1 −2 Original line number Diff line number Diff line Loading @@ -111,8 +111,7 @@ public class CallScreeningServiceFilterTest extends TelecomTestCase { when(mCallsManager.getCurrentUserHandle()).thenReturn(UserHandle.CURRENT); when(mCall.getId()).thenReturn(CALL_ID); when(mContext.getPackageManager()).thenReturn(mPackageManager); when(mAppLabelProxy.getAppLabel(eq(PKG_NAME))) .thenReturn(APP_NAME); when(mAppLabelProxy.getAppLabel(PKG_NAME)).thenReturn(APP_NAME); when(mParcelableCallUtilsConverter.toParcelableCall( eq(mCall), anyBoolean(), eq(mPhoneAccountRegistrar))).thenReturn(null); when(mContext.bindServiceAsUser(nullable(Intent.class), nullable(ServiceConnection.class), Loading