ProfileSyncService.java revision 5b62eb5758cb7b791cfdd45cf78f35dc060631b6
1// Copyright 2013 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5package org.chromium.chrome.browser.sync;
6
7import android.content.Context;
8import android.util.Log;
9
10import org.chromium.base.CalledByNative;
11import org.chromium.base.ThreadUtils;
12import org.chromium.base.VisibleForTesting;
13import org.chromium.chrome.browser.identity.UniqueIdentificationGenerator;
14import org.chromium.sync.internal_api.pub.SyncDecryptionPassphraseType;
15import org.chromium.sync.internal_api.pub.base.ModelType;
16
17import java.util.HashSet;
18import java.util.Iterator;
19import java.util.List;
20import java.util.Set;
21import java.util.SortedSet;
22import java.util.TreeSet;
23import java.util.concurrent.CopyOnWriteArrayList;
24
25/**
26 * Android wrapper of the ProfileSyncService which provides access from the Java layer.
27 * <p/>
28 * This class mostly wraps native classes, but it make a few business logic decisions, both in Java
29 * and in native.
30 * <p/>
31 * Only usable from the UI thread as the native ProfileSyncService requires its access to be in the
32 * UI thread.
33 * <p/>
34 * See chrome/browser/sync/profile_sync_service.h for more details.
35 */
36public class ProfileSyncService {
37
38    public interface SyncStateChangedListener {
39        // Invoked when the underlying sync status has changed.
40        public void syncStateChanged();
41    }
42
43    private static final String TAG = "ProfileSyncService";
44
45    @VisibleForTesting
46    public static final String SESSION_TAG_PREFIX = "session_sync";
47
48    private static ProfileSyncService sSyncSetupManager;
49
50    @VisibleForTesting
51    protected final Context mContext;
52
53    // Sync state changes more often than listeners are added/removed, so using CopyOnWrite.
54    private final List<SyncStateChangedListener> mListeners =
55            new CopyOnWriteArrayList<SyncStateChangedListener>();
56
57    // Native ProfileSyncServiceAndroid object. Can not be final since we set it to 0 in destroy().
58    private final long mNativeProfileSyncServiceAndroid;
59
60    /**
61     * A helper method for retrieving the application-wide SyncSetupManager.
62     * <p/>
63     * Can only be accessed on the main thread.
64     *
65     * @param context the ApplicationContext is retrieved from the context used as an argument.
66     * @return a singleton instance of the SyncSetupManager
67     */
68    public static ProfileSyncService get(Context context) {
69        ThreadUtils.assertOnUiThread();
70        if (sSyncSetupManager == null) {
71            sSyncSetupManager = new ProfileSyncService(context);
72        }
73        return sSyncSetupManager;
74    }
75
76    /**
77     * This is called pretty early in our application. Avoid any blocking operations here.
78     */
79    private ProfileSyncService(Context context) {
80        ThreadUtils.assertOnUiThread();
81        // We should store the application context, as we outlive any activity which may create us.
82        mContext = context.getApplicationContext();
83
84        // This may cause us to create ProfileSyncService even if sync has not
85        // been set up, but ProfileSyncService::Startup() won't be called until
86        // credentials are available.
87        mNativeProfileSyncServiceAndroid = nativeInit();
88    }
89
90    @CalledByNative
91    private static long getProfileSyncServiceAndroid(Context context) {
92        return get(context).mNativeProfileSyncServiceAndroid;
93    }
94
95    /**
96     * If we are currently in the process of setting up sync, this method clears the
97     * sync setup in progress flag.
98     */
99    @VisibleForTesting
100    public void finishSyncFirstSetupIfNeeded() {
101        if (isFirstSetupInProgress()) {
102            setSyncSetupCompleted();
103            setSetupInProgress(false);
104        }
105    }
106
107    public void signOut() {
108        nativeSignOutSync(mNativeProfileSyncServiceAndroid);
109    }
110
111    /**
112     * Signs in to sync, using the currently signed-in account.
113     */
114    public void syncSignIn() {
115        nativeSignInSync(mNativeProfileSyncServiceAndroid);
116        // Notify listeners right away that the sync state has changed (native side does not do
117        // this)
118        syncStateChanged();
119    }
120
121    /**
122     * Signs in to sync, using the existing auth token.
123     */
124    @Deprecated
125    public void syncSignIn(String account) {
126        syncSignIn();
127    }
128
129    /**
130     * Signs in to sync.
131     *
132     * @param account   The username of the account that is signing in.
133     * @param authToken Not used. ProfileSyncService switched to OAuth2 tokens.
134     * Deprecated. Use syncSignIn instead.
135     */
136    @Deprecated
137    public void syncSignInWithAuthToken(String account, String authToken) {
138        syncSignIn(account);
139    }
140
141    public void requestSyncFromNativeChrome(
142            int objectSource, String objectId, long version, String payload) {
143        ThreadUtils.assertOnUiThread();
144        nativeNudgeSyncer(
145                mNativeProfileSyncServiceAndroid, objectSource, objectId, version, payload);
146    }
147
148    public void requestSyncFromNativeChromeForAllTypes() {
149        ThreadUtils.assertOnUiThread();
150        nativeNudgeSyncerForAllTypes(mNativeProfileSyncServiceAndroid);
151    }
152
153    /**
154     * Nudge the syncer to start a new sync cycle.
155     */
156    @VisibleForTesting
157    public void requestSyncCycleForTest() {
158        ThreadUtils.assertOnUiThread();
159        requestSyncFromNativeChromeForAllTypes();
160    }
161
162    public String querySyncStatus() {
163        ThreadUtils.assertOnUiThread();
164        return nativeQuerySyncStatusSummary(mNativeProfileSyncServiceAndroid);
165    }
166
167    /**
168     * Sets the the machine tag used by session sync to a unique value.
169     */
170    public void setSessionsId(UniqueIdentificationGenerator generator) {
171        ThreadUtils.assertOnUiThread();
172        String uniqueTag = generator.getUniqueId(null);
173        if (uniqueTag.isEmpty()) {
174            Log.e(TAG, "Unable to get unique tag for sync. " +
175                    "This may lead to unexpected tab sync behavior.");
176            return;
177        }
178        String sessionTag = SESSION_TAG_PREFIX + uniqueTag;
179        if (!nativeSetSyncSessionsId(mNativeProfileSyncServiceAndroid, sessionTag)) {
180            Log.e(TAG, "Unable to write session sync tag. " +
181                    "This may lead to unexpected tab sync behavior.");
182        }
183    }
184
185    /**
186     * Checks if a password or a passphrase is required for decryption of sync data.
187     * <p/>
188     * Returns NONE if the state is unavailable, or decryption passphrase/password is not required.
189     *
190     * @return the enum describing the decryption passphrase type required
191     */
192    public SyncDecryptionPassphraseType getSyncDecryptionPassphraseTypeIfRequired() {
193        // ProfileSyncService::IsUsingSecondaryPassphrase() requires the sync backend to be
194        // initialized, and that happens just after OnPassphraseRequired(). Therefore, we need to
195        // guard that call with a check of the sync backend since we can not be sure which
196        // passphrase type we should tell the user we need.
197        // This is tracked in:
198        // http://code.google.com/p/chromium/issues/detail?id=108127
199        if (isSyncInitialized() && isPassphraseRequiredForDecryption()) {
200            return getSyncDecryptionPassphraseType();
201        }
202        return SyncDecryptionPassphraseType.NONE;
203    }
204
205    /**
206     * Returns the actual passphrase type being used for encryption. The sync backend must be
207     * running (isSyncInitialized() returns true) before calling this function.
208     * <p/>
209     * This method should only be used if you want to know the raw value. For checking whether we
210     * should ask the user for a passphrase, you should instead use
211     * getSyncDecryptionPassphraseTypeIfRequired().
212     */
213    public SyncDecryptionPassphraseType getSyncDecryptionPassphraseType() {
214        assert isSyncInitialized();
215        int passphraseType = nativeGetPassphraseType(mNativeProfileSyncServiceAndroid);
216        return SyncDecryptionPassphraseType.fromInternalValue(passphraseType);
217    }
218
219    public boolean isSyncKeystoreMigrationDone() {
220        assert isSyncInitialized();
221        return nativeIsSyncKeystoreMigrationDone(mNativeProfileSyncServiceAndroid);
222    }
223
224    /**
225     * Returns true if the current explicit passphrase time is defined.
226     */
227    public boolean hasExplicitPassphraseTime() {
228        assert isSyncInitialized();
229        return nativeHasExplicitPassphraseTime(mNativeProfileSyncServiceAndroid);
230    }
231
232    /**
233     * Returns the current explicit passphrase time in milliseconds since epoch.
234     */
235    public long getExplicitPassphraseTime() {
236        assert isSyncInitialized();
237        return nativeGetExplicitPassphraseTime(mNativeProfileSyncServiceAndroid);
238    }
239
240    public String getSyncEnterGooglePassphraseBodyWithDateText() {
241        assert isSyncInitialized();
242        return nativeGetSyncEnterGooglePassphraseBodyWithDateText(mNativeProfileSyncServiceAndroid);
243    }
244
245    public String getSyncEnterCustomPassphraseBodyWithDateText() {
246        assert isSyncInitialized();
247        return nativeGetSyncEnterCustomPassphraseBodyWithDateText(mNativeProfileSyncServiceAndroid);
248    }
249
250    public String getCurrentSignedInAccountText() {
251        assert isSyncInitialized();
252        return nativeGetCurrentSignedInAccountText(mNativeProfileSyncServiceAndroid);
253    }
254
255    public String getSyncEnterCustomPassphraseBodyText() {
256        return nativeGetSyncEnterCustomPassphraseBodyText(mNativeProfileSyncServiceAndroid);
257    }
258
259    /**
260     * Checks if sync is currently set to use a custom passphrase. The sync backend must be running
261     * (isSyncInitialized() returns true) before calling this function.
262     *
263     * @return true if sync is using a custom passphrase.
264     */
265    public boolean isUsingSecondaryPassphrase() {
266        assert isSyncInitialized();
267        return nativeIsUsingSecondaryPassphrase(mNativeProfileSyncServiceAndroid);
268    }
269
270    /**
271     * Checks if we need a passphrase to decrypt a currently-enabled data type. This returns false
272     * if a passphrase is needed for a type that is not currently enabled.
273     *
274     * @return true if we need a passphrase.
275     */
276    public boolean isPassphraseRequiredForDecryption() {
277        assert isSyncInitialized();
278        return nativeIsPassphraseRequiredForDecryption(mNativeProfileSyncServiceAndroid);
279    }
280
281    /**
282     * Checks if we need a passphrase to decrypt any data type (including types that aren't
283     * currently enabled or supported, such as passwords). This API is used to determine if we
284     * need to provide a decryption passphrase before we can re-encrypt with a custom passphrase.
285     *
286     * @return true if we need a passphrase for some type.
287     */
288    public boolean isPassphraseRequiredForExternalType() {
289        assert isSyncInitialized();
290        return nativeIsPassphraseRequiredForExternalType(mNativeProfileSyncServiceAndroid);
291    }
292
293    /**
294     * Checks if the sync backend is running.
295     *
296     * @return true if sync is initialized/running.
297     */
298    public boolean isSyncInitialized() {
299        return nativeIsSyncInitialized(mNativeProfileSyncServiceAndroid);
300    }
301
302    /**
303     * Checks if the first sync setup is currently in progress.
304     *
305     * @return true if first sync setup is in progress
306     */
307    public boolean isFirstSetupInProgress() {
308        return nativeIsFirstSetupInProgress(mNativeProfileSyncServiceAndroid);
309    }
310
311    /**
312     * Checks if the all the data types are encrypted.
313     *
314     * @return true if all data types are encrypted, false if only passwords are encrypted.
315     */
316    public boolean isEncryptEverythingEnabled() {
317        assert isSyncInitialized();
318        return nativeIsEncryptEverythingEnabled(mNativeProfileSyncServiceAndroid);
319    }
320
321    /**
322     * Turns on encryption of all data types. This only takes effect after sync configuration is
323     * completed and setPreferredDataTypes() is invoked.
324     */
325    public void enableEncryptEverything() {
326        assert isSyncInitialized();
327        nativeEnableEncryptEverything(mNativeProfileSyncServiceAndroid);
328    }
329
330    public void setEncryptionPassphrase(String passphrase, boolean isGaia) {
331        assert isSyncInitialized();
332        nativeSetEncryptionPassphrase(mNativeProfileSyncServiceAndroid, passphrase, isGaia);
333    }
334
335    public boolean isCryptographerReady() {
336        assert isSyncInitialized();
337        return nativeIsCryptographerReady(mNativeProfileSyncServiceAndroid);
338    }
339
340    public boolean setDecryptionPassphrase(String passphrase) {
341        assert isSyncInitialized();
342        return nativeSetDecryptionPassphrase(mNativeProfileSyncServiceAndroid, passphrase);
343    }
344
345    public GoogleServiceAuthError.State getAuthError() {
346        int authErrorCode = nativeGetAuthError(mNativeProfileSyncServiceAndroid);
347        return GoogleServiceAuthError.State.fromCode(authErrorCode);
348    }
349
350    /**
351     * Gets the set of data types that are currently enabled to sync.
352     *
353     * @return Set of enabled types.
354     */
355    public Set<ModelType> getPreferredDataTypes() {
356        long modelTypeSelection =
357                nativeGetEnabledDataTypes(mNativeProfileSyncServiceAndroid);
358        return modelTypeSelectionToSet(modelTypeSelection);
359    }
360
361    @VisibleForTesting
362    public static Set<ModelType> modelTypeSelectionToSet(long modelTypeSelection) {
363        Set<ModelType> syncTypes = new HashSet<ModelType>();
364        if ((modelTypeSelection & ModelTypeSelection.AUTOFILL) != 0) {
365            syncTypes.add(ModelType.AUTOFILL);
366        }
367        if ((modelTypeSelection & ModelTypeSelection.AUTOFILL_PROFILE) != 0) {
368            syncTypes.add(ModelType.AUTOFILL_PROFILE);
369        }
370        if ((modelTypeSelection & ModelTypeSelection.BOOKMARK) != 0) {
371            syncTypes.add(ModelType.BOOKMARK);
372        }
373        if ((modelTypeSelection & ModelTypeSelection.EXPERIMENTS) != 0) {
374            syncTypes.add(ModelType.EXPERIMENTS);
375        }
376        if ((modelTypeSelection & ModelTypeSelection.NIGORI) != 0) {
377            syncTypes.add(ModelType.NIGORI);
378        }
379        if ((modelTypeSelection & ModelTypeSelection.PASSWORD) != 0) {
380            syncTypes.add(ModelType.PASSWORD);
381        }
382        if ((modelTypeSelection & ModelTypeSelection.SESSION) != 0) {
383            syncTypes.add(ModelType.SESSION);
384        }
385        if ((modelTypeSelection & ModelTypeSelection.TYPED_URL) != 0) {
386            syncTypes.add(ModelType.TYPED_URL);
387        }
388        if ((modelTypeSelection & ModelTypeSelection.HISTORY_DELETE_DIRECTIVE) != 0) {
389            syncTypes.add(ModelType.HISTORY_DELETE_DIRECTIVE);
390        }
391        if ((modelTypeSelection & ModelTypeSelection.DEVICE_INFO) != 0) {
392            syncTypes.add(ModelType.DEVICE_INFO);
393        }
394        if ((modelTypeSelection & ModelTypeSelection.PROXY_TABS) != 0) {
395            syncTypes.add(ModelType.PROXY_TABS);
396        }
397        if ((modelTypeSelection & ModelTypeSelection.FAVICON_IMAGE) != 0) {
398            syncTypes.add(ModelType.FAVICON_IMAGE);
399        }
400        if ((modelTypeSelection & ModelTypeSelection.FAVICON_TRACKING) != 0) {
401            syncTypes.add(ModelType.FAVICON_TRACKING);
402        }
403        if ((modelTypeSelection & ModelTypeSelection.SUPERVISED_USER_SETTING) != 0) {
404            syncTypes.add(ModelType.MANAGED_USER_SETTING);
405        }
406        return syncTypes;
407    }
408
409    public boolean hasKeepEverythingSynced() {
410        return nativeHasKeepEverythingSynced(mNativeProfileSyncServiceAndroid);
411    }
412
413    /**
414     * Enables syncing for the passed data types.
415     *
416     * @param syncEverything Set to true if the user wants to sync all data types
417     *                       (including new data types we add in the future).
418     * @param enabledTypes   The set of types to enable. Ignored (can be null) if
419     *                       syncEverything is true.
420     */
421    public void setPreferredDataTypes(boolean syncEverything, Set<ModelType> enabledTypes) {
422        long modelTypeSelection = 0;
423        if (syncEverything || enabledTypes.contains(ModelType.AUTOFILL)) {
424            modelTypeSelection |= ModelTypeSelection.AUTOFILL;
425        }
426        if (syncEverything || enabledTypes.contains(ModelType.BOOKMARK)) {
427            modelTypeSelection |= ModelTypeSelection.BOOKMARK;
428        }
429        if (syncEverything || enabledTypes.contains(ModelType.PASSWORD)) {
430            modelTypeSelection |= ModelTypeSelection.PASSWORD;
431        }
432        if (syncEverything || enabledTypes.contains(ModelType.PROXY_TABS)) {
433            modelTypeSelection |= ModelTypeSelection.PROXY_TABS;
434        }
435        if (syncEverything || enabledTypes.contains(ModelType.TYPED_URL)) {
436            modelTypeSelection |= ModelTypeSelection.TYPED_URL;
437        }
438        nativeSetPreferredDataTypes(
439                mNativeProfileSyncServiceAndroid, syncEverything, modelTypeSelection);
440    }
441
442    public void setSyncSetupCompleted() {
443        nativeSetSyncSetupCompleted(mNativeProfileSyncServiceAndroid);
444    }
445
446    public boolean hasSyncSetupCompleted() {
447        return nativeHasSyncSetupCompleted(mNativeProfileSyncServiceAndroid);
448    }
449
450    public boolean isStartSuppressed() {
451        return nativeIsStartSuppressed(mNativeProfileSyncServiceAndroid);
452    }
453
454    /**
455     * Notifies sync whether sync setup is in progress - this tells sync whether it should start
456     * syncing data types when it starts up, or if it should just stay in "configuration mode".
457     *
458     * @param inProgress True to put sync in configuration mode, false to turn off configuration
459     *                   and allow syncing.
460     */
461    public void setSetupInProgress(boolean inProgress) {
462        nativeSetSetupInProgress(mNativeProfileSyncServiceAndroid, inProgress);
463    }
464
465    public void addSyncStateChangedListener(SyncStateChangedListener listener) {
466        ThreadUtils.assertOnUiThread();
467        mListeners.add(listener);
468    }
469
470    public void removeSyncStateChangedListener(SyncStateChangedListener listener) {
471        ThreadUtils.assertOnUiThread();
472        mListeners.remove(listener);
473    }
474
475    public boolean hasUnrecoverableError() {
476        return nativeHasUnrecoverableError(mNativeProfileSyncServiceAndroid);
477    }
478
479    /**
480     * Called when the state of the native sync engine has changed, so various
481     * UI elements can update themselves.
482     */
483    @CalledByNative
484    public void syncStateChanged() {
485        if (!mListeners.isEmpty()) {
486            for (SyncStateChangedListener listener : mListeners) {
487                listener.syncStateChanged();
488            }
489        }
490    }
491
492    @VisibleForTesting
493    public String getSyncInternalsInfoForTest() {
494        ThreadUtils.assertOnUiThread();
495        return nativeGetAboutInfoForTest(mNativeProfileSyncServiceAndroid);
496    }
497
498    /**
499     * Starts the sync engine.
500     */
501    public void enableSync() {
502        nativeEnableSync(mNativeProfileSyncServiceAndroid);
503    }
504
505    /**
506     * Stops the sync engine.
507     */
508    public void disableSync() {
509        nativeDisableSync(mNativeProfileSyncServiceAndroid);
510    }
511
512    /**
513     * Returns the time when the last sync cycle was completed.
514     *
515     * @return The difference measured in microseconds, between last sync cycle completion time
516     * and 1 January 1970 00:00:00 UTC.
517     */
518    @VisibleForTesting
519    public long getLastSyncedTimeForTest() {
520        return nativeGetLastSyncedTimeForTest(mNativeProfileSyncServiceAndroid);
521    }
522
523    /**
524     * Overrides the Sync engine's NetworkResources. This is used to set up the Sync FakeServer for
525     * testing.
526     *
527     * @param networkResources the pointer to the NetworkResources created by the native code. It
528     *                         is assumed that the Java caller has ownership of this pointer;
529     *                         ownership is transferred as part of this call.
530     */
531    public void overrideNetworkResourcesForTest(long networkResources) {
532        nativeOverrideNetworkResourcesForTest(mNativeProfileSyncServiceAndroid, networkResources);
533    }
534
535    @CalledByNative
536    private static String modelTypeSelectionToStringForTest(long modelTypeSelection) {
537        SortedSet<String> set = new TreeSet<String>();
538        Set<ModelType> filteredTypes = ModelType.filterOutNonInvalidationTypes(
539                modelTypeSelectionToSet(modelTypeSelection));
540        for (ModelType type : filteredTypes) {
541            set.add(type.toString());
542        }
543        StringBuilder sb = new StringBuilder();
544        Iterator<String> it = set.iterator();
545        if (it.hasNext()) {
546            sb.append(it.next());
547            while (it.hasNext()) {
548                sb.append(", ");
549                sb.append(it.next());
550            }
551        }
552        return sb.toString();
553    }
554
555    // Native methods
556    private native void nativeNudgeSyncer(
557            long nativeProfileSyncServiceAndroid, int objectSource, String objectId, long version,
558            String payload);
559    private native void nativeNudgeSyncerForAllTypes(long nativeProfileSyncServiceAndroid);
560    private native long nativeInit();
561    private native void nativeEnableSync(long nativeProfileSyncServiceAndroid);
562    private native void nativeDisableSync(long nativeProfileSyncServiceAndroid);
563    private native void nativeSignInSync(long nativeProfileSyncServiceAndroid);
564    private native void nativeSignOutSync(long nativeProfileSyncServiceAndroid);
565    private native boolean nativeSetSyncSessionsId(
566            long nativeProfileSyncServiceAndroid, String tag);
567    private native String nativeQuerySyncStatusSummary(long nativeProfileSyncServiceAndroid);
568    private native int nativeGetAuthError(long nativeProfileSyncServiceAndroid);
569    private native boolean nativeIsSyncInitialized(long nativeProfileSyncServiceAndroid);
570    private native boolean nativeIsFirstSetupInProgress(long nativeProfileSyncServiceAndroid);
571    private native boolean nativeIsEncryptEverythingEnabled(long nativeProfileSyncServiceAndroid);
572    private native void nativeEnableEncryptEverything(long nativeProfileSyncServiceAndroid);
573    private native boolean nativeIsPassphraseRequiredForDecryption(
574            long nativeProfileSyncServiceAndroid);
575    private native boolean nativeIsPassphraseRequiredForExternalType(
576            long nativeProfileSyncServiceAndroid);
577    private native boolean nativeIsUsingSecondaryPassphrase(long nativeProfileSyncServiceAndroid);
578    private native boolean nativeSetDecryptionPassphrase(
579            long nativeProfileSyncServiceAndroid, String passphrase);
580    private native void nativeSetEncryptionPassphrase(
581            long nativeProfileSyncServiceAndroid, String passphrase, boolean isGaia);
582    private native boolean nativeIsCryptographerReady(long nativeProfileSyncServiceAndroid);
583    private native int nativeGetPassphraseType(long nativeProfileSyncServiceAndroid);
584    private native boolean nativeHasExplicitPassphraseTime(long nativeProfileSyncServiceAndroid);
585    private native long nativeGetExplicitPassphraseTime(long nativeProfileSyncServiceAndroid);
586    private native String nativeGetSyncEnterGooglePassphraseBodyWithDateText(
587            long nativeProfileSyncServiceAndroid);
588    private native String nativeGetSyncEnterCustomPassphraseBodyWithDateText(
589            long nativeProfileSyncServiceAndroid);
590    private native String nativeGetCurrentSignedInAccountText(long nativeProfileSyncServiceAndroid);
591    private native String nativeGetSyncEnterCustomPassphraseBodyText(
592            long nativeProfileSyncServiceAndroid);
593    private native boolean nativeIsSyncKeystoreMigrationDone(long nativeProfileSyncServiceAndroid);
594    private native long nativeGetEnabledDataTypes(
595        long nativeProfileSyncServiceAndroid);
596    private native void nativeSetPreferredDataTypes(
597            long nativeProfileSyncServiceAndroid, boolean syncEverything, long modelTypeSelection);
598    private native void nativeSetSetupInProgress(
599            long nativeProfileSyncServiceAndroid, boolean inProgress);
600    private native void nativeSetSyncSetupCompleted(long nativeProfileSyncServiceAndroid);
601    private native boolean nativeHasSyncSetupCompleted(long nativeProfileSyncServiceAndroid);
602    private native boolean nativeIsStartSuppressed(long nativeProfileSyncServiceAndroid);
603    private native boolean nativeHasKeepEverythingSynced(long nativeProfileSyncServiceAndroid);
604    private native boolean nativeHasUnrecoverableError(long nativeProfileSyncServiceAndroid);
605    private native String nativeGetAboutInfoForTest(long nativeProfileSyncServiceAndroid);
606    private native long nativeGetLastSyncedTimeForTest(long nativeProfileSyncServiceAndroid);
607    private native void nativeOverrideNetworkResourcesForTest(
608            long nativeProfileSyncServiceAndroid, long networkResources);
609}
610