diff options
author | Benjamin Franz <bfranz@google.com> | 2014-12-10 20:29:22 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-12-10 20:29:25 +0000 |
commit | a96ba381cf7ecbed31da94b8ebc93da3c42151ad (patch) | |
tree | a0fdab8092b341df5d8dddba5059838d82522a8d | |
parent | 844af56b85260d9e6a8e89436a5e8862fbeb3812 (diff) | |
parent | 5b614593e1a212e8ad9ac4a1e22a2954bb499233 (diff) | |
download | frameworks_base-a96ba381cf7ecbed31da94b8ebc93da3c42151ad.zip frameworks_base-a96ba381cf7ecbed31da94b8ebc93da3c42151ad.tar.gz frameworks_base-a96ba381cf7ecbed31da94b8ebc93da3c42151ad.tar.bz2 |
Merge "Only add successfully bound profile services to mProfileServices." into lmp-mr1-dev
-rw-r--r-- | services/core/java/com/android/server/BluetoothManagerService.java | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/services/core/java/com/android/server/BluetoothManagerService.java b/services/core/java/com/android/server/BluetoothManagerService.java index 3117a17..ca376fd 100644 --- a/services/core/java/com/android/server/BluetoothManagerService.java +++ b/services/core/java/com/android/server/BluetoothManagerService.java @@ -535,15 +535,14 @@ class BluetoothManagerService extends IBluetoothManager.Stub { Log.d(TAG, "Creating new ProfileServiceConnections object for" + " profile: " + bluetoothProfile); } - Intent intent = null; - if (bluetoothProfile == BluetoothProfile.HEADSET) { - intent = new Intent(IBluetoothHeadset.class.getName()); - } else { - return false; - } + + if (bluetoothProfile != BluetoothProfile.HEADSET) return false; + + Intent intent = new Intent(IBluetoothHeadset.class.getName()); psc = new ProfileServiceConnections(intent); + if (!psc.bindService()) return false; + mProfileServices.put(new Integer(bluetoothProfile), psc); - psc.bindService(); } } @@ -571,7 +570,11 @@ class BluetoothManagerService extends IBluetoothManager.Stub { synchronized (mProfileServices) { for (Integer i : mProfileServices.keySet()) { ProfileServiceConnections psc = mProfileServices.get(i); - mContext.unbindService(psc); + try { + mContext.unbindService(psc); + } catch (IllegalArgumentException e) { + Log.e(TAG, "Unable to unbind service with intent: " + psc.mIntent, e); + } psc.removeAllProxies(); } mProfileServices.clear(); @@ -596,16 +599,16 @@ class BluetoothManagerService extends IBluetoothManager.Stub { mIntent = intent; } - private void bindService() { - if (mIntent != null && mService == null) { - if (!doBind(mIntent, this, 0, UserHandle.CURRENT_OR_SELF)) { - Log.w(TAG, "Unable to bind with intent: " + mIntent - + ". Triggering retry."); - } + private boolean bindService() { + if (mIntent != null && mService == null && + doBind(mIntent, this, 0, UserHandle.CURRENT_OR_SELF)) { Message msg = mHandler.obtainMessage(MESSAGE_BIND_PROFILE_SERVICE); msg.obj = this; mHandler.sendMessageDelayed(msg, TIMEOUT_BIND_MS); + return true; } + Log.w(TAG, "Unable to bind with intent: " + mIntent); + return false; } private void addProxy(IBluetoothProfileServiceConnection proxy) { |