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

Commit 1dbeef99 authored by Jonathan Klee's avatar Jonathan Klee
Browse files

Implement FORCE_SYNC intent

To force a sync, you can now:

adb shell am broadcast -a foundation.e.drive.action.FORCE_SYNC
parent ca317764
Loading
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -84,5 +84,12 @@ http://www.gnu.org/licenses/gpl.html
                <action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
            </intent-filter>
        </receiver>
        <receiver
            android:name=".receivers.ForceSyncReceiver"
            android:enabled="true">
            <intent-filter>
                <action android:name="foundation.e.drive.action.FORCE_SYNC" />
            </intent-filter>
        </receiver>
    </application>
</manifest>
+23 −0
Original line number Diff line number Diff line
package foundation.e.drive.receivers;

import android.content.BroadcastReceiver;
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 {

    public static final String ACTION_FORCE_SYNC = "foundation.e.drive.action.FORCE_SYNC";
    public static final String TAG = "ForceSyncReceiver";

    @Override
    public void onReceive(Context context, Intent intent) {
        if (ACTION_FORCE_SYNC.equals(intent.getAction()) && BuildConfig.DEBUG) {
            Log.i(TAG, "Start ObserverService");
            context.startService(new Intent(context, ObserverService.class));
        }
    }
}
 No newline at end of file
+2 −1
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ 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;
@@ -129,7 +130,7 @@ public class ObserverService extends Service implements OnRemoteOperationListene
        long currentTime = System.currentTimeMillis();

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