Skip to content

Commit 8d3197d

Browse files
xaionaro@dx.centerxaionaro@dx.center
authored andcommitted
feat: add BLE callback adapter classes for ScanCallback and BluetoothGattCallback
Add generated Java adapter classes required by the Proxy mechanism to create proxies for abstract BLE callback classes.
1 parent 74b6a6b commit 8d3197d

3 files changed

Lines changed: 184 additions & 0 deletions

File tree

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package center.dx.jni.generated;
2+
3+
import center.dx.jni.internal.GoAbstractDispatch;
4+
5+
/**
6+
* Generated by callbackgen. DO NOT EDIT.
7+
* Adapter for android.bluetooth.BluetoothGattCallback
8+
*/
9+
public class BluetoothGattCallbackAdapter
10+
extends android.bluetooth.BluetoothGattCallback {
11+
12+
private final long handlerID;
13+
14+
public BluetoothGattCallbackAdapter(long handlerID) {
15+
this.handlerID = handlerID;
16+
}
17+
18+
@Override
19+
public void onConnectionStateChange(android.bluetooth.BluetoothGatt gatt, int status, int newState) {
20+
GoAbstractDispatch.invoke(handlerID, "onConnectionStateChange", new Object[]{gatt, Integer.valueOf(status), Integer.valueOf(newState)});
21+
}
22+
23+
@Override
24+
public void onServicesDiscovered(android.bluetooth.BluetoothGatt gatt, int status) {
25+
GoAbstractDispatch.invoke(handlerID, "onServicesDiscovered", new Object[]{gatt, Integer.valueOf(status)});
26+
}
27+
28+
@Override
29+
public void onCharacteristicRead(android.bluetooth.BluetoothGatt gatt, android.bluetooth.BluetoothGattCharacteristic characteristic, int status) {
30+
GoAbstractDispatch.invoke(handlerID, "onCharacteristicRead", new Object[]{gatt, characteristic, Integer.valueOf(status)});
31+
}
32+
33+
@Override
34+
public void onCharacteristicWrite(android.bluetooth.BluetoothGatt gatt, android.bluetooth.BluetoothGattCharacteristic characteristic, int status) {
35+
GoAbstractDispatch.invoke(handlerID, "onCharacteristicWrite", new Object[]{gatt, characteristic, Integer.valueOf(status)});
36+
}
37+
38+
@Override
39+
public void onCharacteristicChanged(android.bluetooth.BluetoothGatt gatt, android.bluetooth.BluetoothGattCharacteristic characteristic) {
40+
GoAbstractDispatch.invoke(handlerID, "onCharacteristicChanged", new Object[]{gatt, characteristic});
41+
}
42+
43+
@Override
44+
public void onDescriptorRead(android.bluetooth.BluetoothGatt gatt, android.bluetooth.BluetoothGattDescriptor descriptor, int status) {
45+
GoAbstractDispatch.invoke(handlerID, "onDescriptorRead", new Object[]{gatt, descriptor, Integer.valueOf(status)});
46+
}
47+
48+
@Override
49+
public void onDescriptorWrite(android.bluetooth.BluetoothGatt gatt, android.bluetooth.BluetoothGattDescriptor descriptor, int status) {
50+
GoAbstractDispatch.invoke(handlerID, "onDescriptorWrite", new Object[]{gatt, descriptor, Integer.valueOf(status)});
51+
}
52+
53+
@Override
54+
public void onReadRemoteRssi(android.bluetooth.BluetoothGatt gatt, int rssi, int status) {
55+
GoAbstractDispatch.invoke(handlerID, "onReadRemoteRssi", new Object[]{gatt, Integer.valueOf(rssi), Integer.valueOf(status)});
56+
}
57+
58+
@Override
59+
public void onMtuChanged(android.bluetooth.BluetoothGatt gatt, int mtu, int status) {
60+
GoAbstractDispatch.invoke(handlerID, "onMtuChanged", new Object[]{gatt, Integer.valueOf(mtu), Integer.valueOf(status)});
61+
}
62+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package center.dx.jni.generated;
2+
3+
import center.dx.jni.internal.GoAbstractDispatch;
4+
5+
/**
6+
* Generated by callbackgen. DO NOT EDIT.
7+
* Adapter for android.bluetooth.le.ScanCallback
8+
*/
9+
public class ScanCallbackAdapter
10+
extends android.bluetooth.le.ScanCallback {
11+
12+
private final long handlerID;
13+
14+
public ScanCallbackAdapter(long handlerID) {
15+
this.handlerID = handlerID;
16+
}
17+
18+
@Override
19+
public void onScanResult(int callbackType, android.bluetooth.le.ScanResult result) {
20+
GoAbstractDispatch.invoke(handlerID, "onScanResult", new Object[]{Integer.valueOf(callbackType), result});
21+
}
22+
23+
@Override
24+
public void onBatchScanResults(java.util.List results) {
25+
GoAbstractDispatch.invoke(handlerID, "onBatchScanResults", new Object[]{results});
26+
}
27+
28+
@Override
29+
public void onScanFailed(int errorCode) {
30+
GoAbstractDispatch.invoke(handlerID, "onScanFailed", new Object[]{Integer.valueOf(errorCode)});
31+
}
32+
}

spec/callbacks.yaml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,96 @@ callbacks:
3131
- type: android.hardware.camera2.CameraCaptureSession
3232
name: session
3333

34+
- class: android.bluetooth.le.ScanCallback
35+
adapter: ScanCallbackAdapter
36+
methods:
37+
- name: onScanResult
38+
params:
39+
- type: int
40+
name: callbackType
41+
- type: android.bluetooth.le.ScanResult
42+
name: result
43+
- name: onBatchScanResults
44+
params:
45+
- type: java.util.List
46+
name: results
47+
- name: onScanFailed
48+
params:
49+
- type: int
50+
name: errorCode
51+
52+
- class: android.bluetooth.BluetoothGattCallback
53+
adapter: BluetoothGattCallbackAdapter
54+
methods:
55+
- name: onConnectionStateChange
56+
params:
57+
- type: android.bluetooth.BluetoothGatt
58+
name: gatt
59+
- type: int
60+
name: status
61+
- type: int
62+
name: newState
63+
- name: onServicesDiscovered
64+
params:
65+
- type: android.bluetooth.BluetoothGatt
66+
name: gatt
67+
- type: int
68+
name: status
69+
- name: onCharacteristicRead
70+
params:
71+
- type: android.bluetooth.BluetoothGatt
72+
name: gatt
73+
- type: android.bluetooth.BluetoothGattCharacteristic
74+
name: characteristic
75+
- type: int
76+
name: status
77+
- name: onCharacteristicWrite
78+
params:
79+
- type: android.bluetooth.BluetoothGatt
80+
name: gatt
81+
- type: android.bluetooth.BluetoothGattCharacteristic
82+
name: characteristic
83+
- type: int
84+
name: status
85+
- name: onCharacteristicChanged
86+
params:
87+
- type: android.bluetooth.BluetoothGatt
88+
name: gatt
89+
- type: android.bluetooth.BluetoothGattCharacteristic
90+
name: characteristic
91+
- name: onDescriptorRead
92+
params:
93+
- type: android.bluetooth.BluetoothGatt
94+
name: gatt
95+
- type: android.bluetooth.BluetoothGattDescriptor
96+
name: descriptor
97+
- type: int
98+
name: status
99+
- name: onDescriptorWrite
100+
params:
101+
- type: android.bluetooth.BluetoothGatt
102+
name: gatt
103+
- type: android.bluetooth.BluetoothGattDescriptor
104+
name: descriptor
105+
- type: int
106+
name: status
107+
- name: onReadRemoteRssi
108+
params:
109+
- type: android.bluetooth.BluetoothGatt
110+
name: gatt
111+
- type: int
112+
name: rssi
113+
- type: int
114+
name: status
115+
- name: onMtuChanged
116+
params:
117+
- type: android.bluetooth.BluetoothGatt
118+
name: gatt
119+
- type: int
120+
name: mtu
121+
- type: int
122+
name: status
123+
34124
- class: android.media.ImageReader.OnImageAvailableListener
35125
adapter: ImageReaderOnImageAvailableListenerAdapter
36126
interface: true

0 commit comments

Comments
 (0)