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

Commit d3ef403f authored by sallyyuen's avatar sallyyuen
Browse files

Laziliy initialize SystemActionPerformer

Tests indicate starting up AccessibilityManagerService takes 5ms longer
than expected and may be due to ag/9726764. Unsure how that change
could cause it, but we can take action and avoid initializing
SystemActionPerformer on start up.

Bug: 145909124
Test: builds and registers actions
Change-Id: Id7b8d5bfc450f96691b1810bf701644a0b1ef637
parent b6eaf6ed
Loading
Loading
Loading
Loading
+15 −8
Original line number Diff line number Diff line
@@ -197,7 +197,8 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub

    private final MainHandler mMainHandler;

    private final SystemActionPerformer mSystemActionPerformer;
    // Lazily initialized - access through getSystemActionPerfomer()
    private SystemActionPerformer mSystemActionPerformer;

    private MagnificationController mMagnificationController;

@@ -295,8 +296,6 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
        mActivityTaskManagerService = LocalServices.getService(ActivityTaskManagerInternal.class);
        mPackageManager = mContext.getPackageManager();
        mSecurityPolicy = new AccessibilitySecurityPolicy(mContext, this);
        mSystemActionPerformer =
                new SystemActionPerformer(mContext, mWindowManagerService, null, this);
        mA11yWindowManager = new AccessibilityWindowManager(mLock, mMainHandler,
                mWindowManagerService, this, mSecurityPolicy, this);
        mA11yDisplayListener = new AccessibilityDisplayListener(mContext, mMainHandler);
@@ -667,7 +666,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
        mSecurityPolicy.enforceCallerIsRecentsOrHasPermission(
                Manifest.permission.MANAGE_ACCESSIBILITY,
                FUNCTION_REGISTER_SYSTEM_ACTION);
        mSystemActionPerformer.registerSystemAction(actionId, action);
        getSystemActionPerformer().registerSystemAction(actionId, action);
    }

    /**
@@ -680,7 +679,15 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
        mSecurityPolicy.enforceCallerIsRecentsOrHasPermission(
                Manifest.permission.MANAGE_ACCESSIBILITY,
                FUNCTION_UNREGISTER_SYSTEM_ACTION);
        mSystemActionPerformer.unregisterSystemAction(actionId);
        getSystemActionPerformer().unregisterSystemAction(actionId);
    }

    private SystemActionPerformer getSystemActionPerformer() {
        if (mSystemActionPerformer == null) {
            mSystemActionPerformer =
                    new SystemActionPerformer(mContext, mWindowManagerService, null, this);
        }
        return mSystemActionPerformer;
    }

    @Override
@@ -792,7 +799,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
        synchronized (mLock) {
            mUiAutomationManager.registerUiTestAutomationServiceLocked(owner, serviceClient,
                    mContext, accessibilityServiceInfo, sIdCounter++, mMainHandler,
                    mSecurityPolicy, this, mWindowManagerService, mSystemActionPerformer,
                    mSecurityPolicy, this, mWindowManagerService, getSystemActionPerformer(),
                    mA11yWindowManager, flags);
            onUserStateChangedLocked(getCurrentUserStateLocked());
        }
@@ -1503,7 +1510,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
                if (service == null) {
                    service = new AccessibilityServiceConnection(userState, mContext, componentName,
                            installedService, sIdCounter++, mMainHandler, mLock, mSecurityPolicy,
                            this, mWindowManagerService, mSystemActionPerformer,
                            this, mWindowManagerService, getSystemActionPerformer(),
                            mA11yWindowManager, mActivityTaskManagerService);
                } else if (userState.mBoundServices.contains(service)) {
                    continue;
@@ -2741,7 +2748,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
                    userState, mContext,
                    COMPONENT_NAME, info, sIdCounter++, mMainHandler, mLock, mSecurityPolicy,
                    AccessibilityManagerService.this, mWindowManagerService,
                    mSystemActionPerformer, mA11yWindowManager, mActivityTaskManagerService) {
                    getSystemActionPerformer(), mA11yWindowManager, mActivityTaskManagerService) {
                @Override
                public boolean supportsFlagForNotImportantViews(AccessibilityServiceInfo info) {
                    return true;