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

Commit 69e34915 authored by Rhed Jao's avatar Rhed Jao Committed by Android (Google) Code Review
Browse files

Merge "Apply package visibility to the getSyncAdapterPackages" into sc-dev

parents 78d8d4d6 1efdc1f4
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -807,12 +807,14 @@ public final class ContentService extends IContentService.Stub {
    public String[] getSyncAdapterPackagesForAuthorityAsUser(String authority, int userId) {
        enforceCrossUserPermission(userId,
                "no permission to read sync settings for user " + userId);
        final int callingUid = Binder.getCallingUid();
        // This makes it so that future permission checks will be in the context of this
        // process rather than the caller's process. We will restore this before returning.
        final long identityToken = clearCallingIdentity();
        try {
            SyncManager syncManager = getSyncManager();
            return syncManager.getSyncAdapterPackagesForAuthorityAsUser(authority, userId);
            return syncManager.getSyncAdapterPackagesForAuthorityAsUser(authority, callingUid,
                    userId);
        } finally {
            restoreCallingIdentity(identityToken);
        }
+13 −2
Original line number Diff line number Diff line
@@ -1268,8 +1268,19 @@ public class SyncManager {
        return types.toArray(new SyncAdapterType[] {});
    }

    public String[] getSyncAdapterPackagesForAuthorityAsUser(String authority, int userId) {
        return mSyncAdapters.getSyncAdapterPackagesForAuthority(authority, userId);
    public String[] getSyncAdapterPackagesForAuthorityAsUser(String authority, int callingUid,
            int userId) {
        final String[] syncAdapterPackages = mSyncAdapters.getSyncAdapterPackagesForAuthority(
                authority, userId);
        final List<String> filteredResult = new ArrayList<>(syncAdapterPackages.length);
        for (String packageName : syncAdapterPackages) {
            if (TextUtils.isEmpty(packageName) || mPackageManagerInternal.filterAppAccess(
                    packageName, callingUid, userId)) {
                continue;
            }
            filteredResult.add(packageName);
        }
        return filteredResult.toArray(new String[] {});
    }

    private void sendSyncFinishedOrCanceledMessage(ActiveSyncContext syncContext,