Merge "Bluetooth: Fix to avoid BluetoothPan ServiceConnection leak" into pi-dev
am: d924894652
Change-Id: Ia7a01f35e8a231cf53b481e71266982359a810cf
This commit is contained in:
@@ -131,7 +131,8 @@ public class TetherPreferenceController extends AbstractPreferenceController imp
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
if (mBluetoothAdapter != null) {
|
if (mBluetoothAdapter != null &&
|
||||||
|
mBluetoothAdapter.getState() == BluetoothAdapter.STATE_ON) {
|
||||||
mBluetoothAdapter.getProfileProxy(mContext, mBtProfileServiceListener,
|
mBluetoothAdapter.getProfileProxy(mContext, mBtProfileServiceListener,
|
||||||
BluetoothProfile.PAN);
|
BluetoothProfile.PAN);
|
||||||
}
|
}
|
||||||
|
@@ -75,10 +75,21 @@ public class TetherPreferenceControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void lifeCycle_onCreate_shouldInitBluetoothPan() {
|
public void lifeCycle_onCreate_shouldInitBluetoothPan() {
|
||||||
|
when(mBluetoothAdapter.getState()).thenReturn(BluetoothAdapter.STATE_ON);
|
||||||
mController.onCreate(null);
|
mController.onCreate(null);
|
||||||
|
|
||||||
verify(mBluetoothAdapter)
|
verify(mBluetoothAdapter).getState();
|
||||||
.getProfileProxy(mContext, mController.mBtProfileServiceListener, BluetoothProfile.PAN);
|
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
|
@Test
|
||||||
|
Reference in New Issue
Block a user