Loading android/app/jni/com_android_bluetooth_btservice_AdapterService.cpp +30 −1 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ static jmethodID method_setWakeAlarm; static jmethodID method_acquireWakeLock; static jmethodID method_releaseWakeLock; static jmethodID method_deviceMasInstancesFoundCallback; static jmethodID method_energyInfo; static const bt_interface_t *sBluetoothInterface = NULL; static const btsock_interface_t *sBluetoothSocketInterface = NULL; Loading Loading @@ -446,6 +447,21 @@ static void le_test_mode_recv_callback (bt_status_t status, uint16_t packet_coun ALOGV("%s: status:%d packet_count:%d ", __FUNCTION__, status, packet_count); } static void energy_info_recv_callback(bt_activity_energy_info *p_energy_info) { if (!checkCallbackThread()) { ALOGE("Callback: '%s' is not called on the correct thread", __FUNCTION__); return; } callbackEnv->CallVoidMethod(sJniCallbacksObj, method_energyInfo, p_energy_info->status, p_energy_info->ctrl_state, p_energy_info->tx_time, p_energy_info->rx_time, p_energy_info->idle_time, p_energy_info->energy_used); checkAndClearExceptionFromCallback(callbackEnv, __FUNCTION__); } static bt_callbacks_t sBluetoothCallbacks = { sizeof(sBluetoothCallbacks), adapter_state_change_callback, Loading @@ -460,7 +476,8 @@ static bt_callbacks_t sBluetoothCallbacks = { callback_thread_event, dut_mode_recv_callback, le_test_mode_recv_callback le_test_mode_recv_callback, energy_info_recv_callback }; // The callback to call when the wake alarm fires. Loading Loading @@ -689,6 +706,7 @@ static void classInitNative(JNIEnv* env, jclass clazz) { method_deviceMasInstancesFoundCallback = env->GetMethodID(jniCallbackClass, "deviceMasInstancesFoundCallback", "(I[B[Ljava/lang/String;[I[I[I)V"); method_energyInfo = env->GetMethodID(clazz, "energyInfoCallback", "(IIJJJJ)V"); char value[PROPERTY_VALUE_MAX]; property_get("bluetooth.mock_stack", value, ""); Loading Loading @@ -1179,6 +1197,16 @@ static jboolean configHciSnoopLogNative(JNIEnv* env, jobject obj, jboolean enabl return result; } static int readEnergyInfo() { ALOGV("%s:",__FUNCTION__); jboolean result = JNI_FALSE; if (!sBluetoothInterface) return result; int ret = sBluetoothInterface->read_energy_info(); result = (ret == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE; return result; } static JNINativeMethod sMethods[] = { /* name, signature, funcPtr */ {"classInitNative", "()V", (void *) classInitNative}, Loading Loading @@ -1206,6 +1234,7 @@ static JNINativeMethod sMethods[] = { (void*) createSocketChannelNative}, {"configHciSnoopLogNative", "(Z)Z", (void*) configHciSnoopLogNative}, {"alarmFiredNative", "()V", (void *) alarmFiredNative}, {"readEnergyInfo", "()I", (void*) readEnergyInfo}, }; int register_com_android_bluetooth_btservice_AdapterService(JNIEnv* env) Loading android/app/jni/com_android_bluetooth_gatt.cpp +0 −2 Original line number Diff line number Diff line Loading @@ -149,7 +149,6 @@ static jmethodID method_onWriteCharacteristic; static jmethodID method_onExecuteCompleted; static jmethodID method_onSearchCompleted; static jmethodID method_onSearchResult; static jmethodID method_onReadDescrExtProp; static jmethodID method_onReadDescriptor; static jmethodID method_onWriteDescriptor; static jmethodID method_onNotify; Loading Loading @@ -564,7 +563,6 @@ void btgattc_track_adv_event_cb(int client_if, int filt_index, int addr_type, checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__); } static const btgatt_client_callbacks_t sGattClientCallbacks = { btgattc_register_app_cb, btgattc_scan_result_cb, Loading android/app/src/com/android/bluetooth/btservice/AdapterProperties.java +1 −0 Original line number Diff line number Diff line Loading @@ -537,6 +537,7 @@ class AdapterProperties { mNumOfOffloadedIrkSupported = (0x000000FF & ((int)val[3])); mNumOfOffloadedScanFilterSupported = (0x000000FF & ((int)val[4])); mOffloadedScanResultStorageBytes = (0x000000FF & ((int)val[5])); // TBD for energy support Log.d(TAG, "BT_PROPERTY_LOCAL_LE_FEATURES: update from BT controller" + " mNumOfAdvertisementInstancesSupported = " + mNumOfAdvertisementInstancesSupported Loading android/app/src/com/android/bluetooth/btservice/AdapterService.java +21 −0 Original line number Diff line number Diff line Loading @@ -959,6 +959,11 @@ public class AdapterService extends Service { service.sendConnectionStateChange(device, profile, state, prevState); } public void getEnergyInfo(){ AdapterService service = getService(); if (service == null) return; service.getEnergyInfo(); } public ParcelFileDescriptor connectSocket(BluetoothDevice device, int type, ParcelUuid uuid, int port, int flag) { if (!Utils.checkCaller()) { Loading Loading @@ -1522,6 +1527,11 @@ public class AdapterService extends Service { return mAdapterProperties.getOffloadedScanResultStorage(); } public int getEnergyInfo() { enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); return readEnergyInfo(); } private static int convertScanModeToHal(int mode) { switch (mode) { case BluetoothAdapter.SCAN_MODE_NONE: Loading Loading @@ -1611,6 +1621,16 @@ public class AdapterService extends Service { return true; } private void energyInfoCallback (int status, int ctrl_state, long tx_time, long rx_time, long idle_time, long energy_used) throws RemoteException { // TBD debugLog("energyInfoCallback " + "status = " + status + "tx_time = " + tx_time + "rx_time = " + rx_time + "idle_time = " + idle_time + "energy_used = " + energy_used + "ctrl_state = " + ctrl_state); } private void debugLog(String msg) { if (DBG) Log.d(TAG +"(" +hashCode()+")", msg); } Loading Loading @@ -1658,6 +1678,7 @@ public class AdapterService extends Service { /*package*/ native boolean getRemoteServicesNative(byte[] address); /*package*/ native boolean getRemoteMasInstancesNative(byte[] address); private native int readEnergyInfo(); // TODO(BT) move this to ../btsock dir private native int connectSocketNative(byte[] address, int type, byte[] uuid, int port, int flag); Loading Loading
android/app/jni/com_android_bluetooth_btservice_AdapterService.cpp +30 −1 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ static jmethodID method_setWakeAlarm; static jmethodID method_acquireWakeLock; static jmethodID method_releaseWakeLock; static jmethodID method_deviceMasInstancesFoundCallback; static jmethodID method_energyInfo; static const bt_interface_t *sBluetoothInterface = NULL; static const btsock_interface_t *sBluetoothSocketInterface = NULL; Loading Loading @@ -446,6 +447,21 @@ static void le_test_mode_recv_callback (bt_status_t status, uint16_t packet_coun ALOGV("%s: status:%d packet_count:%d ", __FUNCTION__, status, packet_count); } static void energy_info_recv_callback(bt_activity_energy_info *p_energy_info) { if (!checkCallbackThread()) { ALOGE("Callback: '%s' is not called on the correct thread", __FUNCTION__); return; } callbackEnv->CallVoidMethod(sJniCallbacksObj, method_energyInfo, p_energy_info->status, p_energy_info->ctrl_state, p_energy_info->tx_time, p_energy_info->rx_time, p_energy_info->idle_time, p_energy_info->energy_used); checkAndClearExceptionFromCallback(callbackEnv, __FUNCTION__); } static bt_callbacks_t sBluetoothCallbacks = { sizeof(sBluetoothCallbacks), adapter_state_change_callback, Loading @@ -460,7 +476,8 @@ static bt_callbacks_t sBluetoothCallbacks = { callback_thread_event, dut_mode_recv_callback, le_test_mode_recv_callback le_test_mode_recv_callback, energy_info_recv_callback }; // The callback to call when the wake alarm fires. Loading Loading @@ -689,6 +706,7 @@ static void classInitNative(JNIEnv* env, jclass clazz) { method_deviceMasInstancesFoundCallback = env->GetMethodID(jniCallbackClass, "deviceMasInstancesFoundCallback", "(I[B[Ljava/lang/String;[I[I[I)V"); method_energyInfo = env->GetMethodID(clazz, "energyInfoCallback", "(IIJJJJ)V"); char value[PROPERTY_VALUE_MAX]; property_get("bluetooth.mock_stack", value, ""); Loading Loading @@ -1179,6 +1197,16 @@ static jboolean configHciSnoopLogNative(JNIEnv* env, jobject obj, jboolean enabl return result; } static int readEnergyInfo() { ALOGV("%s:",__FUNCTION__); jboolean result = JNI_FALSE; if (!sBluetoothInterface) return result; int ret = sBluetoothInterface->read_energy_info(); result = (ret == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE; return result; } static JNINativeMethod sMethods[] = { /* name, signature, funcPtr */ {"classInitNative", "()V", (void *) classInitNative}, Loading Loading @@ -1206,6 +1234,7 @@ static JNINativeMethod sMethods[] = { (void*) createSocketChannelNative}, {"configHciSnoopLogNative", "(Z)Z", (void*) configHciSnoopLogNative}, {"alarmFiredNative", "()V", (void *) alarmFiredNative}, {"readEnergyInfo", "()I", (void*) readEnergyInfo}, }; int register_com_android_bluetooth_btservice_AdapterService(JNIEnv* env) Loading
android/app/jni/com_android_bluetooth_gatt.cpp +0 −2 Original line number Diff line number Diff line Loading @@ -149,7 +149,6 @@ static jmethodID method_onWriteCharacteristic; static jmethodID method_onExecuteCompleted; static jmethodID method_onSearchCompleted; static jmethodID method_onSearchResult; static jmethodID method_onReadDescrExtProp; static jmethodID method_onReadDescriptor; static jmethodID method_onWriteDescriptor; static jmethodID method_onNotify; Loading Loading @@ -564,7 +563,6 @@ void btgattc_track_adv_event_cb(int client_if, int filt_index, int addr_type, checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__); } static const btgatt_client_callbacks_t sGattClientCallbacks = { btgattc_register_app_cb, btgattc_scan_result_cb, Loading
android/app/src/com/android/bluetooth/btservice/AdapterProperties.java +1 −0 Original line number Diff line number Diff line Loading @@ -537,6 +537,7 @@ class AdapterProperties { mNumOfOffloadedIrkSupported = (0x000000FF & ((int)val[3])); mNumOfOffloadedScanFilterSupported = (0x000000FF & ((int)val[4])); mOffloadedScanResultStorageBytes = (0x000000FF & ((int)val[5])); // TBD for energy support Log.d(TAG, "BT_PROPERTY_LOCAL_LE_FEATURES: update from BT controller" + " mNumOfAdvertisementInstancesSupported = " + mNumOfAdvertisementInstancesSupported Loading
android/app/src/com/android/bluetooth/btservice/AdapterService.java +21 −0 Original line number Diff line number Diff line Loading @@ -959,6 +959,11 @@ public class AdapterService extends Service { service.sendConnectionStateChange(device, profile, state, prevState); } public void getEnergyInfo(){ AdapterService service = getService(); if (service == null) return; service.getEnergyInfo(); } public ParcelFileDescriptor connectSocket(BluetoothDevice device, int type, ParcelUuid uuid, int port, int flag) { if (!Utils.checkCaller()) { Loading Loading @@ -1522,6 +1527,11 @@ public class AdapterService extends Service { return mAdapterProperties.getOffloadedScanResultStorage(); } public int getEnergyInfo() { enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); return readEnergyInfo(); } private static int convertScanModeToHal(int mode) { switch (mode) { case BluetoothAdapter.SCAN_MODE_NONE: Loading Loading @@ -1611,6 +1621,16 @@ public class AdapterService extends Service { return true; } private void energyInfoCallback (int status, int ctrl_state, long tx_time, long rx_time, long idle_time, long energy_used) throws RemoteException { // TBD debugLog("energyInfoCallback " + "status = " + status + "tx_time = " + tx_time + "rx_time = " + rx_time + "idle_time = " + idle_time + "energy_used = " + energy_used + "ctrl_state = " + ctrl_state); } private void debugLog(String msg) { if (DBG) Log.d(TAG +"(" +hashCode()+")", msg); } Loading Loading @@ -1658,6 +1678,7 @@ public class AdapterService extends Service { /*package*/ native boolean getRemoteServicesNative(byte[] address); /*package*/ native boolean getRemoteMasInstancesNative(byte[] address); private native int readEnergyInfo(); // TODO(BT) move this to ../btsock dir private native int connectSocketNative(byte[] address, int type, byte[] uuid, int port, int flag); Loading