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

Unverified Commit bca01d01 authored by Marvin W.'s avatar Marvin W. 🐿️
Browse files

Fix some very rare crashes

parent 47720085
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -34,32 +34,32 @@ class ClearcutLoggerServiceImpl(private val lifecycle: Lifecycle) : IClearcutLog

    override fun log(callbacks: IClearcutLoggerCallbacks, event: LogEventParcelable) {
        lifecycleScope.launchWhenStarted {
            callbacks.onLogResult(Status.SUCCESS)
            runCatching { callbacks.onLogResult(Status.SUCCESS) }
        }
    }

    override fun forceUpload(callbacks: IClearcutLoggerCallbacks) {
        lifecycleScope.launchWhenStarted {
            callbacks.onLogResult(Status.SUCCESS)
            runCatching { callbacks.onLogResult(Status.SUCCESS) }
        }
    }

    override fun startCollectForDebug(callbacks: IClearcutLoggerCallbacks) {
        lifecycleScope.launchWhenStarted {
            collectForDebugExpiryTime = System.currentTimeMillis() + COLLECT_FOR_DEBUG_DURATION
            callbacks.onStartCollectForDebugResult(Status.SUCCESS, collectForDebugExpiryTime)
            runCatching { callbacks.onStartCollectForDebugResult(Status.SUCCESS, collectForDebugExpiryTime) }
        }
    }

    override fun stopCollectForDebug(callbacks: IClearcutLoggerCallbacks) {
        lifecycleScope.launchWhenStarted {
            callbacks.onStopCollectForDebugResult(Status.SUCCESS)
            runCatching { callbacks.onStopCollectForDebugResult(Status.SUCCESS) }
        }
    }

    override fun getCollectForDebugExpiryTime(callbacks: IClearcutLoggerCallbacks) {
        lifecycleScope.launchWhenStarted {
            callbacks.onCollectForDebugExpiryTime(Status.SUCCESS, collectForDebugExpiryTime)
            runCatching { callbacks.onCollectForDebugExpiryTime(Status.SUCCESS, collectForDebugExpiryTime) }
        }
    }

@@ -69,7 +69,7 @@ class ClearcutLoggerServiceImpl(private val lifecycle: Lifecycle) : IClearcutLog

    override fun getLogEventParcelables(callbacks: IClearcutLoggerCallbacks) {
        lifecycleScope.launchWhenStarted {
            callbacks.onLogEventParcelables(DataHolder.empty(CommonStatusCodes.SUCCESS))
            runCatching { callbacks.onLogEventParcelables(DataHolder.empty(CommonStatusCodes.SUCCESS)) }
        }
    }

+9 −1
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CountDownLatch;

import okio.ByteString;

@@ -89,6 +90,7 @@ public class WearableImpl {
    private ConnectionConfiguration[] configurations;
    private boolean configurationsUpdated = false;
    private ClockworkNodePreferences clockworkNodePreferences;
    private CountDownLatch networkHandlerLock = new CountDownLatch(1);
    public Handler networkHandler;

    public WearableImpl(Context context, NodeDatabaseHelper nodeDatabase, ConfigurationDatabaseHelper configDatabase) {
@@ -100,6 +102,7 @@ public class WearableImpl {
        new Thread(() -> {
            Looper.prepare();
            networkHandler = new Handler(Looper.myLooper());
            networkHandlerLock.countDown();
            Looper.loop();
        }).start();
    }
@@ -619,7 +622,12 @@ public class WearableImpl {
    }

    public void stop() {
        try {
            this.networkHandlerLock.await();
            this.networkHandler.getLooper().quit();
        } catch (InterruptedException e) {
            Log.w(TAG, e);
        }
    }

    private class ListenerInfo {