summaryrefslogtreecommitdiffstats
path: root/core/jni
diff options
context:
space:
mode:
authorWolfgang Wiedmeyer <wolfgit@wiedmeyer.de>2016-03-18 10:36:07 +0100
committerWolfgang Wiedmeyer <wolfgit@wiedmeyer.de>2016-03-18 10:36:07 +0100
commit813d4309fb2144b96ffcd644c71a30aadc50fd1e (patch)
tree532609cc34968f682701176114c484f5278b8349 /core/jni
parent8bc386657e4bd582ea0897410523e27230a8e157 (diff)
parentdf301d4a64fe0dfc812b39e3f7e2c2ca4b93c305 (diff)
downloadframeworks_base-813d4309fb2144b96ffcd644c71a30aadc50fd1e.zip
frameworks_base-813d4309fb2144b96ffcd644c71a30aadc50fd1e.tar.gz
frameworks_base-813d4309fb2144b96ffcd644c71a30aadc50fd1e.tar.bz2
Merge branch 'cm-13.0' of https://github.com/CyanogenMod/android_frameworks_base into replicant-6.0
Diffstat (limited to 'core/jni')
-rw-r--r--core/jni/Android.mk4
-rw-r--r--core/jni/AndroidRuntime.cpp10
-rwxr-xr-xcore/jni/android/graphics/Bitmap.cpp1
-rw-r--r--core/jni/android_media_AudioSystem.cpp35
-rw-r--r--core/jni/com_android_internal_content_NativeLibraryHelper.cpp18
-rw-r--r--core/jni/com_android_internal_os_Zygote.cpp26
6 files changed, 91 insertions, 3 deletions
diff --git a/core/jni/Android.mk b/core/jni/Android.mk
index ad52bd6..42b10c4 100644
--- a/core/jni/Android.mk
+++ b/core/jni/Android.mk
@@ -16,6 +16,10 @@ else
LOCAL_CFLAGS += -DPACKED=""
endif
+ifeq ($(TARGET_ARCH), x86)
+ LOCAL_CFLAGS += -DPICK_SUPPORTED_ABI_WITH_MAX_LIBS
+endif
+
ifneq ($(ENABLE_CPUSETS),)
LOCAL_CFLAGS += -DENABLE_CPUSETS
endif
diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp
index a715c5f..9acdab4 100644
--- a/core/jni/AndroidRuntime.cpp
+++ b/core/jni/AndroidRuntime.cpp
@@ -1034,6 +1034,16 @@ void AndroidRuntime::start(const char* className, const Vector<String8>& options
setenv("ANDROID_ROOT", rootDir, 1);
}
+ const char* prebundledDir = getenv("PREBUNDLED_ROOT");
+ if (prebundledDir == NULL) {
+ if (hasDir("/system/bundled-app")) {
+ prebundledDir = "/system/bundled-app";
+ } else {
+ prebundledDir = "/vendor/bundled-app";
+ }
+ setenv("PREBUNDLED_ROOT", prebundledDir, 1);
+ }
+
//const char* kernelHack = getenv("LD_ASSUME_KERNEL");
//ALOGD("Found LD_ASSUME_KERNEL='%s'\n", kernelHack);
diff --git a/core/jni/android/graphics/Bitmap.cpp b/core/jni/android/graphics/Bitmap.cpp
index 6cbdeaa..f5fe086 100755
--- a/core/jni/android/graphics/Bitmap.cpp
+++ b/core/jni/android/graphics/Bitmap.cpp
@@ -1006,6 +1006,7 @@ static jobject Bitmap_createFromParcel(JNIEnv* env, jobject, jobject parcel) {
// is disposed.
int dupFd = dup(blob.fd());
if (dupFd < 0) {
+ ALOGE("Error allocating dup fd. Error:%d", errno);
blob.release();
SkSafeUnref(ctable);
doThrowRE(env, "Could not allocate dup blob fd.");
diff --git a/core/jni/android_media_AudioSystem.cpp b/core/jni/android_media_AudioSystem.cpp
index 91b3278..1acf867 100644
--- a/core/jni/android_media_AudioSystem.cpp
+++ b/core/jni/android_media_AudioSystem.cpp
@@ -154,6 +154,11 @@ static struct {
jmethodID postDynPolicyEventFromNative;
} gDynPolicyEventHandlerMethods;
+static struct {
+ jmethodID postEffectSessionEventFromNative;
+} gEffectSessionEventHandlerMethods;
+
+
static Mutex gLock;
enum AudioError {
@@ -386,6 +391,24 @@ android_media_AudioSystem_dyn_policy_callback(int event, String8 regId, int val)
}
+static void
+android_media_AudioSystem_effect_session_callback(int event, audio_stream_type_t stream,
+ audio_unique_id_t sessionId, bool added)
+{
+ JNIEnv *env = AndroidRuntime::getJNIEnv();
+ if (env == NULL) {
+ return;
+ }
+
+ jclass clazz = env->FindClass(kClassPathName);
+
+ env->CallStaticVoidMethod(clazz, gEffectSessionEventHandlerMethods.postEffectSessionEventFromNative,
+ event, stream, sessionId, added);
+
+ env->DeleteLocalRef(clazz);
+
+}
+
static jint
android_media_AudioSystem_setDeviceConnectionState(JNIEnv *env, jobject thiz, jint device, jint state, jstring device_address, jstring device_name)
{
@@ -1487,6 +1510,12 @@ android_media_AudioSystem_registerDynPolicyCallback(JNIEnv *env, jobject thiz)
AudioSystem::setDynPolicyCallback(android_media_AudioSystem_dyn_policy_callback);
}
+static void
+android_media_AudioSystem_registerEffectSessionCallback(JNIEnv *env, jobject thiz)
+{
+ AudioSystem::setEffectSessionCallback(android_media_AudioSystem_effect_session_callback);
+}
+
static jint convertAudioMixToNative(JNIEnv *env,
AudioMix *nAudioMix,
@@ -1659,6 +1688,8 @@ static JNINativeMethod gMethods[] = {
(void *)android_media_AudioSystem_registerPolicyMixes},
{"native_register_dynamic_policy_callback", "()V",
(void *)android_media_AudioSystem_registerDynPolicyCallback},
+ {"native_register_effect_session_callback", "()V",
+ (void *)android_media_AudioSystem_registerEffectSessionCallback},
{"systemReady", "()I", (void *)android_media_AudioSystem_systemReady},
};
@@ -1766,6 +1797,10 @@ int register_android_media_AudioSystem(JNIEnv *env)
GetStaticMethodIDOrDie(env, env->FindClass(kClassPathName),
"dynamicPolicyCallbackFromNative", "(ILjava/lang/String;I)V");
+ gEffectSessionEventHandlerMethods.postEffectSessionEventFromNative =
+ GetStaticMethodIDOrDie(env, env->FindClass(kClassPathName),
+ "effectSessionCallbackFromNative", "(IIIZ)V");
+
jclass audioMixClass = FindClassOrDie(env, "android/media/audiopolicy/AudioMix");
gAudioMixClass = MakeGlobalRefOrDie(env, audioMixClass);
gAudioMixFields.mRule = GetFieldIDOrDie(env, audioMixClass, "mRule",
diff --git a/core/jni/com_android_internal_content_NativeLibraryHelper.cpp b/core/jni/com_android_internal_content_NativeLibraryHelper.cpp
index c830ffd..91765f9 100644
--- a/core/jni/com_android_internal_content_NativeLibraryHelper.cpp
+++ b/core/jni/com_android_internal_content_NativeLibraryHelper.cpp
@@ -457,6 +457,10 @@ iterateOverNativeFiles(JNIEnv *env, jlong apkHandle, jstring javaCpuAbi,
static int findSupportedAbi(JNIEnv *env, jlong apkHandle, jobjectArray supportedAbisArray) {
const int numAbis = env->GetArrayLength(supportedAbisArray);
Vector<ScopedUtfChars*> supportedAbis;
+#ifdef PICK_SUPPORTED_ABI_WITH_MAX_LIBS
+ int numLibs[numAbis+1] = {0}; // +1 to avoid 0 sized array
+ int maxLibs = 0;
+#endif
for (int i = 0; i < numAbis; ++i) {
supportedAbis.add(new ScopedUtfChars(env,
@@ -492,10 +496,20 @@ static int findSupportedAbi(JNIEnv *env, jlong apkHandle, jobjectArray supported
for (int i = 0; i < numAbis; i++) {
const ScopedUtfChars* abi = supportedAbis[i];
if (abi->size() == abiSize && !strncmp(abiOffset, abi->c_str(), abiSize)) {
- // The entry that comes in first (i.e. with a lower index) has the higher priority.
- if (((i < status) && (status >= 0)) || (status < 0) ) {
+#ifdef PICK_SUPPORTED_ABI_WITH_MAX_LIBS
+ numLibs[i]++;
+ if (numLibs[i] > maxLibs) {
+ maxLibs = numLibs[i];
status = i;
+ } else if (numLibs[i] == maxLibs) {
+#endif
+ // The entry that comes in first (i.e. with a lower index) has the higher priority.
+ if (((i < status) && (status >= 0)) || (status < 0) ) {
+ status = i;
+ }
+#ifdef PICK_SUPPORTED_ABI_WITH_MAX_LIBS
}
+#endif
}
}
}
diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp
index aef70be..ac64edf 100644
--- a/core/jni/com_android_internal_os_Zygote.cpp
+++ b/core/jni/com_android_internal_os_Zygote.cpp
@@ -611,10 +611,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,