diff --git a/app/src/main/java/foundation/e/drive/services/SynchronizationService.java b/app/src/main/java/foundation/e/drive/services/SynchronizationService.java index 321dcaf47502f42f87c6768c8566ed27f17c7dd4..4615e30bb520b20793891a6d19001c6862d7f19f 100644 --- a/app/src/main/java/foundation/e/drive/services/SynchronizationService.java +++ b/app/src/main/java/foundation/e/drive/services/SynchronizationService.java @@ -16,10 +16,8 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.os.Binder; -import android.os.Bundle; import android.os.Handler; import android.os.IBinder; -import android.os.Message; import android.util.Log; import androidx.annotation.Nullable; @@ -29,7 +27,6 @@ import com.owncloud.android.lib.common.operations.OnRemoteOperationListener; import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.operations.RemoteOperationResult; -import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Collection; import java.util.Map; @@ -60,7 +57,7 @@ public class SynchronizationService extends Service implements OnRemoteOperation private final int workerAmount = 4; private Thread[] threadPool; private OwnCloudClient client; - private OperationHandler handler; + private Handler handler; @Override public int onStartCommand(Intent intent, int flags, int startId) { @@ -81,7 +78,7 @@ public class SynchronizationService extends Service implements OnRemoteOperation startedSync = new ConcurrentHashMap<>(); threadPool = new Thread[workerAmount]; client = DavClientProvider.getInstance().getClientInstance(account, getApplicationContext()); - handler = new OperationHandler(this); + handler = new Handler(); return START_REDELIVER_INTENT; } @@ -266,31 +263,6 @@ public class SynchronizationService extends Service implements OnRemoteOperation } } - /** - * Handler for the class - */ - static class OperationHandler extends Handler { - private final String TAG = SynchronizationService.OperationHandler.class.getSimpleName(); - - private final WeakReference serviceWeakRef; - - OperationHandler(SynchronizationService mOperationService){ - serviceWeakRef = new WeakReference<>(mOperationService); - } - - @Override - public void handleMessage(Message msg) { - Log.i(TAG, "handler.handleMessage()"); - final Bundle data = msg.getData(); - if (data == null || !data.containsKey("thread index") || !data.containsKey("mThreadWorkingState")) { - return ; - } - final SyncWrapper syncWrapper = serviceWeakRef.get().startedSync.get(data.getInt("thread index")); - if (syncWrapper != null) syncWrapper.setRunning(data.getBoolean("mThreadWorkingState")); - } - } - - private void updateFailureCounter(SyncRequest request, boolean success) { final SharedPreferences prefs = getSharedPreferences(FAILED_TRANSFER_PREF, Context.MODE_PRIVATE); final String failure_key = request.getSyncedFileState().getLocalPath();