summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Mantler <nicoya@google.com>2016-05-27 20:08:29 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-05-27 20:08:29 +0000
commit9961a8956b968df9bc7f1866b2285c8c496bcc65 (patch)
treecdddaa8645543cb8be9618176e03b92d556214d7
parent75e7f83409c113eb83c1ce08ec58f3435b7e83e7 (diff)
parentc6586d4bbb98a6f70aadea2e7b727959de930042 (diff)
downloadTvSettings-9961a8956b968df9bc7f1866b2285c8c496bcc65.tar.gz
Merge "Only unbind from GamepadPairingService if previously bound" into nyc-dev
-rw-r--r--Settings/src/com/android/tv/settings/accessories/AddAccessoryActivity.java10
1 files changed, 8 insertions, 2 deletions
diff --git a/Settings/src/com/android/tv/settings/accessories/AddAccessoryActivity.java b/Settings/src/com/android/tv/settings/accessories/AddAccessoryActivity.java
index 38f5e831f..e1bff1c44 100644
--- a/Settings/src/com/android/tv/settings/accessories/AddAccessoryActivity.java
+++ b/Settings/src/com/android/tv/settings/accessories/AddAccessoryActivity.java
@@ -120,7 +120,9 @@ public class AddAccessoryActivity extends Activity implements BluetoothDevicePai
private static final int GAMEPAD_MESSAGE_RESUME_PAIRING = 4;
private final List<Message> mGamepadMessageQueue = new ArrayList<>();
private Messenger mGamepadService;
- private ServiceConnection mGamepadServiceConn = new ServiceConnection() {
+ private ServiceConnection mGamepadServiceConn;
+
+ private class GamepadServiceConnection implements ServiceConnection {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
Log.d(TAG, "Gamepad Service Connected");
@@ -234,6 +236,7 @@ public class AddAccessoryActivity extends Activity implements BluetoothDevicePai
intent.setPackage(GAMEPAD_PAIRING_PACKAGE);
if (serviceIntentIsHandled(intent)) {
// Don't auto-start the service. If it's not running we don't need to pause it.
+ mGamepadServiceConn = new GamepadServiceConnection();
bindService(intent, mGamepadServiceConn, BIND_ADJUST_WITH_ACTIVITY);
}
@@ -340,7 +343,10 @@ public class AddAccessoryActivity extends Activity implements BluetoothDevicePai
protected void onDestroy() {
super.onDestroy();
resumeGamepadPairingService();
- unbindService(mGamepadServiceConn);
+ if (mGamepadServiceConn != null) {
+ unbindService(mGamepadServiceConn);
+ mGamepadServiceConn = null;
+ }
stopBluetoothPairer();
mMsgHandler.removeCallbacksAndMessages(null);
}