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

Commit 997690fe authored by vince-bourgmayer's avatar vince-bourgmayer
Browse files

Revert "replace service context by app context"

This reverts commit 10974f6d.
parent 10974f6d
Loading
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -123,7 +123,7 @@ public class ObserverService extends Service implements OnRemoteOperationListene
        super.onCreate();

        /* Test */
        Intent opMgrSrvIntent = new Intent(getApplicationContext(), OperationManagerService.class);
        Intent opMgrSrvIntent = new Intent(this, OperationManagerService.class);
        getApplicationContext().startService(opMgrSrvIntent);
    }

@@ -131,6 +131,8 @@ public class ObserverService extends Service implements OnRemoteOperationListene
    public int onStartCommand(Intent intent, int flags, int startId) {
        Log.i(TAG, "onStartCommand");



        SharedPreferences prefs = this.getSharedPreferences(AppConstants.SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE);

        if (prefs.getBoolean(INITIALIZATION_HAS_BEEN_DONE, false)) {
@@ -138,11 +140,11 @@ public class ObserverService extends Service implements OnRemoteOperationListene
            String accountName = prefs.getString(AccountManager.KEY_ACCOUNT_NAME, "");
            String accountType = prefs.getString(AccountManager.KEY_ACCOUNT_TYPE, "");
            initialFolderCounter = prefs.getInt(AppConstants.INITIALFOLDERS_NUMBER, 0);
            this.mAccount = CommonUtils.getAccount(accountName, accountType, AccountManager.get(getApplicationContext()));
            this.mAccount = CommonUtils.getAccount(accountName, accountType, AccountManager.get(this));

            if (this.mAccount != null ){

                JobUtils.scheduleScannerJob(getApplicationContext()); //It should restart counter so we are sure that a synchro will ever happen between now and 30 minutes
                JobUtils.scheduleScannerJob(this); //It should restart counter so we are sure that a synchro will ever happen between now and 30 minutes
                if ( CommonUtils.isMediaSyncEnabled(this.mAccount) || CommonUtils.isSettingsSyncEnabled(this.mAccount) ) {
                    if (mClient == null) //background task
                        CommonUtils.getOwnCloudClient(this.mAccount, getApplicationContext(), this);
@@ -158,7 +160,7 @@ public class ObserverService extends Service implements OnRemoteOperationListene
            }
        }else{
            Log.w(TAG, "Server must be initialized before to start");
            Intent initializerIntent = new Intent(getApplicationContext(), InitializerService.class);
            Intent initializerIntent = new Intent(this, InitializerService.class);
            startService(initializerIntent);
            this.stopSelf();
        }
@@ -177,7 +179,7 @@ public class ObserverService extends Service implements OnRemoteOperationListene
            //If there is a internet connexion
            if (CommonUtils.haveNetworkConnexion(this)) {
                if (!mBoundToOperationManager) {
                    Intent opMgrSrvIntent = new Intent(getApplicationContext(), OperationManagerService.class);
                    Intent opMgrSrvIntent = new Intent(this, OperationManagerService.class);
                    bindService(opMgrSrvIntent, this.mOperationManagerServiceConnection, Context.BIND_NOT_FOREGROUND);
                } else {
                    clearCachedFile();