Return-Path: X-Original-To: apmail-cordova-issues-archive@minotaur.apache.org Delivered-To: apmail-cordova-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 542ED10208 for ; Thu, 17 Oct 2013 15:21:51 +0000 (UTC) Received: (qmail 51977 invoked by uid 500); 17 Oct 2013 15:21:48 -0000 Delivered-To: apmail-cordova-issues-archive@cordova.apache.org Received: (qmail 51742 invoked by uid 500); 17 Oct 2013 15:21:43 -0000 Mailing-List: contact issues-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list issues@cordova.apache.org Received: (qmail 51716 invoked by uid 99); 17 Oct 2013 15:21:42 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Oct 2013 15:21:42 +0000 Date: Thu, 17 Oct 2013 15:21:42 +0000 (UTC) From: "Mike Billau (JIRA)" To: issues@cordova.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CB-4518) Battery "level" is not calculated correctly MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CB-4518?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13797995#comment-13797995 ] Mike Billau commented on CB-4518: --------------------------------- Not sure if these are the same issues or not... > Battery "level" is not calculated correctly > ------------------------------------------- > > Key: CB-4518 > URL: https://issues.apache.org/jira/browse/CB-4518 > Project: Apache Cordova > Issue Type: Bug > Components: Android > Affects Versions: 2.9.0 > Reporter: Peter > Assignee: Joe Bowser > Priority: Minor > > The meaning of the Battery "level" in Cordova is a charge *percentage*. > Ref http://cordova.apache.org/docs/en/2.9.0/cordova_events_events.md.html#batterylow > But the Battery EXTRA_LEVEL is not a percentage. It's just a number in the range 0 to EXTRA_SCALE > Ref http://developer.android.com/reference/android/os/BatteryManager.html#EXTRA_LEVEL > So the battery level calculation should be something like: > {code} > int level = batteryIntent.getIntExtra(android.os.BatteryManager.EXTRA_LEVEL, 0); > int scale = batteryIntent.getIntExtra(android.os.BatteryManager.EXTRA_SCALE, 100); > int percent = 100 * level / scale; > obj.put("level", percent); > {code} -- This message was sent by Atlassian JIRA (v6.1#6144)