fune/devtools/shared/adb/adb-device.js
Victor Porof b8157dfaaf Bug 1561435 - Format remaining devtools/, a=automatic-formatting, CLOSED TREE
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D35894

--HG--
extra : source : 4722b924e08478f5337ab509718bd66906bf472f
extra : amend_source : a5baa1aab21639fdba44537e3a10b179b0073cb4
2019-07-05 11:29:32 +02:00

51 lines
1.4 KiB
JavaScript

/* 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("devtools/shared/adb/commands/index");
/**
* 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;