mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-09-02 01:35:32 +00:00
Minor adjustments to battery.el on Android
* src/android.c (android_query_battery): * java/org/gnu/emacs/EmacsService.java (queryBattery19) (queryBattery): Reorder items in value for consistency with Fandroid_query_battery. * lisp/battery.el (battery-status-function): Select battery-android only when android-query-battery is present. (battery-android): Return temperature and correct values of power source constants.
This commit is contained in:
parent
aefcccc1d4
commit
a39f6480ea
3 changed files with 19 additions and 11 deletions
|
@ -1212,7 +1212,7 @@ If a display name can be requested from URI (using the resolver
|
|||
temp = battery.getIntExtra (BatteryManager.EXTRA_TEMPERATURE, 0);
|
||||
|
||||
return new long[] { capacity, chargeCounter, currentAvg,
|
||||
currentNow, remaining, status, plugged,
|
||||
currentNow, status, remaining, plugged,
|
||||
temp, };
|
||||
}
|
||||
|
||||
|
@ -1289,7 +1289,7 @@ else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
|
|||
}
|
||||
|
||||
return new long[] { capacity, chargeCounter, currentAvg,
|
||||
currentNow, remaining, status, plugged,
|
||||
currentNow, status, remaining, plugged,
|
||||
temp, };
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
;; - BSD by using the `apm' program.
|
||||
;; - Darwin (macOS) by using the `pmset' program.
|
||||
;; - Windows via the GetSystemPowerStatus API call.
|
||||
;; - Android 5 or later via the BatteryManager APIs.
|
||||
;; - Android via the BatteryManager APIs.
|
||||
|
||||
;;; Code:
|
||||
|
||||
|
@ -112,7 +112,7 @@ Value does not include \".\" or \"..\"."
|
|||
;; Note that even though the Linux kernel APIs are sometimes
|
||||
;; available on Android, they are badly implemented by Android
|
||||
;; kernels, so avoid using those.
|
||||
((eq system-type 'android)
|
||||
((fboundp 'android-query-battery)
|
||||
#'battery-android)
|
||||
((and (eq system-type 'berkeley-unix)
|
||||
(file-executable-p "/usr/sbin/apm"))
|
||||
|
@ -1107,7 +1107,8 @@ The following %-sequences are provided:
|
|||
(rate nil)
|
||||
(remaining nil)
|
||||
(hours nil)
|
||||
(minutes nil))
|
||||
(minutes nil)
|
||||
(temperature nil))
|
||||
;; Figure out the percentage.
|
||||
(setq percentage (number-to-string (car status)))
|
||||
;; Figure out the capacity
|
||||
|
@ -1133,6 +1134,12 @@ The following %-sequences are provided:
|
|||
(setq remaining (format "%d:%d" hours-left mins)
|
||||
hours (number-to-string hours-left)
|
||||
minutes (number-to-string mins))))
|
||||
;; Return the temperature, so long as its value is not downright
|
||||
;; absurd (as when the sensor is faulty or the battery controller
|
||||
;; driver does not provide temperature readouts).
|
||||
(unless (or (< (nth 7 status) -1000)
|
||||
(> (nth 7 status) 1000))
|
||||
(setq temperature (/ (nth 7 status) 10.0)))
|
||||
;; Return results.
|
||||
(list (cons ?c capacity)
|
||||
(cons ?p percentage)
|
||||
|
@ -1145,11 +1152,12 @@ The following %-sequences are provided:
|
|||
(cons ?L (cl-case (nth 6 status)
|
||||
(0 "off-line")
|
||||
(1 "on-line")
|
||||
(2 "on-line (dock)")
|
||||
(3 "on-line (USB)")
|
||||
(4 "on-line (wireless)")
|
||||
(2 "on-line (USB)")
|
||||
(4 "on-line (dock)")
|
||||
(8 "on-line (wireless)")
|
||||
(t "unknown")))
|
||||
(cons ?t (/ (or (nth 7 status) 0) 10.0))))))
|
||||
(cons ?t (/ (or (nth 7 status) 0) 10.0))
|
||||
(cons ?d temperature)))))
|
||||
|
||||
|
||||
;;; Private functions.
|
||||
|
|
|
@ -6574,8 +6574,8 @@ android_query_battery (struct android_battery_state *status)
|
|||
status->charge_counter = longs[1];
|
||||
status->current_average = longs[2];
|
||||
status->current_now = longs[3];
|
||||
status->remaining = longs[4];
|
||||
status->status = longs[5];
|
||||
status->status = longs[4];
|
||||
status->remaining = longs[5];
|
||||
status->plugged = longs[6];
|
||||
status->temperature = longs[7];
|
||||
|
||||
|
|
Loading…
Reference in a new issue