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

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

Merge branch '7-3-removeJobUtils' into '7-issue-workmanagerAPI'

Remove JobUtils.java

See merge request e/apps/eDrive!76
parents c616ea09 4d67e919
Loading
Loading
Loading
Loading
Loading
+1 −9
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@ import android.util.Log;

import foundation.e.drive.utils.AppConstants;
import foundation.e.drive.utils.CommonUtils;
import foundation.e.drive.utils.JobUtils;

/**
 * Class representing the eDrive application.
@@ -36,7 +35,7 @@ public class EdriveApplication extends Application {

        SharedPreferences prefs = getSharedPreferences(AppConstants.SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE);
        if (prefs.getString(AccountManager.KEY_ACCOUNT_NAME, null) != null) {
            scheduleScannerJob();
            Log.d(TAG, "Account already registered");
        } else {
            Account mAccount = CommonUtils.getAccount(getString(R.string.eelo_account_type), AccountManager.get(this));
            if (mAccount != null) {
@@ -47,17 +46,10 @@ public class EdriveApplication extends Application {
                        .putString(AccountManager.KEY_ACCOUNT_TYPE, accountType)
                        .apply();

                scheduleScannerJob();
            }
        }
    }

    private void scheduleScannerJob() {
        if (!JobUtils.isScannerJobRegistered(this)) {
            JobUtils.scheduleScannerJob(this);
        }
    }

    private void resetOperationManagerSetting() {
        getSharedPreferences(AppConstants.SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE).edit()
                .putBoolean(AppConstants.KEY_OMS_IS_WORKING, false)
+1 −3
Original line number Diff line number Diff line
@@ -12,7 +12,6 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import foundation.e.drive.utils.JobUtils;

/**
 * @author Vincent Bourgmayer
@@ -28,9 +27,8 @@ 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);
            Log.d(TAG, "BATTERY is Okay. Synchronization job isn't reschedule anymore. Expected behaviour");
        }else if(intentAction.equals(Intent.ACTION_BATTERY_LOW)){
            JobUtils.stopScheduledJob(context, JobUtils.ScannerJobId);
            try {
                context.unregisterReceiver(ScreenOffReceiver.getInstance());
            }catch(Exception e){
+1 −4
Original line number Diff line number Diff line
@@ -35,7 +35,6 @@ import foundation.e.drive.operations.CreateInitialFolderRemoteOperation;
import foundation.e.drive.receivers.ScreenOffReceiver;
import foundation.e.drive.utils.AppConstants;
import foundation.e.drive.utils.CommonUtils;
import foundation.e.drive.utils.JobUtils;
import foundation.e.drive.utils.ServiceExceptionHandler;

import static com.owncloud.android.lib.resources.files.FileUtils.PATH_SEPARATOR;
@@ -75,7 +74,6 @@ 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);
            Log.w(TAG, "Initializer has already been run");
        }else{
            String accountName = prefs.getString( AccountManager.KEY_ACCOUNT_NAME, "" );
@@ -285,8 +283,7 @@ public class InitializerService extends Service implements OnRemoteOperationList
                .apply();

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


        Log.d(TAG, "RegisterReceiver: screenOffReceiver");
        IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
+0 −2
Original line number Diff line number Diff line
@@ -49,7 +49,6 @@ import foundation.e.drive.receivers.ForceSyncReceiver;
import foundation.e.drive.utils.AppConstants;
import foundation.e.drive.utils.CommonUtils;
import foundation.e.drive.utils.DavClientProvider;
import foundation.e.drive.utils.JobUtils;
import foundation.e.drive.utils.ServiceExceptionHandler;

import static com.owncloud.android.lib.resources.files.FileUtils.PATH_SEPARATOR;
@@ -95,7 +94,6 @@ public class ObserverService extends Service implements OnRemoteOperationListene
        // Check if account is invalid
        if(this.mAccount == null){
            Log.w(TAG, "No account registered");
            JobUtils.stopScheduledJob(this, JobUtils.ScannerJobId); //If no account
            return super.onStartCommand(intent, flags, startId);
        }

+1 −4
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import java.io.File;
import foundation.e.drive.database.DbHelper;
import foundation.e.drive.utils.AppConstants;
import foundation.e.drive.utils.CommonUtils;
import foundation.e.drive.utils.JobUtils;

import static foundation.e.drive.utils.AppConstants.INITIALFOLDERS_NUMBER;
import static foundation.e.drive.utils.AppConstants.INITIALIZATION_HAS_BEEN_DONE;
@@ -64,9 +63,7 @@ public class ResetService extends Service {
                    result = getApplicationContext().stopService( stopperIntent );
                    Log.d(TAG, "stop OperationManagerService: "+result);

                    //2. Stop the scheduledJob
                    JobUtils.stopScheduledJob(this, JobUtils.ScannerJobId);
                    //JobUtils.stopScheduledJob(this, JobUtils.InitializerJobId);

                    //3. delete DB
                    result = this.deleteDatabase(DbHelper.DATABASE_NAME);
                    Log.d(TAG, "Remove Database: "+result);
Loading