Bind service in onCreate

This cl puts the binding to onCreate instead of constructor, so
preference controller won't bind/unbind service without registering
Lifecycle.

Bug: 62105045
Test: RunSettingsRoboTests
Change-Id: I1e60d4b6ad7270aa5d04b7ec9fae1d3200fccc5f
Merged-In: I1e60d4b6ad7270aa5d04b7ec9fae1d3200fccc5f
This commit is contained in:
jackqdyulei
2017-07-10 13:22:50 -07:00
parent 8dc795d64b
commit 50b0daee90
2 changed files with 26 additions and 10 deletions

View File

@@ -16,7 +16,6 @@
package com.android.settings.network;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothPan;
import android.bluetooth.BluetoothProfile;
@@ -77,6 +76,14 @@ public class TetherPreferenceControllerTest {
ReflectionHelpers.setField(mController, "mPreference", mPreference);
}
@Test
public void lifeCycle_onCreate_shouldInitBluetoothPan() {
mController.onCreate(null);
verify(mBluetoothAdapter).getProfileProxy(mContext, mController.mBtProfileServiceListener,
BluetoothProfile.PAN);
}
@Test
public void goThroughLifecycle_shouldDestoryBluetoothProfile() {
final BluetoothPan pan = mock(BluetoothPan.class);
@@ -161,7 +168,8 @@ public class TetherPreferenceControllerTest {
mController.onResume();
verify(mContext).registerReceiver(
any(TetherPreferenceController.TetherBroadcastReceiver.class), any(IntentFilter.class));
any(TetherPreferenceController.TetherBroadcastReceiver.class),
any(IntentFilter.class));
}
@Test
@@ -172,7 +180,7 @@ public class TetherPreferenceControllerTest {
mController.onPause();
verify(mContext).unregisterReceiver(
any(TetherPreferenceController.TetherBroadcastReceiver.class));
any(TetherPreferenceController.TetherBroadcastReceiver.class));
}
@Test