androiddump: Add support for Bluetooth on Android 7.0

Now "ps" command does not support process name as parameter,
use grep instead.

Change-Id: I0c35bc7d560e237e4140000e67af097744cb2c1b
Reviewed-on: https://code.wireshark.org/review/19087
Petri-Dish: Michal Labedzki <michal.labedzki@tieto.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
This commit is contained in:
Michal Labedzki 2016-11-03 10:46:25 +01:00 committed by Alexis La Goutte
parent e0a4f0c79b
commit a7d404a972
1 changed files with 9 additions and 2 deletions

View File

@ -696,6 +696,7 @@ static int register_interfaces(extcap_parameters * extcap_conf, const char *adb_
const char *adb_hcidump_version = "0017""shell:hcidump --version";
const char *adb_ps_droid_bluetooth = "0018""shell:ps droid.bluetooth";
const char *adb_ps_bluetooth_app = "001E""shell:ps com.android.bluetooth";
const char *adb_ps_with_grep = "0025""shell:ps | grep com.android.bluetooth";
const char *adb_tcpdump_help = "0010""shell:tcpdump -h";
char serial_number[SERIAL_NUMBER_LENGTH_MAX];
size_t serial_number_length;
@ -982,7 +983,9 @@ static int register_interfaces(extcap_parameters * extcap_conf, const char *adb_
return EXIT_CODE_GENERIC;
}
if (api_level >= 23) {
if (api_level >= 24) {
response = adb_send_and_read(sock, adb_ps_with_grep, helpful_packet, sizeof(helpful_packet), &data_length);
} else if (api_level >= 23) {
response = adb_send_and_read(sock, adb_ps_bluetooth_app, helpful_packet, sizeof(helpful_packet), &data_length);
} else
response = adb_send_and_read(sock, adb_ps_droid_bluetooth, helpful_packet, sizeof(helpful_packet), &data_length);
@ -999,7 +1002,11 @@ static int register_interfaces(extcap_parameters * extcap_conf, const char *adb_
memset(pid, 0, sizeof(pid));
response[data_length] = '\0';
data_str = strchr(response, '\n');
if (api_level >= 24)
data_str = response;
else
data_str = strchr(response, '\n');
if (data_str && sscanf(data_str, "%*s %s", pid) == 1) {
g_debug("Android Bluetooth application PID for %s is %s", serial_number, pid);