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

Commit 0cef8ce9 authored by Idriss Juhoor's avatar Idriss Juhoor Committed by Android (Google) Code Review
Browse files

Merge "Fix the initialization issue in AccessibilityManager" into main

parents 88e629d6 4434526c
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -220,3 +220,13 @@ flag {
    description: "Feature allows users to change color correction saturation for daltonizer."
    bug: "322829049"
}

flag {
    name: "skip_package_change_before_user_switch"
    namespace: "accessibility"
    description: "Skip onSomePackageChanged callback if the SwitchUser signal is not received yet."
    bug: "340927041"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}
+18 −0
Original line number Diff line number Diff line
@@ -588,6 +588,15 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
        return Thread.holdsLock(mLock);
    }

    /**
     * Returns if the service is initialized.
     *
     * The service is considered initialized when the user switch happened.
     */
    private boolean isServiceInitializedLocked() {
        return mInitialized;
    }

    @Override
    public int getCurrentUserIdLocked() {
        return mCurrentUserId;
@@ -6234,6 +6243,15 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
                if (userId != mManagerService.getCurrentUserIdLocked()) {
                    return;
                }

                // Only continue setting up the packages if the service has been initialized.
                // See: b/340927041
                if (Flags.skipPackageChangeBeforeUserSwitch()
                        && !mManagerService.isServiceInitializedLocked()) {
                    Slog.w(LOG_TAG,
                            "onSomePackagesChanged: service not initialized, skip the callback.");
                    return;
                }
                mManagerService.onSomePackagesChangedLocked(parsedAccessibilityServiceInfos,
                        parsedAccessibilityShortcutInfos);
            }
+2 −0
Original line number Diff line number Diff line
@@ -923,6 +923,8 @@ public class AccessibilityManagerServiceTest {
        ResolveInfo resolveInfo1 = installedService1.getResolveInfo();
        AccessibilityServiceInfo installedService2 =
                mA11yms.getCurrentUserState().mInstalledServices.getLast();
        // Invokes client change to trigger onUserStateChanged.
        mA11yms.onClientChangeLocked(false);

        // Disables `installedService2`
        when(mMockPackageManager.queryIntentServicesAsUser(any(), anyInt(), anyInt()))