blob: 5aa684d51a013434cbb1535f7c77bef7d963e50c [file] [log] [blame]
Tim Murray59f3dc12018-10-22 15:26:08 -07001/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "jni.h"
Tim Murray59f3dc12018-10-22 15:26:08 -070018#include <nativehelper/JNIHelp.h>
19
Tim Murray59f3dc12018-10-22 15:26:08 -070020#include "core_jni_helpers.h"
21#include <unistd.h>
22
Christopher Ferris8269f3a32019-09-11 19:08:52 -070023#include <bionic/malloc.h>
Derek Sollenbergereec1b862019-10-24 09:44:55 -040024#include <android/graphics/renderthread.h>
Ryan Savitskicfdc1512018-12-14 16:20:52 +000025
Tim Murray59f3dc12018-10-22 15:26:08 -070026namespace android {
27
28static void android_app_ActivityThread_purgePendingResources(JNIEnv* env, jobject clazz) {
29 // Don't care about return values.
30 mallopt(M_PURGE, 0);
31}
32
33static void
34android_app_ActivityThread_dumpGraphics(JNIEnv* env, jobject clazz, jobject javaFileDescriptor) {
35 int fd = jniGetFDFromFileDescriptor(env, javaFileDescriptor);
Derek Sollenbergereec1b862019-10-24 09:44:55 -040036 ARenderThread_dumpGraphicsMemory(fd);
Tim Murray59f3dc12018-10-22 15:26:08 -070037}
38
Ryan Savitskicfdc1512018-12-14 16:20:52 +000039static void android_app_ActivityThread_initZygoteChildHeapProfiling(JNIEnv* env, jobject clazz) {
40 android_mallopt(M_INIT_ZYGOTE_CHILD_PROFILING, nullptr, 0);
41}
Tim Murray59f3dc12018-10-22 15:26:08 -070042
43static JNINativeMethod gActivityThreadMethods[] = {
44 // ------------ Regular JNI ------------------
45 { "nPurgePendingResources", "()V",
46 (void*) android_app_ActivityThread_purgePendingResources },
47 { "nDumpGraphicsInfo", "(Ljava/io/FileDescriptor;)V",
Ryan Savitskicfdc1512018-12-14 16:20:52 +000048 (void*) android_app_ActivityThread_dumpGraphics },
49 { "nInitZygoteChildHeapProfiling", "()V",
50 (void*) android_app_ActivityThread_initZygoteChildHeapProfiling }
Tim Murray59f3dc12018-10-22 15:26:08 -070051};
52
53int register_android_app_ActivityThread(JNIEnv* env) {
54 return RegisterMethodsOrDie(env, "android/app/ActivityThread",
55 gActivityThreadMethods, NELEM(gActivityThreadMethods));
56}
57
58};