xref: /aosp_15_r20/frameworks/base/core/jni/com_android_internal_os_ZygoteInit.cpp (revision d57664e9bc4670b3ecf6748a746a57c557b6bc9e)
1 /*
2  * Copyright (C) 2017 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 #define LOG_TAG "Zygote"
18 
19 #include <android/graphics/jni_runtime.h>
20 #include <ui/GraphicBufferMapper.h>
21 
22 #include "core_jni_helpers.h"
23 
24 namespace {
25 
android_internal_os_ZygoteInit_nativePreloadAppProcessHALs(JNIEnv * env,jclass)26 void android_internal_os_ZygoteInit_nativePreloadAppProcessHALs(JNIEnv* env, jclass) {
27     android::GraphicBufferMapper::preloadHal();
28     // Add preloading here for other HALs that are (a) always passthrough, and
29     // (b) loaded by most app processes.
30 }
31 
android_internal_os_ZygoteInit_nativePreloadGraphicsDriver(JNIEnv * env,jclass)32 void android_internal_os_ZygoteInit_nativePreloadGraphicsDriver(JNIEnv* env, jclass) {
33     zygote_preload_graphics();
34 }
35 
36 const JNINativeMethod gMethods[] = {
37     { "nativePreloadAppProcessHALs", "()V",
38       (void*)android_internal_os_ZygoteInit_nativePreloadAppProcessHALs },
39     { "nativePreloadGraphicsDriver", "()V",
40       (void*)android_internal_os_ZygoteInit_nativePreloadGraphicsDriver },
41 };
42 
43 }  // anonymous namespace
44 
45 namespace android {
46 
register_com_android_internal_os_ZygoteInit(JNIEnv * env)47 int register_com_android_internal_os_ZygoteInit(JNIEnv* env) {
48     return RegisterMethodsOrDie(env, "com/android/internal/os/ZygoteInit",
49             gMethods, NELEM(gMethods));
50 }
51 
52 }  // namespace android
53