From: Po Lu Date: Fri, 10 Mar 2023 02:02:36 +0000 (+0800) Subject: Avoid using Linux sysfs APIs to access battery state on Android X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=417e0539cfe5af5ab20ffc2342b0796ad5c0ef1b;p=emacs.git 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. --- 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 \"..\"." (defcustom battery-status-function (cond ((member battery-upower-service (dbus-list-activatable-names)) #'battery-upower) - ;; Try to find the relevant devices in /sys and /proc on - ;; Android as well, in case the system makes them available. - ((and (memq system-type '(gnu/linux android)) + ((and (eq system-type 'gnu/linux) (file-readable-p "/sys/") (battery--find-linux-sysfs-batteries)) #'battery-linux-sysfs) - ((and (memq system-type '(gnu/linux android)) + ((and (eq system-type 'gnu/linux) (file-directory-p "/proc/acpi/battery")) #'battery-linux-proc-acpi) - ((and (memq system-type '(gnu/linux android)) + ((and (eq system-type 'gnu/linux) (file-readable-p "/proc/") (file-readable-p "/proc/apm")) #'battery-linux-proc-apm) ;; Now try the Android battery status function. + ;; 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) #'battery-android) ((and (eq system-type 'berkeley-unix)