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

Commit e3423097 authored by Amith Yamasani's avatar Amith Yamasani
Browse files

Fix account filtering for specific package name

Hacks to enable gms to see accounts were interfering with checking for
explicit package name.

Bug: 9095427
Change-Id: Iae65ea2a678d7403d023fa1a61c01347b77c3b5a
parent d6619ed8
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -2802,12 +2802,19 @@ public class AccountManagerService
            if (sharedAccounts == null || sharedAccounts.length == 0) return unfiltered;
            String requiredAccountType = "";
            try {
                // If there's an explicit callingPackage specified, check if that package
                // opted in to see restricted accounts.
                if (callingPackage != null) {
                    PackageInfo pi = mPackageManager.getPackageInfo(callingPackage, 0);
                    if (pi != null && pi.restrictedAccountType != null) {
                        requiredAccountType = pi.restrictedAccountType;
                    }
                } else {
                    // Otherwise check if the callingUid has a package that has opted in
                    for (String packageName : packages) {
                        PackageInfo pi = mPackageManager.getPackageInfo(packageName, 0);
                        if (pi != null && pi.restrictedAccountType != null) {
                            requiredAccountType = pi.restrictedAccountType;
                        // If it matches the package name of the original caller, use this choice.
                        if (callingPackage != null && packageName.equals(callingPackage)) {
                            break;
                        }
                    }