| Index: device/bluetooth/android/java/src/org/chromium/device/bluetooth/ChromeBluetoothDevice.java
|
| diff --git a/device/bluetooth/android/java/src/org/chromium/device/bluetooth/ChromeBluetoothDevice.java b/device/bluetooth/android/java/src/org/chromium/device/bluetooth/ChromeBluetoothDevice.java
|
| index 2741e7c6e44492fb4269e1da1f44f363075beb32..00b00b1864955c630b734b8d14d31434c81321f9 100644
|
| --- a/device/bluetooth/android/java/src/org/chromium/device/bluetooth/ChromeBluetoothDevice.java
|
| +++ b/device/bluetooth/android/java/src/org/chromium/device/bluetooth/ChromeBluetoothDevice.java
|
| @@ -14,6 +14,7 @@ import org.chromium.base.Log;
|
| import org.chromium.base.ThreadUtils;
|
| import org.chromium.base.annotations.CalledByNative;
|
| import org.chromium.base.annotations.JNINamespace;
|
| +import org.chromium.base.metrics.RecordHistogram;
|
|
|
| import java.util.HashMap;
|
| import java.util.HashSet;
|
| @@ -153,12 +154,21 @@ final class ChromeBluetoothDevice {
|
| ? "Connected"
|
| : "Disconnected");
|
| if (newState == android.bluetooth.BluetoothProfile.STATE_CONNECTED) {
|
| + RecordHistogram.recordSparseSlowlyHistogram(
|
| + "Bluetooth.Web.Android.onConnectionStateChange.Status.Connected", status);
|
| mBluetoothGatt.discoverServices();
|
| } else if (newState == android.bluetooth.BluetoothProfile.STATE_DISCONNECTED) {
|
| + RecordHistogram.recordSparseSlowlyHistogram(
|
| + "Bluetooth.Web.Android.onConnectionStateChange.Status.Disconnected",
|
| + status);
|
| if (mBluetoothGatt != null) {
|
| mBluetoothGatt.close();
|
| mBluetoothGatt = null;
|
| }
|
| + } else {
|
| + RecordHistogram.recordSparseSlowlyHistogram(
|
| + "Bluetooth.Web.Android.onConnectionStateChange.Status.InvalidState",
|
| + status);
|
| }
|
| ThreadUtils.runOnUiThread(new Runnable() {
|
| @Override
|
| @@ -179,11 +189,19 @@ final class ChromeBluetoothDevice {
|
| @Override
|
| public void run() {
|
| if (mNativeBluetoothDeviceAndroid != 0) {
|
| - // When the device disconnects is deletes
|
| + // When the device disconnects it deletes
|
| // mBluetoothGatt, so we need to check it's not null.
|
| if (mBluetoothGatt == null) {
|
| + RecordHistogram.recordSparseSlowlyHistogram(
|
| + "Bluetooth.Web.Android.onServicesDiscovered.Status."
|
| + + "Disconnected",
|
| + status);
|
| return;
|
| }
|
| + RecordHistogram.recordSparseSlowlyHistogram(
|
| + "Bluetooth.Web.Android.onServicesDiscovered.Status.Connected",
|
| + status);
|
| +
|
| // TODO(crbug.com/576906): Update or replace existing GATT objects if they
|
| // change after initial discovery.
|
| for (Wrappers.BluetoothGattServiceWrapper service :
|
| @@ -235,6 +253,8 @@ final class ChromeBluetoothDevice {
|
| // when the event races object destruction.
|
| Log.v(TAG, "onCharacteristicRead when chromeCharacteristic == null.");
|
| } else {
|
| + RecordHistogram.recordSparseSlowlyHistogram(
|
| + "Bluetooth.Web.Android.onCharacteristicRead.Status", status);
|
| chromeCharacteristic.onCharacteristicRead(status);
|
| }
|
| }
|
| @@ -255,6 +275,8 @@ final class ChromeBluetoothDevice {
|
| // when the event races object destruction.
|
| Log.v(TAG, "onCharacteristicWrite when chromeCharacteristic == null.");
|
| } else {
|
| + RecordHistogram.recordSparseSlowlyHistogram(
|
| + "Bluetooth.Web.Android.onCharacteristicWrite.Status", status);
|
| chromeCharacteristic.onCharacteristicWrite(status);
|
| }
|
| }
|
| @@ -274,6 +296,8 @@ final class ChromeBluetoothDevice {
|
| // when the event races object destruction.
|
| Log.v(TAG, "onDescriptorRead when chromeDescriptor == null.");
|
| } else {
|
| + RecordHistogram.recordSparseSlowlyHistogram(
|
| + "Bluetooth.Web.Android.onDescriptorRead.Status", status);
|
| chromeDescriptor.onDescriptorRead(status);
|
| }
|
| }
|
| @@ -293,6 +317,8 @@ final class ChromeBluetoothDevice {
|
| // when the event races object destruction.
|
| Log.v(TAG, "onDescriptorWrite when chromeDescriptor == null.");
|
| } else {
|
| + RecordHistogram.recordSparseSlowlyHistogram(
|
| + "Bluetooth.Web.Android.onDescriptorWrite.Status", status);
|
| chromeDescriptor.onDescriptorWrite(status);
|
| }
|
| }
|
|
|