Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(366)

Unified Diff: chrome/test/chromedriver/chrome/adb_impl.cc

Issue 2375613002: Fix Chromedriver Issue 749
Patch Set: Fix for chromedriver issue 749 Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/chromedriver/chrome/adb_impl.cc
diff --git a/chrome/test/chromedriver/chrome/adb_impl.cc b/chrome/test/chromedriver/chrome/adb_impl.cc
index a60d8bce5dfaf31e0242ac49126df9da868effa1..512027464cbb7ce8bf440c27c36156f158a24f7e 100644
--- a/chrome/test/chromedriver/chrome/adb_impl.cc
+++ b/chrome/test/chromedriver/chrome/adb_impl.cc
@@ -226,6 +226,50 @@ Status AdbImpl::GetPidByName(const std::string& device_serial,
"Failed to get PID for the following process: " + process_name);
}
+Status AdbImpl::GetDevtoolsRemoteSocket(const std::string& device_serial,
+ const std::string& process_name,
+ std::string* device_socket) {
+ // Parse 'cat /proc/net/unix' output which on Android looks like this:
+ //
+ // Num RefCount Protocol Flags Type St Inode Path
+ // 00000000: 00000002 00000000 00010000 0001 01 331813 /dev/socket/zygote
+ // 00000000: 00000002 00000000 00010000 0001 01 358606 @xxx_devtools_remote
+ // 00000000: 00000002 00000000 00010000 0001 01 347300 @yyy_devtools_remote
+ //
+ // We need to find records with paths starting from '@' (abstract socket)
+ // and containing the channel pattern ("_devtools_remote").
+
+ std::string response;
+ Status status = ExecuteHostShellCommand(device_serial, "cat /proc/net/unix", &response);
samuong 2016/10/03 18:50:40 this line is too long (>80 chars)
Rahul Kavalapara 2016/10/05 08:06:42 Done.
+ if (!status.IsOk())
+ return status;
+ for (const base::StringPiece& line :
+ base::SplitStringPiece(response, "\n", base::KEEP_WHITESPACE,
+ base::SPLIT_WANT_NONEMPTY)) {
+ std::vector<std::string> fields =
+ base::SplitString(line, " \r", base::KEEP_WHITESPACE,
+ base::SPLIT_WANT_NONEMPTY);
+ if (fields.size() < 8)
+ continue;
+ if (fields[3] != "00010000" || fields[5] != "01")
samuong 2016/10/03 18:50:40 it's not really clear to me what these magic numbe
Rahul Kavalapara 2016/10/03 22:15:52 Please check MapSocketsToProcesses function. https
Rahul Kavalapara 2016/10/04 01:18:04 I did some more digging, Similar question was post
samuong 2016/10/05 17:29:49 Thanks for digging that up. I was mostly curious a
Rahul Kavalapara 2016/10/05 18:41:53 This code is essentially exercised targeting andro
samuong 2016/10/12 05:18:35 OK, that makes sense. However I'd still like to ma
Rahul Kavalapara 2016/10/12 08:23:04 Fixed.
+ continue;
+ std::string path_field = fields[7];
+ if (path_field.size() < 1 || path_field[0] != '@')
+ continue;
+ if (path_field.find(process_name) == std::string::npos)
samuong 2016/10/03 18:50:40 what if there are two processes, where one of the
Rahul Kavalapara 2016/10/03 22:15:52 This is the adaptation from devtools code. That wo
samuong 2016/10/05 17:29:49 I think we should know the full socket name that w
Rahul Kavalapara 2016/10/05 18:41:53 I am sending back the entire name when trying to c
+ continue;
+
+ *device_socket = path_field.substr(1);
+ }
+
+ // We could not find a device socket for the expected process name
+ if (device_socket->empty()) {
+ return Status(kUnknownError,
+ "Failed to find the remote devtools socket for the following process: " + process_name);
samuong 2016/10/03 18:50:40 this line is too long (>80 chars)
Rahul Kavalapara 2016/10/05 08:06:42 Done.
+ }
+ return Status(kOk);
+}
+
Status AdbImpl::ExecuteCommand(
const std::string& command, std::string* response) {
scoped_refptr<ResponseBuffer> response_buffer = new ResponseBuffer;

Powered by Google App Engine
This is Rietveld 408576698