am a96ba381: Merge "Only add successfully bound profile services to mProfileServices." into lmp-mr1-dev
* commit 'a96ba381cf7ecbed31da94b8ebc93da3c42151ad': Only add successfully bound profile services to mProfileServices.
This commit is contained in:
@@ -535,15 +535,14 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
|
|||||||
Log.d(TAG, "Creating new ProfileServiceConnections object for"
|
Log.d(TAG, "Creating new ProfileServiceConnections object for"
|
||||||
+ " profile: " + bluetoothProfile);
|
+ " profile: " + bluetoothProfile);
|
||||||
}
|
}
|
||||||
Intent intent = null;
|
|
||||||
if (bluetoothProfile == BluetoothProfile.HEADSET) {
|
if (bluetoothProfile != BluetoothProfile.HEADSET) return false;
|
||||||
intent = new Intent(IBluetoothHeadset.class.getName());
|
|
||||||
} else {
|
Intent intent = new Intent(IBluetoothHeadset.class.getName());
|
||||||
return false;
|
|
||||||
}
|
|
||||||
psc = new ProfileServiceConnections(intent);
|
psc = new ProfileServiceConnections(intent);
|
||||||
|
if (!psc.bindService()) return false;
|
||||||
|
|
||||||
mProfileServices.put(new Integer(bluetoothProfile), psc);
|
mProfileServices.put(new Integer(bluetoothProfile), psc);
|
||||||
psc.bindService();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -571,7 +570,11 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
|
|||||||
synchronized (mProfileServices) {
|
synchronized (mProfileServices) {
|
||||||
for (Integer i : mProfileServices.keySet()) {
|
for (Integer i : mProfileServices.keySet()) {
|
||||||
ProfileServiceConnections psc = mProfileServices.get(i);
|
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();
|
psc.removeAllProxies();
|
||||||
}
|
}
|
||||||
mProfileServices.clear();
|
mProfileServices.clear();
|
||||||
@@ -596,16 +599,16 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
|
|||||||
mIntent = intent;
|
mIntent = intent;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bindService() {
|
private boolean bindService() {
|
||||||
if (mIntent != null && mService == null) {
|
if (mIntent != null && mService == null &&
|
||||||
if (!doBind(mIntent, this, 0, UserHandle.CURRENT_OR_SELF)) {
|
doBind(mIntent, this, 0, UserHandle.CURRENT_OR_SELF)) {
|
||||||
Log.w(TAG, "Unable to bind with intent: " + mIntent
|
|
||||||
+ ". Triggering retry.");
|
|
||||||
}
|
|
||||||
Message msg = mHandler.obtainMessage(MESSAGE_BIND_PROFILE_SERVICE);
|
Message msg = mHandler.obtainMessage(MESSAGE_BIND_PROFILE_SERVICE);
|
||||||
msg.obj = this;
|
msg.obj = this;
|
||||||
mHandler.sendMessageDelayed(msg, TIMEOUT_BIND_MS);
|
mHandler.sendMessageDelayed(msg, TIMEOUT_BIND_MS);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
Log.w(TAG, "Unable to bind with intent: " + mIntent);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addProxy(IBluetoothProfileServiceConnection proxy) {
|
private void addProxy(IBluetoothProfileServiceConnection proxy) {
|
||||||
|
|||||||
Reference in New Issue
Block a user