You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by mm...@apache.org on 2014/05/05 17:06:31 UTC
[10/37] git commit: Modify Device.platform logic to use amazon-fireos
as the platform for Amazon Devices
Modify Device.platform logic to use amazon-fireos as the platform for Amazon Devices
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/7256fdd5
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/tree/7256fdd5
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/diff/7256fdd5
Branch: refs/heads/cdvtest
Commit: 7256fdd59e1a290ce12e7ba09928246df45d81ce
Parents: 71c0a89
Author: Archana Naik <na...@lab126.com>
Authored: Fri Nov 15 14:18:14 2013 -0800
Committer: Archana Naik <na...@lab126.com>
Committed: Fri Nov 15 14:18:14 2013 -0800
----------------------------------------------------------------------
src/android/Device.java | 34 ++++++++++++++++++++++++++++------
1 file changed, 28 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/blob/7256fdd5/src/android/Device.java
----------------------------------------------------------------------
diff --git a/src/android/Device.java b/src/android/Device.java
index 2ce3cc7..fe5dd14 100644
--- a/src/android/Device.java
+++ b/src/android/Device.java
@@ -40,8 +40,12 @@ public class Device extends CordovaPlugin {
public static final String TAG = "Device";
public static String cordovaVersion = "dev"; // Cordova version
- public static String platform = "Android"; // Device OS
- public static String uuid; // Device UUID
+ public static String platform; // Device OS
+ public static String uuid; // Device UUID
+
+ private static final String ANDROID_PLATFORM = "Android";
+ private static final String AMAZON_PLATFORM = "amazon-fireos";
+ private static final String AMAZON_DEVICE = "Amazon";
BroadcastReceiver telephonyReceiver = null;
@@ -77,7 +81,7 @@ public class Device extends CordovaPlugin {
JSONObject r = new JSONObject();
r.put("uuid", Device.uuid);
r.put("version", this.getOSVersion());
- r.put("platform", Device.platform);
+ r.put("platform", this.getPlatform());
r.put("cordova", Device.cordovaVersion);
r.put("model", this.getModel());
callbackContext.success(r);
@@ -111,7 +115,7 @@ public class Device extends CordovaPlugin {
this.telephonyReceiver = new BroadcastReceiver() {
@Override
- public void onReceive(Context context, Intent intent) {
+ public void onReceive(Context context, Intent intent) {
// If state has changed
if ((intent != null) && intent.getAction().equals(TelephonyManager.ACTION_PHONE_STATE_CHANGED)) {
@@ -140,11 +144,17 @@ public class Device extends CordovaPlugin {
/**
* Get the OS name.
- *
+ *
* @return
*/
public String getPlatform() {
- return Device.platform;
+ String platform;
+ if (isAmazonDevice()) {
+ platform = AMAZON_PLATFORM;
+ } else {
+ platform = ANDROID_PLATFORM;
+ }
+ return platform;
}
/**
@@ -197,4 +207,16 @@ public class Device extends CordovaPlugin {
return (tz.getID());
}
+ /**
+ * Function to check if the device is manufactured by Amazon
+ *
+ * @return
+ */
+ public boolean isAmazonDevice() {
+ if (android.os.Build.MANUFACTURER.equals(AMAZON_DEVICE)) {
+ return true;
+ }
+ return false;
+ }
+
}