blob: 93f2525eb29d5c971fa8d9fd3c3a2689ae7c15d6 [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"
18#include "GraphicsJNI.h"
19#include <nativehelper/JNIHelp.h>
20
21#include <minikin/Layout.h>
22#include <renderthread/RenderProxy.h>
23
24#include "core_jni_helpers.h"
25#include <unistd.h>
26
Ryan Savitskicfdc1512018-12-14 16:20:52 +000027#include <bionic_malloc.h>
28
Tim Murray59f3dc12018-10-22 15:26:08 -070029namespace android {
30
31static void android_app_ActivityThread_purgePendingResources(JNIEnv* env, jobject clazz) {
32 // Don't care about return values.
33 mallopt(M_PURGE, 0);
34}
35
36static void
37android_app_ActivityThread_dumpGraphics(JNIEnv* env, jobject clazz, jobject javaFileDescriptor) {
38 int fd = jniGetFDFromFileDescriptor(env, javaFileDescriptor);
39 android::uirenderer::renderthread::RenderProxy::dumpGraphicsMemory(fd);
40 minikin::Layout::dumpMinikinStats(fd);
41}
42
Ryan Savitskicfdc1512018-12-14 16:20:52 +000043static void android_app_ActivityThread_initZygoteChildHeapProfiling(JNIEnv* env, jobject clazz) {
44 android_mallopt(M_INIT_ZYGOTE_CHILD_PROFILING, nullptr, 0);
45}
Tim Murray59f3dc12018-10-22 15:26:08 -070046
47static JNINativeMethod gActivityThreadMethods[] = {
48 // ------------ Regular JNI ------------------
49 { "nPurgePendingResources", "()V",
50 (void*) android_app_ActivityThread_purgePendingResources },
51 { "nDumpGraphicsInfo", "(Ljava/io/FileDescriptor;)V",
Ryan Savitskicfdc1512018-12-14 16:20:52 +000052 (void*) android_app_ActivityThread_dumpGraphics },
53 { "nInitZygoteChildHeapProfiling", "()V",
54 (void*) android_app_ActivityThread_initZygoteChildHeapProfiling }
Tim Murray59f3dc12018-10-22 15:26:08 -070055};
56
57int register_android_app_ActivityThread(JNIEnv* env) {
58 return RegisterMethodsOrDie(env, "android/app/ActivityThread",
59 gActivityThreadMethods, NELEM(gActivityThreadMethods));
60}
61
62};