From a1fd669571bc72aebfb9f1099f4469a4940cd1a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabrice=20Desr=C3=A9?= Date: Sat, 7 Sep 2013 16:28:51 -0700 Subject: [PATCH] Bug 912898 - B2G: Don't kill adb (or lock the screen) if a debugger client is connected r=past --- b2g/chrome/content/settings.js | 11 +++++++++-- b2g/chrome/content/shell.js | 4 ++++ toolkit/devtools/server/main.js | 18 ++++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/b2g/chrome/content/settings.js b/b2g/chrome/content/settings.js index d708873cb7a..ffa6c7b5153 100644 --- a/b2g/chrome/content/settings.js +++ b/b2g/chrome/content/settings.js @@ -314,8 +314,15 @@ let AdbController = { } return; } + + // Check if we have a remote debugging session going on. If so, we won't + // disable adb even if the screen is locked. + let isDebugging = Object.keys(DebuggerServer._connections).length > 0; + debug("isDebugging=" + isDebugging); + let enableAdb = this.remoteDebuggerEnabled && - !(this.lockEnabled && this.locked); + (!(this.lockEnabled && this.locked) || isDebugging); + let useDisableAdbTimer = true; try { if (Services.prefs.getBoolPref("marionette.defaultPrefs.enabled")) { @@ -366,7 +373,7 @@ let AdbController = { } } if (useDisableAdbTimer) { - if (enableAdb) { + if (enableAdb && !isDebugging) { this.startDisableAdbTimer(); } else { this.stopDisableAdbTimer(); diff --git a/b2g/chrome/content/shell.js b/b2g/chrome/content/shell.js index d332323578e..788b8d5b183 100644 --- a/b2g/chrome/content/shell.js +++ b/b2g/chrome/content/shell.js @@ -1025,6 +1025,10 @@ let RemoteDebugger = { DebuggerServer.addActors('chrome://browser/content/dbg-browser-actors.js'); DebuggerServer.addActors("resource://gre/modules/devtools/server/actors/webapps.js"); DebuggerServer.registerModule("devtools/server/actors/device"); + + DebuggerServer.onConnectionChange = function(what) { + AdbController.updateState(); + } } let port = Services.prefs.getIntPref('devtools.debugger.remote-port') || 6000; diff --git a/toolkit/devtools/server/main.js b/toolkit/devtools/server/main.js index bc084396b91..38b9d2c56ea 100644 --- a/toolkit/devtools/server/main.js +++ b/toolkit/devtools/server/main.js @@ -177,6 +177,19 @@ var DebuggerServer = { */ chromeWindowType: null, + /** + * Set that to a function that will be called anytime a new connection + * is opened or one is closed. + */ + onConnectionChange: null, + + _fireConnectionChange: function(aWhat) { + if (this.onConnectionChange && + typeof this.onConnectionChange === "function") { + this.onConnectionChange(aWhat); + } + }, + /** * Prompt the user to accept or decline the incoming connection. This is the * default implementation that products embedding the debugger server may @@ -275,6 +288,9 @@ var DebuggerServer = { delete this._allowConnection; this._transportInitialized = false; this._initialized = false; + + this._fireConnectionChange("closed"); + dumpn("Debugger server is shut down."); }, @@ -546,6 +562,7 @@ var DebuggerServer = { } aTransport.ready(); + this._fireConnectionChange("opened"); return conn; }, @@ -554,6 +571,7 @@ var DebuggerServer = { */ _connectionClosed: function DS_connectionClosed(aConnection) { delete this._connections[aConnection.prefix]; + this._fireConnectionChange("closed"); }, // DebuggerServer extension API.