diff options
author | Fred Quintana <fredq@google.com> | 2009-08-19 13:13:18 -0700 |
---|---|---|
committer | Fred Quintana <fredq@google.com> | 2009-08-20 13:52:22 -0700 |
commit | e0616ffb741b64e3bc7a1e3ad9def3d50eee53fd (patch) | |
tree | 36beef758104791c49182db6cf4499d5ba885bcb /core/java/android/content/SyncAdapterType.java | |
parent | 9e61acd9ff267fe9fdbcd130905bdd63ff70db3a (diff) | |
download | frameworks_base-e0616ffb741b64e3bc7a1e3ad9def3d50eee53fd.zip frameworks_base-e0616ffb741b64e3bc7a1e3ad9def3d50eee53fd.tar.gz frameworks_base-e0616ffb741b64e3bc7a1e3ad9def3d50eee53fd.tar.bz2 |
add a supportsUploading flag in the SyncAdapter description and honor it in the SyncManager
Diffstat (limited to 'core/java/android/content/SyncAdapterType.java')
-rw-r--r-- | core/java/android/content/SyncAdapterType.java | 69 |
1 files changed, 61 insertions, 8 deletions
diff --git a/core/java/android/content/SyncAdapterType.java b/core/java/android/content/SyncAdapterType.java index 93b61ec..25cbdb1 100644 --- a/core/java/android/content/SyncAdapterType.java +++ b/core/java/android/content/SyncAdapterType.java @@ -27,9 +27,12 @@ import android.os.Parcel; public class SyncAdapterType implements Parcelable { public final String authority; public final String accountType; - public final boolean userVisible; + public final boolean isKey; + private final boolean userVisible; + private final boolean supportsUploading; - public SyncAdapterType(String authority, String accountType, boolean userVisible) { + public SyncAdapterType(String authority, String accountType, boolean userVisible, + boolean supportsUploading) { if (TextUtils.isEmpty(authority)) { throw new IllegalArgumentException("the authority must not be empty: " + authority); } @@ -39,17 +42,49 @@ public class SyncAdapterType implements Parcelable { this.authority = authority; this.accountType = accountType; this.userVisible = userVisible; + this.supportsUploading = supportsUploading; + this.isKey = false; + } + + private SyncAdapterType(String authority, String accountType) { + if (TextUtils.isEmpty(authority)) { + throw new IllegalArgumentException("the authority must not be empty: " + authority); + } + if (TextUtils.isEmpty(accountType)) { + throw new IllegalArgumentException("the accountType must not be empty: " + accountType); + } + this.authority = authority; + this.accountType = accountType; + this.userVisible = true; + this.supportsUploading = true; + this.isKey = true; + } + + public boolean supportsUploading() { + if (isKey) { + throw new IllegalStateException( + "this method is not allowed to be called when this is a key"); + } + return supportsUploading; + } + + public boolean isUserVisible() { + if (isKey) { + throw new IllegalStateException( + "this method is not allowed to be called when this is a key"); + } + return userVisible; } public static SyncAdapterType newKey(String authority, String accountType) { - return new SyncAdapterType(authority, accountType, true); + return new SyncAdapterType(authority, accountType); } public boolean equals(Object o) { if (o == this) return true; if (!(o instanceof SyncAdapterType)) return false; final SyncAdapterType other = (SyncAdapterType)o; - // don't include userVisible in the equality check + // don't include userVisible or supportsUploading in the equality check return authority.equals(other.authority) && accountType.equals(other.accountType); } @@ -57,13 +92,22 @@ public class SyncAdapterType implements Parcelable { int result = 17; result = 31 * result + authority.hashCode(); result = 31 * result + accountType.hashCode(); - // don't include userVisible in the hash + // don't include userVisible or supportsUploading the hash return result; } public String toString() { - return "SyncAdapterType {name=" + authority + ", type=" + accountType - + ", userVisible=" + userVisible + "}"; + if (isKey) { + return "SyncAdapterType Key {name=" + authority + + ", type=" + accountType + + "}"; + } else { + return "SyncAdapterType {name=" + authority + + ", type=" + accountType + + ", userVisible=" + userVisible + + ", supportsUploading=" + supportsUploading + + "}"; + } } public int describeContents() { @@ -71,13 +115,22 @@ public class SyncAdapterType implements Parcelable { } public void writeToParcel(Parcel dest, int flags) { + if (isKey) { + throw new IllegalStateException("keys aren't parcelable"); + } + dest.writeString(authority); dest.writeString(accountType); dest.writeInt(userVisible ? 1 : 0); + dest.writeInt(supportsUploading ? 1 : 0); } public SyncAdapterType(Parcel source) { - this(source.readString(), source.readString(), source.readInt() != 0); + this( + source.readString(), + source.readString(), + source.readInt() != 0, + source.readInt() != 0); } public static final Creator<SyncAdapterType> CREATOR = new Creator<SyncAdapterType>() { |