Loading app/src/main/java/foundation/e/drive/services/SynchronizationService.java +2 −30 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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) { Loading @@ -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; } Loading Loading @@ -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<SynchronizationService> 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(); Loading Loading
app/src/main/java/foundation/e/drive/services/SynchronizationService.java +2 −30 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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) { Loading @@ -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; } Loading Loading @@ -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<SynchronizationService> 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(); Loading