diff options
author | Sharvil Nanavati <sharvil@google.com> | 2015-08-31 23:25:06 -0700 |
---|---|---|
committer | Sharvil Nanavati <sharvil@google.com> | 2015-08-31 23:25:06 -0700 |
commit | babe81546ef001ae26a5c4b572f1480ba737ae32 (patch) | |
tree | 5980426cdb76ab7085002bcddf6bee5946b87136 /core | |
parent | 3bd58233ab3ec8509a3f8922344ae30a330f5159 (diff) | |
download | frameworks_base-babe81546ef001ae26a5c4b572f1480ba737ae32.zip frameworks_base-babe81546ef001ae26a5c4b572f1480ba737ae32.tar.gz frameworks_base-babe81546ef001ae26a5c4b572f1480ba737ae32.tar.bz2 |
DO NOT MERGE Add 'bluetooth' user to the 'system' group.
Also grant the Bluetooth process CAP_BLOCK_SUSPEND so it can acquire
wake locks directly from /sys/power/wake_lock.
Bug: 23375670
Change-Id: Ib094c5752d49488c2560897ff6bb821daf98a281
Diffstat (limited to 'core')
-rw-r--r-- | core/jni/com_android_internal_os_Zygote.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp index 4c920dc..dce2ecb 100644 --- a/core/jni/com_android_internal_os_Zygote.cpp +++ b/core/jni/com_android_internal_os_Zygote.cpp @@ -601,10 +601,34 @@ static jint com_android_internal_os_Zygote_nativeForkAndSpecialize( jint debug_flags, jobjectArray rlimits, jint mount_external, jstring se_info, jstring se_name, jintArray fdsToClose, jstring instructionSet, jstring appDataDir) { - // Grant CAP_WAKE_ALARM to the Bluetooth process. jlong capabilities = 0; if (uid == AID_BLUETOOTH) { + // Grant CAP_WAKE_ALARM and CAP_BLOCK_SUSPEND to the Bluetooth process. capabilities |= (1LL << CAP_WAKE_ALARM); + capabilities |= (1LL << CAP_BLOCK_SUSPEND); + + // Add the Bluetooth process to the system group. + jsize length = env->GetArrayLength(reinterpret_cast<jarray>(gids)); + jintArray gids_with_system = env->NewIntArray(length + 1); + if (!gids_with_system) { + ALOGE("could not allocate java array for gids"); + RuntimeAbort(env); + } + + jint *gids_elements = env->GetIntArrayElements(gids, NULL); + jint *gids_with_system_elements = env->GetIntArrayElements(gids_with_system, NULL); + + if (!gids_elements || !gids_with_system_elements) { + ALOGE("could not allocate arrays for gids"); + RuntimeAbort(env); + } + + gids_with_system_elements[0] = AID_SYSTEM; + memcpy(&gids_with_system_elements[1], &gids_elements[0], length * sizeof(jint)); + + env->ReleaseIntArrayElements(gids, gids_elements, JNI_ABORT); + env->ReleaseIntArrayElements(gids_with_system, gids_with_system_elements, 0); + gids = gids_with_system; } return ForkAndSpecializeCommon(env, uid, gid, gids, debug_flags, |