Loading app/src/main/java/foundation/e/drive/receivers/BatteryStateReceiver.java +1 −1 Original line number Diff line number Diff line Loading @@ -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); Loading app/src/main/java/foundation/e/drive/services/InitializerService.java +2 −4 Original line number Diff line number Diff line Loading @@ -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, "" ); Loading @@ -89,7 +89,6 @@ public class InitializerService extends Service implements OnRemoteOperationList if(accountName.isEmpty() ) { Log.w(TAG, "Account's name not found. Neither in shared prefs nor in intent's extras"); //JobUtils.stopScheduledJob(getApplicationContext(), JobUtils.InitializerJobId); stopSelf(); }else{ this.mAccount = CommonUtils.getAccount( accountName, accountType, AccountManager.get(this) ); Loading @@ -98,7 +97,6 @@ public class InitializerService extends Service implements OnRemoteOperationList CommonUtils.getOwnCloudClient( this.mAccount, getApplicationContext(), this); }else { Log.w(TAG, "Got account is invalid."); //JobUtils.stopScheduledJob(getApplicationContext(), JobUtils.initializerJobID); stopSelf(); } } Loading Loading @@ -284,7 +282,7 @@ public class InitializerService extends Service implements OnRemoteOperationList .apply(); //all folder have been created JobUtils.scheduleScannerJob(this, 120000); JobUtils.scheduleScannerJob(this); //JobUtils.stopScheduledJob(appContext, JobUtils.InitializerJobId); stopSelf(); Loading app/src/main/java/foundation/e/drive/utils/JobUtils.java +3 −4 Original line number Diff line number Diff line Loading @@ -24,19 +24,18 @@ 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 seconds .setPersisted(true) .setRequiredNetworkType( JobInfo.NETWORK_TYPE_ANY ) .build(); Loading Loading
app/src/main/java/foundation/e/drive/receivers/BatteryStateReceiver.java +1 −1 Original line number Diff line number Diff line Loading @@ -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); Loading
app/src/main/java/foundation/e/drive/services/InitializerService.java +2 −4 Original line number Diff line number Diff line Loading @@ -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, "" ); Loading @@ -89,7 +89,6 @@ public class InitializerService extends Service implements OnRemoteOperationList if(accountName.isEmpty() ) { Log.w(TAG, "Account's name not found. Neither in shared prefs nor in intent's extras"); //JobUtils.stopScheduledJob(getApplicationContext(), JobUtils.InitializerJobId); stopSelf(); }else{ this.mAccount = CommonUtils.getAccount( accountName, accountType, AccountManager.get(this) ); Loading @@ -98,7 +97,6 @@ public class InitializerService extends Service implements OnRemoteOperationList CommonUtils.getOwnCloudClient( this.mAccount, getApplicationContext(), this); }else { Log.w(TAG, "Got account is invalid."); //JobUtils.stopScheduledJob(getApplicationContext(), JobUtils.initializerJobID); stopSelf(); } } Loading Loading @@ -284,7 +282,7 @@ public class InitializerService extends Service implements OnRemoteOperationList .apply(); //all folder have been created JobUtils.scheduleScannerJob(this, 120000); JobUtils.scheduleScannerJob(this); //JobUtils.stopScheduledJob(appContext, JobUtils.InitializerJobId); stopSelf(); Loading
app/src/main/java/foundation/e/drive/utils/JobUtils.java +3 −4 Original line number Diff line number Diff line Loading @@ -24,19 +24,18 @@ 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 seconds .setPersisted(true) .setRequiredNetworkType( JobInfo.NETWORK_TYPE_ANY ) .build(); Loading