Bug 759911 - include human readable build ID, version, and channel in device info. r=lsblakk
authorVivien Nicolas <21@vingtetun.org>
Thu, 25 Oct 2012 15:02:15 +0200
changeset 111510 c2d82d7c1dbc0f8005617a7eeae787df2b6e1662
parent 111509 293bdc2afe11f479e8394229f04281abe13ceb25
child 111511 f6293f153a6b78241b4a4494beb616ed173e5dcc
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewerslsblakk
bugs759911
milestone19.0a1
Bug 759911 - include human readable build ID, version, and channel in device info. r=lsblakk
b2g/chrome/content/settings.js
b2g/chrome/content/shell.js
--- a/b2g/chrome/content/settings.js
+++ b/b2g/chrome/content/settings.js
@@ -1,16 +1,24 @@
 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
 /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict;"
 
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+const Cu = Components.utils;
+const Cr = Components.results;
+
+Cu.import('resource://gre/modules/XPCOMUtils.jsm');
+Cu.import('resource://gre/modules/Services.jsm');
+
 // Once Bug 731746 - Allow chrome JS object to implement nsIDOMEventTarget
 // is resolved this helper could be removed.
 var SettingsListener = {
   _callbacks: {},
 
   init: function sl_init() {
     if ('mozSettings' in navigator && navigator.mozSettings) {
       navigator.mozSettings.onsettingchange = this.onchange.bind(this);
@@ -91,18 +99,26 @@ Components.utils.import('resource://gre/
   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);
 
+  let appInfo = Cc["@mozilla.org/xre/app-info;1"]
+                  .getService(Ci.nsIXULAppInfo);
+  lock.set('deviceinfo.platform_version', appInfo.platformVersion, null, null);
+  lock.set('deviceinfo.platform_build_id', appInfo.platformBuildID, null, null);
+
+  let update_channel = Services.prefs.getCharPref('app.update.channel');
+  lock.set('deviceinfo.update_channel', update_channel, null, null);
+
   //Get the hardware info from android properties
-  var hardware_version = null;
+  let 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
--- a/b2g/chrome/content/shell.js
+++ b/b2g/chrome/content/shell.js
@@ -1,21 +1,14 @@
 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
 /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cu = Components.utils;
-const Cr = Components.results;
-
-Cu.import('resource://gre/modules/XPCOMUtils.jsm');
-Cu.import('resource://gre/modules/Services.jsm');
 Cu.import('resource://gre/modules/ContactService.jsm');
 Cu.import('resource://gre/modules/SettingsChangeNotifier.jsm');
 #ifdef MOZ_B2G_FM
 Cu.import('resource://gre/modules/DOMFMRadioParent.jsm');
 #endif
 Cu.import('resource://gre/modules/AlarmService.jsm');
 Cu.import('resource://gre/modules/ActivitiesService.jsm');
 Cu.import('resource://gre/modules/PermissionPromptHelper.jsm');