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

Commit 38acc08d authored by Tyler Gunn's avatar Tyler Gunn Committed by Android Build Coastguard Worker
Browse files

Handle null bindings returned from ConnectionService.

When a ConnectionService returns a null binding, immediately unbind from
the ConnectionService and cancel any ongoing calls related to it.

Bug: 211114016
Test: Added new CTS test to verify auto unbind from null binding ConnectionService.
Test: Manually tested using test app which implements null binding ConnectionService and verified via telecom log inspection that the service is unbound and the call is terminated.
Change-Id: I0757557e66725dddfd871cd9857071a8749bd7ba
(cherry picked from commit 410ce026)
Merged-In: I0757557e66725dddfd871cd9857071a8749bd7ba
parent 11c8303d
Loading
Loading
Loading
Loading
+24 −1
Original line number Original line Diff line number Diff line
@@ -149,7 +149,6 @@ public abstract class ServiceBinder {
                    Log.i(this, "Service bound %s", componentName);
                    Log.i(this, "Service bound %s", componentName);


                    Log.addEvent(mCall, LogUtils.Events.CS_BOUND, componentName);
                    Log.addEvent(mCall, LogUtils.Events.CS_BOUND, componentName);
                    mCall = null;


                    // Unbind request was queued so unbind immediately.
                    // Unbind request was queued so unbind immediately.
                    if (mIsBindingAborted) {
                    if (mIsBindingAborted) {
@@ -191,6 +190,30 @@ public abstract class ServiceBinder {
                Log.endSession();
                Log.endSession();
            }
            }
        }
        }

        /**
         * Handles the case where the {@link ConnectionService} we bound to returned a null binding.
         * We want to unbind from the service and cleanup and call resources at this time.
         * @param componentName The component of the {@link ConnectionService}.
         */
        @Override
        public void onNullBinding(ComponentName componentName) {
            try {
                Log.startSession("SBC.oNB");
                synchronized (mLock) {
                    Log.w(this, "Null binding %s", componentName);
                    Log.addEvent(mCall, "NULL_BINDING", componentName);
                    String componentStr = componentName == null ? "null" : componentName.toString();
                    android.util.EventLog.writeEvent(0x534e4554, "211114016", -1, componentStr);
                    logServiceDisconnected("onNullBinding");
                    mContext.unbindService(this);
                    clearAbort();
                    handleFailedConnection();
                }
            } finally {
                Log.endSession();
            }
        }
    }
    }


    private void handleDisconnect() {
    private void handleDisconnect() {