Apply package visibility to the getSyncAdapterPackages
Bug: 184525389 Test: atest AppEnumerationTests Test: atest AppStandbyControllerTests Change-Id: I592c32c05b2276221c03ce751dd41a94a78d4b65
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user