mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 874484 - Disable ADB after a timeout. r=fabrice
This patch causes ADB to be disabled after 12 hours. The timeout is only used when marionette is disabled, which implies production builds. Engineering builds (VARIANT=eng or VARIANT=userdebug) will continue to have ADB enabled indefinitely.
This commit is contained in:
parent
398da3c43b
commit
4865334a10
@ -746,3 +746,7 @@ pref("disk_space_watcher.enabled", true);
|
||||
// Enable promise
|
||||
pref("dom.promise.enabled", false);
|
||||
|
||||
// Allow ADB to run for this many hours before disabling
|
||||
// (only applies when marionette is disabled)
|
||||
// 0 disables the timer.
|
||||
pref("b2g.adb.timeout-hours", 12);
|
||||
|
@ -206,6 +206,8 @@ let AdbController = {
|
||||
locked: undefined,
|
||||
remoteDebuggerEnabled: undefined,
|
||||
lockEnabled: undefined,
|
||||
disableAdbTimer: null,
|
||||
disableAdbTimeoutHours: 12,
|
||||
|
||||
debug: function(str) {
|
||||
dump("AdbController: " + str + "\n");
|
||||
@ -235,6 +237,57 @@ let AdbController = {
|
||||
this.updateState();
|
||||
},
|
||||
|
||||
startDisableAdbTimer: function() {
|
||||
if (this.disableAdbTimer) {
|
||||
this.disableAdbTimer.cancel();
|
||||
} else {
|
||||
this.disableAdbTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
|
||||
try {
|
||||
this.disableAdbTimeoutHours =
|
||||
Services.prefs.getIntPref("b2g.adb.timeout-hours");
|
||||
} catch (e) {
|
||||
// This happens if the pref doesn't exist, in which case
|
||||
// disableAdbTimeoutHours will still be set to the default.
|
||||
}
|
||||
}
|
||||
if (this.disableAdbTimeoutHours <= 0) {
|
||||
if (this.DEBUG) {
|
||||
this.debug("Timer to disable ADB not started due to zero timeout");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.DEBUG) {
|
||||
this.debug("Starting timer to disable ADB in " +
|
||||
this.disableAdbTimeoutHours + " hours");
|
||||
}
|
||||
let timeoutMilliseconds = this.disableAdbTimeoutHours * 60 * 60 * 1000;
|
||||
this.disableAdbTimer.initWithCallback(this, timeoutMilliseconds,
|
||||
Ci.nsITimer.TYPE_ONE_SHOT);
|
||||
},
|
||||
|
||||
stopDisableAdbTimer: function() {
|
||||
if (this.DEBUG) {
|
||||
this.debug("Stopping timer to disable ADB");
|
||||
}
|
||||
if (this.disableAdbTimer) {
|
||||
this.disableAdbTimer.cancel();
|
||||
this.disableAdbTimer = null;
|
||||
}
|
||||
},
|
||||
|
||||
notify: function(aTimer) {
|
||||
if (aTimer == this.disableAdbTimer) {
|
||||
this.disableAdbTimer = null;
|
||||
// The following dump will be the last thing that shows up in logcat,
|
||||
// and will at least give the user a clue about why logcat was
|
||||
// disconnected, if the user happens to be using logcat.
|
||||
dump("AdbController: ADB timer expired - disabling ADB\n");
|
||||
navigator.mozSettings.createLock().set(
|
||||
{'devtools.debugger.remote-enabled': false});
|
||||
}
|
||||
},
|
||||
|
||||
updateState: function() {
|
||||
if (this.remoteDebuggerEnabled === undefined ||
|
||||
this.lockEnabled === undefined ||
|
||||
@ -263,6 +316,7 @@ let AdbController = {
|
||||
}
|
||||
let enableAdb = this.remoteDebuggerEnabled &&
|
||||
!(this.lockEnabled && this.locked);
|
||||
let useDisableAdbTimer = true;
|
||||
try {
|
||||
if (Services.prefs.getBoolPref("marionette.defaultPrefs.enabled")) {
|
||||
// Marionette is enabled. Marionette requires that adb be on (and also
|
||||
@ -270,6 +324,7 @@ let AdbController = {
|
||||
// is enabled also implies that we're doing a non-production build, so
|
||||
// we want adb enabled all of the time.
|
||||
enableAdb = true;
|
||||
useDisableAdbTimer = false;
|
||||
}
|
||||
} catch (e) {
|
||||
// This means that the pref doesn't exist. Which is fine. We just leave
|
||||
@ -310,6 +365,13 @@ let AdbController = {
|
||||
dump("Error configuring adb: " + e);
|
||||
}
|
||||
}
|
||||
if (useDisableAdbTimer) {
|
||||
if (enableAdb) {
|
||||
this.startDisableAdbTimer();
|
||||
} else {
|
||||
this.stopDisableAdbTimer();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user