Validate input for ContentService#setIsSyncable
The syncable parameter value cannot be set to
SYNCABLE_NO_ACCOUNT_ACCESS which is a synthetic state that
is computed but never persisted. It just means that the sync
adapter cannot access the account regardless of its current
syncable state and we want to keep its current syncable state
to start from there once account access is granted.
bug:31794527
Change-Id: I606c4b517977d0b0d3e7ffe753dfd235a875fcd7
diff --git a/services/core/java/com/android/server/content/SyncManager.java b/services/core/java/com/android/server/content/SyncManager.java
index 131da0b..653d241 100644
--- a/services/core/java/com/android/server/content/SyncManager.java
+++ b/services/core/java/com/android/server/content/SyncManager.java
@@ -1001,7 +1001,12 @@
}
}
- public int computeSyncable(Account account, int userId, String authority) {
+ private int computeSyncable(Account account, int userId, String authority) {
+ return computeSyncable(account, userId, authority, true);
+ }
+
+ public int computeSyncable(Account account, int userId, String authority,
+ boolean checkAccountAccess) {
final int status = getIsSyncable(account, userId, authority);
if (status == AuthorityInfo.NOT_SYNCABLE) {
return AuthorityInfo.NOT_SYNCABLE;
@@ -1025,7 +1030,7 @@
} catch (RemoteException e) {
/* ignore - local call */
}
- if (!canAccessAccount(account, owningPackage, owningUid)) {
+ if (checkAccountAccess && !canAccessAccount(account, owningPackage, owningUid)) {
Log.w(TAG, "Access to " + account + " denied for package "
+ owningPackage + " in UID " + syncAdapterInfo.uid);
return AuthorityInfo.SYNCABLE_NO_ACCOUNT_ACCESS;