Loading android/app/src/com/android/bluetooth/avrcp/Avrcp.java +2 −2 Original line number Diff line number Diff line Loading @@ -2867,11 +2867,11 @@ public final class Avrcp { private native boolean setBrowsedPlayerRspNative(byte[] address, int rspStatus, byte depth, int numItems, String[] textArray); private native boolean mediaPlayerListRspNative(byte[] address, int rsStatus, int uidCounter, byte item_type, int numItems, int[] playerIds, byte[] playerTypes, int[] playerSubTypes, byte itemType, int numItems, int[] playerIds, byte[] playerTypes, int[] playerSubTypes, byte[] playStatusValues, short[] featureBitMaskValues, String[] textArray); private native boolean getFolderItemsRspNative(byte[] address, int rspStatus, short uidCounter, byte scope, int numItems, byte[] folderTypes, byte[] playable, byte[] itemTypes, byte[] itemUidArray, String[] textArray, int[] AttributesNum, int[] AttributesIds, byte[] itemUidArray, String[] textArray, int[] attributesNum, int[] attributesIds, String[] attributesArray); private native boolean changePathRspNative(byte[] address, int rspStatus, int numItems); private native boolean getItemAttrRspNative(byte[] address, int rspStatus, byte numAttr, Loading android/app/src/com/android/bluetooth/avrcp/AvrcpHelperClasses.java +11 −11 Original line number Diff line number Diff line Loading @@ -129,11 +129,11 @@ class MediaPlayerListRsp { String[] mPlayerNameList; int mNumItems; public MediaPlayerListRsp(byte status, short UIDCounter, int numItems, byte itemType, public MediaPlayerListRsp(byte status, short uidCounter, int numItems, byte itemType, int[] playerIds, byte[] playerTypes, int[] playerSubTypes, byte[] playStatusValues, short[] featureBitMaskValues, String[] playerNameList) { this.mStatus = status; this.mUIDCounter = UIDCounter; this.mUIDCounter = uidCounter; this.mNumItems = numItems; this.itemType = itemType; this.mPlayerIds = playerIds; Loading Loading @@ -165,20 +165,20 @@ class FolderItemsRsp { int[] mAttrIds; String[] mAttrValues; public FolderItemsRsp(byte Status, short UIDCounter, byte scope, int numItems, byte[] folderTypes, byte[] playable, byte[] ItemTypes, byte[] ItemsUid, String[] displayNameArray, int[] AttributesNum, int[] AttrIds, String[] attrValues) { this.mStatus = Status; this.mUIDCounter = UIDCounter; public FolderItemsRsp(byte status, short uidCounter, byte scope, int numItems, byte[] folderTypes, byte[] playable, byte[] itemTypes, byte[] itemsUid, String[] displayNameArray, int[] attributesNum, int[] attrIds, String[] attrValues) { this.mStatus = status; this.mUIDCounter = uidCounter; this.mScope = scope; this.mNumItems = numItems; this.mFolderTypes = folderTypes; this.mPlayable = playable; this.mItemTypes = ItemTypes; this.mItemUid = ItemsUid; this.mItemTypes = itemTypes; this.mItemUid = itemsUid; this.mDisplayNames = displayNameArray; this.mAttributesNum = AttributesNum; this.mAttrIds = AttrIds; this.mAttributesNum = attributesNum; this.mAttrIds = attrIds; this.mAttrValues = attrValues; } } Loading android/app/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerService.java +6 −6 Original line number Diff line number Diff line Loading @@ -754,9 +754,9 @@ public class AvrcpControllerService extends ProfileService { // Called by JNI when a device has connected or disconnected. private synchronized void onConnectionStateChanged( boolean rc_connected, boolean br_connected, byte[] address) { boolean rcConnected, boolean brConnected, byte[] address) { BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); Log.d(TAG, "onConnectionStateChanged " + rc_connected + " " + br_connected + Log.d(TAG, "onConnectionStateChanged " + rcConnected + " " + brConnected + device + " conn device " + mConnectedDevice); if (device == null) { Log.e(TAG, "onConnectionStateChanged Device is null"); Loading @@ -766,10 +766,10 @@ public class AvrcpControllerService extends ProfileService { // Adjust the AVRCP connection state. int oldState = (device.equals(mConnectedDevice) ? BluetoothProfile.STATE_CONNECTED : BluetoothProfile.STATE_DISCONNECTED); int newState = (rc_connected ? BluetoothProfile.STATE_CONNECTED : int newState = (rcConnected ? BluetoothProfile.STATE_CONNECTED : BluetoothProfile.STATE_DISCONNECTED); if (rc_connected && oldState == BluetoothProfile.STATE_DISCONNECTED) { if (rcConnected && oldState == BluetoothProfile.STATE_DISCONNECTED) { /* AVRCPControllerService supports single connection */ if (mConnectedDevice != null) { Log.d(TAG, "A Connection already exists, returning"); Loading @@ -780,7 +780,7 @@ public class AvrcpControllerService extends ProfileService { AvrcpControllerStateMachine.MESSAGE_PROCESS_CONNECTION_CHANGE, newState, oldState, device); mAvrcpCtSm.sendMessage(msg); } else if (!rc_connected && oldState == BluetoothProfile.STATE_CONNECTED) { } else if (!rcConnected && oldState == BluetoothProfile.STATE_CONNECTED) { mConnectedDevice = null; Message msg = mAvrcpCtSm.obtainMessage( AvrcpControllerStateMachine.MESSAGE_PROCESS_CONNECTION_CHANGE, newState, Loading @@ -790,7 +790,7 @@ public class AvrcpControllerService extends ProfileService { // Adjust the browse connection state. If RC is connected we should have already sent the // connection status out. if (rc_connected && br_connected) { if (rcConnected && brConnected) { mBrowseConnected = true; Message msg = mAvrcpCtSm.obtainMessage( AvrcpControllerStateMachine.MESSAGE_PROCESS_BROWSE_CONNECTION_CHANGE); Loading android/app/src/com/android/bluetooth/btservice/AdapterService.java +17 −17 Original line number Diff line number Diff line Loading @@ -2167,18 +2167,18 @@ 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, UidTraffic[] data) throws RemoteException { if (ctrl_state >= BluetoothActivityEnergyInfo.BT_STACK_STATE_INVALID && ctrl_state <= BluetoothActivityEnergyInfo.BT_STACK_STATE_STATE_IDLE) { private void energyInfoCallback(int status, int ctrlState, long txTime, long rxTime, long idleTime, long energyUsed, UidTraffic[] data) throws RemoteException { if (ctrlState >= BluetoothActivityEnergyInfo.BT_STACK_STATE_INVALID && ctrlState <= BluetoothActivityEnergyInfo.BT_STACK_STATE_STATE_IDLE) { // Energy is product of mA, V and ms. If the chipset doesn't // report it, we have to compute it from time if (energy_used == 0) { if (energyUsed == 0) { try { final long txMah = Math.multiplyExact(tx_time, getTxCurrentMa()); final long rxMah = Math.multiplyExact(rx_time, getRxCurrentMa()); final long idleMah = Math.multiplyExact(idle_time, getIdleCurrentMa()); energy_used = (long) (Math.addExact(Math.addExact(txMah, rxMah), idleMah) final long txMah = Math.multiplyExact(txTime, getTxCurrentMa()); final long rxMah = Math.multiplyExact(rxTime, getRxCurrentMa()); final long idleMah = Math.multiplyExact(idleTime, getIdleCurrentMa()); energyUsed = (long) (Math.addExact(Math.addExact(txMah, rxMah), idleMah) * getOperatingVolt()); } catch (ArithmeticException e) { Slog.wtf(TAG, "overflow in bluetooth energy callback", e); Loading @@ -2187,16 +2187,16 @@ public class AdapterService extends Service { } synchronized (mEnergyInfoLock) { mStackReportedState = ctrl_state; mStackReportedState = ctrlState; long totalTxTimeMs; long totalRxTimeMs; long totalIdleTimeMs; long totalEnergy; try { totalTxTimeMs = Math.addExact(mTxTimeTotalMs, tx_time); totalRxTimeMs = Math.addExact(mRxTimeTotalMs, rx_time); totalIdleTimeMs = Math.addExact(mIdleTimeTotalMs, idle_time); totalEnergy = Math.addExact(mEnergyUsedTotalVoltAmpSecMicro, energy_used); totalTxTimeMs = Math.addExact(mTxTimeTotalMs, txTime); totalRxTimeMs = Math.addExact(mRxTimeTotalMs, rxTime); totalIdleTimeMs = Math.addExact(mIdleTimeTotalMs, idleTime); totalEnergy = Math.addExact(mEnergyUsedTotalVoltAmpSecMicro, energyUsed); } catch (ArithmeticException e) { // This could be because we accumulated a lot of time, or we got a very strange // value from the controller (more likely). Discard this data. Loading Loading @@ -2225,9 +2225,9 @@ public class AdapterService extends Service { } } verboseLog("energyInfoCallback() status = " + status + "tx_time = " + tx_time + "rx_time = " + rx_time + "idle_time = " + idle_time + "energy_used = " + energy_used + "ctrl_state = " + ctrl_state + "traffic = " + Arrays.toString(data)); verboseLog("energyInfoCallback() status = " + status + "txTime = " + txTime + "rxTime = " + rxTime + "idleTime = " + idleTime + "energyUsed = " + energyUsed + "ctrlState = " + ctrlState + "traffic = " + Arrays.toString(data)); } private int getIdleCurrentMa() { Loading android/app/src/com/android/bluetooth/gatt/AdvertiseManager.java +55 −55 Original line number Diff line number Diff line Loading @@ -123,10 +123,10 @@ class AdvertiseManager { } } Map.Entry<IBinder, AdvertiserInfo> findAdvertiser(int advertiser_id) { Map.Entry<IBinder, AdvertiserInfo> findAdvertiser(int advertiserId) { Map.Entry<IBinder, AdvertiserInfo> entry = null; for (Map.Entry<IBinder, AdvertiserInfo> e : mAdvertisers.entrySet()) { if (e.getValue().id == advertiser_id) { if (e.getValue().id == advertiserId) { entry = e; break; } Loading @@ -134,50 +134,50 @@ class AdvertiseManager { return entry; } void onAdvertisingSetStarted(int reg_id, int advertiser_id, int tx_power, int status) void onAdvertisingSetStarted(int regId, int advertiserId, int txPower, int status) throws Exception { if (DBG) { Log.d(TAG, "onAdvertisingSetStarted() - reg_id=" + reg_id + ", advertiser_id=" + advertiser_id + ", status=" + status); Log.d(TAG, "onAdvertisingSetStarted() - regId=" + regId + ", advertiserId=" + advertiserId + ", status=" + status); } Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(reg_id); Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(regId); if (entry == null) { Log.i(TAG, "onAdvertisingSetStarted() - no callback found for reg_id " + reg_id); Log.i(TAG, "onAdvertisingSetStarted() - no callback found for regId " + regId); // Advertising set was stopped before it was properly registered. stopAdvertisingSetNative(advertiser_id); stopAdvertisingSetNative(advertiserId); return; } IAdvertisingSetCallback callback = entry.getValue().callback; if (status == 0) { entry.setValue( new AdvertiserInfo(advertiser_id, entry.getValue().deathRecipient, callback)); new AdvertiserInfo(advertiserId, entry.getValue().deathRecipient, callback)); } else { IBinder binder = entry.getKey(); binder.unlinkToDeath(entry.getValue().deathRecipient, 0); mAdvertisers.remove(binder); } callback.onAdvertisingSetStarted(advertiser_id, tx_power, status); callback.onAdvertisingSetStarted(advertiserId, txPower, status); } void onAdvertisingEnabled(int advertiser_id, boolean enable, int status) throws Exception { void onAdvertisingEnabled(int advertiserId, boolean enable, int status) throws Exception { if (DBG) { Log.d(TAG, "onAdvertisingSetEnabled() - advertiser_id=" + advertiser_id + ", enable=" Log.d(TAG, "onAdvertisingSetEnabled() - advertiserId=" + advertiserId + ", enable=" + enable + ", status=" + status); } Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id); Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiserId); if (entry == null) { Log.i(TAG, "onAdvertisingSetEnable() - no callback found for advertiser_id " + advertiser_id); Log.i(TAG, "onAdvertisingSetEnable() - no callback found for advertiserId " + advertiserId); return; } IAdvertisingSetCallback callback = entry.getValue().callback; callback.onAdvertisingEnabled(advertiser_id, enable, status); callback.onAdvertisingEnabled(advertiserId, enable, status); } void startAdvertisingSet(AdvertisingSetParameters parameters, AdvertiseData advertiseData, Loading Loading @@ -205,18 +205,18 @@ class AdvertiseManager { periodic_data, duration, maxExtAdvEvents, cb_id); } void onOwnAddressRead(int advertiser_id, int addressType, String address) void onOwnAddressRead(int advertiserId, int addressType, String address) throws RemoteException { if (DBG) Log.d(TAG, "onOwnAddressRead() advertiser_id=" + advertiser_id); if (DBG) Log.d(TAG, "onOwnAddressRead() advertiserId=" + advertiserId); Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id); Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiserId); if (entry == null) { Log.i(TAG, "onOwnAddressRead() - bad advertiser_id " + advertiser_id); Log.i(TAG, "onOwnAddressRead() - bad advertiserId " + advertiserId); return; } IAdvertisingSetCallback callback = entry.getValue().callback; callback.onOwnAddressRead(advertiser_id, addressType, address); callback.onOwnAddressRead(advertiserId, addressType, address); } void getOwnAddress(int advertiserId) { Loading Loading @@ -286,102 +286,102 @@ class AdvertiseManager { setPeriodicAdvertisingEnableNative(advertiserId, enable); } void onAdvertisingDataSet(int advertiser_id, int status) throws Exception { void onAdvertisingDataSet(int advertiserId, int status) throws Exception { if (DBG) { Log.d(TAG, "onAdvertisingDataSet() advertiser_id=" + advertiser_id + ", status=" + status); "onAdvertisingDataSet() advertiserId=" + advertiserId + ", status=" + status); } Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id); Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiserId); if (entry == null) { Log.i(TAG, "onAdvertisingDataSet() - bad advertiser_id " + advertiser_id); Log.i(TAG, "onAdvertisingDataSet() - bad advertiserId " + advertiserId); return; } IAdvertisingSetCallback callback = entry.getValue().callback; callback.onAdvertisingDataSet(advertiser_id, status); callback.onAdvertisingDataSet(advertiserId, status); } void onScanResponseDataSet(int advertiser_id, int status) throws Exception { void onScanResponseDataSet(int advertiserId, int status) throws Exception { if (DBG) Log.d(TAG, "onScanResponseDataSet() advertiser_id=" + advertiser_id + ", status=" Log.d(TAG, "onScanResponseDataSet() advertiserId=" + advertiserId + ", status=" + status); Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id); Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiserId); if (entry == null) { Log.i(TAG, "onScanResponseDataSet() - bad advertiser_id " + advertiser_id); Log.i(TAG, "onScanResponseDataSet() - bad advertiserId " + advertiserId); return; } IAdvertisingSetCallback callback = entry.getValue().callback; callback.onScanResponseDataSet(advertiser_id, status); callback.onScanResponseDataSet(advertiserId, status); } void onAdvertisingParametersUpdated(int advertiser_id, int tx_power, int status) void onAdvertisingParametersUpdated(int advertiserId, int txPower, int status) throws Exception { if (DBG) { Log.d(TAG, "onAdvertisingParametersUpdated() advertiser_id=" + advertiser_id + ", tx_power=" + tx_power + ", status=" + status); Log.d(TAG, "onAdvertisingParametersUpdated() advertiserId=" + advertiserId + ", txPower=" + txPower + ", status=" + status); } Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id); Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiserId); if (entry == null) { Log.i(TAG, "onAdvertisingParametersUpdated() - bad advertiser_id " + advertiser_id); Log.i(TAG, "onAdvertisingParametersUpdated() - bad advertiserId " + advertiserId); return; } IAdvertisingSetCallback callback = entry.getValue().callback; callback.onAdvertisingParametersUpdated(advertiser_id, tx_power, status); callback.onAdvertisingParametersUpdated(advertiserId, txPower, status); } void onPeriodicAdvertisingParametersUpdated(int advertiser_id, int status) throws Exception { void onPeriodicAdvertisingParametersUpdated(int advertiserId, int status) throws Exception { if (DBG) { Log.d(TAG, "onPeriodicAdvertisingParametersUpdated() advertiser_id=" + advertiser_id Log.d(TAG, "onPeriodicAdvertisingParametersUpdated() advertiserId=" + advertiserId + ", status=" + status); } Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id); Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiserId); if (entry == null) { Log.i(TAG, "onPeriodicAdvertisingParametersUpdated() - bad advertiser_id " + advertiser_id); Log.i(TAG, "onPeriodicAdvertisingParametersUpdated() - bad advertiserId " + advertiserId); return; } IAdvertisingSetCallback callback = entry.getValue().callback; callback.onPeriodicAdvertisingParametersUpdated(advertiser_id, status); callback.onPeriodicAdvertisingParametersUpdated(advertiserId, status); } void onPeriodicAdvertisingDataSet(int advertiser_id, int status) throws Exception { void onPeriodicAdvertisingDataSet(int advertiserId, int status) throws Exception { if (DBG) { Log.d(TAG, "onPeriodicAdvertisingDataSet() advertiser_id=" + advertiser_id + ", status=" Log.d(TAG, "onPeriodicAdvertisingDataSet() advertiserId=" + advertiserId + ", status=" + status); } Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id); Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiserId); if (entry == null) { Log.i(TAG, "onPeriodicAdvertisingDataSet() - bad advertiser_id " + advertiser_id); Log.i(TAG, "onPeriodicAdvertisingDataSet() - bad advertiserId " + advertiserId); return; } IAdvertisingSetCallback callback = entry.getValue().callback; callback.onPeriodicAdvertisingDataSet(advertiser_id, status); callback.onPeriodicAdvertisingDataSet(advertiserId, status); } void onPeriodicAdvertisingEnabled(int advertiser_id, boolean enable, int status) void onPeriodicAdvertisingEnabled(int advertiserId, boolean enable, int status) throws Exception { if (DBG) { Log.d(TAG, "onPeriodicAdvertisingEnabled() advertiser_id=" + advertiser_id + ", status=" Log.d(TAG, "onPeriodicAdvertisingEnabled() advertiserId=" + advertiserId + ", status=" + status); } Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id); Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiserId); if (entry == null) { Log.i(TAG, "onAdvertisingSetEnable() - bad advertiser_id " + advertiser_id); Log.i(TAG, "onAdvertisingSetEnable() - bad advertiserId " + advertiserId); return; } IAdvertisingSetCallback callback = entry.getValue().callback; callback.onPeriodicAdvertisingEnabled(advertiser_id, enable, status); callback.onPeriodicAdvertisingEnabled(advertiserId, enable, status); } static { Loading @@ -394,9 +394,9 @@ class AdvertiseManager { private native void startAdvertisingSetNative(AdvertisingSetParameters parameters, byte[] advertiseData, byte[] scanResponse, PeriodicAdvertisingParameters periodicParameters, byte[] periodicData, int duration, int maxExtAdvEvents, int reg_id); int maxExtAdvEvents, int regId); private native void getOwnAddressNative(int advertiserId); private native void stopAdvertisingSetNative(int advertiser_id); private native void stopAdvertisingSetNative(int advertiserId); private native void enableAdvertisingSetNative( int advertiserId, boolean enable, int duration, int maxExtAdvEvents); private native void setAdvertisingDataNative(int advertiserId, byte[] data); Loading Loading
android/app/src/com/android/bluetooth/avrcp/Avrcp.java +2 −2 Original line number Diff line number Diff line Loading @@ -2867,11 +2867,11 @@ public final class Avrcp { private native boolean setBrowsedPlayerRspNative(byte[] address, int rspStatus, byte depth, int numItems, String[] textArray); private native boolean mediaPlayerListRspNative(byte[] address, int rsStatus, int uidCounter, byte item_type, int numItems, int[] playerIds, byte[] playerTypes, int[] playerSubTypes, byte itemType, int numItems, int[] playerIds, byte[] playerTypes, int[] playerSubTypes, byte[] playStatusValues, short[] featureBitMaskValues, String[] textArray); private native boolean getFolderItemsRspNative(byte[] address, int rspStatus, short uidCounter, byte scope, int numItems, byte[] folderTypes, byte[] playable, byte[] itemTypes, byte[] itemUidArray, String[] textArray, int[] AttributesNum, int[] AttributesIds, byte[] itemUidArray, String[] textArray, int[] attributesNum, int[] attributesIds, String[] attributesArray); private native boolean changePathRspNative(byte[] address, int rspStatus, int numItems); private native boolean getItemAttrRspNative(byte[] address, int rspStatus, byte numAttr, Loading
android/app/src/com/android/bluetooth/avrcp/AvrcpHelperClasses.java +11 −11 Original line number Diff line number Diff line Loading @@ -129,11 +129,11 @@ class MediaPlayerListRsp { String[] mPlayerNameList; int mNumItems; public MediaPlayerListRsp(byte status, short UIDCounter, int numItems, byte itemType, public MediaPlayerListRsp(byte status, short uidCounter, int numItems, byte itemType, int[] playerIds, byte[] playerTypes, int[] playerSubTypes, byte[] playStatusValues, short[] featureBitMaskValues, String[] playerNameList) { this.mStatus = status; this.mUIDCounter = UIDCounter; this.mUIDCounter = uidCounter; this.mNumItems = numItems; this.itemType = itemType; this.mPlayerIds = playerIds; Loading Loading @@ -165,20 +165,20 @@ class FolderItemsRsp { int[] mAttrIds; String[] mAttrValues; public FolderItemsRsp(byte Status, short UIDCounter, byte scope, int numItems, byte[] folderTypes, byte[] playable, byte[] ItemTypes, byte[] ItemsUid, String[] displayNameArray, int[] AttributesNum, int[] AttrIds, String[] attrValues) { this.mStatus = Status; this.mUIDCounter = UIDCounter; public FolderItemsRsp(byte status, short uidCounter, byte scope, int numItems, byte[] folderTypes, byte[] playable, byte[] itemTypes, byte[] itemsUid, String[] displayNameArray, int[] attributesNum, int[] attrIds, String[] attrValues) { this.mStatus = status; this.mUIDCounter = uidCounter; this.mScope = scope; this.mNumItems = numItems; this.mFolderTypes = folderTypes; this.mPlayable = playable; this.mItemTypes = ItemTypes; this.mItemUid = ItemsUid; this.mItemTypes = itemTypes; this.mItemUid = itemsUid; this.mDisplayNames = displayNameArray; this.mAttributesNum = AttributesNum; this.mAttrIds = AttrIds; this.mAttributesNum = attributesNum; this.mAttrIds = attrIds; this.mAttrValues = attrValues; } } Loading
android/app/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerService.java +6 −6 Original line number Diff line number Diff line Loading @@ -754,9 +754,9 @@ public class AvrcpControllerService extends ProfileService { // Called by JNI when a device has connected or disconnected. private synchronized void onConnectionStateChanged( boolean rc_connected, boolean br_connected, byte[] address) { boolean rcConnected, boolean brConnected, byte[] address) { BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); Log.d(TAG, "onConnectionStateChanged " + rc_connected + " " + br_connected + Log.d(TAG, "onConnectionStateChanged " + rcConnected + " " + brConnected + device + " conn device " + mConnectedDevice); if (device == null) { Log.e(TAG, "onConnectionStateChanged Device is null"); Loading @@ -766,10 +766,10 @@ public class AvrcpControllerService extends ProfileService { // Adjust the AVRCP connection state. int oldState = (device.equals(mConnectedDevice) ? BluetoothProfile.STATE_CONNECTED : BluetoothProfile.STATE_DISCONNECTED); int newState = (rc_connected ? BluetoothProfile.STATE_CONNECTED : int newState = (rcConnected ? BluetoothProfile.STATE_CONNECTED : BluetoothProfile.STATE_DISCONNECTED); if (rc_connected && oldState == BluetoothProfile.STATE_DISCONNECTED) { if (rcConnected && oldState == BluetoothProfile.STATE_DISCONNECTED) { /* AVRCPControllerService supports single connection */ if (mConnectedDevice != null) { Log.d(TAG, "A Connection already exists, returning"); Loading @@ -780,7 +780,7 @@ public class AvrcpControllerService extends ProfileService { AvrcpControllerStateMachine.MESSAGE_PROCESS_CONNECTION_CHANGE, newState, oldState, device); mAvrcpCtSm.sendMessage(msg); } else if (!rc_connected && oldState == BluetoothProfile.STATE_CONNECTED) { } else if (!rcConnected && oldState == BluetoothProfile.STATE_CONNECTED) { mConnectedDevice = null; Message msg = mAvrcpCtSm.obtainMessage( AvrcpControllerStateMachine.MESSAGE_PROCESS_CONNECTION_CHANGE, newState, Loading @@ -790,7 +790,7 @@ public class AvrcpControllerService extends ProfileService { // Adjust the browse connection state. If RC is connected we should have already sent the // connection status out. if (rc_connected && br_connected) { if (rcConnected && brConnected) { mBrowseConnected = true; Message msg = mAvrcpCtSm.obtainMessage( AvrcpControllerStateMachine.MESSAGE_PROCESS_BROWSE_CONNECTION_CHANGE); Loading
android/app/src/com/android/bluetooth/btservice/AdapterService.java +17 −17 Original line number Diff line number Diff line Loading @@ -2167,18 +2167,18 @@ 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, UidTraffic[] data) throws RemoteException { if (ctrl_state >= BluetoothActivityEnergyInfo.BT_STACK_STATE_INVALID && ctrl_state <= BluetoothActivityEnergyInfo.BT_STACK_STATE_STATE_IDLE) { private void energyInfoCallback(int status, int ctrlState, long txTime, long rxTime, long idleTime, long energyUsed, UidTraffic[] data) throws RemoteException { if (ctrlState >= BluetoothActivityEnergyInfo.BT_STACK_STATE_INVALID && ctrlState <= BluetoothActivityEnergyInfo.BT_STACK_STATE_STATE_IDLE) { // Energy is product of mA, V and ms. If the chipset doesn't // report it, we have to compute it from time if (energy_used == 0) { if (energyUsed == 0) { try { final long txMah = Math.multiplyExact(tx_time, getTxCurrentMa()); final long rxMah = Math.multiplyExact(rx_time, getRxCurrentMa()); final long idleMah = Math.multiplyExact(idle_time, getIdleCurrentMa()); energy_used = (long) (Math.addExact(Math.addExact(txMah, rxMah), idleMah) final long txMah = Math.multiplyExact(txTime, getTxCurrentMa()); final long rxMah = Math.multiplyExact(rxTime, getRxCurrentMa()); final long idleMah = Math.multiplyExact(idleTime, getIdleCurrentMa()); energyUsed = (long) (Math.addExact(Math.addExact(txMah, rxMah), idleMah) * getOperatingVolt()); } catch (ArithmeticException e) { Slog.wtf(TAG, "overflow in bluetooth energy callback", e); Loading @@ -2187,16 +2187,16 @@ public class AdapterService extends Service { } synchronized (mEnergyInfoLock) { mStackReportedState = ctrl_state; mStackReportedState = ctrlState; long totalTxTimeMs; long totalRxTimeMs; long totalIdleTimeMs; long totalEnergy; try { totalTxTimeMs = Math.addExact(mTxTimeTotalMs, tx_time); totalRxTimeMs = Math.addExact(mRxTimeTotalMs, rx_time); totalIdleTimeMs = Math.addExact(mIdleTimeTotalMs, idle_time); totalEnergy = Math.addExact(mEnergyUsedTotalVoltAmpSecMicro, energy_used); totalTxTimeMs = Math.addExact(mTxTimeTotalMs, txTime); totalRxTimeMs = Math.addExact(mRxTimeTotalMs, rxTime); totalIdleTimeMs = Math.addExact(mIdleTimeTotalMs, idleTime); totalEnergy = Math.addExact(mEnergyUsedTotalVoltAmpSecMicro, energyUsed); } catch (ArithmeticException e) { // This could be because we accumulated a lot of time, or we got a very strange // value from the controller (more likely). Discard this data. Loading Loading @@ -2225,9 +2225,9 @@ public class AdapterService extends Service { } } verboseLog("energyInfoCallback() status = " + status + "tx_time = " + tx_time + "rx_time = " + rx_time + "idle_time = " + idle_time + "energy_used = " + energy_used + "ctrl_state = " + ctrl_state + "traffic = " + Arrays.toString(data)); verboseLog("energyInfoCallback() status = " + status + "txTime = " + txTime + "rxTime = " + rxTime + "idleTime = " + idleTime + "energyUsed = " + energyUsed + "ctrlState = " + ctrlState + "traffic = " + Arrays.toString(data)); } private int getIdleCurrentMa() { Loading
android/app/src/com/android/bluetooth/gatt/AdvertiseManager.java +55 −55 Original line number Diff line number Diff line Loading @@ -123,10 +123,10 @@ class AdvertiseManager { } } Map.Entry<IBinder, AdvertiserInfo> findAdvertiser(int advertiser_id) { Map.Entry<IBinder, AdvertiserInfo> findAdvertiser(int advertiserId) { Map.Entry<IBinder, AdvertiserInfo> entry = null; for (Map.Entry<IBinder, AdvertiserInfo> e : mAdvertisers.entrySet()) { if (e.getValue().id == advertiser_id) { if (e.getValue().id == advertiserId) { entry = e; break; } Loading @@ -134,50 +134,50 @@ class AdvertiseManager { return entry; } void onAdvertisingSetStarted(int reg_id, int advertiser_id, int tx_power, int status) void onAdvertisingSetStarted(int regId, int advertiserId, int txPower, int status) throws Exception { if (DBG) { Log.d(TAG, "onAdvertisingSetStarted() - reg_id=" + reg_id + ", advertiser_id=" + advertiser_id + ", status=" + status); Log.d(TAG, "onAdvertisingSetStarted() - regId=" + regId + ", advertiserId=" + advertiserId + ", status=" + status); } Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(reg_id); Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(regId); if (entry == null) { Log.i(TAG, "onAdvertisingSetStarted() - no callback found for reg_id " + reg_id); Log.i(TAG, "onAdvertisingSetStarted() - no callback found for regId " + regId); // Advertising set was stopped before it was properly registered. stopAdvertisingSetNative(advertiser_id); stopAdvertisingSetNative(advertiserId); return; } IAdvertisingSetCallback callback = entry.getValue().callback; if (status == 0) { entry.setValue( new AdvertiserInfo(advertiser_id, entry.getValue().deathRecipient, callback)); new AdvertiserInfo(advertiserId, entry.getValue().deathRecipient, callback)); } else { IBinder binder = entry.getKey(); binder.unlinkToDeath(entry.getValue().deathRecipient, 0); mAdvertisers.remove(binder); } callback.onAdvertisingSetStarted(advertiser_id, tx_power, status); callback.onAdvertisingSetStarted(advertiserId, txPower, status); } void onAdvertisingEnabled(int advertiser_id, boolean enable, int status) throws Exception { void onAdvertisingEnabled(int advertiserId, boolean enable, int status) throws Exception { if (DBG) { Log.d(TAG, "onAdvertisingSetEnabled() - advertiser_id=" + advertiser_id + ", enable=" Log.d(TAG, "onAdvertisingSetEnabled() - advertiserId=" + advertiserId + ", enable=" + enable + ", status=" + status); } Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id); Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiserId); if (entry == null) { Log.i(TAG, "onAdvertisingSetEnable() - no callback found for advertiser_id " + advertiser_id); Log.i(TAG, "onAdvertisingSetEnable() - no callback found for advertiserId " + advertiserId); return; } IAdvertisingSetCallback callback = entry.getValue().callback; callback.onAdvertisingEnabled(advertiser_id, enable, status); callback.onAdvertisingEnabled(advertiserId, enable, status); } void startAdvertisingSet(AdvertisingSetParameters parameters, AdvertiseData advertiseData, Loading Loading @@ -205,18 +205,18 @@ class AdvertiseManager { periodic_data, duration, maxExtAdvEvents, cb_id); } void onOwnAddressRead(int advertiser_id, int addressType, String address) void onOwnAddressRead(int advertiserId, int addressType, String address) throws RemoteException { if (DBG) Log.d(TAG, "onOwnAddressRead() advertiser_id=" + advertiser_id); if (DBG) Log.d(TAG, "onOwnAddressRead() advertiserId=" + advertiserId); Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id); Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiserId); if (entry == null) { Log.i(TAG, "onOwnAddressRead() - bad advertiser_id " + advertiser_id); Log.i(TAG, "onOwnAddressRead() - bad advertiserId " + advertiserId); return; } IAdvertisingSetCallback callback = entry.getValue().callback; callback.onOwnAddressRead(advertiser_id, addressType, address); callback.onOwnAddressRead(advertiserId, addressType, address); } void getOwnAddress(int advertiserId) { Loading Loading @@ -286,102 +286,102 @@ class AdvertiseManager { setPeriodicAdvertisingEnableNative(advertiserId, enable); } void onAdvertisingDataSet(int advertiser_id, int status) throws Exception { void onAdvertisingDataSet(int advertiserId, int status) throws Exception { if (DBG) { Log.d(TAG, "onAdvertisingDataSet() advertiser_id=" + advertiser_id + ", status=" + status); "onAdvertisingDataSet() advertiserId=" + advertiserId + ", status=" + status); } Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id); Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiserId); if (entry == null) { Log.i(TAG, "onAdvertisingDataSet() - bad advertiser_id " + advertiser_id); Log.i(TAG, "onAdvertisingDataSet() - bad advertiserId " + advertiserId); return; } IAdvertisingSetCallback callback = entry.getValue().callback; callback.onAdvertisingDataSet(advertiser_id, status); callback.onAdvertisingDataSet(advertiserId, status); } void onScanResponseDataSet(int advertiser_id, int status) throws Exception { void onScanResponseDataSet(int advertiserId, int status) throws Exception { if (DBG) Log.d(TAG, "onScanResponseDataSet() advertiser_id=" + advertiser_id + ", status=" Log.d(TAG, "onScanResponseDataSet() advertiserId=" + advertiserId + ", status=" + status); Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id); Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiserId); if (entry == null) { Log.i(TAG, "onScanResponseDataSet() - bad advertiser_id " + advertiser_id); Log.i(TAG, "onScanResponseDataSet() - bad advertiserId " + advertiserId); return; } IAdvertisingSetCallback callback = entry.getValue().callback; callback.onScanResponseDataSet(advertiser_id, status); callback.onScanResponseDataSet(advertiserId, status); } void onAdvertisingParametersUpdated(int advertiser_id, int tx_power, int status) void onAdvertisingParametersUpdated(int advertiserId, int txPower, int status) throws Exception { if (DBG) { Log.d(TAG, "onAdvertisingParametersUpdated() advertiser_id=" + advertiser_id + ", tx_power=" + tx_power + ", status=" + status); Log.d(TAG, "onAdvertisingParametersUpdated() advertiserId=" + advertiserId + ", txPower=" + txPower + ", status=" + status); } Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id); Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiserId); if (entry == null) { Log.i(TAG, "onAdvertisingParametersUpdated() - bad advertiser_id " + advertiser_id); Log.i(TAG, "onAdvertisingParametersUpdated() - bad advertiserId " + advertiserId); return; } IAdvertisingSetCallback callback = entry.getValue().callback; callback.onAdvertisingParametersUpdated(advertiser_id, tx_power, status); callback.onAdvertisingParametersUpdated(advertiserId, txPower, status); } void onPeriodicAdvertisingParametersUpdated(int advertiser_id, int status) throws Exception { void onPeriodicAdvertisingParametersUpdated(int advertiserId, int status) throws Exception { if (DBG) { Log.d(TAG, "onPeriodicAdvertisingParametersUpdated() advertiser_id=" + advertiser_id Log.d(TAG, "onPeriodicAdvertisingParametersUpdated() advertiserId=" + advertiserId + ", status=" + status); } Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id); Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiserId); if (entry == null) { Log.i(TAG, "onPeriodicAdvertisingParametersUpdated() - bad advertiser_id " + advertiser_id); Log.i(TAG, "onPeriodicAdvertisingParametersUpdated() - bad advertiserId " + advertiserId); return; } IAdvertisingSetCallback callback = entry.getValue().callback; callback.onPeriodicAdvertisingParametersUpdated(advertiser_id, status); callback.onPeriodicAdvertisingParametersUpdated(advertiserId, status); } void onPeriodicAdvertisingDataSet(int advertiser_id, int status) throws Exception { void onPeriodicAdvertisingDataSet(int advertiserId, int status) throws Exception { if (DBG) { Log.d(TAG, "onPeriodicAdvertisingDataSet() advertiser_id=" + advertiser_id + ", status=" Log.d(TAG, "onPeriodicAdvertisingDataSet() advertiserId=" + advertiserId + ", status=" + status); } Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id); Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiserId); if (entry == null) { Log.i(TAG, "onPeriodicAdvertisingDataSet() - bad advertiser_id " + advertiser_id); Log.i(TAG, "onPeriodicAdvertisingDataSet() - bad advertiserId " + advertiserId); return; } IAdvertisingSetCallback callback = entry.getValue().callback; callback.onPeriodicAdvertisingDataSet(advertiser_id, status); callback.onPeriodicAdvertisingDataSet(advertiserId, status); } void onPeriodicAdvertisingEnabled(int advertiser_id, boolean enable, int status) void onPeriodicAdvertisingEnabled(int advertiserId, boolean enable, int status) throws Exception { if (DBG) { Log.d(TAG, "onPeriodicAdvertisingEnabled() advertiser_id=" + advertiser_id + ", status=" Log.d(TAG, "onPeriodicAdvertisingEnabled() advertiserId=" + advertiserId + ", status=" + status); } Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id); Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiserId); if (entry == null) { Log.i(TAG, "onAdvertisingSetEnable() - bad advertiser_id " + advertiser_id); Log.i(TAG, "onAdvertisingSetEnable() - bad advertiserId " + advertiserId); return; } IAdvertisingSetCallback callback = entry.getValue().callback; callback.onPeriodicAdvertisingEnabled(advertiser_id, enable, status); callback.onPeriodicAdvertisingEnabled(advertiserId, enable, status); } static { Loading @@ -394,9 +394,9 @@ class AdvertiseManager { private native void startAdvertisingSetNative(AdvertisingSetParameters parameters, byte[] advertiseData, byte[] scanResponse, PeriodicAdvertisingParameters periodicParameters, byte[] periodicData, int duration, int maxExtAdvEvents, int reg_id); int maxExtAdvEvents, int regId); private native void getOwnAddressNative(int advertiserId); private native void stopAdvertisingSetNative(int advertiser_id); private native void stopAdvertisingSetNative(int advertiserId); private native void enableAdvertisingSetNative( int advertiserId, boolean enable, int duration, int maxExtAdvEvents); private native void setAdvertisingDataNative(int advertiserId, byte[] data); Loading