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

Commit ec5a3f9c authored by Nitin Shivpure's avatar Nitin Shivpure Committed by android-build-merger
Browse files

Merge "Bluetooth: Fix to avoid BluetoothPan ServiceConnection leak" into pi-dev am: d9248946

am: 75787c8a

Change-Id: Ib111a099149a8a6852f029d5c8b1334ea891a7fc
parents 11916e00 75787c8a
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -127,7 +127,8 @@ public class TetherPreferenceController extends AbstractPreferenceController imp

    @Override
    public void onCreate(Bundle savedInstanceState) {
        if (mBluetoothAdapter != null) {
        if (mBluetoothAdapter != null &&
            mBluetoothAdapter.getState() == BluetoothAdapter.STATE_ON) {
            mBluetoothAdapter.getProfileProxy(mContext, mBtProfileServiceListener,
                    BluetoothProfile.PAN);
        }
+13 −2
Original line number Diff line number Diff line
@@ -75,10 +75,21 @@ public class TetherPreferenceControllerTest {

    @Test
    public void lifeCycle_onCreate_shouldInitBluetoothPan() {
        when(mBluetoothAdapter.getState()).thenReturn(BluetoothAdapter.STATE_ON);
        mController.onCreate(null);

        verify(mBluetoothAdapter)
            .getProfileProxy(mContext, mController.mBtProfileServiceListener, BluetoothProfile.PAN);
        verify(mBluetoothAdapter).getState();
        verify(mBluetoothAdapter).getProfileProxy(mContext, mController.mBtProfileServiceListener,
                BluetoothProfile.PAN);
    }

    @Test
    public void lifeCycle_onCreate_shouldNotInitBluetoothPanWhenBluetoothOff() {
        when(mBluetoothAdapter.getState()).thenReturn(BluetoothAdapter.STATE_OFF);
        mController.onCreate(null);

        verify(mBluetoothAdapter).getState();
        verifyNoMoreInteractions(mBluetoothAdapter);
    }

    @Test