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

Commit cbb04a42 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix ServiceConnector failing unbind if not connected." into sc-v2-dev

parents d47ad7b2 efc50877
Loading
Loading
Loading
Loading
+12 −1
Original line number Original line Diff line number Diff line
@@ -507,10 +507,21 @@ public interface ServiceConnector<I extends IInterface> {
        void unbindJobThread() {
        void unbindJobThread() {
            cancelTimeout();
            cancelTimeout();
            I service = mService;
            I service = mService;
            // TODO(b/224695239): This is actually checking wasConnected. Rename and/or fix
            // implementation based on what this should actually be checking. At least the first
            // check for calling unbind is the correct behavior, though.
            boolean wasBound = service != null;
            boolean wasBound = service != null;
            if (wasBound || mBinding) {
                try {
                    mContext.unbindService(mServiceConnection);
                } catch (IllegalArgumentException e) {  // TODO(b/224697137): Fix the race condition
                                                        // that requires catching this (crashes if
                                                        // service isn't currently bound).
                    Log.e(LOG_TAG, "Failed to unbind: " + e);
                }
            }
            if (wasBound) {
            if (wasBound) {
                onServiceConnectionStatusChanged(service, false);
                onServiceConnectionStatusChanged(service, false);
                mContext.unbindService(mServiceConnection);
                service.asBinder().unlinkToDeath(this, 0);
                service.asBinder().unlinkToDeath(this, 0);
                mService = null;
                mService = null;
            }
            }