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

Commit 8146d24d authored by sallyyuen's avatar sallyyuen
Browse files

Initialize SystemActionPerformer lazily

System health tests indicate regressions.

Bug: 145909124, 154547990
Test: builds
Change-Id: I855dc18ed68ba6cb98e7d921e3f25e4dee147fcb
parent 5e9aed81
Loading
Loading
Loading
Loading
+15 −8
Original line number Diff line number Diff line
@@ -201,7 +201,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;

@@ -299,8 +300,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);
@@ -677,7 +676,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);
    }

    /**
@@ -690,7 +689,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
@@ -802,7 +809,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());
        }
@@ -1522,7 +1529,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;
@@ -2804,7 +2811,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;