cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From an-s...@apache.org
Subject cordova-plugin-battery-status git commit: CB-8831 Adds extra check for available API on Windows
Date Thu, 09 Apr 2015 11:45:22 GMT
Repository: cordova-plugin-battery-status
Updated Branches:
  refs/heads/master 29d23daa7 -> 9447f7b8b


CB-8831 Adds extra check for available API on Windows


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/commit/9447f7b8
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/tree/9447f7b8
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/diff/9447f7b8

Branch: refs/heads/master
Commit: 9447f7b8bd34f720ad0f85c9a0e00ba83c06247d
Parents: 29d23da
Author: Vladimir Kotikov <v-vlkoti@microsoft.com>
Authored: Thu Apr 9 13:56:51 2015 +0300
Committer: Vladimir Kotikov <v-vlkoti@microsoft.com>
Committed: Thu Apr 9 14:08:25 2015 +0300

----------------------------------------------------------------------
 plugin.xml                  |  2 +-
 src/windows/BatteryProxy.js | 18 +++++++++++++-----
 2 files changed, 14 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/blob/9447f7b8/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index 17945ed..415943a 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -107,7 +107,7 @@
             <runs />
         </js-module>
         
-        <framework src="src/windows/BatteryStatus.winmd" custom="true"/>
+        <framework src="src/windows/BatteryStatus.winmd" custom="true" target="phone"/>
     </platform>
 
     <!-- tizen -->

http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/blob/9447f7b8/src/windows/BatteryProxy.js
----------------------------------------------------------------------
diff --git a/src/windows/BatteryProxy.js b/src/windows/BatteryProxy.js
index b6644c0..4c7e101 100644
--- a/src/windows/BatteryProxy.js
+++ b/src/windows/BatteryProxy.js
@@ -34,13 +34,15 @@ function handleResponse(successCb, errorCb, jsonResponse) {
 
 var Battery = {
     start: function (win, fail, args, env) {
+        // Battery API supported on Phone devices only so in case of
+        // desktop/tablet the only one choice is to fail with appropriate message.
+        if (!WinJS.Utilities.isPhone) {
+            fail("The operation is not supported on Windows Desktop devices.");
+            return;
+        }
+
         stopped = false;
         try {
-            if (!WinJS.Utilities.isPhone) {
-                fail("The operation is not supported by this platform.");
-                return;
-            }
-
             function getBatteryStatus(success, error) {
                 handleResponse(success, error, BatteryStatus.BatteryStatus.start());
             }
@@ -68,6 +70,12 @@ var Battery = {
     },
 
     stop: function () {
+        // Battery API supported on Phone devices only so in case of
+        // desktop/tablet device we don't need for any actions.
+        if (!WinJS.Utilities.isPhone) {
+            return;
+        }
+
         stopped = true;
         BatteryStatus.BatteryStatus.stop();
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message