1a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe/* 2a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe * Copyright (C) 2014 The Android Open Source Project 3a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe * 4a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe * Licensed under the Apache License, Version 2.0 (the "License"); 5a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe * you may not use this file except in compliance with the License. 6a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe * You may obtain a copy of the License at 7a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe * 8a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe * http://www.apache.org/licenses/LICENSE-2.0 9a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe * 10a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe * Unless required by applicable law or agreed to in writing, software 11a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe * distributed under the License is distributed on an "AS IS" BASIS, 12a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe * See the License for the specific language governing permissions and 14a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe * limitations under the License. 15a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe */ 16a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe 17a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe// A dummy implementation of the native-bridge interface. 18a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe 19a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe#include "nativebridge/native_bridge.h" 20a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe 21a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe#include <signal.h> 22a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe 23a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe// NativeBridgeCallbacks implementations 24a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampeextern "C" bool native_bridge2_initialize(const android::NativeBridgeRuntimeCallbacks* /* art_cbs */, 25a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe const char* /* app_code_cache_dir */, 26a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe const char* /* isa */) { 27a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe return true; 28a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe} 29a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe 30a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampeextern "C" void* native_bridge2_loadLibrary(const char* /* libpath */, int /* flag */) { 31a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe return nullptr; 32a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe} 33a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe 34a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampeextern "C" void* native_bridge2_getTrampoline(void* /* handle */, const char* /* name */, 35a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe const char* /* shorty */, uint32_t /* len */) { 36a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe return nullptr; 37a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe} 38a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe 39a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampeextern "C" bool native_bridge2_isSupported(const char* /* libpath */) { 40a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe return false; 41a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe} 42a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe 43a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampeextern "C" const struct android::NativeBridgeRuntimeValues* native_bridge2_getAppEnv( 44a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe const char* /* abi */) { 45a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe return nullptr; 46a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe} 47a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe 48a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampeextern "C" bool native_bridge2_is_compatible_compatible_with(uint32_t version) { 49a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe // For testing, allow 1 and 2, but disallow 3+. 50a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe return version <= 2; 51a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe} 52a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe 53a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampestatic bool native_bridge2_dummy_signal_handler(int, siginfo_t*, void*) { 54a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe // TODO: Implement something here. We'd either have to have a death test with a log here, or 55a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe // we'd have to be able to resume after the faulting instruction... 56a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe return true; 57a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe} 58a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe 59a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampeextern "C" android::NativeBridgeSignalHandlerFn native_bridge2_get_signal_handler(int signal) { 60a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe if (signal == SIGSEGV) { 61a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe return &native_bridge2_dummy_signal_handler; 62a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe } 63a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe return nullptr; 64a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe} 65a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe 66a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampeandroid::NativeBridgeCallbacks NativeBridgeItf { 67a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe .version = 2, 68a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe .initialize = &native_bridge2_initialize, 69a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe .loadLibrary = &native_bridge2_loadLibrary, 70a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe .getTrampoline = &native_bridge2_getTrampoline, 71a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe .isSupported = &native_bridge2_isSupported, 72a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe .getAppEnv = &native_bridge2_getAppEnv, 73a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe .isCompatibleWith = &native_bridge2_is_compatible_compatible_with, 74a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe .getSignalHandler = &native_bridge2_get_signal_handler 75a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe}; 76a6ac9ce98bd38099a4e89010111d14e4d5fc190eAndreas Gampe 77