diff options
author | jgu21 <jinghui.gu@intel.com> | 2014-09-10 06:58:32 -0400 |
---|---|---|
committer | Andreas Gampe <agampe@google.com> | 2014-09-26 13:04:36 -0700 |
commit | b3facbfdecf46eb7c063b99529ab8c18a08a6b42 (patch) | |
tree | 5b02a2e8455391fe4f38b8e7442e16d71606f7ab /include | |
parent | 8dd3ea58fdd99912f631156c37bcb2555ce8aec3 (diff) | |
download | system_core-b3facbfdecf46eb7c063b99529ab8c18a08a6b42.zip system_core-b3facbfdecf46eb7c063b99529ab8c18a08a6b42.tar.gz system_core-b3facbfdecf46eb7c063b99529ab8c18a08a6b42.tar.bz2 |
LibNativeBridge: Add early init & env setup
Add a method to set up /proc/cpuinfo with enough privileges. Set
up the environment for an app in InitializeNativeBridge().
Turn on -Wall for libnativebridge.
(cherry picked from commit 962eb40abb68eb60077da158755b6a09c306aa41)
(cherry picked from commit ab0da5a9a6860046619629b8e6b83692d35dff86)
(cherry picked from commit 2f71cb24fa16c0388591918f1354d1f8608cc6e5)
(cherry picked from commit 04054e28e24866d76034236843490829b80df40c)
(cherry picked from commit 4390a632366ecf89af5f6c0fed39baf9aab2d0f1)
Bug: 17671501
Change-Id: Id4f4127d82737b5e56a77175e1068ff5cea60f9d
Diffstat (limited to 'include')
-rw-r--r-- | include/nativebridge/native_bridge.h | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/include/nativebridge/native_bridge.h b/include/nativebridge/native_bridge.h index 16939f1..ac254e9 100644 --- a/include/nativebridge/native_bridge.h +++ b/include/nativebridge/native_bridge.h @@ -19,18 +19,29 @@ #include "jni.h" #include <stdint.h> +#include <sys/types.h> namespace android { struct NativeBridgeRuntimeCallbacks; +struct NativeBridgeRuntimeValues; // Open the native bridge, if any. Should be called by Runtime::Init(). A null library filename // signals that we do not want to load a native bridge. bool LoadNativeBridge(const char* native_bridge_library_filename, const NativeBridgeRuntimeCallbacks* runtime_callbacks); -// Initialize the native bridge, if any. Should be called by Runtime::DidForkFromZygote. -bool InitializeNativeBridge(); +// Quick check whether a native bridge will be needed. This is based off of the instruction set +// of the process. +bool NeedsNativeBridge(const char* instruction_set); + +// Do the early initialization part of the native bridge, if necessary. This should be done under +// high privileges. +void PreInitializeNativeBridge(const char* app_data_dir, const char* instruction_set); + +// Initialize the native bridge, if any. Should be called by Runtime::DidForkFromZygote. The JNIEnv* +// will be used to modify the app environment for the bridge. +bool InitializeNativeBridge(JNIEnv* env, const char* instruction_set); // Unload the native bridge, if any. Should be called by Runtime::DidForkFromZygote. void UnloadNativeBridge(); @@ -65,6 +76,9 @@ bool NativeBridgeNameAcceptable(const char* native_bridge_library_filename); // Native bridge interfaces to runtime. struct NativeBridgeCallbacks { + // Version number of the interface. + uint32_t version; + // Initialize native bridge. Native bridge's internal implementation must ensure MT safety and // that the native bridge is initialized only once. Thus it is OK to call this interface for an // already initialized native bridge. @@ -73,7 +87,8 @@ struct NativeBridgeCallbacks { // runtime_cbs [IN] the pointer to NativeBridgeRuntimeCallbacks. // Returns: // true iff initialization was successful. - bool (*initialize)(const NativeBridgeRuntimeCallbacks* runtime_cbs); + bool (*initialize)(const NativeBridgeRuntimeCallbacks* runtime_cbs, const char* private_dir, + const char* instruction_set); // Load a shared library that is supported by the native bridge. // @@ -102,6 +117,16 @@ struct NativeBridgeCallbacks { // Returns: // TRUE if library is supported by native bridge, FALSE otherwise bool (*isSupported)(const char* libpath); + + // Provide environment values required by the app running with native bridge according to the + // instruction set. + // + // Parameters: + // instruction_set [IN] the instruction set of the app + // Returns: + // NULL if not supported by native bridge. + // Otherwise, return all environment values to be set after fork. + const struct NativeBridgeRuntimeValues* (*getAppEnv)(const char* instruction_set); }; // Runtime interfaces to native bridge. |