diff options
| author | 2011-03-21 12:07:04 -0700 | |
|---|---|---|
| committer | 2011-03-21 14:17:19 -0700 | |
| commit | fe90059c8a8011225730c036715ba3d675866738 (patch) | |
| tree | 5426e0642da0cc0a5ed3eed1c1b16720d65bbcba | |
| parent | f916a5537c53b19f0b54a179c3b0954919ae322a (diff) | |
Use mask_eighth_bit function to replace is_ascii check.
According to ITU V.250 section 5.1, IA5 7 bit chars are used, the eighth bit or higher bits are ignored if they exists.
bug: 3379257
Change-Id: Id46bda10702f4defa148b34b7538bd5b38ffc7fc
| -rw-r--r-- | core/jni/android_bluetooth_HeadsetBase.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/core/jni/android_bluetooth_HeadsetBase.cpp b/core/jni/android_bluetooth_HeadsetBase.cpp index bbf1ae5f8e41..5b21c56d431e 100644 --- a/core/jni/android_bluetooth_HeadsetBase.cpp +++ b/core/jni/android_bluetooth_HeadsetBase.cpp @@ -96,11 +96,12 @@ static int send_line(int fd, const char* line) { return 0; } -static int is_ascii(char *line) { - for (;;line++) { - if (*line == 0) return 1; - if (*line >> 7) return 0; - } +static void mask_eighth_bit(char *line) +{ + for (;;line++) { + if (0 == *line) return; + *line &= 0x7F; + } } static const char* get_line(int fd, char *buf, int len, int timeout_ms, @@ -164,16 +165,15 @@ again: *bufit = NULL; - // Simple validation. Must be all ASCII. - // (we sometimes send non-ASCII UTF-8 in address book, but should - // never receive non-ASCII UTF-8). - // This was added because of the BMW 2005 E46 which sends binary junk. - if (is_ascii(buf)) { - IF_LOGV() LOG(LOG_VERBOSE, "Bluetooth AT recv", "%s", buf); - } else { - LOGW("Ignoring invalid AT command: %s", buf); - buf[0] = NULL; - } + // According to ITU V.250 section 5.1, IA5 7 bit chars are used, + // the eighth bit or higher bits are ignored if they exists + // We mask out only eighth bit, no higher bit, since we do char + // string here, not wide char. + // We added this processing due to 2 real world problems. + // 1 BMW 2005 E46 which sends binary junk + // 2 Audi 2010 A3, dial command use 0xAD (soft-hyphen) as number + // formater, which was rejected by the AT handler + mask_eighth_bit(buf); return buf; } |