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

Commit 331c0fb7 authored by Kyunglyul Hyun's avatar Kyunglyul Hyun Committed by Gerrit Code Review
Browse files

Merge "Ensure UpdateNotificationThread being terminated" into main

parents 6976c730 bd308ffb
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -141,7 +141,7 @@ class BluetoothOppNotification {


    private final HashMap<String, NotificationItem> mNotifications = new HashMap<>();
    private final HashMap<String, NotificationItem> mNotifications = new HashMap<>();


    private NotificationUpdateThread mUpdateNotificationThread;
    @VisibleForTesting NotificationUpdateThread mUpdateNotificationThread;


    private int mPendingUpdate = 0;
    private int mPendingUpdate = 0;


+1 −1
Original line number Original line Diff line number Diff line
@@ -135,7 +135,7 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti
    private BluetoothShareContentObserver mObserver;
    private BluetoothShareContentObserver mObserver;


    /** Class to handle Notification Manager updates */
    /** Class to handle Notification Manager updates */
    private BluetoothOppNotification mNotifier;
    @VisibleForTesting BluetoothOppNotification mNotifier;


    private boolean mPendingUpdate;
    private boolean mPendingUpdate;


+9 −2
Original line number Original line Diff line number Diff line
@@ -46,7 +46,7 @@ public class BluetoothOppServiceCleanupTest {


    @Test
    @Test
    @UiThreadTest
    @UiThreadTest
    public void testStopAndCleanup() {
    public void testStopAndCleanup() throws Exception {
        AdapterService adapterService = new AdapterService(mTargetContext);
        AdapterService adapterService = new AdapterService(mTargetContext);


        // Don't need to disable again since it will be handled in OppService.stop
        // Don't need to disable again since it will be handled in OppService.stop
@@ -58,8 +58,9 @@ public class BluetoothOppServiceCleanupTest {
            mTargetContext.getContentResolver().insert(BluetoothShare.CONTENT_URI, values);
            mTargetContext.getContentResolver().insert(BluetoothShare.CONTENT_URI, values);
        }
        }


        BluetoothOppService service = null;
        try {
        try {
            BluetoothOppService service = new BluetoothOppService(adapterService);
            service = new BluetoothOppService(adapterService);
            service.start();
            service.start();
            service.setAvailable(true);
            service.setAvailable(true);


@@ -67,6 +68,12 @@ public class BluetoothOppServiceCleanupTest {
            service.stop();
            service.stop();
            service.cleanup();
            service.cleanup();
        } finally {
        } finally {
            if (service != null) {
                Thread updateNotificationThread = service.mNotifier.mUpdateNotificationThread;
                if (updateNotificationThread != null) {
                    updateNotificationThread.join();
                }
            }
            mTargetContext.getContentResolver().delete(BluetoothShare.CONTENT_URI, null, null);
            mTargetContext.getContentResolver().delete(BluetoothShare.CONTENT_URI, null, null);
        }
        }
    }
    }
+4 −0
Original line number Original line Diff line number Diff line
@@ -107,6 +107,10 @@ public class BluetoothOppServiceTest {
        BluetoothOppService service = mService;
        BluetoothOppService service = mService;
        if (service != null) {
        if (service != null) {
            service.mUpdateThread = null;
            service.mUpdateThread = null;
            Thread updateNotificationThread = service.mNotifier.mUpdateNotificationThread;
            if (updateNotificationThread != null) {
                updateNotificationThread.join();
            }
        }
        }


        BluetoothMethodProxy.setInstanceForTesting(null);
        BluetoothMethodProxy.setInstanceForTesting(null);