|
27 | 27 | #include "hcimsgs.h" |
28 | 28 | #include "osi/include/log.h" |
29 | 29 |
|
| 30 | +#include <cutils/properties.h> |
| 31 | + |
30 | 32 | static const command_opcode_t NO_OPCODE_CHECKING = 0; |
31 | 33 |
|
32 | 34 | static const allocator_t* buffer_allocator; |
@@ -123,6 +125,33 @@ static void parse_read_local_extended_features_response( |
123 | 125 | STREAM_TO_ARRAY(feature_pages[*page_number_ptr].as_array, stream, |
124 | 126 | (int)sizeof(bt_device_features_t)); |
125 | 127 |
|
| 128 | + int ijk; |
| 129 | + for (ijk = 0; ijk < ((int)sizeof(bt_device_features_t)); ijk++) LOG_DEBUG(LOG_TAG, "supported feature 0x%x is 0x%x", ijk, feature_pages[*page_number_ptr].as_array[ijk]); |
| 130 | + |
| 131 | + char unsupport_bitmask_str[PROPERTY_VALUE_MAX]; |
| 132 | + property_get("persist.sys.bt.unsupport.features", unsupport_bitmask_str, "0"); |
| 133 | + |
| 134 | + unsigned int len = strlen(unsupport_bitmask_str); |
| 135 | + uint8_t unsupport_bitmask[8] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; |
| 136 | + unsigned int c; |
| 137 | + |
| 138 | + for (c = 0; c < len; c++) { |
| 139 | + if (unsupport_bitmask_str[c] == '1') { |
| 140 | + unsupport_bitmask[c/8] = ~ ( (1 << c%8) | ~ unsupport_bitmask[c/8] ); // The logic here is hard to represent in C(++), basically we do a bitwise AND for the bit we are on now. But C(++) pads with 0s so we end up 0ing too much. |
| 141 | + } else if (unsupport_bitmask_str[c] != '0') { |
| 142 | + LOG_ERROR(LOG_TAG, "invalid characters in bitmask; skipping %c", unsupport_bitmask_str[c]); |
| 143 | + goto out; |
| 144 | + } |
| 145 | + } |
| 146 | + |
| 147 | + |
| 148 | + for (c = 0; c < ((int)sizeof(bt_device_features_t)); c++) |
| 149 | + feature_pages[*page_number_ptr].as_array[c] &= unsupport_bitmask[c]; |
| 150 | + LOG_DEBUG(LOG_TAG, "generated bitmask 0x%x%x%x%x%x%x%x%x from prop persist.sys.bt.unsupport.features", unsupport_bitmask[0], unsupport_bitmask[1], unsupport_bitmask[2], unsupport_bitmask[3], unsupport_bitmask[4], unsupport_bitmask[5], unsupport_bitmask[6], unsupport_bitmask[7]); |
| 151 | +out: |
| 152 | + for (ijk = 0; ijk < ((int)sizeof(bt_device_features_t)); ijk++) LOG_ERROR(LOG_TAG, "supported feature 0x%x is 0x%x", ijk, feature_pages[*page_number_ptr].as_array[ijk]); |
| 153 | + LOG_DEBUG(LOG_TAG, "supported_features array done"); |
| 154 | + |
126 | 155 | buffer_allocator->free(response); |
127 | 156 | } |
128 | 157 |
|
@@ -156,6 +185,32 @@ static void parse_ble_read_supported_states_response( |
156 | 185 | CHECK(stream != NULL); |
157 | 186 | STREAM_TO_ARRAY(supported_states, stream, (int)supported_states_size); |
158 | 187 |
|
| 188 | + int ijk; |
| 189 | + for (ijk = 0; ijk < ((int)supported_states_size); ijk++) LOG_DEBUG(LOG_TAG, "supported state 0x%x is 0x%x", ijk, supported_states[ijk]); |
| 190 | + |
| 191 | + char unsupport_bitmask_str[PROPERTY_VALUE_MAX]; |
| 192 | + property_get("persist.sys.bt.unsupport.states", unsupport_bitmask_str, "0"); |
| 193 | + |
| 194 | + unsigned int len = strlen(unsupport_bitmask_str); |
| 195 | + uint8_t unsupport_bitmask[8] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; |
| 196 | + unsigned int c; |
| 197 | + |
| 198 | + for (c = 0; c < len; c++) { |
| 199 | + if (unsupport_bitmask_str[c] == '1') { |
| 200 | + unsupport_bitmask[c/8] = ~ ( (1 << c%8) | ~ unsupport_bitmask[c/8] ); // The logic here is hard to represent in C(++), basically we do a bitwise AND for the bit we are on now. But C(++) pads with 0s so we end up 0ing too much. |
| 201 | + } else if (unsupport_bitmask_str[c] != '0') { |
| 202 | + LOG_ERROR(LOG_TAG, "invalid characters in bitmask; skipping %c", unsupport_bitmask_str[c]); |
| 203 | + goto out; |
| 204 | + } |
| 205 | + } |
| 206 | + |
| 207 | + |
| 208 | + for (c = 0; c < supported_states_size; c++) |
| 209 | + supported_states[c] &= unsupport_bitmask[c]; |
| 210 | + LOG_DEBUG(LOG_TAG, "generated bitmask 0x%x%x%x%x%x%x%x%x from prop persist.sys.bt.unsupport.states", unsupport_bitmask[0], unsupport_bitmask[1], unsupport_bitmask[2], unsupport_bitmask[3], unsupport_bitmask[4], unsupport_bitmask[5], unsupport_bitmask[6], unsupport_bitmask[7]); |
| 211 | +out: |
| 212 | + for (ijk = 0; ijk < ((int)supported_states_size); ijk++) LOG_ERROR(LOG_TAG, "supported state 0x%x is 0x%x", ijk, supported_states[ijk]); |
| 213 | + LOG_DEBUG(LOG_TAG, "supported_states array done"); |
159 | 214 | buffer_allocator->free(response); |
160 | 215 | } |
161 | 216 |
|
|
0 commit comments