Commit 9e4e4274 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 a5d6695b
Pipeline #160013 passed with stage
in 1 minute and 32 seconds
......@@ -79,5 +79,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>
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
......@@ -36,6 +36,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;
......@@ -127,7 +128,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 );
}
......
Supports Markdown
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