diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /devtools/client/shared/remote-debugging/adb/adb-device.js | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/shared/remote-debugging/adb/adb-device.js')
-rw-r--r-- | devtools/client/shared/remote-debugging/adb/adb-device.js | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/devtools/client/shared/remote-debugging/adb/adb-device.js b/devtools/client/shared/remote-debugging/adb/adb-device.js new file mode 100644 index 0000000000..def22f27c3 --- /dev/null +++ b/devtools/client/shared/remote-debugging/adb/adb-device.js @@ -0,0 +1,53 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +const { + shell, +} = require("resource://devtools/client/shared/remote-debugging/adb/commands/index.js"); + +/** + * A Device instance is created and registered with the Devices module whenever + * ADB notices a new device is connected. + */ +class AdbDevice { + constructor(id) { + this.id = id; + } + + async initialize() { + const model = await shell(this.id, "getprop ro.product.model"); + this.model = model.trim(); + } + + get name() { + return this.model || this.id; + } + + async getRuntimeSocketPaths() { + // A matching entry looks like: + // 00000000: 00000002 00000000 00010000 0001 01 6551588 + // /data/data/org.mozilla.fennec/firefox-debugger-socket + const query = "cat /proc/net/unix"; + const rawSocketInfo = await shell(this.id, query); + + // Filter to lines with "firefox-debugger-socket" + let socketInfos = rawSocketInfo.split(/\r?\n/); + socketInfos = socketInfos.filter(l => + l.includes("firefox-debugger-socket") + ); + + // It's possible to have multiple lines with the same path, so de-dupe them + const socketPaths = new Set(); + for (const socketInfo of socketInfos) { + const socketPath = socketInfo.split(" ").pop(); + socketPaths.add(socketPath); + } + + return socketPaths; + } +} + +module.exports = AdbDevice; |