mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-11-27 07:37:33 +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
@ -1212,7 +1212,7 @@ If a display name can be requested from URI (using the resolver
|
|||||||
temp = battery.getIntExtra (BatteryManager.EXTRA_TEMPERATURE, 0);
|
temp = battery.getIntExtra (BatteryManager.EXTRA_TEMPERATURE, 0);
|
||||||
|
|
||||||
return new long[] { capacity, chargeCounter, currentAvg,
|
return new long[] { capacity, chargeCounter, currentAvg,
|
||||||
currentNow, remaining, status, plugged,
|
currentNow, status, remaining, plugged,
|
||||||
temp, };
|
temp, };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1289,7 +1289,7 @@ else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return new long[] { capacity, chargeCounter, currentAvg,
|
return new long[] { capacity, chargeCounter, currentAvg,
|
||||||
currentNow, remaining, status, plugged,
|
currentNow, status, remaining, plugged,
|
||||||
temp, };
|
temp, };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
;; - BSD by using the `apm' program.
|
;; - BSD by using the `apm' program.
|
||||||
;; - Darwin (macOS) by using the `pmset' program.
|
;; - Darwin (macOS) by using the `pmset' program.
|
||||||
;; - Windows via the GetSystemPowerStatus API call.
|
;; - Windows via the GetSystemPowerStatus API call.
|
||||||
;; - Android 5 or later via the BatteryManager APIs.
|
;; - Android via the BatteryManager APIs.
|
||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ Value does not include \".\" or \"..\"."
|
|||||||
;; Note that even though the Linux kernel APIs are sometimes
|
;; Note that even though the Linux kernel APIs are sometimes
|
||||||
;; available on Android, they are badly implemented by Android
|
;; available on Android, they are badly implemented by Android
|
||||||
;; kernels, so avoid using those.
|
;; kernels, so avoid using those.
|
||||||
((eq system-type 'android)
|
((fboundp 'android-query-battery)
|
||||||
#'battery-android)
|
#'battery-android)
|
||||||
((and (eq system-type 'berkeley-unix)
|
((and (eq system-type 'berkeley-unix)
|
||||||
(file-executable-p "/usr/sbin/apm"))
|
(file-executable-p "/usr/sbin/apm"))
|
||||||
@ -1107,7 +1107,8 @@ The following %-sequences are provided:
|
|||||||
(rate nil)
|
(rate nil)
|
||||||
(remaining nil)
|
(remaining nil)
|
||||||
(hours nil)
|
(hours nil)
|
||||||
(minutes nil))
|
(minutes nil)
|
||||||
|
(temperature nil))
|
||||||
;; Figure out the percentage.
|
;; Figure out the percentage.
|
||||||
(setq percentage (number-to-string (car status)))
|
(setq percentage (number-to-string (car status)))
|
||||||
;; Figure out the capacity
|
;; Figure out the capacity
|
||||||
@ -1133,6 +1134,12 @@ The following %-sequences are provided:
|
|||||||
(setq remaining (format "%d:%d" hours-left mins)
|
(setq remaining (format "%d:%d" hours-left mins)
|
||||||
hours (number-to-string hours-left)
|
hours (number-to-string hours-left)
|
||||||
minutes (number-to-string mins))))
|
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.
|
;; Return results.
|
||||||
(list (cons ?c capacity)
|
(list (cons ?c capacity)
|
||||||
(cons ?p percentage)
|
(cons ?p percentage)
|
||||||
@ -1145,11 +1152,12 @@ The following %-sequences are provided:
|
|||||||
(cons ?L (cl-case (nth 6 status)
|
(cons ?L (cl-case (nth 6 status)
|
||||||
(0 "off-line")
|
(0 "off-line")
|
||||||
(1 "on-line")
|
(1 "on-line")
|
||||||
(2 "on-line (dock)")
|
(2 "on-line (USB)")
|
||||||
(3 "on-line (USB)")
|
(4 "on-line (dock)")
|
||||||
(4 "on-line (wireless)")
|
(8 "on-line (wireless)")
|
||||||
(t "unknown")))
|
(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.
|
;;; Private functions.
|
||||||
|
@ -6574,8 +6574,8 @@ android_query_battery (struct android_battery_state *status)
|
|||||||
status->charge_counter = longs[1];
|
status->charge_counter = longs[1];
|
||||||
status->current_average = longs[2];
|
status->current_average = longs[2];
|
||||||
status->current_now = longs[3];
|
status->current_now = longs[3];
|
||||||
status->remaining = longs[4];
|
status->status = longs[4];
|
||||||
status->status = longs[5];
|
status->remaining = longs[5];
|
||||||
status->plugged = longs[6];
|
status->plugged = longs[6];
|
||||||
status->temperature = longs[7];
|
status->temperature = longs[7];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user