Repository: cordova-plugin-device
Updated Branches:
  refs/heads/master 09a215b0a -> 408c3a20b


Added basic Android support for hardware serial number


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/commit/e26f5443
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/tree/e26f5443
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/diff/e26f5443

Branch: refs/heads/master
Commit: e26f544368ed26c5f425e8bef07fffa3998d470f
Parents: ad5f1e7
Author: Gabriel Dumitrescu <[email protected]>
Authored: Mon Sep 8 23:57:26 2014 +0000
Committer: Gabriel Dumitrescu <[email protected]>
Committed: Mon Jun 1 03:28:08 2015 +0000

----------------------------------------------------------------------
 README.md               | 10 ++++++++++
 src/android/Device.java | 11 +++++++++--
 tests/tests.js          |  6 ++++++
 www/device.js           |  2 ++
 4 files changed, 27 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/blob/e26f5443/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index e6b5f92..b439f12 100644
--- a/README.md
+++ b/README.md
@@ -40,6 +40,7 @@ Although the object is in the global scope, it is not 
available until after the
 - device.platform
 - device.uuid
 - device.version
+- device.serial
 
 ## device.cordova
 
@@ -218,3 +219,12 @@ Get the operating system version.
     // Tizen: returns "TIZEN_20120425_2"
     var deviceVersion = device.version;
 
+## device.serial
+
+Get the device hardware serial number 
([SERIAL](http://developer.android.com/reference/android/os/Build.html#SERIAL)).
+
+    var string = device.serial;
+
+### Supported Platforms
+
+- Android

http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/blob/e26f5443/src/android/Device.java
----------------------------------------------------------------------
diff --git a/src/android/Device.java b/src/android/Device.java
index 5eded90..305ed66 100644
--- a/src/android/Device.java
+++ b/src/android/Device.java
@@ -74,6 +74,7 @@ public class Device extends CordovaPlugin {
             r.put("platform", this.getPlatform());
             r.put("model", this.getModel());
             r.put("manufacturer", this.getManufacturer());
+            r.put("serial", this.getSerialNumber());
             callbackContext.success(r);
         }
         else {
@@ -88,7 +89,7 @@ public class Device extends CordovaPlugin {
 
     /**
      * Get the OS name.
-     * 
+     *
      * @return
      */
     public String getPlatform() {
@@ -125,6 +126,12 @@ public class Device extends CordovaPlugin {
         String manufacturer = android.os.Build.MANUFACTURER;
         return manufacturer;
     }
+
+    public String getSerialNumber() {
+        String serial = android.os.Build.SERIAL;
+        return serial;
+    }
+
     /**
      * Get the OS version.
      *
@@ -148,7 +155,7 @@ public class Device extends CordovaPlugin {
 
     /**
      * Function to check if the device is manufactured by Amazon
-     * 
+     *
      * @return
      */
     public boolean isAmazonDevice() {

http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/blob/e26f5443/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index 1f49d7e..a9544a9 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -67,6 +67,12 @@ exports.defineAutoTests = function() {
       expect(window.device.manufacturer).toBeDefined();
       expect((new String(window.device.manufacturer)).length > 0).toBe(true);
     });
+
+    it("should contain a serial number specification that is a string", 
function() {
+      expect(window.device.serial).toBeDefined();
+      expect((new String(window.device.serial)).length > 0).toBe(true);
+    });
+
   });
 };
 

http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/blob/e26f5443/www/device.js
----------------------------------------------------------------------
diff --git a/www/device.js b/www/device.js
index b1d0d25..55af80c 100644
--- a/www/device.js
+++ b/www/device.js
@@ -42,6 +42,7 @@ function Device() {
     this.cordova = null;
     this.model = null;
     this.manufacturer = null;
+    this.serial = null;
 
     var me = this;
 
@@ -57,6 +58,7 @@ function Device() {
             me.cordova = buildLabel;
             me.model = info.model;
             me.manufacturer = info.manufacturer || 'unknown';
+            me.serial = info.serial || 'unknown';
             channel.onCordovaInfoReady.fire();
         },function(e) {
             me.available = false;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to