From 231cc608d06ffc31c24bf8aa8c8275bdd2636581 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Mon, 27 Apr 2009 17:10:36 -0700 Subject: Rewrite SyncStorageEngine to use flat files and in-memory data structures. The previous implementation used a database for storing all of its state, which could cause a significant amount of IO activity as its tables were updated through the stages of a sync. This new implementation replaces that in-memory data structures, with hand-written code for writing them to persistent storage. There are now 4 files associated with this class, holding various pieces of its state that should be consistent. These are everything from a main XML file of account information that must always be retained, to a binary file of per-day statistics that can be thrown away at any time. Writes of these files as scheduled at various times based on their importance of the frequency at which they change. Because the database no longer exists, there needs to be a new explicit interface for interacting with the sync manager database. This is provided by new APIs on IContentService, with a hidden method on ContentResolver to retrieve the IContentService so that various system entities can use it. Other changes in other projects are required to update to the new API. The goal here is to have as little an impact on the code and functionality outside of SyncStorageEngine, though due to the necessary change in API it is still somewhat extensive. --- .../android/test/SyncBaseInstrumentation.java | 41 +++++----------------- 1 file changed, 8 insertions(+), 33 deletions(-) (limited to 'test-runner') diff --git a/test-runner/android/test/SyncBaseInstrumentation.java b/test-runner/android/test/SyncBaseInstrumentation.java index c1d2507..772d75c 100644 --- a/test-runner/android/test/SyncBaseInstrumentation.java +++ b/test-runner/android/test/SyncBaseInstrumentation.java @@ -18,12 +18,10 @@ package android.test; import android.content.ContentResolver; import android.content.Context; -import android.content.ContentValues; import android.os.Bundle; +import android.os.RemoteException; import android.os.SystemClock; -import android.provider.Sync; import android.net.Uri; -import java.util.Map; /** * If you would like to test sync a single provider with an @@ -75,11 +73,11 @@ public class SyncBaseInstrumentation extends InstrumentationTestCase { } protected void cancelSyncsandDisableAutoSync() { - Sync.Settings.QueryMap mSyncSettings = - new Sync.Settings.QueryMap(mContentResolver, true, null); - mSyncSettings.setListenForNetworkTickles(false); + try { + ContentResolver.getContentService().setListenForNetworkTickles(false); + } catch (RemoteException e) { + } mContentResolver.cancelSync(null); - mSyncSettings.close(); } /** @@ -88,34 +86,11 @@ public class SyncBaseInstrumentation extends InstrumentationTestCase { * @return */ private boolean isSyncActive(String account, String authority) { - Sync.Pending.QueryMap pendingQueryMap = null; - Sync.Active.QueryMap activeQueryMap = null; try { - pendingQueryMap = new Sync.Pending.QueryMap(mContentResolver, false, null); - activeQueryMap = new Sync.Active.QueryMap(mContentResolver, false, null); - - if (pendingQueryMap.isPending(account, authority)) { - return true; - } - if (isActiveInActiveQueryMap(activeQueryMap, account, authority)) { - return true; - } + return ContentResolver.getContentService().isSyncActive(account, + authority); + } catch (RemoteException e) { return false; - } finally { - activeQueryMap.close(); - pendingQueryMap.close(); - } - } - - private boolean isActiveInActiveQueryMap(Sync.Active.QueryMap activemap, String account, - String authority) { - Map rows = activemap.getRows(); - for (ContentValues values : rows.values()) { - if (values.getAsString("account").equals(account) - && values.getAsString("authority").equals(authority)) { - return true; - } } - return false; } } -- cgit v1.1