OSDN Git Service

Launch processes running under the 'bluetooth' uid with CAP_WAKE_ALARM.
authorSharvil Nanavati <sharvil@google.com>
Mon, 30 Jun 2014 00:06:52 +0000 (17:06 -0700)
committerSharvil Nanavati <sharvil@google.com>
Wed, 16 Jul 2014 18:26:48 +0000 (18:26 +0000)
This is required since bluedroid needs to set wake alarms and timers.
Going through JNI back into Java code and then across Binder to
AlarmManager is both inefficient and doesn't provide the resolution
required for functions like A2DP.

Change-Id: I4c9a8b326e7b9056dfa105f5638e7509ff467342

core/jni/com_android_internal_os_Zygote.cpp

index 64366e5..1f7acec 100644 (file)
@@ -39,6 +39,7 @@
 #include <cutils/fs.h>
 #include <cutils/multiuser.h>
 #include <cutils/sched_policy.h>
+#include <private/android_filesystem_config.h>
 #include <utils/String8.h>
 #include <selinux/android.h>
 #include <processgroup/processgroup.h>
@@ -536,8 +537,15 @@ static jint com_android_internal_os_Zygote_nativeForkAndSpecialize(
         jint debug_flags, jobjectArray rlimits,
         jint mount_external, jstring se_info, jstring se_name,
         jintArray fdsToClose) {
+    // Grant CAP_WAKE_ALARM to the Bluetooth process.
+    jlong capabilities = 0;
+    if (uid == AID_BLUETOOTH) {
+        capabilities |= (1LL << CAP_WAKE_ALARM);
+    }
+
     return ForkAndSpecializeCommon(env, uid, gid, gids, debug_flags,
-            rlimits, 0, 0, mount_external, se_info, se_name, false, fdsToClose);
+            rlimits, capabilities, capabilities, mount_external, se_info,
+            se_name, false, fdsToClose);
 }
 
 static jint com_android_internal_os_Zygote_nativeForkSystemServer(