system/corennnnn
修訂 | 63c87a2ed725118b6183e302f9f780da2490b557 (tree) |
---|---|
時間 | 2016-07-20 18:01:29 |
作者 | jgu21 <jinghui.gu@inte...> |
Commiter | Chih-Wei Huang |
core: Enable houdini to Support the apps which put all libs under assets dir.
1. Many apps in PRC market put all arm native libs under assets/ dir in
2. Fix GTS case failure caused by above modification,
NOTE: Must merged together with https://android.intel.com/449222
Change-Id: I6d8cd263e3463f8e938b30f27e5db414eb2c96e9
Tracked-On: https://jira01.devtools.intel.com/browse/OAM-12442
Signed-off-by: jgu21 <jinghui.gu@intel.com>
Signed-off-by: Zhou,KaiX K <kaix.k.zhou@intel.com>
Reviewed-on: https://android.intel.com:443/449223
@@ -14,6 +14,9 @@ LOCAL_SHARED_LIBRARIES := liblog | ||
14 | 14 | LOCAL_CLANG := true |
15 | 15 | LOCAL_CPP_EXTENSION := .cc |
16 | 16 | LOCAL_CFLAGS += -Werror -Wall |
17 | +ifeq ($(COMPATIBILITY_ENHANCEMENT_HOUDINI), true) | |
18 | + LOCAL_CFLAGS += -D_COMPATIBILITY_ENHANCEMENT_HOUDINI_ | |
19 | +endif | |
17 | 20 | LOCAL_CPPFLAGS := -std=gnu++11 -fvisibility=protected |
18 | 21 | LOCAL_LDFLAGS := -ldl |
19 | 22 | LOCAL_MULTILIB := both |
@@ -98,6 +98,10 @@ static constexpr const char* kCodeCacheDir = "code_cache"; | ||
98 | 98 | |
99 | 99 | static constexpr uint32_t kLibNativeBridgeVersion = 2; |
100 | 100 | |
101 | +#ifdef _COMPATIBILITY_ENHANCEMENT_HOUDINI_ | |
102 | +static bool null_instruction_set = false; | |
103 | +#endif | |
104 | + | |
101 | 105 | // Characters allowed in a native bridge filename. The first character must |
102 | 106 | // be in [a-zA-Z] (expected 'l' for "libx"). The rest must be in [a-zA-Z0-9._-]. |
103 | 107 | static bool CharacterAllowed(char c, bool first) { |
@@ -244,8 +248,14 @@ static const char* kRuntimeISA = "unknown"; | ||
244 | 248 | |
245 | 249 | bool NeedsNativeBridge(const char* instruction_set) { |
246 | 250 | if (instruction_set == nullptr) { |
251 | + | |
252 | +#ifdef _COMPATIBILITY_ENHANCEMENT_HOUDINI_ | |
253 | + null_instruction_set = true; | |
254 | + return true; | |
255 | +#else | |
247 | 256 | ALOGE("Null instruction set in NeedsNativeBridge."); |
248 | 257 | return false; |
258 | +#endif | |
249 | 259 | } |
250 | 260 | return strncmp(instruction_set, kRuntimeISA, strlen(kRuntimeISA) + 1) != 0; |
251 | 261 | } |
@@ -261,6 +271,15 @@ bool PreInitializeNativeBridge(const char* app_data_dir_in, const char* instruct | ||
261 | 271 | return false; |
262 | 272 | } |
263 | 273 | |
274 | +#ifdef _COMPATIBILITY_ENHANCEMENT_HOUDINI_ | |
275 | + if (app_data_dir_in != nullptr) { | |
276 | + // Create the path to the application code cache directory. | |
277 | + // The memory will be release after Initialization or when the native bridge is closed. | |
278 | + const size_t len = strlen(app_data_dir_in) + strlen(kCodeCacheDir) + 2; // '\0' + '/' | |
279 | + app_code_cache_dir = new char[len]; | |
280 | + snprintf(app_code_cache_dir, len, "%s/%s", app_data_dir_in, kCodeCacheDir); | |
281 | + } | |
282 | +#else | |
264 | 283 | if (app_data_dir_in == nullptr) { |
265 | 284 | ALOGE("Application private directory cannot be null."); |
266 | 285 | CloseNativeBridge(true); |
@@ -272,13 +291,18 @@ bool PreInitializeNativeBridge(const char* app_data_dir_in, const char* instruct | ||
272 | 291 | const size_t len = strlen(app_data_dir_in) + strlen(kCodeCacheDir) + 2; // '\0' + '/' |
273 | 292 | app_code_cache_dir = new char[len]; |
274 | 293 | snprintf(app_code_cache_dir, len, "%s/%s", app_data_dir_in, kCodeCacheDir); |
294 | +#endif | |
275 | 295 | |
276 | 296 | // Bind-mount /system/lib{,64}/<isa>/cpuinfo to /proc/cpuinfo. |
277 | 297 | // Failure is not fatal and will keep the native bridge in kPreInitialized. |
278 | 298 | state = NativeBridgeState::kPreInitialized; |
279 | 299 | |
280 | 300 | #ifndef __APPLE__ |
301 | +#ifdef _COMPATIBILITY_ENHANCEMENT_HOUDINI_ | |
302 | + if (null_instruction_set || instruction_set == nullptr || app_data_dir_in == nullptr) { | |
303 | +#else | |
281 | 304 | if (instruction_set == nullptr) { |
305 | +#endif | |
282 | 306 | return true; |
283 | 307 | } |
284 | 308 | size_t isa_len = strlen(instruction_set); |
@@ -407,6 +431,9 @@ bool InitializeNativeBridge(JNIEnv* env, const char* instruction_set) { | ||
407 | 431 | // point we are not multi-threaded, so we do not need locking here. |
408 | 432 | |
409 | 433 | if (state == NativeBridgeState::kPreInitialized) { |
434 | +#ifdef _COMPATIBILITY_ENHANCEMENT_HOUDINI_ | |
435 | + if (app_code_cache_dir != nullptr) { | |
436 | +#endif | |
410 | 437 | // Check for code cache: if it doesn't exist try to create it. |
411 | 438 | struct stat st; |
412 | 439 | if (stat(app_code_cache_dir, &st) == -1) { |
@@ -423,11 +450,20 @@ bool InitializeNativeBridge(JNIEnv* env, const char* instruction_set) { | ||
423 | 450 | ALOGW("Code cache is not a directory %s.", app_code_cache_dir); |
424 | 451 | ReleaseAppCodeCacheDir(); |
425 | 452 | } |
453 | +#ifdef _COMPATIBILITY_ENHANCEMENT_HOUDINI_ | |
454 | + } | |
455 | +#endif | |
426 | 456 | |
427 | 457 | // If we're still PreInitialized (dind't fail the code cache checks) try to initialize. |
428 | 458 | if (state == NativeBridgeState::kPreInitialized) { |
429 | 459 | if (callbacks->initialize(runtime_callbacks, app_code_cache_dir, instruction_set)) { |
460 | +#ifdef _COMPATIBILITY_ENHANCEMENT_HOUDINI_ | |
461 | + if (!null_instruction_set) { | |
462 | + SetupEnvironment(callbacks, env, instruction_set); | |
463 | + } | |
464 | +#else | |
430 | 465 | SetupEnvironment(callbacks, env, instruction_set); |
466 | +#endif | |
431 | 467 | state = NativeBridgeState::kInitialized; |
432 | 468 | // We no longer need the code cache path, release the memory. |
433 | 469 | ReleaseAppCodeCacheDir(); |