Java Code Examples for android.content.ContentResolver#getMasterSyncAutomatically()

The following examples show how to use android.content.ContentResolver#getMasterSyncAutomatically() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AlarmReceiver.java    From Onosendai with Apache License 2.0 6 votes vote down vote up
@Override
public void onReceive (final Context context, final Intent intent) {
	final int action = intent.getExtras().getInt(KEY_ACTION, -1);
	final float bl = BatteryHelper.level(context.getApplicationContext());
	LOG.i("AlarmReceiver invoked: action=%s bl=%s.", action, bl);
	switch (action) {
		case ACTION_UPDATE:
			if (!ContentResolver.getMasterSyncAutomatically()) {
				LOG.i("Master sync disabled, update aborted.");
				break;
			}
			updateIfBetteryOk(context, bl);
			break;
		case ACTION_CLEANUP:
			if (bl > C.MIN_BAT_CLEANUP) context.startService(new Intent(context, CleanupService.class));
			break;
		default:
			LOG.e("Unknown action: '%s'.", action);
			break;
	}
}
 
Example 2
Source File: GravityBoxService.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
@Override
protected void onHandleIntent(Intent intent) {
    if (intent.getAction().equals(ACTION_TOGGLE_SYNC)) {
        final boolean newState;
        if (intent.hasExtra(AShortcut.EXTRA_ENABLE)) {
            newState = intent.getBooleanExtra(AShortcut.EXTRA_ENABLE, false);
        } else {
            newState = !ContentResolver.getMasterSyncAutomatically();
        }
        ContentResolver.setMasterSyncAutomatically(newState);
        if (intent.getBooleanExtra(AShortcut.EXTRA_SHOW_TOAST, false)) {
            showToast(newState ? 
                    R.string.quick_settings_sync_on :
                        R.string.quick_settings_sync_off);
        }
    } else if (intent.getAction().equals(ACTION_GET_SYNC_STATUS)) {
        boolean syncStatus = ContentResolver.getMasterSyncAutomatically();
        ResultReceiver receiver = intent.getParcelableExtra("receiver");
        Bundle data = new Bundle();
        data.putBoolean(KEY_SYNC_STATUS, syncStatus);
        receiver.send(RESULT_SYNC_STATUS, data);
    } else if (intent.getAction().equals(QuietHoursActivity.ACTION_SET_QUIET_HOURS_MODE)) {
        QuietHours.Mode qhMode = QuietHoursActivity.setQuietHoursMode(this, intent.getStringExtra(
                QuietHoursActivity.EXTRA_QH_MODE));
        if (qhMode != null && intent.getBooleanExtra(AShortcut.EXTRA_SHOW_TOAST, false)) {
            showToast(QuietHoursActivity.getToastResIdFromMode(qhMode));
        }
    }
}
 
Example 3
Source File: MainActivity.java    From earth with GNU General Public License v3.0 5 votes vote down vote up
private void setupUpdate() {
    switch (pref.getString("update", "sync")) {
        case "sync":
            SyncUtil.disableBackground(this);
            SyncUtil.enableSync(this);
            if (!ContentResolver.getMasterSyncAutomatically()) {
                promptToEnableAutoSync();
            }
            break;
        case "background":
            SyncUtil.disableSync(this);
            SyncUtil.enableBackground(this);
            break;
    }
}
 
Example 4
Source File: InternalApplicationBootstrapper.java    From android-sdk with MIT License 5 votes vote down vote up
@SuppressWarnings("SimplifiableIfStatement")
boolean isSyncEnabled() {
    if (permissionChecker.hasReadSyncSettingsPermissions()) {
        return ContentResolver.getMasterSyncAutomatically();
    } else {
        return true;
    }
}
 
Example 5
Source File: SystemSyncContentResolverDelegate.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
public boolean getMasterSyncAutomatically() {
    return ContentResolver.getMasterSyncAutomatically();
}
 
Example 6
Source File: SyncAdapterHelper.java    From COCOFramework with Apache License 2.0 4 votes vote down vote up
public boolean isAutoSync(Account mAccount) {
    return ContentResolver.getIsSyncable(mAccount, AUTHORITY) > 0 && ContentResolver.getMasterSyncAutomatically() && ContentResolver.getSyncAutomatically(mAccount, AUTHORITY);
}
 
Example 7
Source File: SystemSyncContentResolverDelegate.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public boolean getMasterSyncAutomatically() {
    return ContentResolver.getMasterSyncAutomatically();
}
 
Example 8
Source File: SystemSyncContentResolverDelegate.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public boolean getMasterSyncAutomatically() {
    return ContentResolver.getMasterSyncAutomatically();
}