Loading core/api/test-current.txt +4 −0 Original line number Diff line number Diff line Loading @@ -706,6 +706,10 @@ package android.content { method public int getDisplayId(); } public class SyncAdapterType implements android.os.Parcelable { method @Nullable public String getPackageName(); } } package android.content.integrity { Loading core/java/android/content/SyncAdapterType.java +2 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.content; import android.annotation.Nullable; import android.annotation.TestApi; import android.compat.annotation.UnsupportedAppUsage; import android.os.Build; import android.os.Parcel; Loading Loading @@ -168,6 +169,7 @@ public class SyncAdapterType implements Parcelable { * * @hide */ @TestApi public @Nullable String getPackageName() { return packageName; } Loading services/core/java/com/android/server/content/ContentService.java +2 −1 Original line number Diff line number Diff line Loading @@ -791,12 +791,13 @@ public final class ContentService extends IContentService.Stub { public SyncAdapterType[] getSyncAdapterTypesAsUser(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.getSyncAdapterTypes(userId); return syncManager.getSyncAdapterTypes(callingUid, userId); } finally { restoreCallingIdentity(identityToken); } Loading services/core/java/com/android/server/content/SyncManager.java +10 −6 Original line number Diff line number Diff line Loading @@ -89,6 +89,7 @@ import android.os.UserHandle; import android.os.UserManager; import android.os.WorkSource; import android.provider.Settings; import android.text.TextUtils; import android.text.format.TimeMigrationUtils; import android.util.EventLog; import android.util.Log; Loading Loading @@ -1257,16 +1258,19 @@ public class SyncManager { syncExemptionFlag, callingUid, callingPid, callingPackage); } public SyncAdapterType[] getSyncAdapterTypes(int userId) { public SyncAdapterType[] getSyncAdapterTypes(int callingUid, int userId) { final Collection<RegisteredServicesCache.ServiceInfo<SyncAdapterType>> serviceInfos; serviceInfos = mSyncAdapters.getAllServices(userId); SyncAdapterType[] types = new SyncAdapterType[serviceInfos.size()]; int i = 0; final List<SyncAdapterType> types = new ArrayList<>(serviceInfos.size()); for (RegisteredServicesCache.ServiceInfo<SyncAdapterType> serviceInfo : serviceInfos) { types[i] = serviceInfo.type; ++i; final String packageName = serviceInfo.type.getPackageName(); if (!TextUtils.isEmpty(packageName) && mPackageManagerInternal.filterAppAccess( packageName, callingUid, userId)) { continue; } types.add(serviceInfo.type); } return types; return types.toArray(new SyncAdapterType[] {}); } public String[] getSyncAdapterPackagesForAuthorityAsUser(String authority, int userId) { Loading Loading
core/api/test-current.txt +4 −0 Original line number Diff line number Diff line Loading @@ -706,6 +706,10 @@ package android.content { method public int getDisplayId(); } public class SyncAdapterType implements android.os.Parcelable { method @Nullable public String getPackageName(); } } package android.content.integrity { Loading
core/java/android/content/SyncAdapterType.java +2 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.content; import android.annotation.Nullable; import android.annotation.TestApi; import android.compat.annotation.UnsupportedAppUsage; import android.os.Build; import android.os.Parcel; Loading Loading @@ -168,6 +169,7 @@ public class SyncAdapterType implements Parcelable { * * @hide */ @TestApi public @Nullable String getPackageName() { return packageName; } Loading
services/core/java/com/android/server/content/ContentService.java +2 −1 Original line number Diff line number Diff line Loading @@ -791,12 +791,13 @@ public final class ContentService extends IContentService.Stub { public SyncAdapterType[] getSyncAdapterTypesAsUser(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.getSyncAdapterTypes(userId); return syncManager.getSyncAdapterTypes(callingUid, userId); } finally { restoreCallingIdentity(identityToken); } Loading
services/core/java/com/android/server/content/SyncManager.java +10 −6 Original line number Diff line number Diff line Loading @@ -89,6 +89,7 @@ import android.os.UserHandle; import android.os.UserManager; import android.os.WorkSource; import android.provider.Settings; import android.text.TextUtils; import android.text.format.TimeMigrationUtils; import android.util.EventLog; import android.util.Log; Loading Loading @@ -1257,16 +1258,19 @@ public class SyncManager { syncExemptionFlag, callingUid, callingPid, callingPackage); } public SyncAdapterType[] getSyncAdapterTypes(int userId) { public SyncAdapterType[] getSyncAdapterTypes(int callingUid, int userId) { final Collection<RegisteredServicesCache.ServiceInfo<SyncAdapterType>> serviceInfos; serviceInfos = mSyncAdapters.getAllServices(userId); SyncAdapterType[] types = new SyncAdapterType[serviceInfos.size()]; int i = 0; final List<SyncAdapterType> types = new ArrayList<>(serviceInfos.size()); for (RegisteredServicesCache.ServiceInfo<SyncAdapterType> serviceInfo : serviceInfos) { types[i] = serviceInfo.type; ++i; final String packageName = serviceInfo.type.getPackageName(); if (!TextUtils.isEmpty(packageName) && mPackageManagerInternal.filterAppAccess( packageName, callingUid, userId)) { continue; } types.add(serviceInfo.type); } return types; return types.toArray(new SyncAdapterType[] {}); } public String[] getSyncAdapterPackagesForAuthorityAsUser(String authority, int userId) { Loading