android N:audioserver is not permitted to acquire_wake_lock

381 views
Skip to first unread message

jazz...@gmail.com

unread,
Dec 28, 2016, 10:52:31 AM12/28/16
to android-platform
in the  system/core/rootdir/init.rc
    chown radio wakelock /sys/power/wake_lock
    chown radio wakelock /sys/power/wake_unlock
    chmod 0660 /sys/power/state
    chmod 0660 /sys/power/wake_lock
    chmod 0660 /sys/power/wake_unlock

in the frameworks/av/media/audioserver/audioserver.rc
service audioserver /system/bin/audioserver
    class main
    user audioserver
    # media gid needed for /dev/fm (radio) and for /data/misc/media (tee)
    group audio camera drmrpc inet media mediadrm net_bt net_bt_admin net_bw_acct
    ioprio rt 4
    writepid /dev/cpuset/foreground/tasks

audioserver is not in the wakelock group, but in the frameworks/av/services/audiopolicy/service/AudioPolicyService.cpp
some threads of audioserver try to  acquire_wake_lock and release_wake_lock:
        if (mAudioCommands.isEmpty()) {
            release_wake_lock(mName.string());
        }

so, on my private build device,it will print:
E power   : fatal error opening "/sys/power/wake_lock": Permission denied
from hardware/libhardware_legacy/power/power.c open_file_descriptors

does the AOSP will behave the same as my build?is it reasonable?

if i add audioserver into the wakelock group:
--- a/media/audioserver/audioserver.rc
+++ b/media/audioserver/audioserver.rc
@@ -2,6 +2,6 @@ service audioserver /system/bin/audioserver
     class main
     user audioserver
     # media gid needed for /dev/fm (radio) and for /data/misc/media (tee)
-    group audio camera drmrpc inet media mediadrm net_bt net_bt_admin net_bw_acct
+    group audio camera drmrpc inet media mediadrm net_bt net_bt_admin net_bw_acct wakelock

above
Permission denied error will disappeared,but selinux denied will be observed:
[   16.456298] type=1400 audit(946689889.350:3): avc: denied { read write } for pid=179 comm="ApmAudio" name="wake_lock" dev="sysfs" ino=63 scontext=u:r:audioserver:s0 tcontext=u:object_r:sysfs_wake_lock:s0 tclass=file permissive=1

should give audioserver 
sysfs_wake_lock to pass the denial?



Reply all
Reply to author
Forward
0 new messages