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

Commit 066aa5ed authored by sunjian's avatar sunjian Committed by Jian Sun
Browse files

Notify registered packages of visible accounts change when

authenticators get uninstalled.

Bug: 38332496
Test: manual
Change-Id: I877d52d511deb177d07f9e602d84f33fd0fd2c82
parent 3946916d
Loading
Loading
Loading
Loading
+10 −12
Original line number Diff line number Diff line
@@ -751,6 +751,11 @@ public class AccountManagerService
        }
    }

    private boolean isVisible(int visibility) {
        return visibility == AccountManager.VISIBILITY_VISIBLE ||
            visibility == AccountManager.VISIBILITY_USER_MANAGED_VISIBLE;
    }

    /**
     * Updates visibility for given account name and package.
     *
@@ -803,8 +808,10 @@ public class AccountManagerService
                if (notify) {
                    for (Entry<String, Integer> packageToVisibility : packagesToVisibility
                            .entrySet()) {
                        if (shouldNotifyOnVisibilityChange(packageToVisibility.getValue(),
                                resolveAccountVisibility(account, packageName, accounts))) {
                        int oldVisibility = packageToVisibility.getValue();
                        int currentVisibility =
                            resolveAccountVisibility(account, packageName, accounts);
                        if (isVisible(oldVisibility) != isVisible(currentVisibility)) {
                            notifyPackage(packageToVisibility.getKey(), accounts);
                        }
                    }
@@ -1181,8 +1188,7 @@ public class AccountManagerService

                            for (Entry<String, Integer> packageToVisibility :
                                    packagesToVisibility.entrySet()) {
                                if (shouldNotifyOnVisibilityChange(packageToVisibility.getValue(),
                                        AccountManager.VISIBILITY_NOT_VISIBLE)) {
                                if (isVisible(packageToVisibility.getValue())) {
                                    notifyPackage(packageToVisibility.getKey(), accounts);
                                }
                            }
@@ -1218,14 +1224,6 @@ public class AccountManagerService
        }
    }

    private boolean shouldNotifyOnVisibilityChange(int oldVisibility, int newVisibility) {
        boolean oldVisible = (oldVisibility == AccountManager.VISIBILITY_VISIBLE) ||
            (oldVisibility == AccountManager.VISIBILITY_USER_MANAGED_VISIBLE);
        boolean newVisible = (newVisibility == AccountManager.VISIBILITY_VISIBLE) ||
            (newVisibility == AccountManager.VISIBILITY_USER_MANAGED_VISIBLE);
        return oldVisible == newVisible;
    }

    private SparseBooleanArray getUidsOfInstalledOrUpdatedPackagesAsUser(int userId) {
        // Get the UIDs of all apps that might have data on the device. We want
        // to preserve user data if the app might otherwise be storing data.