summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandroid-build-team Robot2017-06-06 02:12:54 -0500
committerandroid-build-team Robot2017-06-06 02:12:54 -0500
commitf531a01580dd939b3e0dd5bf795e920dfcad9a62 (patch)
tree9d098c5dca3347064638d04cde71e8e228eb1024
parent9e450d1cd621193f9074c9e3fbbbcf38cdfde70e (diff)
parent06cb47a38cf7ccf66d8591cf42c54230ac3ae98f (diff)
downloadplatform-packages-services-car-oreo-r6-release.tar.gz
platform-packages-services-car-oreo-r6-release.tar.xz
platform-packages-services-car-oreo-r6-release.zip
Change-Id: I7b28a55a6c175308adf7babfbfc57bd8b3b1261d
-rw-r--r--car-lib/src/android/car/ICarBluetoothUserService.aidl1
-rw-r--r--service/src/com/android/car/BluetoothDeviceConnectionPolicy.java105
-rw-r--r--service/src/com/android/car/CarBluetoothUserService.java32
-rwxr-xr-xtools/bootanalyze/bootanalyze.py2
4 files changed, 131 insertions, 9 deletions
diff --git a/car-lib/src/android/car/ICarBluetoothUserService.aidl b/car-lib/src/android/car/ICarBluetoothUserService.aidl
index b1f7a39c..a906a3c2 100644
--- a/car-lib/src/android/car/ICarBluetoothUserService.aidl
+++ b/car-lib/src/android/car/ICarBluetoothUserService.aidl
@@ -24,4 +24,5 @@ interface ICarBluetoothUserService {
24 void closeBluetoothConnectionProxy(); 24 void closeBluetoothConnectionProxy();
25 boolean isBluetoothConnectionProxyAvailable(in int profile); 25 boolean isBluetoothConnectionProxyAvailable(in int profile);
26 void bluetoothConnectToProfile(in int profile, in BluetoothDevice device); 26 void bluetoothConnectToProfile(in int profile, in BluetoothDevice device);
27 void setProfilePriority(in int profile, in BluetoothDevice device, in int priority);
27} 28}
diff --git a/service/src/com/android/car/BluetoothDeviceConnectionPolicy.java b/service/src/com/android/car/BluetoothDeviceConnectionPolicy.java
index 4cdb640b..e80b8432 100644
--- a/service/src/com/android/car/BluetoothDeviceConnectionPolicy.java
+++ b/service/src/com/android/car/BluetoothDeviceConnectionPolicy.java
@@ -24,6 +24,7 @@ import android.bluetooth.BluetoothHeadsetClient;
24import android.bluetooth.BluetoothMapClient; 24import android.bluetooth.BluetoothMapClient;
25import android.bluetooth.BluetoothPbapClient; 25import android.bluetooth.BluetoothPbapClient;
26import android.bluetooth.BluetoothProfile; 26import android.bluetooth.BluetoothProfile;
27import android.bluetooth.BluetoothUuid;
27import android.car.hardware.CarPropertyValue; 28import android.car.hardware.CarPropertyValue;
28import android.car.hardware.CarSensorEvent; 29import android.car.hardware.CarSensorEvent;
29import android.car.hardware.CarSensorManager; 30import android.car.hardware.CarSensorManager;
@@ -38,6 +39,8 @@ import static android.car.settings.CarSettings.Secure.KEY_BLUETOOTH_AUTOCONNECT_
38import static android.car.settings.CarSettings.Secure.KEY_BLUETOOTH_AUTOCONNECT_PHONE_DEVICES; 39import static android.car.settings.CarSettings.Secure.KEY_BLUETOOTH_AUTOCONNECT_PHONE_DEVICES;
39import static android.car.settings.CarSettings.Secure.KEY_BLUETOOTH_AUTOCONNECT_MESSAGING_DEVICES; 40import static android.car.settings.CarSettings.Secure.KEY_BLUETOOTH_AUTOCONNECT_MESSAGING_DEVICES;
40 41
42import android.os.ParcelUuid;
43import android.os.Parcelable;
41import android.os.UserHandle; 44import android.os.UserHandle;
42import android.provider.Settings; 45import android.provider.Settings;
43 46
@@ -237,7 +240,7 @@ public class BluetoothDeviceConnectionPolicy {
237 BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); 240 BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
238 if (DBG) { 241 if (DBG) {
239 if (device != null) { 242 if (device != null) {
240 Log.d(TAG, "Received Intent for device: " + device.getName() + action); 243 Log.d(TAG, "Received Intent for device: " + device + " " + action);
241 } else { 244 } else {
242 Log.d(TAG, "Received Intent no device: " + action); 245 Log.d(TAG, "Received Intent no device: " + action);
243 } 246 }
@@ -287,6 +290,91 @@ public class BluetoothDeviceConnectionPolicy {
287 writeDeviceInfoToSettings(); 290 writeDeviceInfoToSettings();
288 resetBluetoothDevicesConnectionInfo(); 291 resetBluetoothDevicesConnectionInfo();
289 } 292 }
293 } else if (BluetoothDevice.ACTION_UUID.equals(action)) {
294 // Received during pairing with the UUIDs of the Bluetooth profiles supported by
295 // the remote device.
296 if (DBG) {
297 Log.d(TAG, "Received UUID intent for device " + device);
298 }
299 Parcelable[] uuids = intent.getParcelableArrayExtra(BluetoothDevice.EXTRA_UUID);
300 if (uuids != null) {
301 ParcelUuid[] uuidsToSend = new ParcelUuid[uuids.length];
302 for (int i = 0; i < uuidsToSend.length; i++) {
303 uuidsToSend[i] = (ParcelUuid)uuids[i];
304 }
305 setProfilePriorities(device, uuidsToSend, BluetoothProfile.PRIORITY_ON);
306 }
307
308 }
309 }
310 }
311
312 /**
313 * Set priority for the Bluetooth profiles.
314 *
315 * The Bluetooth service stores the priority of a Bluetooth profile per device as a key value
316 * pair - BluetoothProfile_device:<Priority>.
317 * When we pair a device from the Settings App, the expected behavior is for the app to connect
318 * on all appropriate profiles after successful pairing automatically, without the user having
319 * to explicitly issue a connect. The settings app checks for the priority of the device from
320 * the above key-value pair and if the priority is set to PRIORITY_OFF or PRIORITY_UNDEFINED,
321 * the settings app will stop with just pairing and not connect.
322 * This scenario will happen when we pair a device, then unpair it and then pair it again. When
323 * the device is unpaired, the BT stack sets the priority for that device to PRIORITY_UNDEFINED
324 * ( as a way of resetting). So, the next time the same device is paired, the Settings app will
325 * stop with just pairing and not connect as explained above. Here, we register to receive the
326 * ACTION_UUID intent, which will broadcast the UUIDs corresponding to the profiles supported by
327 * the remote device which is successfully paired and we turn on the priority so when the
328 * Settings app tries to check before connecting, the priority is set to the expected value.
329 *
330 * @param device - Remote Bluetooth device
331 * @param uuids - UUIDs of the Bluetooth Profiles supported by the remote device
332 * @param priority - priority to set
333 */
334 private void setProfilePriorities(BluetoothDevice device, ParcelUuid[] uuids, int priority) {
335 // need the BluetoothProfile proxy to be able to call the setPriority API
336 if (mCarBluetoothUserService == null) {
337 mCarBluetoothUserService = setupBluetoothUserService();
338 }
339 if (mCarBluetoothUserService != null) {
340 for (Integer profile : mProfilesToConnect) {
341 setBluetoothProfilePriorityIfUuidFound(uuids, profile, device, priority);
342 }
343 }
344 }
345
346 private void setBluetoothProfilePriorityIfUuidFound(ParcelUuid[] uuids, int profile,
347 BluetoothDevice device, int priority) {
348 if (mCarBluetoothUserService == null || device == null) {
349 return;
350 }
351 // Build a list of UUIDs that represent a profile.
352 List<ParcelUuid> uuidsToCheck = new ArrayList<>();
353 switch (profile) {
354 case BluetoothProfile.A2DP_SINK:
355 uuidsToCheck.add(BluetoothUuid.AudioSource);
356 break;
357 case BluetoothProfile.HEADSET_CLIENT:
358 uuidsToCheck.add(BluetoothUuid.Handsfree_AG);
359 uuidsToCheck.add(BluetoothUuid.HSP_AG);
360 break;
361 case BluetoothProfile.PBAP_CLIENT:
362 uuidsToCheck.add(BluetoothUuid.PBAP_PSE);
363 break;
364 case BluetoothProfile.MAP_CLIENT:
365 uuidsToCheck.add(BluetoothUuid.MAS);
366 break;
367 }
368
369 for (ParcelUuid uuid : uuidsToCheck) {
370 if (BluetoothUuid.isUuidPresent(uuids, uuid)) {
371 try {
372 mCarBluetoothUserService.setProfilePriority(profile, device, priority);
373 } catch (RemoteException e) {
374 Log.e(TAG, "RemoteException calling setProfilePriority");
375 }
376 // if any one of the uuid in uuidsTocheck is present, set the priority and break
377 break;
290 } 378 }
291 } 379 }
292 } 380 }
@@ -309,6 +397,9 @@ public class BluetoothDeviceConnectionPolicy {
309 if (DBG) { 397 if (DBG) {
310 Log.d(TAG, "Connected to PerUserCarService"); 398 Log.d(TAG, "Connected to PerUserCarService");
311 } 399 }
400 // Get the BluetoothUserService and also setup the Bluetooth Connection Proxy for
401 // all profiles.
402 mCarBluetoothUserService = setupBluetoothUserService();
312 // re-initialize for current user. 403 // re-initialize for current user.
313 initializeUserSpecificInfo(); 404 initializeUserSpecificInfo();
314 } 405 }
@@ -415,9 +506,6 @@ public class BluetoothDeviceConnectionPolicy {
415 setupBluetoothEventsIntentFilterLocked(); 506 setupBluetoothEventsIntentFilterLocked();
416 507
417 mConnectionInFlight = new ConnectionParams(); 508 mConnectionInFlight = new ConnectionParams();
418 // Get the BluetoothUserService and also setup the Bluetooth Connection Proxy for
419 // all profiles.
420 mCarBluetoothUserService = setupBluetoothUserService();
421 mUserSpecificInfoInitialized = true; 509 mUserSpecificInfoInitialized = true;
422 } 510 }
423 } 511 }
@@ -438,8 +526,11 @@ public class BluetoothDeviceConnectionPolicy {
438 profileFilter.addAction(BluetoothPbapClient.ACTION_CONNECTION_STATE_CHANGED); 526 profileFilter.addAction(BluetoothPbapClient.ACTION_CONNECTION_STATE_CHANGED);
439 profileFilter.addAction(BluetoothMapClient.ACTION_CONNECTION_STATE_CHANGED); 527 profileFilter.addAction(BluetoothMapClient.ACTION_CONNECTION_STATE_CHANGED);
440 profileFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); 528 profileFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
441 mContext.registerReceiverAsUser(mBluetoothBroadcastReceiver, UserHandle.CURRENT, 529 profileFilter.addAction(BluetoothDevice.ACTION_UUID);
442 profileFilter, null, null); 530 if (mContext != null) {
531 mContext.registerReceiverAsUser(mBluetoothBroadcastReceiver, UserHandle.CURRENT,
532 profileFilter, null, null);
533 }
443 } 534 }
444 535
445 /** 536 /**
@@ -646,7 +737,7 @@ public class BluetoothDeviceConnectionPolicy {
646 return; 737 return;
647 } 738 }
648 if (DBG) { 739 if (DBG) {
649 Log.d(TAG, "BondState :" + bondState + " Device: " + device.getName()); 740 Log.d(TAG, "BondState :" + bondState + " Device: " + device);
650 } 741 }
651 // Bonded devices are added to a profile's device list after the device CONNECTS on the 742 // Bonded devices are added to a profile's device list after the device CONNECTS on the
652 // profile. When unpaired, we remove the device from all of the profiles' device list. 743 // profile. When unpaired, we remove the device from all of the profiles' device list.
diff --git a/service/src/com/android/car/CarBluetoothUserService.java b/service/src/com/android/car/CarBluetoothUserService.java
index 7ee02cf5..55365a08 100644
--- a/service/src/com/android/car/CarBluetoothUserService.java
+++ b/service/src/com/android/car/CarBluetoothUserService.java
@@ -31,7 +31,7 @@ import java.util.List;
31 31
32 32
33public class CarBluetoothUserService extends ICarBluetoothUserService.Stub { 33public class CarBluetoothUserService extends ICarBluetoothUserService.Stub {
34 private static final boolean DBG = false; 34 private static final boolean DBG = true;
35 private static final String TAG = "CarBluetoothUsrSvc"; 35 private static final String TAG = "CarBluetoothUsrSvc";
36 private BluetoothAdapter mBluetoothAdapter = null; 36 private BluetoothAdapter mBluetoothAdapter = null;
37 private final PerUserCarService mService; 37 private final PerUserCarService mService;
@@ -164,6 +164,36 @@ public class CarBluetoothUserService extends ICarBluetoothUserService.Stub {
164 } 164 }
165 165
166 /** 166 /**
167 * Set the priority of the given Bluetooth profile for the given remote device
168 * @param profile - Bluetooth profile
169 * @param device - remote Bluetooth device
170 * @param priority - priority to set
171 */
172 @Override
173 public void setProfilePriority(int profile, BluetoothDevice device, int priority) {
174 if (!isBluetoothConnectionProxyAvailable(profile)) {
175 Log.e(TAG, "Cannot connect to Profile. Proxy Unavailable");
176 return;
177 }
178 switch (profile) {
179 case BluetoothProfile.A2DP_SINK:
180 mBluetoothA2dpSink.setPriority(device, priority);
181 break;
182 case BluetoothProfile.HEADSET_CLIENT:
183 mBluetoothHeadsetClient.setPriority(device, priority);
184 break;
185 case BluetoothProfile.MAP_CLIENT:
186 mBluetoothMapClient.setPriority(device, priority);
187 break;
188 case BluetoothProfile.PBAP_CLIENT:
189 mBluetoothPbapClient.setPriority(device, priority);
190 break;
191 default:
192 Log.d(TAG, "Unknown Profile");
193 break;
194 }
195 }
196 /**
167 * All the BluetoothProfile.ServiceListeners to get the Profile Proxy objects 197 * All the BluetoothProfile.ServiceListeners to get the Profile Proxy objects
168 */ 198 */
169 private BluetoothProfile.ServiceListener mProfileListener = 199 private BluetoothProfile.ServiceListener mProfileListener =
diff --git a/tools/bootanalyze/bootanalyze.py b/tools/bootanalyze/bootanalyze.py
index 7010725b..da874ce8 100755
--- a/tools/bootanalyze/bootanalyze.py
+++ b/tools/bootanalyze/bootanalyze.py
@@ -680,7 +680,7 @@ def stddev(data):
680 return math.sqrt(variance) 680 return math.sqrt(variance)
681 681
682def grab_bootchart(boot_chart_file_name): 682def grab_bootchart(boot_chart_file_name):
683 subprocess.call("./system/core/init/grab-bootchart.sh --no-viewer", shell=True) 683 subprocess.call("./system/core/init/grab-bootchart.sh", shell=True)
684 print "Saving boot chart as " + boot_chart_file_name + ".tgz" 684 print "Saving boot chart as " + boot_chart_file_name + ".tgz"
685 subprocess.call('cp /tmp/android-bootchart/bootchart.tgz ./' + boot_chart_file_name + '.tgz',\ 685 subprocess.call('cp /tmp/android-bootchart/bootchart.tgz ./' + boot_chart_file_name + '.tgz',\
686 shell=True) 686 shell=True)