Bug 1492724 - Add ADBScanner once after the extension is installed or is ready. r=jdescottes

And remove the ADBScanner once the extension is uninstalled.

When RuntimeScanners.add is called for ADBScanner, RuntimeScanner calls
ADBScanner.enable(), thus ADB.start() is called.  Meanwhile WebIDE installs the
devtools adb extension if the extension hasn't installed yet.  So if the
ADB.start() is called before the installation finishes, ADB.start() fails.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Hiroyuki Ikezoe 2018-09-21 08:17:15 +00:00
Родитель cffaacada5
Коммит 7ea3b5e685
2 изменённых файлов: 7 добавлений и 3 удалений

Просмотреть файл

@ -7,6 +7,8 @@ const Services = require("Services");
const {gDevTools} = require("devtools/client/framework/devtools");
const {GetAvailableAddons, ForgetAddonsList} = require("devtools/client/webide/modules/addons");
const Strings = Services.strings.createBundle("chrome://devtools/locale/webide.properties");
const {ADBScanner} = require("devtools/shared/adb/adb-scanner");
const {RuntimeScanners} = require("devtools/client/webide/modules/runtimes");
window.addEventListener("load", function() {
document.querySelector("#aboutaddons").onclick = function() {
@ -36,6 +38,11 @@ function BuildItem(addon, type) {
progress.removeAttribute("value");
li.setAttribute("status", addon.status);
status.textContent = Strings.GetStringFromName("addons_status_" + addon.status);
if (addon.status == "installed") {
RuntimeScanners.add(ADBScanner);
} else if (addon.status == "uninstalled") {
RuntimeScanners.remove(ADBScanner);
}
}
function onAddonFailure(arg) {

Просмотреть файл

@ -8,7 +8,6 @@ const Services = require("Services");
const {DebuggerServer} = require("devtools/server/main");
const discovery = require("devtools/shared/discovery/discovery");
const EventEmitter = require("devtools/shared/event-emitter");
const {ADBScanner} = require("devtools/shared/adb/adb-scanner");
const {RuntimeTypes} = require("devtools/client/webide/modules/runtime-types");
const promise = require("promise");
loader.lazyRequireGetter(this, "AuthenticationResult",
@ -193,8 +192,6 @@ exports.RuntimeScanners = RuntimeScanners;
/* SCANNERS */
RuntimeScanners.add(ADBScanner);
var WiFiScanner = {
_runtimes: [],