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

Commit 0b3bdfa4 authored by William Escande's avatar William Escande
Browse files

SystemServer: factoryReset on main thread

Bug: 262605980
Bug: 288450479
Test: atest ServiceBluetoothTests
Change-Id: Ie4a61e27be9f50051089725e5efd82154d98ac49
parent 6ce65d02
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -248,7 +248,7 @@ class BluetoothManagerService {
        }
    }

    boolean onFactoryReset() {
    boolean onFactoryResetFromBinder() {
        // Wait for stable state if bluetooth is temporary state.
        int state = getState();
        if (state == STATE_BLE_TURNING_ON
@@ -258,10 +258,13 @@ class BluetoothManagerService {
                return false;
            }
        }
        return postAndWait(() -> onFactoryReset());
    }

    boolean onFactoryReset() {
        // Clear registered LE apps to force shut-off Bluetooth
        clearBleApps();
        state = getState();
        int state = getState();
        mAdapterLock.readLock().lock();
        try {
            if (mAdapter == null) {
+1 −1
Original line number Diff line number Diff line
@@ -232,7 +232,7 @@ class BluetoothServiceBinder extends IBluetoothManager.Stub {
            return false;
        }

        return mBluetoothManagerService.onFactoryReset();
        return mBluetoothManagerService.onFactoryResetFromBinder();
    }

    @Override
+1 −1
Original line number Diff line number Diff line
@@ -288,7 +288,7 @@ public class BluetoothServiceBinderTest {
                .adoptShellPermissionIdentity(BLUETOOTH_PRIVILEGED, BLUETOOTH_CONNECT);

        assertThat(mBinder.onFactoryReset(mSource)).isFalse();
        verify(mManagerService).onFactoryReset();
        verify(mManagerService).onFactoryResetFromBinder();
        verifyMock();
    }