diff options
Diffstat (limited to 'core/jni')
-rw-r--r-- | core/jni/Android.mk | 7 | ||||
-rw-r--r-- | core/jni/AndroidRuntime.cpp | 2 | ||||
-rw-r--r-- | core/jni/android/opengl/util.cpp | 4 | ||||
-rw-r--r-- | core/jni/android_hardware_Camera.cpp | 39 | ||||
-rw-r--r-- | core/jni/android_hardware_SensorManager.cpp | 2 | ||||
-rw-r--r-- | core/jni/android_hardware_camera2_DngCreator.cpp | 43 | ||||
-rw-r--r-- | core/jni/android_opengl_GLES20.cpp | 148 | ||||
-rw-r--r-- | core/jni/android_util_AssetManager.cpp | 191 | ||||
-rw-r--r-- | core/jni/android_util_Process.cpp | 37 | ||||
-rw-r--r-- | core/jni/android_view_SurfaceControl.cpp | 46 | ||||
-rw-r--r-- | core/jni/com_android_internal_app_ActivityTrigger.cpp | 210 | ||||
-rw-r--r-- | core/jni/com_android_internal_content_NativeLibraryHelper.cpp | 2 | ||||
-rw-r--r-- | core/jni/com_android_internal_os_Zygote.cpp | 45 |
13 files changed, 458 insertions, 318 deletions
diff --git a/core/jni/Android.mk b/core/jni/Android.mk index c3e79dc..ad52bd6 100644 --- a/core/jni/Android.mk +++ b/core/jni/Android.mk @@ -20,6 +20,10 @@ ifneq ($(ENABLE_CPUSETS),) LOCAL_CFLAGS += -DENABLE_CPUSETS endif +ifneq ($(ENABLE_SCHED_BOOST),) + LOCAL_CFLAGS += -DENABLE_SCHED_BOOST +endif + LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES LOCAL_CFLAGS += -DU_USING_ICU_NAMESPACE=0 @@ -171,8 +175,7 @@ LOCAL_SRC_FILES:= \ com_android_internal_net_NetworkStatsFactory.cpp \ com_android_internal_os_Zygote.cpp \ com_android_internal_util_VirtualRefBasePtr.cpp \ - com_android_internal_view_animation_NativeInterpolatorFactoryHelper.cpp \ - com_android_internal_app_ActivityTrigger.cpp + com_android_internal_view_animation_NativeInterpolatorFactoryHelper.cpp LOCAL_C_INCLUDES += \ $(JNI_H_INCLUDE) \ diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp index f39d127..a715c5f 100644 --- a/core/jni/AndroidRuntime.cpp +++ b/core/jni/AndroidRuntime.cpp @@ -192,7 +192,6 @@ extern int register_com_android_internal_content_NativeLibraryHelper(JNIEnv *env extern int register_com_android_internal_net_NetworkStatsFactory(JNIEnv *env); extern int register_com_android_internal_os_Zygote(JNIEnv *env); extern int register_com_android_internal_util_VirtualRefBasePtr(JNIEnv *env); -extern int register_com_android_internal_app_ActivityTrigger(JNIEnv *env); static AndroidRuntime* gCurRuntime = NULL; @@ -1435,7 +1434,6 @@ static const RegJNIRec gRegJNI[] = { REG_JNI(register_android_animation_PropertyValuesHolder), REG_JNI(register_com_android_internal_content_NativeLibraryHelper), REG_JNI(register_com_android_internal_net_NetworkStatsFactory), - REG_JNI(register_com_android_internal_app_ActivityTrigger), }; /* diff --git a/core/jni/android/opengl/util.cpp b/core/jni/android/opengl/util.cpp index 40029bb..1bf861a 100644 --- a/core/jni/android/opengl/util.cpp +++ b/core/jni/android/opengl/util.cpp @@ -1088,8 +1088,8 @@ static jint etc1_getHeight(JNIEnv *env, jclass clazz, */ static JNINativeMethod gMatrixMethods[] = { - { "multiplyMM", "([FI[FI[FI)V", (void*)util_multiplyMM }, - { "multiplyMV", "([FI[FI[FI)V", (void*)util_multiplyMV }, + { "multiplyMM", "!([FI[FI[FI)V", (void*)util_multiplyMM }, + { "multiplyMV", "!([FI[FI[FI)V", (void*)util_multiplyMV }, }; static JNINativeMethod gVisibilityMethods[] = { diff --git a/core/jni/android_hardware_Camera.cpp b/core/jni/android_hardware_Camera.cpp index e22725b..4cf317e 100644 --- a/core/jni/android_hardware_Camera.cpp +++ b/core/jni/android_hardware_Camera.cpp @@ -488,6 +488,21 @@ static void android_hardware_Camera_setLongshot(JNIEnv *env, jobject thiz, jbool } } +static void android_hardware_Camera_stopLongshot(JNIEnv *env, jobject thiz) +{ + ALOGV("stopLongshot"); + JNICameraContext* context; + status_t rc; + sp<Camera> camera = get_native_camera(env, thiz, &context); + if (camera == 0) return; + + rc = camera->sendCommand(CAMERA_CMD_STOP_LONGSHOT, 0, 0); + + if (rc != NO_ERROR) { + jniThrowException(env, "java/lang/RuntimeException", "enabling longshot mode failed"); + } +} + static void android_hardware_Camera_sendHistogramData(JNIEnv *env, jobject thiz) { ALOGV("sendHistogramData" ); @@ -1050,6 +1065,18 @@ static void android_hardware_Camera_enableFocusMoveCallback(JNIEnv *env, jobject } } +static void android_hardware_Camera_sendVendorCommand(JNIEnv *env, jobject thiz, + jint cmd, jint arg1, jint arg2) +{ + ALOGV("sendVendorCommand"); + sp<Camera> camera = get_native_camera(env, thiz, NULL); + if (camera == 0) return; + + if (camera->sendCommand(cmd, arg1, arg2) != NO_ERROR) { + jniThrowRuntimeException(env, "sending vendor command failed"); + } +} + //------------------------------------------------- static JNINativeMethod camMethods[] = { @@ -1107,9 +1134,12 @@ static JNINativeMethod camMethods[] = { { "native_sendHistogramData", "()V", (void *)android_hardware_Camera_sendHistogramData }, - { "native_setLongshot", - "(Z)V", - (void *)android_hardware_Camera_setLongshot }, + { "native_setLongshot", + "(Z)V", + (void *)android_hardware_Camera_setLongshot }, + { "native_stopLongshot", + "()V", + (void *)android_hardware_Camera_stopLongshot }, { "native_setParameters", "(Ljava/lang/String;)V", (void *)android_hardware_Camera_setParameters }, @@ -1146,6 +1176,9 @@ static JNINativeMethod camMethods[] = { { "enableFocusMoveCallback", "(I)V", (void *)android_hardware_Camera_enableFocusMoveCallback}, + { "_sendVendorCommand", + "(III)V", + (void *)android_hardware_Camera_sendVendorCommand }, }; struct field { diff --git a/core/jni/android_hardware_SensorManager.cpp b/core/jni/android_hardware_SensorManager.cpp index ec56507..7d0afdc 100644 --- a/core/jni/android_hardware_SensorManager.cpp +++ b/core/jni/android_hardware_SensorManager.cpp @@ -138,7 +138,7 @@ nativeCreate (JNIEnv *env, jclass clazz, jstring opPackageName) { ScopedUtfChars opPackageNameUtf(env, opPackageName); - return (jlong) new SensorManager(String16(opPackageNameUtf.c_str())); + return (jlong) &SensorManager::getInstanceForPackage(String16(opPackageNameUtf.c_str())); } static jboolean diff --git a/core/jni/android_hardware_camera2_DngCreator.cpp b/core/jni/android_hardware_camera2_DngCreator.cpp index 261cd7c..8b69bbd 100644 --- a/core/jni/android_hardware_camera2_DngCreator.cpp +++ b/core/jni/android_hardware_camera2_DngCreator.cpp @@ -20,6 +20,7 @@ #include <string.h> #include <algorithm> #include <memory> +#include <vector> #include <utils/Log.h> #include <utils/Errors.h> @@ -1649,8 +1650,7 @@ static sp<TiffWriter> DngCreator_setup(JNIEnv* env, jobject thiz, uint32_t image lsmHeight = static_cast<uint32_t>(entry1.data.i32[1]); } - camera_metadata_entry entry2 = - results.find(ANDROID_STATISTICS_LENS_SHADING_MAP); + camera_metadata_entry entry2 = results.find(ANDROID_STATISTICS_LENS_SHADING_MAP); camera_metadata_entry entry = characteristics.find(ANDROID_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE); @@ -1675,6 +1675,45 @@ static sp<TiffWriter> DngCreator_setup(JNIEnv* env, jobject thiz, uint32_t image } } + + // Set up bad pixel correction list + camera_metadata_entry entry3 = characteristics.find(ANDROID_STATISTICS_HOT_PIXEL_MAP); + + if ((entry3.count % 2) != 0) { + ALOGE("%s: Hot pixel map contains odd number of values, cannot map to pairs!", + __FUNCTION__); + jniThrowRuntimeException(env, "failed to add hotpixel map."); + return nullptr; + } + + // Adjust the bad pixel coordinates to be relative to the origin of the active area DNG tag + std::vector<uint32_t> v; + for (size_t i = 0; i < entry3.count; i+=2) { + int32_t x = entry3.data.i32[i]; + int32_t y = entry3.data.i32[i + 1]; + x -= static_cast<int32_t>(xmin); + y -= static_cast<int32_t>(ymin); + if (x < 0 || y < 0 || static_cast<uint32_t>(x) >= width || + static_cast<uint32_t>(y) >= width) { + continue; + } + v.push_back(x); + v.push_back(y); + } + const uint32_t* badPixels = &v[0]; + uint32_t badPixelCount = v.size(); + + if (badPixelCount > 0) { + err = builder.addBadPixelListForMetadata(badPixels, badPixelCount, opcodeCfaLayout); + + if (err != OK) { + ALOGE("%s: Could not add hotpixel map.", __FUNCTION__); + jniThrowRuntimeException(env, "failed to add hotpixel map."); + return nullptr; + } + } + + size_t listSize = builder.getSize(); uint8_t opcodeListBuf[listSize]; err = builder.buildOpList(opcodeListBuf); diff --git a/core/jni/android_opengl_GLES20.cpp b/core/jni/android_opengl_GLES20.cpp index f9a0dfe..65331b0 100644 --- a/core/jni/android_opengl_GLES20.cpp +++ b/core/jni/android_opengl_GLES20.cpp @@ -6154,14 +6154,14 @@ static const char *classPathName = "android/opengl/GLES20"; static JNINativeMethod methods[] = { {"_nativeClassInit", "()V", (void*)nativeClassInit }, -{"glActiveTexture", "(I)V", (void *) android_glActiveTexture__I }, +{"glActiveTexture", "!(I)V", (void *) android_glActiveTexture__I }, {"glAttachShader", "(II)V", (void *) android_glAttachShader__II }, {"glBindAttribLocation", "(IILjava/lang/String;)V", (void *) android_glBindAttribLocation__IILjava_lang_String_2 }, -{"glBindBuffer", "(II)V", (void *) android_glBindBuffer__II }, +{"glBindBuffer", "!(II)V", (void *) android_glBindBuffer__II }, {"glBindFramebuffer", "(II)V", (void *) android_glBindFramebuffer__II }, {"glBindRenderbuffer", "(II)V", (void *) android_glBindRenderbuffer__II }, -{"glBindTexture", "(II)V", (void *) android_glBindTexture__II }, -{"glBlendColor", "(FFFF)V", (void *) android_glBlendColor__FFFF }, +{"glBindTexture", "!(II)V", (void *) android_glBindTexture__II }, +{"glBlendColor", "!(FFFF)V", (void *) android_glBlendColor__FFFF }, {"glBlendEquation", "(I)V", (void *) android_glBlendEquation__I }, {"glBlendEquationSeparate", "(II)V", (void *) android_glBlendEquationSeparate__II }, {"glBlendFunc", "(II)V", (void *) android_glBlendFunc__II }, @@ -6171,9 +6171,9 @@ static JNINativeMethod methods[] = { {"glCheckFramebufferStatus", "(I)I", (void *) android_glCheckFramebufferStatus__I }, {"glClear", "(I)V", (void *) android_glClear__I }, {"glClearColor", "(FFFF)V", (void *) android_glClearColor__FFFF }, -{"glClearDepthf", "(F)V", (void *) android_glClearDepthf__F }, -{"glClearStencil", "(I)V", (void *) android_glClearStencil__I }, -{"glColorMask", "(ZZZZ)V", (void *) android_glColorMask__ZZZZ }, +{"glClearDepthf", "!(F)V", (void *) android_glClearDepthf__F }, +{"glClearStencil", "!(I)V", (void *) android_glClearStencil__I }, +{"glColorMask", "!(ZZZZ)V", (void *) android_glColorMask__ZZZZ }, {"glCompileShader", "(I)V", (void *) android_glCompileShader__I }, {"glCompressedTexImage2D", "(IIIIIIILjava/nio/Buffer;)V", (void *) android_glCompressedTexImage2D__IIIIIIILjava_nio_Buffer_2 }, {"glCompressedTexSubImage2D", "(IIIIIIIILjava/nio/Buffer;)V", (void *) android_glCompressedTexSubImage2D__IIIIIIIILjava_nio_Buffer_2 }, @@ -6181,7 +6181,7 @@ static JNINativeMethod methods[] = { {"glCopyTexSubImage2D", "(IIIIIIII)V", (void *) android_glCopyTexSubImage2D__IIIIIIII }, {"glCreateProgram", "()I", (void *) android_glCreateProgram__ }, {"glCreateShader", "(I)I", (void *) android_glCreateShader__I }, -{"glCullFace", "(I)V", (void *) android_glCullFace__I }, +{"glCullFace", "!(I)V", (void *) android_glCullFace__I }, {"glDeleteBuffers", "(I[II)V", (void *) android_glDeleteBuffers__I_3II }, {"glDeleteBuffers", "(ILjava/nio/IntBuffer;)V", (void *) android_glDeleteBuffers__ILjava_nio_IntBuffer_2 }, {"glDeleteFramebuffers", "(I[II)V", (void *) android_glDeleteFramebuffers__I_3II }, @@ -6192,22 +6192,22 @@ static JNINativeMethod methods[] = { {"glDeleteShader", "(I)V", (void *) android_glDeleteShader__I }, {"glDeleteTextures", "(I[II)V", (void *) android_glDeleteTextures__I_3II }, {"glDeleteTextures", "(ILjava/nio/IntBuffer;)V", (void *) android_glDeleteTextures__ILjava_nio_IntBuffer_2 }, -{"glDepthFunc", "(I)V", (void *) android_glDepthFunc__I }, -{"glDepthMask", "(Z)V", (void *) android_glDepthMask__Z }, +{"glDepthFunc", "!(I)V", (void *) android_glDepthFunc__I }, +{"glDepthMask", "!(Z)V", (void *) android_glDepthMask__Z }, {"glDepthRangef", "(FF)V", (void *) android_glDepthRangef__FF }, {"glDetachShader", "(II)V", (void *) android_glDetachShader__II }, -{"glDisable", "(I)V", (void *) android_glDisable__I }, -{"glDisableVertexAttribArray", "(I)V", (void *) android_glDisableVertexAttribArray__I }, -{"glDrawArrays", "(III)V", (void *) android_glDrawArrays__III }, -{"glDrawElements", "(IIII)V", (void *) android_glDrawElements__IIII }, -{"glDrawElements", "(IIILjava/nio/Buffer;)V", (void *) android_glDrawElements__IIILjava_nio_Buffer_2 }, -{"glEnable", "(I)V", (void *) android_glEnable__I }, -{"glEnableVertexAttribArray", "(I)V", (void *) android_glEnableVertexAttribArray__I }, +{"glDisable", "!(I)V", (void *) android_glDisable__I }, +{"glDisableVertexAttribArray", "!(I)V", (void *) android_glDisableVertexAttribArray__I }, +{"glDrawArrays", "!(III)V", (void *) android_glDrawArrays__III }, +{"glDrawElements", "!(IIII)V", (void *) android_glDrawElements__IIII }, +{"glDrawElements", "!(IIILjava/nio/Buffer;)V", (void *) android_glDrawElements__IIILjava_nio_Buffer_2 }, +{"glEnable", "!(I)V", (void *) android_glEnable__I }, +{"glEnableVertexAttribArray", "!(I)V", (void *) android_glEnableVertexAttribArray__I }, {"glFinish", "()V", (void *) android_glFinish__ }, {"glFlush", "()V", (void *) android_glFlush__ }, {"glFramebufferRenderbuffer", "(IIII)V", (void *) android_glFramebufferRenderbuffer__IIII }, {"glFramebufferTexture2D", "(IIIII)V", (void *) android_glFramebufferTexture2D__IIIII }, -{"glFrontFace", "(I)V", (void *) android_glFrontFace__I }, +{"glFrontFace", "!(I)V", (void *) android_glFrontFace__I }, {"glGenBuffers", "(I[II)V", (void *) android_glGenBuffers__I_3II }, {"glGenBuffers", "(ILjava/nio/IntBuffer;)V", (void *) android_glGenBuffers__ILjava_nio_IntBuffer_2 }, {"glGenerateMipmap", "(I)V", (void *) android_glGenerateMipmap__I }, @@ -6232,12 +6232,12 @@ static JNINativeMethod methods[] = { {"glGetBooleanv", "(ILjava/nio/IntBuffer;)V", (void *) android_glGetBooleanv__ILjava_nio_IntBuffer_2 }, {"glGetBufferParameteriv", "(II[II)V", (void *) android_glGetBufferParameteriv__II_3II }, {"glGetBufferParameteriv", "(IILjava/nio/IntBuffer;)V", (void *) android_glGetBufferParameteriv__IILjava_nio_IntBuffer_2 }, -{"glGetError", "()I", (void *) android_glGetError__ }, -{"glGetFloatv", "(I[FI)V", (void *) android_glGetFloatv__I_3FI }, +{"glGetError", "!()I", (void *) android_glGetError__ }, +{"glGetFloatv", "!(I[FI)V", (void *) android_glGetFloatv__I_3FI }, {"glGetFloatv", "(ILjava/nio/FloatBuffer;)V", (void *) android_glGetFloatv__ILjava_nio_FloatBuffer_2 }, {"glGetFramebufferAttachmentParameteriv", "(III[II)V", (void *) android_glGetFramebufferAttachmentParameteriv__III_3II }, {"glGetFramebufferAttachmentParameteriv", "(IIILjava/nio/IntBuffer;)V", (void *) android_glGetFramebufferAttachmentParameteriv__IIILjava_nio_IntBuffer_2 }, -{"glGetIntegerv", "(I[II)V", (void *) android_glGetIntegerv__I_3II }, +{"glGetIntegerv", "!(I[II)V", (void *) android_glGetIntegerv__I_3II }, {"glGetIntegerv", "(ILjava/nio/IntBuffer;)V", (void *) android_glGetIntegerv__ILjava_nio_IntBuffer_2 }, {"glGetProgramiv", "(II[II)V", (void *) android_glGetProgramiv__II_3II }, {"glGetProgramiv", "(IILjava/nio/IntBuffer;)V", (void *) android_glGetProgramiv__IILjava_nio_IntBuffer_2 }, @@ -6282,16 +6282,16 @@ static JNINativeMethod methods[] = { {"glReleaseShaderCompiler", "()V", (void *) android_glReleaseShaderCompiler__ }, {"glRenderbufferStorage", "(IIII)V", (void *) android_glRenderbufferStorage__IIII }, {"glSampleCoverage", "(FZ)V", (void *) android_glSampleCoverage__FZ }, -{"glScissor", "(IIII)V", (void *) android_glScissor__IIII }, +{"glScissor", "!(IIII)V", (void *) android_glScissor__IIII }, {"glShaderBinary", "(I[IIILjava/nio/Buffer;I)V", (void *) android_glShaderBinary__I_3IIILjava_nio_Buffer_2I }, {"glShaderBinary", "(ILjava/nio/IntBuffer;ILjava/nio/Buffer;I)V", (void *) android_glShaderBinary__ILjava_nio_IntBuffer_2ILjava_nio_Buffer_2I }, {"glShaderSource", "(ILjava/lang/String;)V", (void *) android_glShaderSource }, -{"glStencilFunc", "(III)V", (void *) android_glStencilFunc__III }, -{"glStencilFuncSeparate", "(IIII)V", (void *) android_glStencilFuncSeparate__IIII }, -{"glStencilMask", "(I)V", (void *) android_glStencilMask__I }, -{"glStencilMaskSeparate", "(II)V", (void *) android_glStencilMaskSeparate__II }, -{"glStencilOp", "(III)V", (void *) android_glStencilOp__III }, -{"glStencilOpSeparate", "(IIII)V", (void *) android_glStencilOpSeparate__IIII }, +{"glStencilFunc", "!(III)V", (void *) android_glStencilFunc__III }, +{"glStencilFuncSeparate", "!(IIII)V", (void *) android_glStencilFuncSeparate__IIII }, +{"glStencilMask", "!(I)V", (void *) android_glStencilMask__I }, +{"glStencilMaskSeparate", "!(II)V", (void *) android_glStencilMaskSeparate__II }, +{"glStencilOp", "!(III)V", (void *) android_glStencilOp__III }, +{"glStencilOpSeparate", "!(IIII)V", (void *) android_glStencilOpSeparate__IIII }, {"glTexImage2D", "(IIIIIIIILjava/nio/Buffer;)V", (void *) android_glTexImage2D__IIIIIIIILjava_nio_Buffer_2 }, {"glTexParameterf", "(IIF)V", (void *) android_glTexParameterf__IIF }, {"glTexParameterfv", "(II[FI)V", (void *) android_glTexParameterfv__II_3FI }, @@ -6300,53 +6300,53 @@ static JNINativeMethod methods[] = { {"glTexParameteriv", "(II[II)V", (void *) android_glTexParameteriv__II_3II }, {"glTexParameteriv", "(IILjava/nio/IntBuffer;)V", (void *) android_glTexParameteriv__IILjava_nio_IntBuffer_2 }, {"glTexSubImage2D", "(IIIIIIIILjava/nio/Buffer;)V", (void *) android_glTexSubImage2D__IIIIIIIILjava_nio_Buffer_2 }, -{"glUniform1f", "(IF)V", (void *) android_glUniform1f__IF }, -{"glUniform1fv", "(II[FI)V", (void *) android_glUniform1fv__II_3FI }, -{"glUniform1fv", "(IILjava/nio/FloatBuffer;)V", (void *) android_glUniform1fv__IILjava_nio_FloatBuffer_2 }, -{"glUniform1i", "(II)V", (void *) android_glUniform1i__II }, -{"glUniform1iv", "(II[II)V", (void *) android_glUniform1iv__II_3II }, -{"glUniform1iv", "(IILjava/nio/IntBuffer;)V", (void *) android_glUniform1iv__IILjava_nio_IntBuffer_2 }, -{"glUniform2f", "(IFF)V", (void *) android_glUniform2f__IFF }, -{"glUniform2fv", "(II[FI)V", (void *) android_glUniform2fv__II_3FI }, -{"glUniform2fv", "(IILjava/nio/FloatBuffer;)V", (void *) android_glUniform2fv__IILjava_nio_FloatBuffer_2 }, -{"glUniform2i", "(III)V", (void *) android_glUniform2i__III }, -{"glUniform2iv", "(II[II)V", (void *) android_glUniform2iv__II_3II }, -{"glUniform2iv", "(IILjava/nio/IntBuffer;)V", (void *) android_glUniform2iv__IILjava_nio_IntBuffer_2 }, -{"glUniform3f", "(IFFF)V", (void *) android_glUniform3f__IFFF }, -{"glUniform3fv", "(II[FI)V", (void *) android_glUniform3fv__II_3FI }, -{"glUniform3fv", "(IILjava/nio/FloatBuffer;)V", (void *) android_glUniform3fv__IILjava_nio_FloatBuffer_2 }, -{"glUniform3i", "(IIII)V", (void *) android_glUniform3i__IIII }, -{"glUniform3iv", "(II[II)V", (void *) android_glUniform3iv__II_3II }, -{"glUniform3iv", "(IILjava/nio/IntBuffer;)V", (void *) android_glUniform3iv__IILjava_nio_IntBuffer_2 }, -{"glUniform4f", "(IFFFF)V", (void *) android_glUniform4f__IFFFF }, -{"glUniform4fv", "(II[FI)V", (void *) android_glUniform4fv__II_3FI }, -{"glUniform4fv", "(IILjava/nio/FloatBuffer;)V", (void *) android_glUniform4fv__IILjava_nio_FloatBuffer_2 }, -{"glUniform4i", "(IIIII)V", (void *) android_glUniform4i__IIIII }, -{"glUniform4iv", "(II[II)V", (void *) android_glUniform4iv__II_3II }, -{"glUniform4iv", "(IILjava/nio/IntBuffer;)V", (void *) android_glUniform4iv__IILjava_nio_IntBuffer_2 }, -{"glUniformMatrix2fv", "(IIZ[FI)V", (void *) android_glUniformMatrix2fv__IIZ_3FI }, -{"glUniformMatrix2fv", "(IIZLjava/nio/FloatBuffer;)V", (void *) android_glUniformMatrix2fv__IIZLjava_nio_FloatBuffer_2 }, -{"glUniformMatrix3fv", "(IIZ[FI)V", (void *) android_glUniformMatrix3fv__IIZ_3FI }, -{"glUniformMatrix3fv", "(IIZLjava/nio/FloatBuffer;)V", (void *) android_glUniformMatrix3fv__IIZLjava_nio_FloatBuffer_2 }, -{"glUniformMatrix4fv", "(IIZ[FI)V", (void *) android_glUniformMatrix4fv__IIZ_3FI }, -{"glUniformMatrix4fv", "(IIZLjava/nio/FloatBuffer;)V", (void *) android_glUniformMatrix4fv__IIZLjava_nio_FloatBuffer_2 }, -{"glUseProgram", "(I)V", (void *) android_glUseProgram__I }, +{"glUniform1f", "!(IF)V", (void *) android_glUniform1f__IF }, +{"glUniform1fv", "!(II[FI)V", (void *) android_glUniform1fv__II_3FI }, +{"glUniform1fv", "!(IILjava/nio/FloatBuffer;)V", (void *) android_glUniform1fv__IILjava_nio_FloatBuffer_2 }, +{"glUniform1i", "!(II)V", (void *) android_glUniform1i__II }, +{"glUniform1iv", "!(II[II)V", (void *) android_glUniform1iv__II_3II }, +{"glUniform1iv", "!(IILjava/nio/IntBuffer;)V", (void *) android_glUniform1iv__IILjava_nio_IntBuffer_2 }, +{"glUniform2f", "!(IFF)V", (void *) android_glUniform2f__IFF }, +{"glUniform2fv", "!(II[FI)V", (void *) android_glUniform2fv__II_3FI }, +{"glUniform2fv", "!(IILjava/nio/FloatBuffer;)V", (void *) android_glUniform2fv__IILjava_nio_FloatBuffer_2 }, +{"glUniform2i", "!(III)V", (void *) android_glUniform2i__III }, +{"glUniform2iv", "!(II[II)V", (void *) android_glUniform2iv__II_3II }, +{"glUniform2iv", "!(IILjava/nio/IntBuffer;)V", (void *) android_glUniform2iv__IILjava_nio_IntBuffer_2 }, +{"glUniform3f", "!(IFFF)V", (void *) android_glUniform3f__IFFF }, +{"glUniform3fv", "!(II[FI)V", (void *) android_glUniform3fv__II_3FI }, +{"glUniform3fv", "!(IILjava/nio/FloatBuffer;)V", (void *) android_glUniform3fv__IILjava_nio_FloatBuffer_2 }, +{"glUniform3i", "!(IIII)V", (void *) android_glUniform3i__IIII }, +{"glUniform3iv", "!(II[II)V", (void *) android_glUniform3iv__II_3II }, +{"glUniform3iv", "!(IILjava/nio/IntBuffer;)V", (void *) android_glUniform3iv__IILjava_nio_IntBuffer_2 }, +{"glUniform4f", "!(IFFFF)V", (void *) android_glUniform4f__IFFFF }, +{"glUniform4fv", "!(II[FI)V", (void *) android_glUniform4fv__II_3FI }, +{"glUniform4fv", "!(IILjava/nio/FloatBuffer;)V", (void *) android_glUniform4fv__IILjava_nio_FloatBuffer_2 }, +{"glUniform4i", "!(IIIII)V", (void *) android_glUniform4i__IIIII }, +{"glUniform4iv", "!(II[II)V", (void *) android_glUniform4iv__II_3II }, +{"glUniform4iv", "!(IILjava/nio/IntBuffer;)V", (void *) android_glUniform4iv__IILjava_nio_IntBuffer_2 }, +{"glUniformMatrix2fv", "!(IIZ[FI)V", (void *) android_glUniformMatrix2fv__IIZ_3FI }, +{"glUniformMatrix2fv", "!(IIZLjava/nio/FloatBuffer;)V", (void *) android_glUniformMatrix2fv__IIZLjava_nio_FloatBuffer_2 }, +{"glUniformMatrix3fv", "!(IIZ[FI)V", (void *) android_glUniformMatrix3fv__IIZ_3FI }, +{"glUniformMatrix3fv", "!(IIZLjava/nio/FloatBuffer;)V", (void *) android_glUniformMatrix3fv__IIZLjava_nio_FloatBuffer_2 }, +{"glUniformMatrix4fv", "!(IIZ[FI)V", (void *) android_glUniformMatrix4fv__IIZ_3FI }, +{"glUniformMatrix4fv", "!(IIZLjava/nio/FloatBuffer;)V", (void *) android_glUniformMatrix4fv__IIZLjava_nio_FloatBuffer_2 }, +{"glUseProgram", "!(I)V", (void *) android_glUseProgram__I }, {"glValidateProgram", "(I)V", (void *) android_glValidateProgram__I }, -{"glVertexAttrib1f", "(IF)V", (void *) android_glVertexAttrib1f__IF }, -{"glVertexAttrib1fv", "(I[FI)V", (void *) android_glVertexAttrib1fv__I_3FI }, -{"glVertexAttrib1fv", "(ILjava/nio/FloatBuffer;)V", (void *) android_glVertexAttrib1fv__ILjava_nio_FloatBuffer_2 }, -{"glVertexAttrib2f", "(IFF)V", (void *) android_glVertexAttrib2f__IFF }, -{"glVertexAttrib2fv", "(I[FI)V", (void *) android_glVertexAttrib2fv__I_3FI }, -{"glVertexAttrib2fv", "(ILjava/nio/FloatBuffer;)V", (void *) android_glVertexAttrib2fv__ILjava_nio_FloatBuffer_2 }, -{"glVertexAttrib3f", "(IFFF)V", (void *) android_glVertexAttrib3f__IFFF }, -{"glVertexAttrib3fv", "(I[FI)V", (void *) android_glVertexAttrib3fv__I_3FI }, -{"glVertexAttrib3fv", "(ILjava/nio/FloatBuffer;)V", (void *) android_glVertexAttrib3fv__ILjava_nio_FloatBuffer_2 }, -{"glVertexAttrib4f", "(IFFFF)V", (void *) android_glVertexAttrib4f__IFFFF }, -{"glVertexAttrib4fv", "(I[FI)V", (void *) android_glVertexAttrib4fv__I_3FI }, -{"glVertexAttrib4fv", "(ILjava/nio/FloatBuffer;)V", (void *) android_glVertexAttrib4fv__ILjava_nio_FloatBuffer_2 }, -{"glVertexAttribPointer", "(IIIZII)V", (void *) android_glVertexAttribPointer__IIIZII }, -{"glVertexAttribPointerBounds", "(IIIZILjava/nio/Buffer;I)V", (void *) android_glVertexAttribPointerBounds__IIIZILjava_nio_Buffer_2I }, -{"glViewport", "(IIII)V", (void *) android_glViewport__IIII }, +{"glVertexAttrib1f", "!(IF)V", (void *) android_glVertexAttrib1f__IF }, +{"glVertexAttrib1fv", "!(I[FI)V", (void *) android_glVertexAttrib1fv__I_3FI }, +{"glVertexAttrib1fv", "!(ILjava/nio/FloatBuffer;)V", (void *) android_glVertexAttrib1fv__ILjava_nio_FloatBuffer_2 }, +{"glVertexAttrib2f", "!(IFF)V", (void *) android_glVertexAttrib2f__IFF }, +{"glVertexAttrib2fv", "!(I[FI)V", (void *) android_glVertexAttrib2fv__I_3FI }, +{"glVertexAttrib2fv", "!(ILjava/nio/FloatBuffer;)V", (void *) android_glVertexAttrib2fv__ILjava_nio_FloatBuffer_2 }, +{"glVertexAttrib3f", "!(IFFF)V", (void *) android_glVertexAttrib3f__IFFF }, +{"glVertexAttrib3fv", "!(I[FI)V", (void *) android_glVertexAttrib3fv__I_3FI }, +{"glVertexAttrib3fv", "!(ILjava/nio/FloatBuffer;)V", (void *) android_glVertexAttrib3fv__ILjava_nio_FloatBuffer_2 }, +{"glVertexAttrib4f", "!(IFFFF)V", (void *) android_glVertexAttrib4f__IFFFF }, +{"glVertexAttrib4fv", "!(I[FI)V", (void *) android_glVertexAttrib4fv__I_3FI }, +{"glVertexAttrib4fv", "!(ILjava/nio/FloatBuffer;)V", (void *) android_glVertexAttrib4fv__ILjava_nio_FloatBuffer_2 }, +{"glVertexAttribPointer", "!(IIIZII)V", (void *) android_glVertexAttribPointer__IIIZII }, +{"glVertexAttribPointerBounds", "!(IIIZILjava/nio/Buffer;I)V", (void *) android_glVertexAttribPointerBounds__IIIZILjava_nio_Buffer_2I }, +{"glViewport", "!(IIII)V", (void *) android_glViewport__IIII }, }; int register_android_opengl_jni_GLES20(JNIEnv *_env) diff --git a/core/jni/android_util_AssetManager.cpp b/core/jni/android_util_AssetManager.cpp index dca04f5..6257265 100644 --- a/core/jni/android_util_AssetManager.cpp +++ b/core/jni/android_util_AssetManager.cpp @@ -520,24 +520,143 @@ static jint android_content_AssetManager_addAssetPath(JNIEnv* env, jobject clazz } static jint android_content_AssetManager_addOverlayPath(JNIEnv* env, jobject clazz, - jstring idmapPath) + jstring idmapPath, + jstring packagePath, + jstring resApkPath, jstring targetPkgPath, + jstring prefixPath) { ScopedUtfChars idmapPath8(env, idmapPath); if (idmapPath8.c_str() == NULL) { return 0; } + ScopedUtfChars packagePath8(env, packagePath); + if (packagePath8.c_str() == NULL) { + return 0; + } + + ScopedUtfChars resApkPath8(env, resApkPath); + if (resApkPath8.c_str() == NULL) { + return 0; + } + + ScopedUtfChars prefixPath8(env, prefixPath); + if (prefixPath8.c_str() == NULL) { + return 0; + } + + ScopedUtfChars targetPkgPath8(env, targetPkgPath); + if (targetPkgPath8.c_str() == NULL) { + return 0; + } + + AssetManager* am = assetManagerForJavaObject(env, clazz); + if (am == NULL) { + return 0; + } + + int32_t cookie; + bool res = am->addOverlayPath( + String8(idmapPath8.c_str()), + String8(packagePath8.c_str()), + &cookie, + String8(resApkPath8.c_str()), + String8(targetPkgPath8.c_str()), + String8(prefixPath8.c_str())); + + return (res) ? (jint)cookie : 0; +} + +static jint android_content_AssetManager_addCommonOverlayPath(JNIEnv* env, jobject clazz, + jstring packagePath, + jstring resApkPath, jstring prefixPath) +{ + ScopedUtfChars packagePath8(env, packagePath); + if (packagePath8.c_str() == NULL) { + return 0; + } + + ScopedUtfChars resApkPath8(env, resApkPath); + if (resApkPath8.c_str() == NULL) { + return 0; + } + + ScopedUtfChars prefixPath8(env, prefixPath); + if (prefixPath8.c_str() == NULL) { + return 0; + } + + if (!access(packagePath8.c_str(), R_OK) == 0 || + !access(resApkPath8.c_str(), R_OK) == 0) { + return 0; + } + AssetManager* am = assetManagerForJavaObject(env, clazz); if (am == NULL) { return 0; } int32_t cookie; - bool res = am->addOverlayPath(String8(idmapPath8.c_str()), &cookie); + bool res = am->addCommonOverlayPath(String8(packagePath8.c_str()), &cookie, + String8(resApkPath8.c_str()), + String8(prefixPath8.c_str())); return (res) ? (jint)cookie : 0; } +static jint android_content_AssetManager_addIconPath(JNIEnv* env, jobject clazz, + jstring packagePath, + jstring resApkPath, jstring prefixPath, + jint pkgIdOverride) +{ + ScopedUtfChars packagePath8(env, packagePath); + if (packagePath8.c_str() == NULL) { + return 0; + } + + ScopedUtfChars resApkPath8(env, resApkPath); + if (resApkPath8.c_str() == NULL) { + return 0; + } + + ScopedUtfChars prefixPath8(env, prefixPath); + if (prefixPath8.c_str() == NULL) { + return 0; + } + + AssetManager* am = assetManagerForJavaObject(env, clazz); + if (am == NULL) { + return 0; + } + + int32_t cookie; + bool res = am->addIconPath(String8(packagePath8.c_str()), &cookie, + String8(resApkPath8.c_str()), + String8(prefixPath8.c_str()), pkgIdOverride); + + return (res) ? (jint)cookie : 0; +} + +static jboolean android_content_AssetManager_removeOverlayPath(JNIEnv* env, jobject clazz, + jstring packageName, jint cookie) +{ + if (packageName == NULL) { + jniThrowException(env, "java/lang/NullPointerException", "packageName"); + return JNI_FALSE; + } + + AssetManager* am = assetManagerForJavaObject(env, clazz); + if (am == NULL) { + return JNI_FALSE; + } + + const char* name8 = env->GetStringUTFChars(packageName, NULL); + bool res = am->removeOverlayPath(String8(name8), cookie); + env->ReleaseStringUTFChars(packageName, name8); + + return res; +} + static jboolean android_content_AssetManager_isUpToDate(JNIEnv* env, jobject clazz) { AssetManager* am = assetManagerForJavaObject(env, clazz); @@ -1139,7 +1258,7 @@ static jboolean android_content_AssetManager_resolveAttrs(JNIEnv* env, jobject c const ResTable::bag_entry* defStyleStart = NULL; uint32_t defStyleTypeSetFlags = 0; ssize_t bagOff = defStyleRes != 0 - ? res.getBagLocked(defStyleRes, &defStyleStart, &defStyleTypeSetFlags) : -1; + ? res.getBagLocked(defStyleRes, &defStyleStart, &defStyleTypeSetFlags, true) : -1; defStyleTypeSetFlags |= defStyleBagTypeSetFlags; const ResTable::bag_entry* const defStyleEnd = defStyleStart + (bagOff >= 0 ? bagOff : 0); BagAttributeFinder defStyleAttrFinder(defStyleStart, defStyleEnd); @@ -1358,7 +1477,7 @@ static jboolean android_content_AssetManager_applyStyle(JNIEnv* env, jobject cla const ResTable::bag_entry* defStyleAttrStart = NULL; uint32_t defStyleTypeSetFlags = 0; ssize_t bagOff = defStyleRes != 0 - ? res.getBagLocked(defStyleRes, &defStyleAttrStart, &defStyleTypeSetFlags) : -1; + ? res.getBagLocked(defStyleRes, &defStyleAttrStart, &defStyleTypeSetFlags, true) : -1; defStyleTypeSetFlags |= defStyleBagTypeSetFlags; const ResTable::bag_entry* const defStyleAttrEnd = defStyleAttrStart + (bagOff >= 0 ? bagOff : 0); BagAttributeFinder defStyleAttrFinder(defStyleAttrStart, defStyleAttrEnd); @@ -1366,7 +1485,7 @@ static jboolean android_content_AssetManager_applyStyle(JNIEnv* env, jobject cla // Retrieve the style class bag, if requested. const ResTable::bag_entry* styleAttrStart = NULL; uint32_t styleTypeSetFlags = 0; - bagOff = style != 0 ? res.getBagLocked(style, &styleAttrStart, &styleTypeSetFlags) : -1; + bagOff = style != 0 ? res.getBagLocked(style, &styleAttrStart, &styleTypeSetFlags, true) : -1; styleTypeSetFlags |= styleBagTypeSetFlags; const ResTable::bag_entry* const styleAttrEnd = styleAttrStart + (bagOff >= 0 ? bagOff : 0); BagAttributeFinder styleAttrFinder(styleAttrStart, styleAttrEnd); @@ -1710,7 +1829,7 @@ static jint android_content_AssetManager_retrieveArray(JNIEnv* env, jobject claz const ResTable::bag_entry* arrayEnt = NULL; uint32_t arrayTypeSetFlags = 0; - ssize_t bagOff = res.getBagLocked(id, &arrayEnt, &arrayTypeSetFlags); + ssize_t bagOff = res.getBagLocked(id, &arrayEnt, &arrayTypeSetFlags, true); const ResTable::bag_entry* endArrayEnt = arrayEnt + (bagOff >= 0 ? bagOff : 0); @@ -2048,6 +2167,50 @@ static jint android_content_AssetManager_getGlobalAssetManagerCount(JNIEnv* env, return AssetManager::getGlobalCount(); } +static jint android_content_AssetManager_getBasePackageCount(JNIEnv* env, jobject clazz) +{ + AssetManager* am = assetManagerForJavaObject(env, clazz); + if (am == NULL) { + return JNI_FALSE; + } + + return am->getResources().getBasePackageCount(); +} + +static jstring android_content_AssetManager_getBasePackageName(JNIEnv* env, jobject clazz, + jint index) +{ + AssetManager* am = assetManagerForJavaObject(env, clazz); + if (am == NULL) { + return JNI_FALSE; + } + + String16 packageName(am->getBasePackageName(index)); + return env->NewString((const jchar*)packageName.string(), packageName.size()); +} + +static jstring android_content_AssetManager_getBaseResourcePackageName(JNIEnv* env, jobject clazz, + jint index) +{ + AssetManager* am = assetManagerForJavaObject(env, clazz); + if (am == NULL) { + return JNI_FALSE; + } + + String16 packageName(am->getResources().getBasePackageName(index)); + return env->NewString((const jchar*)packageName.string(), packageName.size()); +} + +static jint android_content_AssetManager_getBasePackageId(JNIEnv* env, jobject clazz, jint index) +{ + AssetManager* am = assetManagerForJavaObject(env, clazz); + if (am == NULL) { + return JNI_FALSE; + } + + return am->getResources().getBasePackageId(index); +} + // ---------------------------------------------------------------------------- /* @@ -2081,8 +2244,22 @@ static JNINativeMethod gAssetManagerMethods[] = { (void*) android_content_AssetManager_getAssetRemainingLength }, { "addAssetPathNative", "(Ljava/lang/String;)I", (void*) android_content_AssetManager_addAssetPath }, - { "addOverlayPathNative", "(Ljava/lang/String;)I", + { "addOverlayPathNative", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I", (void*) android_content_AssetManager_addOverlayPath }, + { "addCommonOverlayPathNative", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I", + (void*) android_content_AssetManager_addCommonOverlayPath }, + { "addIconPathNative", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)I", + (void*) android_content_AssetManager_addIconPath }, + { "removeOverlayPathNative", "(Ljava/lang/String;I)Z", + (void*) android_content_AssetManager_removeOverlayPath }, + { "getBasePackageCount", "()I", + (void*) android_content_AssetManager_getBasePackageCount }, + { "getBasePackageName", "(I)Ljava/lang/String;", + (void*) android_content_AssetManager_getBasePackageName }, + { "getBaseResourcePackageName", "(I)Ljava/lang/String;", + (void*) android_content_AssetManager_getBaseResourcePackageName }, + { "getBasePackageId", "(I)I", + (void*) android_content_AssetManager_getBasePackageId }, { "isUpToDate", "()Z", (void*) android_content_AssetManager_isUpToDate }, diff --git a/core/jni/android_util_Process.cpp b/core/jni/android_util_Process.cpp index ee8fb19..8967cf2 100644 --- a/core/jni/android_util_Process.cpp +++ b/core/jni/android_util_Process.cpp @@ -370,27 +370,40 @@ jint android_os_Process_getThreadPriority(JNIEnv* env, jobject clazz, return pri; } +static bool memcgSupported = false; +static int memcgTasksFd = -1; +static int memcgSwapTasksFd = -1; +static pthread_once_t memcgInitOnce = PTHREAD_ONCE_INIT; + +static void memcgInit(void) { + if (!access("/sys/fs/cgroup/memory/tasks", F_OK)) { + memcgTasksFd = open("/sys/fs/cgroup/memory/tasks", O_WRONLY); + if (memcgTasksFd < 0) { + return; + } + memcgSwapTasksFd = open("/sys/fs/cgroup/memory/sw/tasks", O_WRONLY); + if (memcgSwapTasksFd < 0) { + close(memcgTasksFd); + return; + } + memcgSupported = true; + } +} + jboolean android_os_Process_setSwappiness(JNIEnv *env, jobject clazz, jint pid, jboolean is_increased) { - char text[64]; - - if (is_increased) { - strcpy(text, "/sys/fs/cgroup/memory/sw/tasks"); - } else { - strcpy(text, "/sys/fs/cgroup/memory/tasks"); - } - - struct stat st; - if (stat(text, &st) || !S_ISREG(st.st_mode)) { + pthread_once(&memcgInitOnce, memcgInit); + if (!memcgSupported) { return false; } - int fd = open(text, O_WRONLY); + int fd = is_increased ? memcgSwapTasksFd : memcgTasksFd; + char text[64]; + if (fd >= 0) { sprintf(text, "%" PRId32, pid); write(fd, text, strlen(text)); - close(fd); } return true; diff --git a/core/jni/android_view_SurfaceControl.cpp b/core/jni/android_view_SurfaceControl.cpp index 77af341..7156c0f 100644 --- a/core/jni/android_view_SurfaceControl.cpp +++ b/core/jni/android_view_SurfaceControl.cpp @@ -64,6 +64,7 @@ static struct { jfieldID secure; jfieldID appVsyncOffsetNanos; jfieldID presentationDeadlineNanos; + jfieldID colorTransform; } gPhysicalDisplayInfoClassInfo; static struct { @@ -315,6 +316,39 @@ static void nativeSetLayerStack(JNIEnv* env, jclass clazz, jlong nativeObject, j } } +static void nativeSetBlur(JNIEnv* env, jclass clazz, jlong nativeObject, jfloat blur) { + SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); + status_t err = ctrl->setBlur(blur); + if (err < 0 && err != NO_INIT) { + doThrowIAE(env); + } +} + +static void nativeSetBlurMaskSurface(JNIEnv* env, jclass clazz, jlong nativeObject, jlong maskLayerNativeObject) { + SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); + SurfaceControl* const maskLayer = reinterpret_cast<SurfaceControl *>(maskLayerNativeObject); + status_t err = ctrl->setBlurMaskSurface(maskLayer); + if (err < 0 && err != NO_INIT) { + doThrowIAE(env); + } +} + +static void nativeSetBlurMaskSampling(JNIEnv* env, jclass clazz, jlong nativeObject, jint blurMaskSampling) { + SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); + status_t err = ctrl->setBlurMaskSampling(blurMaskSampling); + if (err < 0 && err != NO_INIT) { + doThrowIAE(env); + } +} + +static void nativeSetBlurMaskAlphaThreshold(JNIEnv* env, jclass clazz, jlong nativeObject, jfloat alpha) { + SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); + status_t err = ctrl->setBlurMaskAlphaThreshold(alpha); + if (err < 0 && err != NO_INIT) { + doThrowIAE(env); + } +} + static jobject nativeGetBuiltInDisplay(JNIEnv* env, jclass clazz, jint id) { sp<IBinder> token(SurfaceComposerClient::getBuiltInDisplay(id)); return javaObjectForIBinder(env, token); @@ -401,6 +435,8 @@ static jobjectArray nativeGetDisplayConfigs(JNIEnv* env, jclass clazz, info.appVsyncOffset); env->SetLongField(infoObj, gPhysicalDisplayInfoClassInfo.presentationDeadlineNanos, info.presentationDeadline); + env->SetIntField(infoObj, gPhysicalDisplayInfoClassInfo.colorTransform, + info.colorTransform); env->SetObjectArrayElement(configArray, static_cast<jsize>(c), infoObj); env->DeleteLocalRef(infoObj); } @@ -611,6 +647,14 @@ static JNINativeMethod sSurfaceControlMethods[] = { (void*)nativeSetWindowCrop }, {"nativeSetLayerStack", "(JI)V", (void*)nativeSetLayerStack }, + {"nativeSetBlur", "(JF)V", + (void*)nativeSetBlur }, + {"nativeSetBlurMaskSurface", "(JJ)V", + (void*)nativeSetBlurMaskSurface }, + {"nativeSetBlurMaskSampling", "(JI)V", + (void*)nativeSetBlurMaskSampling }, + {"nativeSetBlurMaskAlphaThreshold", "(JF)V", + (void*)nativeSetBlurMaskAlphaThreshold }, {"nativeGetBuiltInDisplay", "(I)Landroid/os/IBinder;", (void*)nativeGetBuiltInDisplay }, {"nativeCreateDisplay", "(Ljava/lang/String;Z)Landroid/os/IBinder;", @@ -663,6 +707,8 @@ int register_android_view_SurfaceControl(JNIEnv* env) clazz, "appVsyncOffsetNanos", "J"); gPhysicalDisplayInfoClassInfo.presentationDeadlineNanos = GetFieldIDOrDie(env, clazz, "presentationDeadlineNanos", "J"); + gPhysicalDisplayInfoClassInfo.colorTransform = GetFieldIDOrDie(env, clazz, + "colorTransform", "I"); jclass rectClazz = FindClassOrDie(env, "android/graphics/Rect"); gRectClassInfo.bottom = GetFieldIDOrDie(env, rectClazz, "bottom", "I"); diff --git a/core/jni/com_android_internal_app_ActivityTrigger.cpp b/core/jni/com_android_internal_app_ActivityTrigger.cpp deleted file mode 100644 index 8ba9e06d..0000000 --- a/core/jni/com_android_internal_app_ActivityTrigger.cpp +++ /dev/null @@ -1,210 +0,0 @@ -/* Copyright (c) 2015, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#define LOG_TAG "ActTriggerJNI" - -#include "jni.h" -#include "JNIHelp.h" -#include <android_runtime/AndroidRuntime.h> - -#include <dlfcn.h> -#include <limits.h> -#include <string.h> - -#include <cutils/properties.h> -#include <utils/Log.h> - -#define LIBRARY_PATH_PREFIX "/vendor/lib/" - -namespace android -{ - -// ---------------------------------------------------------------------------- -/* - * Stuct containing handle to dynamically loaded lib as well as function - * pointers to key interfaces. - */ -typedef struct dlLibHandler { - void *dlhandle; - void (*startActivity)(const char *, int *); - void (*resumeActivity)(const char *); - void (*init)(void); - void (*deinit)(void); - const char *dlname; -}dlLibHandler; - -/* - * Array of dlhandlers - * library -both handlers for Start and Resume events. - */ -static dlLibHandler mDlLibHandlers[] = { - {NULL, NULL, NULL, NULL, NULL, - "ro.vendor.at_library"}, - {NULL, NULL, NULL, NULL, NULL, - "ro.vendor.gt_library"}, - {NULL, NULL, NULL, NULL, NULL, - "ro.vendor.wl_library"} -}; - -// ---------------------------------------------------------------------------- - -static void -com_android_internal_app_ActivityTrigger_native_at_init() -{ - const char *rc; - char buf[PROPERTY_VALUE_MAX]; - bool errored = false; - size_t numlibs = 0; - - numlibs = sizeof (mDlLibHandlers) / sizeof (*mDlLibHandlers); - - for(size_t i = 0; i < numlibs; i++) { - errored = false; - - /* Retrieve name of vendor library */ - if (property_get(mDlLibHandlers[i].dlname, buf, NULL) <= 0) { - continue; - } - - /* Sanity check - ensure */ - buf[PROPERTY_VALUE_MAX-1] = '\0'; - if (strstr(buf, "/") != NULL) { - continue; - } - - mDlLibHandlers[i].dlhandle = dlopen(buf, RTLD_NOW | RTLD_LOCAL); - if (mDlLibHandlers[i].dlhandle == NULL) { - continue; - } - - dlerror(); - - *(void **) (&mDlLibHandlers[i].startActivity) = dlsym(mDlLibHandlers[i].dlhandle, "activity_trigger_start"); - if ((rc = dlerror()) != NULL) { - errored = true; - } - - if (!errored) { - *(void **) (&mDlLibHandlers[i].resumeActivity) = dlsym(mDlLibHandlers[i].dlhandle, "activity_trigger_resume"); - if ((rc = dlerror()) != NULL) { - errored = true; - } - } - if (!errored) { - *(void **) (&mDlLibHandlers[i].init) = dlsym(mDlLibHandlers[i].dlhandle, "activity_trigger_init"); - if ((rc = dlerror()) != NULL) { - errored = true; - } - } - - if (errored) { - mDlLibHandlers[i].startActivity = NULL; - mDlLibHandlers[i].resumeActivity = NULL; - if (mDlLibHandlers[i].dlhandle) { - dlclose(mDlLibHandlers[i].dlhandle); - mDlLibHandlers[i].dlhandle = NULL; - } - } else { - (*mDlLibHandlers[i].init)(); - } - } -} - -static void -com_android_internal_app_ActivityTrigger_native_at_deinit(JNIEnv *env, jobject clazz) -{ - size_t numlibs = sizeof (mDlLibHandlers) / sizeof (*mDlLibHandlers); - - for(size_t i = 0; i < numlibs; i++) { - if (mDlLibHandlers[i].dlhandle) { - mDlLibHandlers[i].startActivity = NULL; - mDlLibHandlers[i].resumeActivity = NULL; - - *(void **) (&mDlLibHandlers[i].deinit) = dlsym(mDlLibHandlers[i].dlhandle, "activity_trigger_deinit"); - if (mDlLibHandlers[i].deinit) { - (*mDlLibHandlers[i].deinit)(); - } - - dlclose(mDlLibHandlers[i].dlhandle); - mDlLibHandlers[i].dlhandle = NULL; - } - } -} - -static jint -com_android_internal_app_ActivityTrigger_native_at_startActivity(JNIEnv *env, jobject clazz, jstring activity, jint flags) -{ - int activiyFlags = flags; - size_t numlibs = sizeof (mDlLibHandlers) / sizeof (*mDlLibHandlers); - for(size_t i = 0; i < numlibs; i++){ - if(mDlLibHandlers[i].startActivity && activity) { - const char *actStr = env->GetStringUTFChars(activity, NULL); - if (actStr) { - (*mDlLibHandlers[i].startActivity)(actStr, &activiyFlags); - env->ReleaseStringUTFChars(activity, actStr); - } - } - } - return activiyFlags; -} - -static void -com_android_internal_app_ActivityTrigger_native_at_resumeActivity(JNIEnv *env, jobject clazz, jstring activity) -{ - size_t numlibs = sizeof (mDlLibHandlers) / sizeof (*mDlLibHandlers); - - for(size_t i = 0; i < numlibs; i++){ - if(mDlLibHandlers[i].resumeActivity && activity) { - const char *actStr = env->GetStringUTFChars(activity, NULL); - if (actStr) { - (*mDlLibHandlers[i].resumeActivity)(actStr); - env->ReleaseStringUTFChars(activity, actStr); - } - } - } -} - -// ---------------------------------------------------------------------------- - -static JNINativeMethod gMethods[] = { - {"native_at_startActivity", "(Ljava/lang/String;I)I", (void *)com_android_internal_app_ActivityTrigger_native_at_startActivity}, - {"native_at_resumeActivity", "(Ljava/lang/String;)V", (void *)com_android_internal_app_ActivityTrigger_native_at_resumeActivity}, - {"native_at_deinit", "()V", (void *)com_android_internal_app_ActivityTrigger_native_at_deinit}, -}; - - -int register_com_android_internal_app_ActivityTrigger(JNIEnv *env) -{ - com_android_internal_app_ActivityTrigger_native_at_init(); - - return AndroidRuntime::registerNativeMethods(env, - "com/android/internal/app/ActivityTrigger", gMethods, NELEM(gMethods)); -} - -} // namespace android diff --git a/core/jni/com_android_internal_content_NativeLibraryHelper.cpp b/core/jni/com_android_internal_content_NativeLibraryHelper.cpp index e6e413d..c830ffd 100644 --- a/core/jni/com_android_internal_content_NativeLibraryHelper.cpp +++ b/core/jni/com_android_internal_content_NativeLibraryHelper.cpp @@ -511,7 +511,7 @@ static int findSupportedAbi(JNIEnv *env, jlong apkHandle, jobjectArray supported if (rc == LIB_INITED_AND_SUCCESS) { asset_status = GetAssetsStatusFunc(zipFile, supportedAbis, numAbis); } else { - ALOGE("Failed to load assets verifier: %d", rc); + ALOGV("Failed to load assets verifier: %d", rc); } if(asset_status >= 0) { // Override the ABI only if diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp index 7a725ae..aef70be 100644 --- a/core/jni/com_android_internal_os_Zygote.cpp +++ b/core/jni/com_android_internal_os_Zygote.cpp @@ -83,6 +83,14 @@ static void SigChldHandler(int /*signal_number*/) { pid_t pid; int status; + // It's necessary to save and restore the errno during this function. + // Since errno is stored per thread, changing it here modifies the errno + // on the thread on which this signal handler executes. If a signal occurs + // between a call and an errno check, it's possible to get the errno set + // here. + // See b/23572286 for extra information. + int saved_errno = errno; + while ((pid = waitpid(-1, &status, WNOHANG)) > 0) { // Log process-death status that we care about. In general it is // not safe to call LOG(...) from a signal handler because of @@ -118,6 +126,8 @@ static void SigChldHandler(int /*signal_number*/) { if (pid < 0 && errno != ECHILD) { ALOGW("Zygote SIGCHLD error in waitpid: %s", strerror(errno)); } + + errno = saved_errno; } // Configures the SIGCHLD handler for the zygote process. This is configured @@ -358,8 +368,8 @@ static void DetachDescriptors(JNIEnv* env, jintArray fdsToClose) { return; } jsize count = env->GetArrayLength(fdsToClose); - jint *ar = env->GetIntArrayElements(fdsToClose, 0); - if (!ar) { + ScopedIntArrayRO ar(env, fdsToClose); + if (ar.get() == NULL) { ALOGE("Bad fd array"); RuntimeAbort(env); } @@ -408,6 +418,27 @@ void SetThreadName(const char* thread_name) { } } +#ifdef ENABLE_SCHED_BOOST +static void SetForkLoad(bool boost) { + // set scheduler knob to boost forked processes + pid_t currentPid = getpid(); + // fits at most "/proc/XXXXXXX/sched_init_task_load\0" + char schedPath[35]; + snprintf(schedPath, sizeof(schedPath), "/proc/%u/sched_init_task_load", currentPid); + int schedBoostFile = open(schedPath, O_WRONLY); + if (schedBoostFile < 0) { + ALOGW("Unable to set zygote scheduler boost"); + return; + } + if (boost) { + write(schedBoostFile, "100\0", 4); + } else { + write(schedBoostFile, "0\0", 2); + } + close(schedBoostFile); +} +#endif + // Utility routine to fork zygote and specialize the child process. static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArray javaGids, jint debug_flags, jobjectArray javaRlimits, @@ -418,6 +449,10 @@ static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArra jstring instructionSet, jstring dataDir) { SetSigChldHandler(); +#ifdef ENABLE_SCHED_BOOST + SetForkLoad(true); +#endif + pid_t pid = fork(); if (pid == 0) { @@ -558,6 +593,12 @@ static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArra } } else if (pid > 0) { // the parent process + +#ifdef ENABLE_SCHED_BOOST + // unset scheduler knob + SetForkLoad(false); +#endif + } return pid; } |