summaryrefslogtreecommitdiffstats
path: root/device
diff options
context:
space:
mode:
authortorne <torne@chromium.org>2015-11-27 04:33:56 -0800
committerCommit bot <commit-bot@chromium.org>2015-11-27 12:35:26 +0000
commitccbc032de67f682c7878324ab4124e87b3fb5b19 (patch)
treed6d44ab9923500ddf239e163f9c786ddeee83f38 /device
parenta891476e82a5be10e69d0dd06772da3ec3c22361 (diff)
downloadchromium_src-ccbc032de67f682c7878324ab4124e87b3fb5b19.zip
chromium_src-ccbc032de67f682c7878324ab4124e87b3fb5b19.tar.gz
chromium_src-ccbc032de67f682c7878324ab4124e87b3fb5b19.tar.bz2
jni: Pass method parameters as JavaParamRef in device/bluetooth.
Pass all object parameters to JNI methods in JavaParamRef<> wrappers. This matches previous changes made to do this for JNI non-method functions. BUG=519562 R=scheib@chromium.org Review URL: https://codereview.chromium.org/1473713003 Cr-Commit-Position: refs/heads/master@{#361982}
Diffstat (limited to 'device')
-rw-r--r--device/bluetooth/bluetooth_adapter_android.cc14
-rw-r--r--device/bluetooth/bluetooth_adapter_android.h13
-rw-r--r--device/bluetooth/bluetooth_device_android.cc21
-rw-r--r--device/bluetooth/bluetooth_device_android.h20
-rw-r--r--device/bluetooth/bluetooth_remote_gatt_characteristic_android.cc16
-rw-r--r--device/bluetooth/bluetooth_remote_gatt_characteristic_android.h9
-rw-r--r--device/bluetooth/bluetooth_remote_gatt_service_android.cc9
-rw-r--r--device/bluetooth/bluetooth_remote_gatt_service_android.h10
-rw-r--r--device/bluetooth/test/bluetooth_test_android.cc20
-rw-r--r--device/bluetooth/test/bluetooth_test_android.h28
10 files changed, 98 insertions, 62 deletions
diff --git a/device/bluetooth/bluetooth_adapter_android.cc b/device/bluetooth/bluetooth_adapter_android.cc
index c0a972ba..144ad52 100644
--- a/device/bluetooth/bluetooth_adapter_android.cc
+++ b/device/bluetooth/bluetooth_adapter_android.cc
@@ -129,16 +129,20 @@ void BluetoothAdapterAndroid::RegisterAdvertisement(
error_callback.Run(BluetoothAdvertisement::ERROR_UNSUPPORTED_PLATFORM);
}
-void BluetoothAdapterAndroid::OnScanFailed(JNIEnv* env, jobject caller) {
+void BluetoothAdapterAndroid::OnScanFailed(
+ JNIEnv* env,
+ const JavaParamRef<jobject>& caller) {
MarkDiscoverySessionsAsInactive();
}
void BluetoothAdapterAndroid::CreateOrUpdateDeviceOnScan(
JNIEnv* env,
- jobject caller,
- const jstring& address,
- jobject bluetooth_device_wrapper, // Java Type: bluetoothDeviceWrapper
- jobject advertised_uuids) { // Java Type: List<ParcelUuid>
+ const JavaParamRef<jobject>& caller,
+ const JavaParamRef<jstring>& address,
+ const JavaParamRef<jobject>&
+ bluetooth_device_wrapper, // Java Type: bluetoothDeviceWrapper
+ const JavaParamRef<jobject>&
+ advertised_uuids) { // Java Type: List<ParcelUuid>
std::string device_address = ConvertJavaStringToUTF8(env, address);
DevicesMap::const_iterator iter = devices_.find(device_address);
diff --git a/device/bluetooth/bluetooth_adapter_android.h b/device/bluetooth/bluetooth_adapter_android.h
index 0d7da69e..9447506 100644
--- a/device/bluetooth/bluetooth_adapter_android.h
+++ b/device/bluetooth/bluetooth_adapter_android.h
@@ -91,16 +91,19 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterAndroid final
}
// Handles a scan error event by invalidating all discovery sessions.
- void OnScanFailed(JNIEnv* env, jobject caller);
+ void OnScanFailed(JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& caller);
// Creates or updates device with advertised UUID information when a device is
// discovered during a scan.
void CreateOrUpdateDeviceOnScan(
JNIEnv* env,
- jobject caller,
- const jstring& address,
- jobject bluetooth_device_wrapper, // Java Type: bluetoothDeviceWrapper
- jobject advertised_uuids); // Java Type: List<ParcelUuid>
+ const base::android::JavaParamRef<jobject>& caller,
+ const base::android::JavaParamRef<jstring>& address,
+ const base::android::JavaParamRef<jobject>&
+ bluetooth_device_wrapper, // Java Type: bluetoothDeviceWrapper
+ const base::android::JavaParamRef<jobject>&
+ advertised_uuids); // Java Type: List<ParcelUuid>
protected:
BluetoothAdapterAndroid();
diff --git a/device/bluetooth/bluetooth_device_android.cc b/device/bluetooth/bluetooth_device_android.cc
index 51d11fc..5fb025d 100644
--- a/device/bluetooth/bluetooth_device_android.cc
+++ b/device/bluetooth/bluetooth_device_android.cc
@@ -201,10 +201,11 @@ void BluetoothDeviceAndroid::ConnectToServiceInsecurely(
NOTIMPLEMENTED();
}
-void BluetoothDeviceAndroid::OnConnectionStateChange(JNIEnv* env,
- jobject jcaller,
- int32_t status,
- bool connected) {
+void BluetoothDeviceAndroid::OnConnectionStateChange(
+ JNIEnv* env,
+ const JavaParamRef<jobject>& jcaller,
+ int32_t status,
+ bool connected) {
gatt_connected_ = connected;
if (gatt_connected_) {
DidConnectGatt();
@@ -225,17 +226,19 @@ void BluetoothDeviceAndroid::OnConnectionStateChange(JNIEnv* env,
}
}
-void BluetoothDeviceAndroid::OnGattServicesDiscovered(JNIEnv* env,
- jobject jcaller) {
+void BluetoothDeviceAndroid::OnGattServicesDiscovered(
+ JNIEnv* env,
+ const JavaParamRef<jobject>& jcaller) {
FOR_EACH_OBSERVER(BluetoothAdapter::Observer, GetAdapter()->GetObservers(),
GattServicesDiscovered(GetAdapter(), this));
}
void BluetoothDeviceAndroid::CreateGattRemoteService(
JNIEnv* env,
- jobject caller,
- const jstring& instanceId,
- jobject /* BluetoothGattServiceWrapper */ bluetooth_gatt_service_wrapper) {
+ const JavaParamRef<jobject>& caller,
+ const JavaParamRef<jstring>& instanceId,
+ const JavaParamRef<jobject>&
+ bluetooth_gatt_service_wrapper) { // BluetoothGattServiceWrapper
std::string instanceIdString =
base::android::ConvertJavaStringToUTF8(env, instanceId);
diff --git a/device/bluetooth/bluetooth_device_android.h b/device/bluetooth/bluetooth_device_android.h
index 5f63a6d..637bcff 100644
--- a/device/bluetooth/bluetooth_device_android.h
+++ b/device/bluetooth/bluetooth_device_android.h
@@ -90,22 +90,26 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothDeviceAndroid final
// Callback indicating when GATT client has connected/disconnected.
// See android.bluetooth.BluetoothGattCallback.onConnectionStateChange.
- void OnConnectionStateChange(JNIEnv* env,
- jobject jcaller,
- int32_t status,
- bool connected);
+ void OnConnectionStateChange(
+ JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& jcaller,
+ int32_t status,
+ bool connected);
// Callback indicating when all services of the device have been
// discovered.
- void OnGattServicesDiscovered(JNIEnv* env, jobject jcaller);
+ void OnGattServicesDiscovered(
+ JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& jcaller);
// Creates Bluetooth GATT service objects and adds them to
// BluetoothDevice::gatt_services_ if they are not already there.
void CreateGattRemoteService(
JNIEnv* env,
- jobject caller,
- const jstring& instanceId,
- jobject /* BluetoothGattServiceWrapper */ bluetooth_gatt_service_wrapper);
+ const base::android::JavaParamRef<jobject>& caller,
+ const base::android::JavaParamRef<jstring>& instanceId,
+ const base::android::JavaParamRef<jobject>&
+ bluetooth_gatt_service_wrapper); // BluetoothGattServiceWrapper
protected:
BluetoothDeviceAndroid(BluetoothAdapterAndroid* adapter);
diff --git a/device/bluetooth/bluetooth_remote_gatt_characteristic_android.cc b/device/bluetooth/bluetooth_remote_gatt_characteristic_android.cc
index 3e0699e..58e4cac 100644
--- a/device/bluetooth/bluetooth_remote_gatt_characteristic_android.cc
+++ b/device/bluetooth/bluetooth_remote_gatt_characteristic_android.cc
@@ -191,10 +191,11 @@ void BluetoothRemoteGattCharacteristicAndroid::WriteRemoteCharacteristic(
write_error_callback_ = error_callback;
}
-void BluetoothRemoteGattCharacteristicAndroid::OnRead(JNIEnv* env,
- jobject jcaller,
- int32_t status,
- jbyteArray value) {
+void BluetoothRemoteGattCharacteristicAndroid::OnRead(
+ JNIEnv* env,
+ const JavaParamRef<jobject>& jcaller,
+ int32_t status,
+ const JavaParamRef<jbyteArray>& value) {
read_pending_ = false;
// Clear callbacks before calling to avoid reentrancy issues.
@@ -213,9 +214,10 @@ void BluetoothRemoteGattCharacteristicAndroid::OnRead(JNIEnv* env,
}
}
-void BluetoothRemoteGattCharacteristicAndroid::OnWrite(JNIEnv* env,
- jobject jcaller,
- int32_t status) {
+void BluetoothRemoteGattCharacteristicAndroid::OnWrite(
+ JNIEnv* env,
+ const JavaParamRef<jobject>& jcaller,
+ int32_t status) {
write_pending_ = false;
// Clear callbacks before calling to avoid reentrancy issues.
diff --git a/device/bluetooth/bluetooth_remote_gatt_characteristic_android.h b/device/bluetooth/bluetooth_remote_gatt_characteristic_android.h
index b386e7e..6b6c0df 100644
--- a/device/bluetooth/bluetooth_remote_gatt_characteristic_android.h
+++ b/device/bluetooth/bluetooth_remote_gatt_characteristic_android.h
@@ -65,10 +65,15 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattCharacteristicAndroid
const ErrorCallback& error_callback) override;
// Callback after Read operation completes.
- void OnRead(JNIEnv* env, jobject jcaller, int32_t status, jbyteArray value);
+ void OnRead(JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& jcaller,
+ int32_t status,
+ const base::android::JavaParamRef<jbyteArray>& value);
// Callback after Write operation completes.
- void OnWrite(JNIEnv* env, jobject jcaller, int32_t status);
+ void OnWrite(JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& jcaller,
+ int32_t status);
private:
BluetoothRemoteGattCharacteristicAndroid(const std::string& instanceId);
diff --git a/device/bluetooth/bluetooth_remote_gatt_service_android.cc b/device/bluetooth/bluetooth_remote_gatt_service_android.cc
index 3cb8c65..e5f7710 100644
--- a/device/bluetooth/bluetooth_remote_gatt_service_android.cc
+++ b/device/bluetooth/bluetooth_remote_gatt_service_android.cc
@@ -178,11 +178,12 @@ void BluetoothRemoteGattServiceAndroid::Unregister(
void BluetoothRemoteGattServiceAndroid::CreateGattRemoteCharacteristic(
JNIEnv* env,
- jobject caller,
- const jstring& instanceId,
- jobject /* BluetoothGattCharacteristicWrapper */
+ const JavaParamRef<jobject>& caller,
+ const JavaParamRef<jstring>& instanceId,
+ const JavaParamRef<jobject>& /* BluetoothGattCharacteristicWrapper */
bluetooth_gatt_characteristic_wrapper,
- jobject /* ChromeBluetoothDevice */ chrome_bluetooth_device) {
+ const JavaParamRef<
+ jobject>& /* ChromeBluetoothDevice */ chrome_bluetooth_device) {
std::string instanceIdString =
base::android::ConvertJavaStringToUTF8(env, instanceId);
diff --git a/device/bluetooth/bluetooth_remote_gatt_service_android.h b/device/bluetooth/bluetooth_remote_gatt_service_android.h
index 9c642b3..7c90954 100644
--- a/device/bluetooth/bluetooth_remote_gatt_service_android.h
+++ b/device/bluetooth/bluetooth_remote_gatt_service_android.h
@@ -81,11 +81,13 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattServiceAndroid
// |characteristics_| if it is not already there.
void CreateGattRemoteCharacteristic(
JNIEnv* env,
- jobject caller,
- const jstring& instanceId,
- jobject /* BluetoothGattCharacteristicWrapper */
+ const base::android::JavaParamRef<jobject>& caller,
+ const base::android::JavaParamRef<jstring>& instanceId,
+ const base::android::JavaParamRef<
+ jobject>& /* BluetoothGattCharacteristicWrapper */
bluetooth_gatt_characteristic_wrapper,
- jobject /* ChromeBluetoothDevice */ chrome_bluetooth_device);
+ const base::android::JavaParamRef<
+ jobject>& /* ChromeBluetoothDevice */ chrome_bluetooth_device);
private:
BluetoothRemoteGattServiceAndroid(BluetoothAdapterAndroid* adapter,
diff --git a/device/bluetooth/test/bluetooth_test_android.cc b/device/bluetooth/test/bluetooth_test_android.cc
index 3e9d83f..bb55650 100644
--- a/device/bluetooth/test/bluetooth_test_android.cc
+++ b/device/bluetooth/test/bluetooth_test_android.cc
@@ -253,36 +253,38 @@ void BluetoothTestAndroid::
void BluetoothTestAndroid::OnFakeBluetoothDeviceConnectGattCalled(
JNIEnv* env,
- jobject caller) {
+ const JavaParamRef<jobject>& caller) {
gatt_connection_attempts_++;
}
-void BluetoothTestAndroid::OnFakeBluetoothGattDisconnect(JNIEnv* env,
- jobject caller) {
+void BluetoothTestAndroid::OnFakeBluetoothGattDisconnect(
+ JNIEnv* env,
+ const JavaParamRef<jobject>& caller) {
gatt_disconnection_attempts_++;
}
-void BluetoothTestAndroid::OnFakeBluetoothGattDiscoverServices(JNIEnv* env,
- jobject caller) {
+void BluetoothTestAndroid::OnFakeBluetoothGattDiscoverServices(
+ JNIEnv* env,
+ const JavaParamRef<jobject>& caller) {
gatt_discovery_attempts_++;
}
void BluetoothTestAndroid::OnFakeBluetoothGattSetCharacteristicNotification(
JNIEnv* env,
- jobject caller) {
+ const JavaParamRef<jobject>& caller) {
gatt_notify_characteristic_attempts_++;
}
void BluetoothTestAndroid::OnFakeBluetoothGattReadCharacteristic(
JNIEnv* env,
- jobject caller) {
+ const JavaParamRef<jobject>& caller) {
gatt_read_characteristic_attempts_++;
}
void BluetoothTestAndroid::OnFakeBluetoothGattWriteCharacteristic(
JNIEnv* env,
- jobject caller,
- jbyteArray value) {
+ const JavaParamRef<jobject>& caller,
+ const JavaParamRef<jbyteArray>& value) {
gatt_write_characteristic_attempts_++;
base::android::JavaByteArrayToByteVector(env, value, &last_write_value_);
}
diff --git a/device/bluetooth/test/bluetooth_test_android.h b/device/bluetooth/test/bluetooth_test_android.h
index 0b917a7..e4c1c82 100644
--- a/device/bluetooth/test/bluetooth_test_android.h
+++ b/device/bluetooth/test/bluetooth_test_android.h
@@ -60,26 +60,36 @@ class BluetoothTestAndroid : public BluetoothTestBase {
BluetoothGattCharacteristic* characteristic) override;
// Records that Java FakeBluetoothDevice connectGatt was called.
- void OnFakeBluetoothDeviceConnectGattCalled(JNIEnv* env, jobject caller);
+ void OnFakeBluetoothDeviceConnectGattCalled(
+ JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& caller);
// Records that Java FakeBluetoothGatt disconnect was called.
- void OnFakeBluetoothGattDisconnect(JNIEnv* env, jobject caller);
+ void OnFakeBluetoothGattDisconnect(
+ JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& caller);
// Records that Java FakeBluetoothGatt discoverServices was called.
- void OnFakeBluetoothGattDiscoverServices(JNIEnv* env, jobject caller);
+ void OnFakeBluetoothGattDiscoverServices(
+ JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& caller);
// Records that Java FakeBluetoothGatt setCharacteristicNotification was
// called.
- void OnFakeBluetoothGattSetCharacteristicNotification(JNIEnv* env,
- jobject caller);
+ void OnFakeBluetoothGattSetCharacteristicNotification(
+ JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& caller);
// Records that Java FakeBluetoothGatt readCharacteristic was called.
- void OnFakeBluetoothGattReadCharacteristic(JNIEnv* env, jobject caller);
+ void OnFakeBluetoothGattReadCharacteristic(
+ JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& caller);
// Records that Java FakeBluetoothGatt writeCharacteristic was called.
- void OnFakeBluetoothGattWriteCharacteristic(JNIEnv* env,
- jobject caller,
- jbyteArray value);
+ void OnFakeBluetoothGattWriteCharacteristic(
+ JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& caller,
+ const base::android::JavaParamRef<jbyteArray>& value);
base::android::ScopedJavaGlobalRef<jobject> j_fake_bluetooth_adapter_;
};