Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bd980bac authored by Jonathan Klee's avatar Jonathan Klee
Browse files

Merge branch 'updade-force-sync-behavior' into 'v1-oreo'

Enable force sync on release build

See merge request e/apps/eDrive!70
parents e9baf294 4ad6a3c3
Loading
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@ import android.content.Context;
import android.content.Intent;
import android.util.Log;

import foundation.e.drive.BuildConfig;
import foundation.e.drive.services.ObserverService;

public class ForceSyncReceiver extends BroadcastReceiver {
@@ -15,9 +14,9 @@ public class ForceSyncReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        if (ACTION_FORCE_SYNC.equals(intent.getAction()) && BuildConfig.DEBUG) {
        if (ACTION_FORCE_SYNC.equals(intent.getAction())) {
            Log.i(TAG, "Start ObserverService");
            context.startService(new Intent(context, ObserverService.class));
            context.startService(new Intent(ACTION_FORCE_SYNC, null, context, ObserverService.class));
        }
    }
}
 No newline at end of file
+6 −2
Original line number Diff line number Diff line
@@ -35,7 +35,6 @@ import java.util.List;
import java.util.ListIterator;
import java.util.Map;

import foundation.e.drive.BuildConfig;
import foundation.e.drive.database.DbHelper;
import foundation.e.drive.fileFilters.CrashlogsFileFilter;
import foundation.e.drive.fileFilters.FileFilterFactory;
@@ -46,6 +45,7 @@ import foundation.e.drive.operations.DownloadFileOperation;
import foundation.e.drive.operations.ListFileRemoteOperation;
import foundation.e.drive.operations.RemoveFileOperation;
import foundation.e.drive.operations.UploadFileOperation;
import foundation.e.drive.receivers.ForceSyncReceiver;
import foundation.e.drive.utils.AppConstants;
import foundation.e.drive.utils.CommonUtils;
import foundation.e.drive.utils.DavClientProvider;
@@ -128,9 +128,13 @@ public class ObserverService extends Service implements OnRemoteOperationListene
        //Check a minimum delay has been respected between two start.
        long lastSyncTime = prefs.getLong(AppConstants.KEY_LAST_SYNC_TIME, 0L);
        long currentTime = System.currentTimeMillis();
        boolean forceSync = false;
        if (intent != null) {
            forceSync = ForceSyncReceiver.ACTION_FORCE_SYNC.equals(intent.getAction());
        }

        //if time diff between current sync and last sync is higher or equal to delay minimum between two sync
        if (!BuildConfig.DEBUG && (currentTime - lastSyncTime ) <  INTERSYNC_MINIMUM_DELAY ){
        if (!forceSync && (currentTime - lastSyncTime ) <  INTERSYNC_MINIMUM_DELAY ){
            Log.w(TAG, "Delay between now and last call is too short");
            return super.onStartCommand( intent, flags, startId );
        }