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

Commit 1f65c79d authored by Svetoslav's avatar Svetoslav Committed by Android Git Automerger
Browse files

am a60c8c25: am 8297e68d: Merge "BinderDied may be called after we...

am a60c8c25: am 8297e68d: Merge "BinderDied may be called after we unregistered the death recipient." into jb-mr2-dev

* commit 'a60c8c25':
  BinderDied may be called after we unregistered the death recipient.
parents dc7e79d6 a60c8c25
Loading
Loading
Loading
Loading
+18 −7
Original line number Original line Diff line number Diff line
@@ -970,7 +970,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {


    private void addServiceLocked(Service service, UserState userState) {
    private void addServiceLocked(Service service, UserState userState) {
        try {
        try {
            service.linkToOwnDeath();
            service.linkToOwnDeathLocked();
            userState.mBoundServices.add(service);
            userState.mBoundServices.add(service);
            userState.mComponentNameToServiceMap.put(service.mComponentName, service);
            userState.mComponentNameToServiceMap.put(service.mComponentName, service);
        } catch (RemoteException re) {
        } catch (RemoteException re) {
@@ -987,7 +987,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
    private void removeServiceLocked(Service service, UserState userState) {
    private void removeServiceLocked(Service service, UserState userState) {
        userState.mBoundServices.remove(service);
        userState.mBoundServices.remove(service);
        userState.mComponentNameToServiceMap.remove(service.mComponentName);
        userState.mComponentNameToServiceMap.remove(service.mComponentName);
        service.unlinkToOwnDeath();
        service.unlinkToOwnDeathLocked();
    }
    }


    /**
    /**
@@ -1765,7 +1765,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
                userState.destroyUiAutomationService();
                userState.destroyUiAutomationService();
            }
            }
            removeServiceLocked(this, userState);
            removeServiceLocked(this, userState);
            dispose();
            resetLocked();
            return true;
            return true;
        }
        }


@@ -2150,15 +2150,15 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
            /* do nothing - #binderDied takes care */
            /* do nothing - #binderDied takes care */
        }
        }


        public void linkToOwnDeath() throws RemoteException {
        public void linkToOwnDeathLocked() throws RemoteException {
            mService.linkToDeath(this, 0);
            mService.linkToDeath(this, 0);
        }
        }


        public void unlinkToOwnDeath() {
        public void unlinkToOwnDeathLocked() {
            mService.unlinkToDeath(this, 0);
            mService.unlinkToDeath(this, 0);
        }
        }


        public void dispose() {
        public void resetLocked() {
            try {
            try {
                // Clear the proxy in the other process so this
                // Clear the proxy in the other process so this
                // IAccessibilityServiceConnection can be garbage collected.
                // IAccessibilityServiceConnection can be garbage collected.
@@ -2170,13 +2170,24 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
            mServiceInterface = null;
            mServiceInterface = null;
        }
        }


        public boolean isInitializedLocked() {
            return (mService != null);
        }

        public void binderDied() {
        public void binderDied() {
            synchronized (mLock) {
            synchronized (mLock) {
                // It is possible that this service's package was force stopped during
                // whose handling the death recipient is unlinked and still get a call
                // on binderDied since the call was made before we unlink but was
                // waiting on the lock we held during the force stop handling.
                if (!isInitializedLocked()) {
                    return;
                }
                mKeyEventDispatcher.flush();
                mKeyEventDispatcher.flush();
                UserState userState = getUserStateLocked(mUserId);
                UserState userState = getUserStateLocked(mUserId);
                // The death recipient is unregistered in removeServiceLocked
                // The death recipient is unregistered in removeServiceLocked
                removeServiceLocked(this, userState);
                removeServiceLocked(this, userState);
                dispose();
                resetLocked();
                if (mIsAutomation) {
                if (mIsAutomation) {
                    // We no longer have an automation service, so restore
                    // We no longer have an automation service, so restore
                    // the state based on values in the settings database.
                    // the state based on values in the settings database.