Bug 790158 - Add os version and hardware info to mozSettings. r=cjones

This commit is contained in:
Shelly Lin 2012-09-19 18:06:40 +08:00
parent 1c0944f4fb
commit 439f951fa8
4 changed files with 46 additions and 2 deletions

View File

@ -81,6 +81,45 @@ SettingsListener.observe('language.current', 'en-US', function(value) {
});
})();
//=================== DeviceInfo ====================
Components.utils.import('resource://gre/modules/XPCOMUtils.jsm');
Components.utils.import('resource://gre/modules/ctypes.jsm');
(function DeviceInfoToSettings() {
XPCOMUtils.defineLazyServiceGetter(this, 'gSettingsService',
'@mozilla.org/settingsService;1',
'nsISettingsService');
let lock = gSettingsService.createLock();
//MOZ_B2G_VERSION is set in b2g/confvars.sh, and is outputed as a #define value
//from configure.in, defaults to 1.0.0 if this value is not exist
#filter attemptSubstitution
let os_version = '@MOZ_B2G_VERSION@';
#unfilter attemptSubstitution
lock.set('deviceinfo.os', os_version, null, null);
//Get the hardware info from android properties
var hardware_version = null;
try {
let cutils = ctypes.open('libcutils.so');
let cbuf = ctypes.char.array(128)();
let c_property_get = cutils.declare('property_get', ctypes.default_abi,
ctypes.int, // return value: length
ctypes.char.ptr, // key
ctypes.char.ptr, // value
ctypes.char.ptr); // default
let property_get = function (key, defaultValue) {
if (defaultValue === undefined) {
defaultValue = null;
}
c_property_get(key, cbuf, defaultValue);
return cbuf.readString();
}
hardware_version = property_get('ro.hardware');
cutils.close();
} catch(e) {
//Error
}
lock.set('deviceinfo.hardware', hardware_version, null, null);
})();
// =================== Debugger ====================
SettingsListener.observe('devtools.debugger.remote-enabled', false, function(enabled) {
@ -110,4 +149,4 @@ SettingsListener.observe('debug.dev-mode', false, function(value) {
// =================== Privacy ====================
SettingsListener.observe('privacy.donottrackheader.enabled', false, function(value) {
Services.prefs.setBoolPref('privacy.donottrackheader.enabled', value);
});
});

View File

@ -11,7 +11,7 @@ chrome.jar:
content/arrow.svg (content/arrow.svg)
content/dbg-browser-actors.js (content/dbg-browser-actors.js)
content/forms.js (content/forms.js)
content/settings.js (content/settings.js)
* content/settings.js (content/settings.js)
* content/shell.xul (content/shell.xul)
* content/shell.js (content/shell.js)
#ifndef ANDROID

View File

@ -8,6 +8,8 @@ MOZ_APP_VENDOR=Mozilla
MOZ_APP_VERSION=18.0a1
MOZ_APP_UA_NAME=Firefox
MOZ_B2G_VERSION=1.0.0
MOZ_BRANDING_DIRECTORY=b2g/branding/unofficial
MOZ_OFFICIAL_BRANDING_DIRECTORY=b2g/branding/official
# MOZ_APP_DISPLAYNAME is set by branding/configure.sh

View File

@ -8353,6 +8353,9 @@ else
MOZ_APP_MAXVERSION=$MOZ_APP_VERSION
fi
MOZ_B2G_VERSION=${MOZ_B2G_VERSION:-"1.0.0"}
AC_DEFINE_UNQUOTED(MOZ_B2G_VERSION,"$MOZ_B2G_VERSION")
AC_SUBST(MOZ_APP_NAME)
AC_SUBST(MOZ_APP_DISPLAYNAME)
AC_SUBST(MOZ_APP_BASENAME)