Commit d98a8607 authored by sgurun's avatar sgurun Committed by Commit bot

Revert of [Sync] Remove periodic sync for Chrome for Android (patchset #2...

Revert of [Sync] Remove periodic sync for Chrome for Android (patchset #2 id:20001 of https://codereview.chromium.org/1148613002/)

Reason for revert:
seems to break the build
https://build.chromium.org/p/chromium/builders/Android/builds/40042

Original issue's description:
> [Sync] Remove periodic sync for Chrome for Android
>
> updateAccount() is always called on startup with the signed in account,
> so the removePeriodicSync() call will be hit even for already signed in
> users when the app restarts.
>
> BUG=480688
>
> Committed: https://crrev.com/20989a55f294c1b1643cbc2b80bf083de1dd7e36
> Cr-Commit-Position: refs/heads/master@{#330588}

TBR=nyquist@chromium.org,maxbogue@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=480688

Review URL: https://codereview.chromium.org/1135113006

Cr-Commit-Position: refs/heads/master@{#330592}
parent 6cdb6927
...@@ -8,7 +8,6 @@ import android.accounts.Account; ...@@ -8,7 +8,6 @@ import android.accounts.Account;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
import android.content.SyncStatusObserver; import android.content.SyncStatusObserver;
import android.os.Bundle;
import android.os.StrictMode; import android.os.StrictMode;
import org.chromium.base.ObserverList; import org.chromium.base.ObserverList;
...@@ -222,9 +221,6 @@ public class AndroidSyncSettings { ...@@ -222,9 +221,6 @@ public class AndroidSyncSettings {
// Make account syncable if there is one. // Make account syncable if there is one.
if (shouldBeSyncable) { if (shouldBeSyncable) {
mSyncContentResolverDelegate.setIsSyncable(mAccount, mContractAuthority, 1); mSyncContentResolverDelegate.setIsSyncable(mAccount, mContractAuthority, 1);
// This reduces unnecessary resource usage. See http://crbug.com/480688 for details.
mSyncContentResolverDelegate.removePeriodicSync(
mAccount, mContractAuthority, Bundle.EMPTY);
} }
// Disable the syncability of Chrome for all other accounts. Don't use // Disable the syncability of Chrome for all other accounts. Don't use
......
...@@ -7,7 +7,6 @@ package org.chromium.sync; ...@@ -7,7 +7,6 @@ package org.chromium.sync;
import android.accounts.Account; import android.accounts.Account;
import android.content.SyncStatusObserver; import android.content.SyncStatusObserver;
import android.os.Bundle;
/** /**
* Since the ContentResolver in Android has a lot of static methods, it is hard to * Since the ContentResolver in Android has a lot of static methods, it is hard to
...@@ -31,6 +30,4 @@ public interface SyncContentResolverDelegate { ...@@ -31,6 +30,4 @@ public interface SyncContentResolverDelegate {
void setIsSyncable(Account account, String authority, int syncable); void setIsSyncable(Account account, String authority, int syncable);
int getIsSyncable(Account account, String authority); int getIsSyncable(Account account, String authority);
void removePeriodicSync(Account account, String authority, Bundle extras);
} }
...@@ -8,7 +8,6 @@ package org.chromium.sync; ...@@ -8,7 +8,6 @@ package org.chromium.sync;
import android.accounts.Account; import android.accounts.Account;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.SyncStatusObserver; import android.content.SyncStatusObserver;
import android.os.Bundle;
/** /**
* A SyncContentResolverDelegate that simply forwards calls to ContentResolver. * A SyncContentResolverDelegate that simply forwards calls to ContentResolver.
...@@ -54,9 +53,4 @@ public class SystemSyncContentResolverDelegate implements SyncContentResolverDel ...@@ -54,9 +53,4 @@ public class SystemSyncContentResolverDelegate implements SyncContentResolverDel
public int getIsSyncable(Account account, String authority) { public int getIsSyncable(Account account, String authority) {
return ContentResolver.getIsSyncable(account, authority); return ContentResolver.getIsSyncable(account, authority);
} }
@Override
public void removePeriodicSync(Account account, String authority, Bundle extras) {
ContentResolver.removePeriodicSync(account, authority, extras);
}
} }
...@@ -6,7 +6,6 @@ package org.chromium.sync; ...@@ -6,7 +6,6 @@ package org.chromium.sync;
import android.accounts.Account; import android.accounts.Account;
import android.content.Context; import android.content.Context;
import android.os.Bundle;
import android.test.InstrumentationTestCase; import android.test.InstrumentationTestCase;
import android.test.suitebuilder.annotation.SmallTest; import android.test.suitebuilder.annotation.SmallTest;
...@@ -30,7 +29,6 @@ public class AndroidSyncSettingsTest extends InstrumentationTestCase { ...@@ -30,7 +29,6 @@ public class AndroidSyncSettingsTest extends InstrumentationTestCase {
private int mGetIsSyncableCalls; private int mGetIsSyncableCalls;
private int mSetIsSyncableCalls; private int mSetIsSyncableCalls;
private int mSetSyncAutomaticallyCalls; private int mSetSyncAutomaticallyCalls;
private int mRemovePeriodicSyncCalls;
@Override @Override
public boolean getMasterSyncAutomatically() { public boolean getMasterSyncAutomatically() {
...@@ -61,12 +59,6 @@ public class AndroidSyncSettingsTest extends InstrumentationTestCase { ...@@ -61,12 +59,6 @@ public class AndroidSyncSettingsTest extends InstrumentationTestCase {
mSetSyncAutomaticallyCalls++; mSetSyncAutomaticallyCalls++;
super.setSyncAutomatically(account, authority, sync); super.setSyncAutomatically(account, authority, sync);
} }
@Override
public void removePeriodicSync(Account account, String authority, Bundle extras) {
mRemovePeriodicSyncCalls++;
super.removePeriodicSync(account, authority, extras);
}
} }
private static class MockSyncSettingsObserver implements AndroidSyncSettingsObserver { private static class MockSyncSettingsObserver implements AndroidSyncSettingsObserver {
...@@ -143,22 +135,6 @@ public class AndroidSyncSettingsTest extends InstrumentationTestCase { ...@@ -143,22 +135,6 @@ public class AndroidSyncSettingsTest extends InstrumentationTestCase {
}); });
} }
@SmallTest
@Feature({"Sync"})
public void testAccountInitialization() throws InterruptedException {
// mAccount was set to be syncable and not have periodic syncs.
assertEquals(1, mSyncContentResolverDelegate.mSetIsSyncableCalls);
assertEquals(1, mSyncContentResolverDelegate.mRemovePeriodicSyncCalls);
mAndroid.updateAccount(null);
// mAccount was set to be not syncable.
assertEquals(2, mSyncContentResolverDelegate.mSetIsSyncableCalls);
assertEquals(1, mSyncContentResolverDelegate.mRemovePeriodicSyncCalls);
mAndroid.updateAccount(mAlternateAccount);
// mAlternateAccount was set to be syncable and not have periodic syncs.
assertEquals(3, mSyncContentResolverDelegate.mSetIsSyncableCalls);
assertEquals(2, mSyncContentResolverDelegate.mRemovePeriodicSyncCalls);
}
@SmallTest @SmallTest
@Feature({"Sync"}) @Feature({"Sync"})
public void testToggleMasterSyncFromSettings() throws InterruptedException { public void testToggleMasterSyncFromSettings() throws InterruptedException {
......
...@@ -9,7 +9,6 @@ import android.accounts.Account; ...@@ -9,7 +9,6 @@ import android.accounts.Account;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.SyncStatusObserver; import android.content.SyncStatusObserver;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle;
import junit.framework.Assert; import junit.framework.Assert;
...@@ -145,10 +144,6 @@ public class MockSyncContentResolverDelegate implements SyncContentResolverDeleg ...@@ -145,10 +144,6 @@ public class MockSyncContentResolverDelegate implements SyncContentResolverDeleg
} }
} }
@Override
public void removePeriodicSync(Account account, String authority, Bundle extras) {
}
private static String createKey(Account account, String authority) { private static String createKey(Account account, String authority) {
return account.name + "@@@" + account.type + "@@@" + authority; return account.name + "@@@" + account.type + "@@@" + authority;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment