Bug 836770 - Don't change persist.sys.usb.config if it already has the correct value (ADB) r=fabrice

This commit is contained in:
Dave Hylands 2013-01-31 14:41:13 -08:00
parent 8fb050f647
commit 7939acff1b

View File

@ -207,11 +207,25 @@ SettingsListener.observe('devtools.debugger.remote-enabled', false, function(val
#ifdef MOZ_WIDGET_GONK
// Configure adb.
try {
let current = libcutils.property_get("persist.sys.usb.config");
let prefix = current.replace(/,adb/, "");
libcutils.property_set("persist.sys.usb.config",
prefix + (value ? ",adb" : ""));
current = libcutils.property_get("persist.sys.usb.config");
let currentConfig = libcutils.property_get("persist.sys.usb.config");
let configFuncs = currentConfig.split(",");
let adbIndex = configFuncs.indexOf("adb");
if (value) {
// Add adb to the list of functions, if not already present
if (adbIndex < 0) {
configFuncs.push("adb");
}
} else {
// Remove adb from the list of functions, if present
if (adbIndex >= 0) {
configFuncs.splice(adbIndex,1);
}
}
let newConfig = configFuncs.join(",");
if (newConfig != currentConfig) {
libcutils.property_set("persist.sys.usb.config", newConfig);
}
} catch(e) {
dump("Error configuring adb: " + e);
}