Commit cc74868a authored by Julian Descottes's avatar Julian Descottes
Browse files

Bug 1493104 - Listen to ADB extension updates in about:debugging usb-runtime...

Bug 1493104 - Listen to ADB extension updates in about:debugging usb-runtime helper;r=ladybenko,daisuke

Depends on D7872. This fixes the bug where about:debugging thinks the addon
is uninstalled the first time it starts.

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

--HG--
extra : moz-landing-system : lando
parent 60524744
......@@ -11,6 +11,18 @@ loader.lazyGetter(this, "adbScanner", () => {
return new ADBScanner();
});
function _onAdbAddonUpdate() {
// We are only listening to adbAddon updates if usb-runtimes are enabled.
if (adbAddon.status === ADB_ADDON_STATES.INSTALLED) {
// If the status switched to installed, the scanner should be enabled.
adbScanner.enable();
} else {
// Otherwise disable the scanner. disable() can be called several times without side
// effect.
adbScanner.disable();
}
}
/**
* This module provides a collection of helper methods to detect USB runtimes whom Firefox
* is running on.
......@@ -21,17 +33,18 @@ function addUSBRuntimesObserver(listener) {
exports.addUSBRuntimesObserver = addUSBRuntimesObserver;
function disableUSBRuntimes() {
adbScanner.disable();
if (adbAddon.status === ADB_ADDON_STATES.INSTALLED) {
adbScanner.disable();
}
adbAddon.off("update", _onAdbAddonUpdate);
}
exports.disableUSBRuntimes = disableUSBRuntimes;
async function enableUSBRuntimes() {
if (adbAddon.status !== ADB_ADDON_STATES.INSTALLED) {
console.error("ADB extension is not installed");
return;
if (adbAddon.status === ADB_ADDON_STATES.INSTALLED) {
adbScanner.enable();
}
adbScanner.enable();
adbAddon.on("update", _onAdbAddonUpdate);
}
exports.enableUSBRuntimes = enableUSBRuntimes;
......
......@@ -37,9 +37,9 @@ function BuildUI() {
progress.removeAttribute("value");
li.setAttribute("status", adbAddon.status);
status.textContent = Strings.GetStringFromName("addons_status_" + adbAddon.status);
if (adbAddon.status == ADB_ADDON_STATES.INSTALLED) {
if (adbAddon.status === ADB_ADDON_STATES.INSTALLED) {
RuntimeScanners.add(adbScanner);
} else if (adbAddon.status == ADB_ADDON_STATES.UNINSTALLED) {
} else if (adbAddon.status === ADB_ADDON_STATES.UNINSTALLED) {
RuntimeScanners.remove(adbScanner);
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment