Loading .idea/misc.xml +1 −1 Original line number Diff line number Diff line Loading @@ -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"> 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 +4 −3 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 Loading @@ -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) Loading @@ -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(); } Loading app/src/main/java/foundation/e/drive/utils/JobUtils.java +4 −4 Original line number Diff line number Diff line Loading @@ -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(); Loading Loading
.idea/misc.xml +1 −1 Original line number Diff line number Diff line Loading @@ -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"> 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 +4 −3 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 Loading @@ -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) Loading @@ -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(); } Loading
app/src/main/java/foundation/e/drive/utils/JobUtils.java +4 −4 Original line number Diff line number Diff line Loading @@ -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(); Loading