Loading core/java/android/content/SyncInfo.java +18 −0 Original line number Original line Diff line number Diff line Loading @@ -24,6 +24,13 @@ import android.os.Parcelable; * Information about the sync operation that is currently underway. * Information about the sync operation that is currently underway. */ */ public class SyncInfo implements Parcelable { public class SyncInfo implements Parcelable { /** * Used when the caller receiving this object doesn't have permission to access the accounts * on device. * @See Manifest.permission.GET_ACCOUNTS */ private static final Account REDACTED_ACCOUNT = new Account("*****", "*****"); /** @hide */ /** @hide */ public final int authorityId; public final int authorityId; Loading @@ -44,6 +51,17 @@ public class SyncInfo implements Parcelable { */ */ public final long startTime; public final long startTime; /** * Creates a SyncInfo object with an unusable Account. Used when the caller receiving this * object doesn't have access to the accounts on the device. * @See Manifest.permission.GET_ACCOUNTS * @hide */ public static SyncInfo createAccountRedacted( int authorityId, String authority, long startTime) { return new SyncInfo(authorityId, REDACTED_ACCOUNT, authority, startTime); } /** @hide */ /** @hide */ public SyncInfo(int authorityId, Account account, String authority, long startTime) { public SyncInfo(int authorityId, Account account, String authority, long startTime) { this.authorityId = authorityId; this.authorityId = authorityId; Loading services/core/java/com/android/server/content/ContentService.java +5 −1 Original line number Original line Diff line number Diff line Loading @@ -775,9 +775,13 @@ public final class ContentService extends IContentService.Stub { mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_STATS, mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_STATS, "no permission to read the sync stats"); "no permission to read the sync stats"); final boolean canAccessAccounts = mContext.checkCallingOrSelfPermission(Manifest.permission.GET_ACCOUNTS) == PackageManager.PERMISSION_GRANTED; long identityToken = clearCallingIdentity(); long identityToken = clearCallingIdentity(); try { try { return getSyncManager().getSyncStorageEngine().getCurrentSyncsCopy(userId); return getSyncManager().getSyncStorageEngine() .getCurrentSyncsCopy(userId, canAccessAccounts); } finally { } finally { restoreCallingIdentity(identityToken); restoreCallingIdentity(identityToken); } } Loading services/core/java/com/android/server/content/SyncStorageEngine.java +20 −6 Original line number Original line Diff line number Diff line Loading @@ -44,6 +44,7 @@ import android.util.Pair; import android.util.SparseArray; import android.util.SparseArray; import android.util.ArrayMap; import android.util.ArrayMap; import android.util.Xml; import android.util.Xml; import android.util.EventLog; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.ArrayUtils; import com.android.internal.util.ArrayUtils; Loading Loading @@ -1426,15 +1427,23 @@ public class SyncStorageEngine extends Handler { } } /** /** * @return a copy of the current syncs data structure. Will not return * @param userId Id of user to return current sync info. * null. * @param canAccessAccounts Determines whether to redact Account information from the result. * @return a copy of the current syncs data structure. Will not return null. */ */ public List<SyncInfo> getCurrentSyncsCopy(int userId) { public List<SyncInfo> getCurrentSyncsCopy(int userId, boolean canAccessAccounts) { synchronized (mAuthorities) { synchronized (mAuthorities) { final List<SyncInfo> syncs = getCurrentSyncsLocked(userId); final List<SyncInfo> syncs = getCurrentSyncsLocked(userId); final List<SyncInfo> syncsCopy = new ArrayList<SyncInfo>(); final List<SyncInfo> syncsCopy = new ArrayList<SyncInfo>(); for (SyncInfo sync : syncs) { for (SyncInfo sync : syncs) { syncsCopy.add(new SyncInfo(sync)); SyncInfo copy; if (!canAccessAccounts) { copy = SyncInfo.createAccountRedacted( sync.authorityId, sync.authority, sync.startTime); } else { copy = new SyncInfo(sync); } syncsCopy.add(copy); } } return syncsCopy; return syncsCopy; } } Loading Loading @@ -1860,9 +1869,14 @@ public class SyncStorageEngine extends Handler { if ("authority".equals(tagName)) { if ("authority".equals(tagName)) { authority = parseAuthority(parser, version); authority = parseAuthority(parser, version); periodicSync = null; periodicSync = null; if (authority != null) { if (authority.ident > highestAuthorityId) { if (authority.ident > highestAuthorityId) { highestAuthorityId = authority.ident; highestAuthorityId = authority.ident; } } } else { EventLog.writeEvent(0x534e4554, "26513719", -1, "Malformed authority"); } } else if (XML_TAG_LISTEN_FOR_TICKLES.equals(tagName)) { } else if (XML_TAG_LISTEN_FOR_TICKLES.equals(tagName)) { parseListenForTickles(parser); parseListenForTickles(parser); } } Loading Loading
core/java/android/content/SyncInfo.java +18 −0 Original line number Original line Diff line number Diff line Loading @@ -24,6 +24,13 @@ import android.os.Parcelable; * Information about the sync operation that is currently underway. * Information about the sync operation that is currently underway. */ */ public class SyncInfo implements Parcelable { public class SyncInfo implements Parcelable { /** * Used when the caller receiving this object doesn't have permission to access the accounts * on device. * @See Manifest.permission.GET_ACCOUNTS */ private static final Account REDACTED_ACCOUNT = new Account("*****", "*****"); /** @hide */ /** @hide */ public final int authorityId; public final int authorityId; Loading @@ -44,6 +51,17 @@ public class SyncInfo implements Parcelable { */ */ public final long startTime; public final long startTime; /** * Creates a SyncInfo object with an unusable Account. Used when the caller receiving this * object doesn't have access to the accounts on the device. * @See Manifest.permission.GET_ACCOUNTS * @hide */ public static SyncInfo createAccountRedacted( int authorityId, String authority, long startTime) { return new SyncInfo(authorityId, REDACTED_ACCOUNT, authority, startTime); } /** @hide */ /** @hide */ public SyncInfo(int authorityId, Account account, String authority, long startTime) { public SyncInfo(int authorityId, Account account, String authority, long startTime) { this.authorityId = authorityId; this.authorityId = authorityId; Loading
services/core/java/com/android/server/content/ContentService.java +5 −1 Original line number Original line Diff line number Diff line Loading @@ -775,9 +775,13 @@ public final class ContentService extends IContentService.Stub { mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_STATS, mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_STATS, "no permission to read the sync stats"); "no permission to read the sync stats"); final boolean canAccessAccounts = mContext.checkCallingOrSelfPermission(Manifest.permission.GET_ACCOUNTS) == PackageManager.PERMISSION_GRANTED; long identityToken = clearCallingIdentity(); long identityToken = clearCallingIdentity(); try { try { return getSyncManager().getSyncStorageEngine().getCurrentSyncsCopy(userId); return getSyncManager().getSyncStorageEngine() .getCurrentSyncsCopy(userId, canAccessAccounts); } finally { } finally { restoreCallingIdentity(identityToken); restoreCallingIdentity(identityToken); } } Loading
services/core/java/com/android/server/content/SyncStorageEngine.java +20 −6 Original line number Original line Diff line number Diff line Loading @@ -44,6 +44,7 @@ import android.util.Pair; import android.util.SparseArray; import android.util.SparseArray; import android.util.ArrayMap; import android.util.ArrayMap; import android.util.Xml; import android.util.Xml; import android.util.EventLog; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.ArrayUtils; import com.android.internal.util.ArrayUtils; Loading Loading @@ -1426,15 +1427,23 @@ public class SyncStorageEngine extends Handler { } } /** /** * @return a copy of the current syncs data structure. Will not return * @param userId Id of user to return current sync info. * null. * @param canAccessAccounts Determines whether to redact Account information from the result. * @return a copy of the current syncs data structure. Will not return null. */ */ public List<SyncInfo> getCurrentSyncsCopy(int userId) { public List<SyncInfo> getCurrentSyncsCopy(int userId, boolean canAccessAccounts) { synchronized (mAuthorities) { synchronized (mAuthorities) { final List<SyncInfo> syncs = getCurrentSyncsLocked(userId); final List<SyncInfo> syncs = getCurrentSyncsLocked(userId); final List<SyncInfo> syncsCopy = new ArrayList<SyncInfo>(); final List<SyncInfo> syncsCopy = new ArrayList<SyncInfo>(); for (SyncInfo sync : syncs) { for (SyncInfo sync : syncs) { syncsCopy.add(new SyncInfo(sync)); SyncInfo copy; if (!canAccessAccounts) { copy = SyncInfo.createAccountRedacted( sync.authorityId, sync.authority, sync.startTime); } else { copy = new SyncInfo(sync); } syncsCopy.add(copy); } } return syncsCopy; return syncsCopy; } } Loading Loading @@ -1860,9 +1869,14 @@ public class SyncStorageEngine extends Handler { if ("authority".equals(tagName)) { if ("authority".equals(tagName)) { authority = parseAuthority(parser, version); authority = parseAuthority(parser, version); periodicSync = null; periodicSync = null; if (authority != null) { if (authority.ident > highestAuthorityId) { if (authority.ident > highestAuthorityId) { highestAuthorityId = authority.ident; highestAuthorityId = authority.ident; } } } else { EventLog.writeEvent(0x534e4554, "26513719", -1, "Malformed authority"); } } else if (XML_TAG_LISTEN_FOR_TICKLES.equals(tagName)) { } else if (XML_TAG_LISTEN_FOR_TICKLES.equals(tagName)) { parseListenForTickles(parser); parseListenForTickles(parser); } } Loading