aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPo Lu2023-03-10 10:02:36 +0800
committerPo Lu2023-03-10 10:02:36 +0800
commit417e0539cfe5af5ab20ffc2342b0796ad5c0ef1b (patch)
tree73f03a4ef542cd561c413216d20f6681a56b64a7
parent488a75f2e2b73038ff341f3484a8cf8584633eff (diff)
downloademacs-417e0539cfe5af5ab20ffc2342b0796ad5c0ef1b.tar.gz
emacs-417e0539cfe5af5ab20ffc2342b0796ad5c0ef1b.zip
Avoid using Linux sysfs APIs to access battery state on Android
* lisp/battery.el (battery-status-function): Don't look for /sys, /proc* on Android. Explain why.
-rw-r--r--lisp/battery.el11
1 files changed, 6 insertions, 5 deletions
diff --git a/lisp/battery.el b/lisp/battery.el
index a51bc5267b3..c55fcbbee8c 100644
--- a/lisp/battery.el
+++ b/lisp/battery.el
@@ -97,20 +97,21 @@ Value does not include \".\" or \"..\"."
97(defcustom battery-status-function 97(defcustom battery-status-function
98 (cond ((member battery-upower-service (dbus-list-activatable-names)) 98 (cond ((member battery-upower-service (dbus-list-activatable-names))
99 #'battery-upower) 99 #'battery-upower)
100 ;; Try to find the relevant devices in /sys and /proc on 100 ((and (eq system-type 'gnu/linux)
101 ;; Android as well, in case the system makes them available.
102 ((and (memq system-type '(gnu/linux android))
103 (file-readable-p "/sys/") 101 (file-readable-p "/sys/")
104 (battery--find-linux-sysfs-batteries)) 102 (battery--find-linux-sysfs-batteries))
105 #'battery-linux-sysfs) 103 #'battery-linux-sysfs)
106 ((and (memq system-type '(gnu/linux android)) 104 ((and (eq system-type 'gnu/linux)
107 (file-directory-p "/proc/acpi/battery")) 105 (file-directory-p "/proc/acpi/battery"))
108 #'battery-linux-proc-acpi) 106 #'battery-linux-proc-acpi)
109 ((and (memq system-type '(gnu/linux android)) 107 ((and (eq system-type 'gnu/linux)
110 (file-readable-p "/proc/") 108 (file-readable-p "/proc/")
111 (file-readable-p "/proc/apm")) 109 (file-readable-p "/proc/apm"))
112 #'battery-linux-proc-apm) 110 #'battery-linux-proc-apm)
113 ;; Now try the Android battery status function. 111 ;; Now try the Android battery status function.
112 ;; Note that even though the Linux kernel APIs are sometimes
113 ;; available on Android, they are badly implemented by Android
114 ;; kernels, so avoid using those.
114 ((eq system-type 'android) 115 ((eq system-type 'android)
115 #'battery-android) 116 #'battery-android)
116 ((and (eq system-type 'berkeley-unix) 117 ((and (eq system-type 'berkeley-unix)