Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 14927c6f authored by Pranav Madapurmath's avatar Pranav Madapurmath
Browse files

Ensure service unbind when receiving a null call screening service in onBind.

Currently, we do not unbind the call screening service when a null
service is returned from onBind when placing MO calls.
CallScreeningServiceHelper (MO) now overrides onNullBinding to ensure
future completion and that we unbind the service after. Similarly, we
need to unbind the service in onServiceDisconnected.
CallScreeningServiceFilter (MT) has also been updated to ensure we
unbind in places when we know that the connection should not exist.

Also, there is a timeout in CallScreeningServiceHelper. This does not
require a call to unbind the service because CallScreeningAdapter also
places a call to unbind the service in onScreeningResponse. We would
risk having duplicate calls to unbind the service, which would cause a
fatal exception. This is demonstrated by the existing CTS tests, namely,
ThirdPartyCallScreeningServiceTest.java.

Bug: 252762941
Test: Manual (no breakage in existing flow), CTS for MO/MT cases
Change-Id: Ia5b62bb93dc666b6b8b8daccb8ef41eb55dde7ea
Merged-In: Ia5b62bb93dc666b6b8b8daccb8ef41eb55dde7ea
parent a0d27810
Loading
Loading
Loading
Loading
+17 −0
Original line number Original line Diff line number Diff line
@@ -152,6 +152,23 @@ public class CallScreeningServiceHelper {
                                "Cancelling outgoing call screen due to service disconnect.");
                                "Cancelling outgoing call screen due to service disconnect.");
                    }
                    }
                    mFuture.complete(null);
                    mFuture.complete(null);
                    mContext.unbindService(this);
                } finally {
                    Log.endSession();
                }
            }

            @Override
            public void onNullBinding(ComponentName name) {
                // No locking needed -- CompletableFuture only lets one thread call complete.
                Log.continueSession(mLoggingSession, "CSSH.oNB");
                try {
                    if (!mFuture.isDone()) {
                        Log.w(CallScreeningServiceHelper.this,
                                "Cancelling outgoing call screen due to null binding.");
                    }
                    mFuture.complete(null);
                    mContext.unbindService(this);
                } finally {
                } finally {
                    Log.endSession();
                    Log.endSession();
                }
                }
+2 −0
Original line number Original line Diff line number Diff line
@@ -201,12 +201,14 @@ public class CallScreeningServiceFilter extends CallFilter {
        public void onServiceDisconnected(ComponentName componentName) {
        public void onServiceDisconnected(ComponentName componentName) {
            mResultFuture.complete(mPriorStageResult);
            mResultFuture.complete(mPriorStageResult);
            Log.i(this, "Service disconnected.");
            Log.i(this, "Service disconnected.");
            unbindCallScreeningService();
        }
        }


        @Override
        @Override
        public void onBindingDied(ComponentName name) {
        public void onBindingDied(ComponentName name) {
            mResultFuture.complete(mPriorStageResult);
            mResultFuture.complete(mPriorStageResult);
            Log.i(this, "Binding died.");
            Log.i(this, "Binding died.");
            unbindCallScreeningService();
        }
        }


        @Override
        @Override