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

Commit 8f022298 authored by Phil Weaver's avatar Phil Weaver Committed by Android (Google) Code Review
Browse files

Merge "Notify system when uiAutomation terminates"

parents 39b4499d 239677da
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -772,7 +772,6 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
    public void unregisterUiTestAutomationService(IAccessibilityServiceClient serviceClient) {
        synchronized (mLock) {
            mUiAutomationManager.unregisterUiTestAutomationServiceLocked(serviceClient);
            onUserStateChangedLocked(getCurrentUserStateLocked());
        }
    }

+16 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.os.RemoteException;
import android.util.Slog;
import android.view.accessibility.AccessibilityEvent;

import com.android.internal.util.DumpUtils;
import com.android.server.wm.WindowManagerInternal;

import java.io.FileDescriptor;
@@ -45,6 +46,8 @@ class UiAutomationManager {

    private AccessibilityServiceInfo mUiAutomationServiceInfo;

    private AccessibilityClientConnection.SystemSupport mSystemSupport;

    private int mUiAutomationFlags;

    private IBinder mUiAutomationServiceOwner;
@@ -92,6 +95,7 @@ class UiAutomationManager {
            return;
        }

        mSystemSupport = systemSupport;
        mUiAutomationService = new UiAutomationService(context, accessibilityServiceInfo, id,
                mainHandler, lock, securityPolicy, systemSupport, windowManagerInternal,
                globalActionPerfomer);
@@ -169,6 +173,7 @@ class UiAutomationManager {
            mUiAutomationServiceOwner.unlinkToDeath(mUiAutomationServiceOwnerDeathRecipient, 0);
            mUiAutomationServiceOwner = null;
        }
        mSystemSupport.onClientChange(false);
    }

    private class UiAutomationService extends AccessibilityClientConnection {
@@ -224,6 +229,17 @@ class UiAutomationManager {
            return true;
        }

        @Override
        public void dump(FileDescriptor fd, final PrintWriter pw, String[] args) {
            if (!DumpUtils.checkDumpPermission(mContext, LOG_TAG, pw)) return;
            synchronized (mLock) {
                pw.append("Ui Automation[eventTypes="
                        + AccessibilityEvent.eventTypeToString(mEventTypes));
                pw.append(", notificationTimeout=" + mNotificationTimeout);
                pw.append("]");
            }
        }

        // Since this isn't really an accessibility service, several methods are just stubbed here.
        @Override
        public boolean setSoftKeyboardShowMode(int mode) {
+2 −1
Original line number Diff line number Diff line
@@ -153,13 +153,14 @@ public class UiAutomationManagerTest {
    }

    @Test
    public void uiAutomationBinderDiesBeforeConnecting_shouldNotCrash() throws Exception {
    public void uiAutomationBinderDiesBeforeConnecting_notifiesSystem() throws Exception {
        register(0);
        ArgumentCaptor<IBinder.DeathRecipient> captor = ArgumentCaptor.forClass(
                IBinder.DeathRecipient.class);
        verify(mMockOwner).linkToDeath(captor.capture(), anyInt());
        captor.getValue().binderDied();
        mMessageCapturingHandler.sendAllMessages();
        verify(mMockSystemSupport).onClientChange(false);
    }

    private void register(int flags) {