emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature/android 417e0539cfe: Avoid using Linux sysfs APIs to access batt


From: Po Lu
Subject: feature/android 417e0539cfe: Avoid using Linux sysfs APIs to access battery state on Android
Date: Thu, 9 Mar 2023 21:03:03 -0500 (EST)

branch: feature/android
commit 417e0539cfe5af5ab20ffc2342b0796ad5c0ef1b
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    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.
---
 lisp/battery.el | 11 ++++++-----
 1 file 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 \"..\"."
 (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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]