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

Commit a6861d86 authored by TYM Tsai's avatar TYM Tsai
Browse files

Refactor to ensure thread safety

Make object pointer safety for multiple thread

Bug: 179834303
Test: atest ContentCapturePerfTests
Change-Id: I5c04dd3b1288fb3ac104738f159dba88b641a0bf
parent 8b5ab656
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -84,18 +84,18 @@ public class MyContentCaptureService extends ContentCaptureService {

    @Override
    public void onDisconnected() {
        Log.i(TAG, "onDisconnected: sServiceWatcher=" + sServiceWatcher);

        if (sServiceWatcher == null) {
        final ServiceWatcher sw = sServiceWatcher;
        Log.i(TAG, "onDisconnected: sServiceWatcher=" + sw);
        if (sw == null) {
            Log.e(TAG, "onDisconnected() without a watcher");
            return;
        }
        if (sServiceWatcher.mService == null) {
            Log.e(TAG, "onDisconnected(): no service on " + sServiceWatcher);
        if (sw.mService == null) {
            Log.e(TAG, "onDisconnected(): no service on " + sw);
            return;
        }

        sServiceWatcher.mDestroyed.countDown();
        sw.mDestroyed.countDown();
        clearServiceWatcher();
    }