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

Commit 1efdc1f4 authored by Rhed Jao's avatar Rhed Jao
Browse files

Apply package visibility to the getSyncAdapterPackages

Bug: 184525389
Test: atest AppEnumerationTests
Test: atest AppStandbyControllerTests
Change-Id: I592c32c05b2276221c03ce751dd41a94a78d4b65
parent c7469537
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
@@ -1261,8 +1261,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,