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

Commit cf789f4e authored by Vincent Bourgmayer's avatar Vincent Bourgmayer
Browse files

standardize sync period

parent c6bf73b3
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@
      </value>
    </option>
  </component>
  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
    <output url="file://$PROJECT_DIR$/build/classes" />
  </component>
  <component name="ProjectType">
+1 −1
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ public class BatteryStateReceiver extends BroadcastReceiver {
        if(intentAction != null) {
            Log.e(TAG, "intent Action is null");
        } else if ( intentAction.equals(Intent.ACTION_BATTERY_OKAY) ) {
            JobUtils.scheduleScannerJob(context, 180000);
            JobUtils.scheduleScannerJob(context);
        }else if(intentAction.equals(Intent.ACTION_BATTERY_LOW)){
            JobUtils.stopScheduledJob(context, JobUtils.ScannerJobId);
            //JobUtils.stopScheduledJob(context, JobUtils.InitializerJobId);
+4 −3
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ public class InitializerService extends Service implements OnRemoteOperationList
        SharedPreferences prefs = this.getSharedPreferences( AppConstants.SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE );

        if( prefs.getBoolean( AppConstants.INITIALIZATION_HAS_BEEN_DONE, false ) ) {
            JobUtils.scheduleScannerJob(this, 120000);
            JobUtils.scheduleScannerJob(this);
            Log.w(TAG, "Initializer has already been run");
        }else{
            String accountName = prefs.getString( AccountManager.KEY_ACCOUNT_NAME, "" );
@@ -275,7 +275,8 @@ public class InitializerService extends Service implements OnRemoteOperationList
    private void doLastStep(){
        Log.i(TAG, "doLastStep()");

        getApplicationContext().getSharedPreferences( AppConstants.SHARED_PREFERENCE_NAME,
        Context appContext = getApplicationContext();
        appContext.getSharedPreferences( AppConstants.SHARED_PREFERENCE_NAME,
                Context.MODE_PRIVATE )
                .edit()
                .putBoolean(AppConstants.INITIALIZATION_HAS_BEEN_DONE, true)
@@ -284,7 +285,7 @@ public class InitializerService extends Service implements OnRemoteOperationList

        //all folder have been created
        //JobUtils.stopScheduledJob(appContext, JobUtils.InitializerJobId);
        JobUtils.scheduleScannerJob(getApplicationContext(), JobUtils.ScannerJobId);
        JobUtils.scheduleScannerJob(appContext);
        stopSelf();

    }
+4 −4
Original line number Diff line number Diff line
@@ -24,19 +24,19 @@ import foundation.e.drive.jobs.ScannerJob;
public abstract class JobUtils {
    final private static String TAG = JobUtils.class.getSimpleName(); //Tag for log
    public final static int ScannerJobId = 3310;
    public final static int InitializerJobId = 3311;
    //public final static int InitializerJobId = 3311;

    /**
     * Start the scheduledJob for observing remote's folder
     * @param context app or service context
     * @param periodicity number of millisecond between two execution of scheduled job
     */
    public static void scheduleScannerJob(Context context, int periodicity){
    public static void scheduleScannerJob(Context context){
        Log.i(TAG, "scheduleJob");
        /* I. Start periodic checkup */
        ComponentName jobService = new ComponentName( context, ScannerJob.class );

        JobInfo job = new JobInfo.Builder(ScannerJobId, jobService )
                .setPeriodic(periodicity, 30000)
                .setPeriodic(120000, 30000) //2 minutes and 30 secondes
                .setPersisted(true)
                .setRequiredNetworkType( JobInfo.NETWORK_TYPE_ANY )
                .build();