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

Commit 8d5b58a6 authored by Jian Sun's avatar Jian Sun Committed by Android (Google) Code Review
Browse files

Merge "Notify registered packages of visible accounts change when...

Merge "Notify registered packages of visible accounts change when authenticators get uninstalled." into oc-dev
parents 6e96251d 066aa5ed
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.