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

Commit 10974f6d authored by vince-bourgmayer's avatar vince-bourgmayer
Browse files

replace service context by app context

parent 163bd07e
Loading
Loading
Loading
Loading
Loading
+5 −7
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(this, OperationManagerService.class);
        Intent opMgrSrvIntent = new Intent(getApplicationContext(), OperationManagerService.class);
        getApplicationContext().startService(opMgrSrvIntent);
    }

@@ -131,8 +131,6 @@ 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)) {
@@ -140,11 +138,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(this));
            this.mAccount = CommonUtils.getAccount(accountName, accountType, AccountManager.get(getApplicationContext()));

            if (this.mAccount != null ){

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