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

Commit 2a7fd906 authored by William Escande's avatar William Escande
Browse files

SystemServer: Prevent Exception in tearDown

Bug: 311772251
Test: atest BluetoothManagerServiceTest
Change-Id: I6e73c14a10aced7950b3d27b59078ac5d2324825
parent dc7a46bb
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -77,8 +77,8 @@ import java.util.stream.IntStream;
@RunWith(AndroidJUnit4.class)
public class BluetoothManagerServiceTest {
    private static final String TAG = BluetoothManagerServiceTest.class.getSimpleName();
    static final int STATE_BLE_TURNING_ON = 14; // can't find the symbol because hidden api
    static final int TIMEOUT_MS = 1000; // TO use to wait for handler execution
    private static final int STATE_BLE_TURNING_ON = 14; // can't find the symbol because hidden api
    private static final int TIMEOUT_MS = 1000; // TO use to wait for handler execution

    BluetoothManagerService mManagerService;

@@ -161,13 +161,15 @@ public class BluetoothManagerServiceTest {

    @After
    public void tearDown() {
        if (mManagerService != null) {
            mManagerService.unregisterAdapter(mManagerCallback);
            mManagerService = null;
        }
        mLooper.moveTimeForward(120_000); // 120 seconds
        // Do not try to assert if `syncHandler()` already raised an exception for it
        if (!mHasException) {
            assertThat(mLooper.nextMessage()).isNull();
        }
        mManagerService = null;
        validateMockitoUsage();
    }