1 /* 2 * Copyright (C) 2023 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 "NativeBridge7CriticalNative_lib.h" 18 19 namespace android { 20 21 static bool g_legacy_get_trampoline_called = false; 22 static bool g_get_trampoline2_called = false; 23 static JNICallType g_jni_call_type = kJNICallTypeRegular; 24 25 static bool g_get_trampoline_fn_ptr_called = false; 26 static JNICallType g_fn_ptr_jni_call_type = kJNICallTypeRegular; 27 ResetTrampolineCalledState()28void ResetTrampolineCalledState() { 29 g_legacy_get_trampoline_called = false; 30 g_get_trampoline2_called = false; 31 g_jni_call_type = kJNICallTypeRegular; 32 } 33 SetLegacyGetTrampolineCalled()34void SetLegacyGetTrampolineCalled() { g_legacy_get_trampoline_called = true; } 35 IsLegacyGetTrampolineCalled()36bool IsLegacyGetTrampolineCalled() { return g_legacy_get_trampoline_called; } 37 SetGetTrampoline2Called(JNICallType jni_call_type)38void SetGetTrampoline2Called(JNICallType jni_call_type) { 39 g_get_trampoline2_called = true; 40 g_jni_call_type = jni_call_type; 41 } 42 IsGetTrampoline2Called()43bool IsGetTrampoline2Called() { return g_get_trampoline2_called; } 44 GetTrampoline2JNICallType()45JNICallType GetTrampoline2JNICallType() { return g_jni_call_type; } 46 SetGetTrampolineFnPtrCalled(JNICallType jni_call_type)47void SetGetTrampolineFnPtrCalled(JNICallType jni_call_type) { 48 g_get_trampoline_fn_ptr_called = true; 49 g_fn_ptr_jni_call_type = jni_call_type; 50 } 51 IsGetTrampolineFnPtrCalled()52bool IsGetTrampolineFnPtrCalled() { return g_get_trampoline_fn_ptr_called; } 53 GetTrampolineFnPtrJNICallType()54JNICallType GetTrampolineFnPtrJNICallType() { return g_fn_ptr_jni_call_type; } 55 56 } // namespace android 57