add a supportsUploading flag in the SyncAdapter description and honor it in the SyncManager
This commit is contained in:
@@ -7489,6 +7489,17 @@
|
|||||||
visibility="public"
|
visibility="public"
|
||||||
>
|
>
|
||||||
</field>
|
</field>
|
||||||
|
<field name="supportsUploading"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="16843410"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
<field name="syncable"
|
<field name="syncable"
|
||||||
type="int"
|
type="int"
|
||||||
transient="false"
|
transient="false"
|
||||||
@@ -36124,6 +36135,8 @@
|
|||||||
</parameter>
|
</parameter>
|
||||||
<parameter name="userVisible" type="boolean">
|
<parameter name="userVisible" type="boolean">
|
||||||
</parameter>
|
</parameter>
|
||||||
|
<parameter name="supportsUploading" type="boolean">
|
||||||
|
</parameter>
|
||||||
</constructor>
|
</constructor>
|
||||||
<constructor name="SyncAdapterType"
|
<constructor name="SyncAdapterType"
|
||||||
type="android.content.SyncAdapterType"
|
type="android.content.SyncAdapterType"
|
||||||
@@ -36146,6 +36159,17 @@
|
|||||||
visibility="public"
|
visibility="public"
|
||||||
>
|
>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="isUserVisible"
|
||||||
|
return="boolean"
|
||||||
|
abstract="false"
|
||||||
|
native="false"
|
||||||
|
synchronized="false"
|
||||||
|
static="false"
|
||||||
|
final="false"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</method>
|
||||||
<method name="newKey"
|
<method name="newKey"
|
||||||
return="android.content.SyncAdapterType"
|
return="android.content.SyncAdapterType"
|
||||||
abstract="false"
|
abstract="false"
|
||||||
@@ -36161,6 +36185,17 @@
|
|||||||
<parameter name="accountType" type="java.lang.String">
|
<parameter name="accountType" type="java.lang.String">
|
||||||
</parameter>
|
</parameter>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="supportsUploading"
|
||||||
|
return="boolean"
|
||||||
|
abstract="false"
|
||||||
|
native="false"
|
||||||
|
synchronized="false"
|
||||||
|
static="false"
|
||||||
|
final="false"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</method>
|
||||||
<method name="writeToParcel"
|
<method name="writeToParcel"
|
||||||
return="void"
|
return="void"
|
||||||
abstract="false"
|
abstract="false"
|
||||||
@@ -36206,7 +36241,7 @@
|
|||||||
visibility="public"
|
visibility="public"
|
||||||
>
|
>
|
||||||
</field>
|
</field>
|
||||||
<field name="userVisible"
|
<field name="isKey"
|
||||||
type="boolean"
|
type="boolean"
|
||||||
transient="false"
|
transient="false"
|
||||||
volatile="false"
|
volatile="false"
|
||||||
|
|||||||
@@ -27,9 +27,12 @@ import android.os.Parcel;
|
|||||||
public class SyncAdapterType implements Parcelable {
|
public class SyncAdapterType implements Parcelable {
|
||||||
public final String authority;
|
public final String authority;
|
||||||
public final String accountType;
|
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)) {
|
if (TextUtils.isEmpty(authority)) {
|
||||||
throw new IllegalArgumentException("the authority must not be empty: " + authority);
|
throw new IllegalArgumentException("the authority must not be empty: " + authority);
|
||||||
}
|
}
|
||||||
@@ -39,17 +42,49 @@ public class SyncAdapterType implements Parcelable {
|
|||||||
this.authority = authority;
|
this.authority = authority;
|
||||||
this.accountType = accountType;
|
this.accountType = accountType;
|
||||||
this.userVisible = userVisible;
|
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) {
|
public static SyncAdapterType newKey(String authority, String accountType) {
|
||||||
return new SyncAdapterType(authority, accountType, true);
|
return new SyncAdapterType(authority, accountType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (o == this) return true;
|
if (o == this) return true;
|
||||||
if (!(o instanceof SyncAdapterType)) return false;
|
if (!(o instanceof SyncAdapterType)) return false;
|
||||||
final SyncAdapterType other = (SyncAdapterType)o;
|
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);
|
return authority.equals(other.authority) && accountType.equals(other.accountType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,13 +92,22 @@ public class SyncAdapterType implements Parcelable {
|
|||||||
int result = 17;
|
int result = 17;
|
||||||
result = 31 * result + authority.hashCode();
|
result = 31 * result + authority.hashCode();
|
||||||
result = 31 * result + accountType.hashCode();
|
result = 31 * result + accountType.hashCode();
|
||||||
// don't include userVisible in the hash
|
// don't include userVisible or supportsUploading the hash
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "SyncAdapterType {name=" + authority + ", type=" + accountType
|
if (isKey) {
|
||||||
+ ", userVisible=" + userVisible + "}";
|
return "SyncAdapterType Key {name=" + authority
|
||||||
|
+ ", type=" + accountType
|
||||||
|
+ "}";
|
||||||
|
} else {
|
||||||
|
return "SyncAdapterType {name=" + authority
|
||||||
|
+ ", type=" + accountType
|
||||||
|
+ ", userVisible=" + userVisible
|
||||||
|
+ ", supportsUploading=" + supportsUploading
|
||||||
|
+ "}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int describeContents() {
|
public int describeContents() {
|
||||||
@@ -71,13 +115,22 @@ public class SyncAdapterType implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
|
if (isKey) {
|
||||||
|
throw new IllegalStateException("keys aren't parcelable");
|
||||||
|
}
|
||||||
|
|
||||||
dest.writeString(authority);
|
dest.writeString(authority);
|
||||||
dest.writeString(accountType);
|
dest.writeString(accountType);
|
||||||
dest.writeInt(userVisible ? 1 : 0);
|
dest.writeInt(userVisible ? 1 : 0);
|
||||||
|
dest.writeInt(supportsUploading ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SyncAdapterType(Parcel source) {
|
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>() {
|
public static final Creator<SyncAdapterType> CREATOR = new Creator<SyncAdapterType>() {
|
||||||
|
|||||||
@@ -49,7 +49,10 @@ import android.util.AttributeSet;
|
|||||||
}
|
}
|
||||||
final boolean userVisible =
|
final boolean userVisible =
|
||||||
sa.getBoolean(com.android.internal.R.styleable.SyncAdapter_userVisible, true);
|
sa.getBoolean(com.android.internal.R.styleable.SyncAdapter_userVisible, true);
|
||||||
return new SyncAdapterType(authority, accountType, userVisible);
|
final boolean supportsUploading =
|
||||||
|
sa.getBoolean(com.android.internal.R.styleable.SyncAdapter_supportsUploading,
|
||||||
|
true);
|
||||||
|
return new SyncAdapterType(authority, accountType, userVisible, supportsUploading);
|
||||||
} finally {
|
} finally {
|
||||||
sa.recycle();
|
sa.recycle();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -526,13 +526,6 @@ class SyncManager implements OnAccountsUpdatedListener {
|
|||||||
public void scheduleSync(Account requestedAccount, String requestedAuthority,
|
public void scheduleSync(Account requestedAccount, String requestedAuthority,
|
||||||
Bundle extras, long delay, boolean onlyThoseWithUnkownSyncableState) {
|
Bundle extras, long delay, boolean onlyThoseWithUnkownSyncableState) {
|
||||||
boolean isLoggable = Log.isLoggable(TAG, Log.VERBOSE);
|
boolean isLoggable = Log.isLoggable(TAG, Log.VERBOSE);
|
||||||
if (isLoggable) {
|
|
||||||
Log.v(TAG, "scheduleSync:"
|
|
||||||
+ " delay " + delay
|
|
||||||
+ ", account " + requestedAccount
|
|
||||||
+ ", authority " + requestedAuthority
|
|
||||||
+ ", extras " + ((extras == null) ? "(null)" : extras));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isSyncEnabled()) {
|
if (!isSyncEnabled()) {
|
||||||
if (isLoggable) {
|
if (isLoggable) {
|
||||||
@@ -617,13 +610,27 @@ class SyncManager implements OnAccountsUpdatedListener {
|
|||||||
if (onlyThoseWithUnkownSyncableState && isSyncable >= 0) {
|
if (onlyThoseWithUnkownSyncableState && isSyncable >= 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (mSyncAdapters.getServiceInfo(SyncAdapterType.newKey(authority, account.type))
|
final RegisteredServicesCache.ServiceInfo<SyncAdapterType> syncAdapterInfo =
|
||||||
!= null) {
|
mSyncAdapters.getServiceInfo(
|
||||||
|
SyncAdapterType.newKey(authority, account.type));
|
||||||
|
if (syncAdapterInfo != null) {
|
||||||
|
if (!syncAdapterInfo.type.supportsUploading() && uploadOnly) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// make this an initialization sync if the isSyncable state is unknown
|
// make this an initialization sync if the isSyncable state is unknown
|
||||||
Bundle extrasCopy = new Bundle(extras);
|
Bundle extrasCopy = extras;
|
||||||
if (isSyncable < 0) {
|
if (isSyncable < 0) {
|
||||||
|
extrasCopy = new Bundle(extras);
|
||||||
extrasCopy.putBoolean(ContentResolver.SYNC_EXTRAS_INITIALIZE, true);
|
extrasCopy.putBoolean(ContentResolver.SYNC_EXTRAS_INITIALIZE, true);
|
||||||
}
|
}
|
||||||
|
if (isLoggable) {
|
||||||
|
Log.v(TAG, "scheduleSync:"
|
||||||
|
+ " delay " + delay
|
||||||
|
+ ", source " + source
|
||||||
|
+ ", account " + account
|
||||||
|
+ ", authority " + authority
|
||||||
|
+ ", extras " + extrasCopy);
|
||||||
|
}
|
||||||
scheduleSyncOperation(
|
scheduleSyncOperation(
|
||||||
new SyncOperation(account, source, authority, extrasCopy, delay));
|
new SyncOperation(account, source, authority, extrasCopy, delay));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,14 +149,12 @@ public class CheckBoxPreference extends Preference {
|
|||||||
* @param checked The checked state.
|
* @param checked The checked state.
|
||||||
*/
|
*/
|
||||||
public void setChecked(boolean checked) {
|
public void setChecked(boolean checked) {
|
||||||
|
if (mChecked != checked) {
|
||||||
mChecked = checked;
|
mChecked = checked;
|
||||||
|
persistBoolean(checked);
|
||||||
persistBoolean(checked);
|
notifyDependencyChange(shouldDisableDependents());
|
||||||
|
notifyChanged();
|
||||||
notifyDependencyChange(shouldDisableDependents());
|
}
|
||||||
|
|
||||||
notifyChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3410,6 +3410,7 @@
|
|||||||
<attr name="contentAuthority" format="string"/>
|
<attr name="contentAuthority" format="string"/>
|
||||||
<attr name="accountType"/>
|
<attr name="accountType"/>
|
||||||
<attr name="userVisible" format="boolean"/>
|
<attr name="userVisible" format="boolean"/>
|
||||||
|
<attr name="supportsUploading" format="boolean"/>
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
<!-- =============================== -->
|
<!-- =============================== -->
|
||||||
|
|||||||
@@ -1159,4 +1159,5 @@
|
|||||||
<public type="style" name="Theme.Wallpaper.NoTitleBar" />
|
<public type="style" name="Theme.Wallpaper.NoTitleBar" />
|
||||||
<public type="style" name="Theme.Wallpaper.NoTitleBar.Fullscreen" />
|
<public type="style" name="Theme.Wallpaper.NoTitleBar.Fullscreen" />
|
||||||
|
|
||||||
|
<public type="attr" name="supportsUploading" />
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user