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

Commit 9fc64cca authored by vince-bourgmayer's avatar vince-bourgmayer
Browse files

Fix issue 64 and 65 for nougat

parent 1da16f7f
Loading
Loading
Loading
Loading
Loading
+2 −14
Original line number Diff line number Diff line
@@ -138,7 +138,7 @@ public class OperationManagerService extends Service implements OnRemoteOperatio
     */
    private synchronized void startWork( int threadIndex ){
        Log.i(TAG, "startWork("+threadIndex+")" );
        if( !mThreadWorkingState[threadIndex] || CommonUtils.haveNetworkConnexion( getApplicationContext() ) ) { //check if the thread corresponding to threadIndex isn't already working
        if( !mThreadWorkingState[threadIndex] && CommonUtils.haveNetworkConnexion( getApplicationContext() ) ) { //check if the thread corresponding to threadIndex isn't already working

            ComparableOperation operation = this.mOperationsQueue.poll(); //return null if deque is empty
            if (operation != null) {
@@ -160,18 +160,6 @@ public class OperationManagerService extends Service implements OnRemoteOperatio
        } //else : thread is already running or no network connexion
    }

    /**
     * Tell if there is at least one thread which can get new task to do
     * @return boolean true if there is a free thread place else return false
     */
    private boolean isThereAFreeThread(){
        for(int i =-1; ++i < workerAmount;){
            if( !mThreadWorkingState[i] )
                return true;
        }
        return false;
    }

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
@@ -339,7 +327,7 @@ public class OperationManagerService extends Service implements OnRemoteOperatio
        }
        mOperationsQueue.add(operation);
        Log.d(TAG, "OperationQueue: "+mOperationsQueue.size());
        if( isThereAFreeThread() ) startAllThreads();
        startAllThreads();
    }

    /**