From 5ebbb4a6b3e16f711735ae0615b9a9ea64faad38 Mon Sep 17 00:00:00 2001 From: Fred Quintana Date: Mon, 9 Nov 2009 15:42:20 -0800 Subject: Make the RegisteredSErvices Cache not allow the registered service for a type to change without first uninstalling the previous service for that type, unless the newly installed service is in the system image. Notify the listener when a service is added or removed. Make the AccountManagerService remove the accounts for an authenticator when the registered authenticator changes from one uid to another. Make the AbstractSyncableContentProvider force a sync when the database is first created. --- core/java/android/content/SyncAdaptersCache.java | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'core/java/android/content/SyncAdaptersCache.java') diff --git a/core/java/android/content/SyncAdaptersCache.java b/core/java/android/content/SyncAdaptersCache.java index 7d9f1de..6ade837 100644 --- a/core/java/android/content/SyncAdaptersCache.java +++ b/core/java/android/content/SyncAdaptersCache.java @@ -17,9 +17,14 @@ package android.content; import android.content.pm.RegisteredServicesCache; +import android.content.pm.XmlSerializerAndParser; import android.content.res.TypedArray; -import android.content.Context; import android.util.AttributeSet; +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlSerializer; +import org.xmlpull.v1.XmlPullParserException; + +import java.io.IOException; /** * A cache of services that export the {@link android.content.ISyncAdapter} interface. @@ -31,9 +36,10 @@ import android.util.AttributeSet; private static final String SERVICE_INTERFACE = "android.content.SyncAdapter"; private static final String SERVICE_META_DATA = "android.content.SyncAdapter"; private static final String ATTRIBUTES_NAME = "sync-adapter"; + private static final MySerializer sSerializer = new MySerializer(); SyncAdaptersCache(Context context) { - super(context, SERVICE_INTERFACE, SERVICE_META_DATA, ATTRIBUTES_NAME); + super(context, SERVICE_INTERFACE, SERVICE_META_DATA, ATTRIBUTES_NAME, sSerializer); } public SyncAdapterType parseServiceAttributes(String packageName, AttributeSet attrs) { @@ -57,4 +63,18 @@ import android.util.AttributeSet; sa.recycle(); } } + + static class MySerializer implements XmlSerializerAndParser { + public void writeAsXml(SyncAdapterType item, XmlSerializer out) throws IOException { + out.attribute(null, "authority", item.authority); + out.attribute(null, "accountType", item.accountType); + } + + public SyncAdapterType createFromXml(XmlPullParser parser) + throws IOException, XmlPullParserException { + final String authority = parser.getAttributeValue(null, "authority"); + final String accountType = parser.getAttributeValue(null, "accountType"); + return SyncAdapterType.newKey(authority, accountType); + } + } } \ No newline at end of file -- cgit v1.1