• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/corennnnn


Commit MetaInfo

修訂63c87a2ed725118b6183e302f9f780da2490b557 (tree)
時間2016-07-20 18:01:29
作者jgu21 <jinghui.gu@inte...>
CommiterChih-Wei Huang

Log Message

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

their APK, instead of lib/ dir.
Since Lollipop, PakcageManager needs clear ABI info during app
installation.
If the ABI is not supported, houdini has not chance to involve in.
For above kind of apps, houdini will not be loaded to help arm libs.
To support such kind of apps, we have to enable houdini even without
clear ABI info only for PRC market

2. Fix GTS case failure caused by above modification,

which enforce to set arm ABI for all pure java

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

Change Summary

差異

--- a/libnativebridge/Android.mk
+++ b/libnativebridge/Android.mk
@@ -14,6 +14,9 @@ LOCAL_SHARED_LIBRARIES := liblog
1414 LOCAL_CLANG := true
1515 LOCAL_CPP_EXTENSION := .cc
1616 LOCAL_CFLAGS += -Werror -Wall
17+ifeq ($(COMPATIBILITY_ENHANCEMENT_HOUDINI), true)
18+ LOCAL_CFLAGS += -D_COMPATIBILITY_ENHANCEMENT_HOUDINI_
19+endif
1720 LOCAL_CPPFLAGS := -std=gnu++11 -fvisibility=protected
1821 LOCAL_LDFLAGS := -ldl
1922 LOCAL_MULTILIB := both
--- a/libnativebridge/native_bridge.cc
+++ b/libnativebridge/native_bridge.cc
@@ -98,6 +98,10 @@ static constexpr const char* kCodeCacheDir = "code_cache";
9898
9999 static constexpr uint32_t kLibNativeBridgeVersion = 2;
100100
101+#ifdef _COMPATIBILITY_ENHANCEMENT_HOUDINI_
102+static bool null_instruction_set = false;
103+#endif
104+
101105 // Characters allowed in a native bridge filename. The first character must
102106 // be in [a-zA-Z] (expected 'l' for "libx"). The rest must be in [a-zA-Z0-9._-].
103107 static bool CharacterAllowed(char c, bool first) {
@@ -244,8 +248,14 @@ static const char* kRuntimeISA = "unknown";
244248
245249 bool NeedsNativeBridge(const char* instruction_set) {
246250 if (instruction_set == nullptr) {
251+
252+#ifdef _COMPATIBILITY_ENHANCEMENT_HOUDINI_
253+ null_instruction_set = true;
254+ return true;
255+#else
247256 ALOGE("Null instruction set in NeedsNativeBridge.");
248257 return false;
258+#endif
249259 }
250260 return strncmp(instruction_set, kRuntimeISA, strlen(kRuntimeISA) + 1) != 0;
251261 }
@@ -261,6 +271,15 @@ bool PreInitializeNativeBridge(const char* app_data_dir_in, const char* instruct
261271 return false;
262272 }
263273
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
264283 if (app_data_dir_in == nullptr) {
265284 ALOGE("Application private directory cannot be null.");
266285 CloseNativeBridge(true);
@@ -272,13 +291,18 @@ bool PreInitializeNativeBridge(const char* app_data_dir_in, const char* instruct
272291 const size_t len = strlen(app_data_dir_in) + strlen(kCodeCacheDir) + 2; // '\0' + '/'
273292 app_code_cache_dir = new char[len];
274293 snprintf(app_code_cache_dir, len, "%s/%s", app_data_dir_in, kCodeCacheDir);
294+#endif
275295
276296 // Bind-mount /system/lib{,64}/<isa>/cpuinfo to /proc/cpuinfo.
277297 // Failure is not fatal and will keep the native bridge in kPreInitialized.
278298 state = NativeBridgeState::kPreInitialized;
279299
280300 #ifndef __APPLE__
301+#ifdef _COMPATIBILITY_ENHANCEMENT_HOUDINI_
302+ if (null_instruction_set || instruction_set == nullptr || app_data_dir_in == nullptr) {
303+#else
281304 if (instruction_set == nullptr) {
305+#endif
282306 return true;
283307 }
284308 size_t isa_len = strlen(instruction_set);
@@ -407,6 +431,9 @@ bool InitializeNativeBridge(JNIEnv* env, const char* instruction_set) {
407431 // point we are not multi-threaded, so we do not need locking here.
408432
409433 if (state == NativeBridgeState::kPreInitialized) {
434+#ifdef _COMPATIBILITY_ENHANCEMENT_HOUDINI_
435+ if (app_code_cache_dir != nullptr) {
436+#endif
410437 // Check for code cache: if it doesn't exist try to create it.
411438 struct stat st;
412439 if (stat(app_code_cache_dir, &st) == -1) {
@@ -423,11 +450,20 @@ bool InitializeNativeBridge(JNIEnv* env, const char* instruction_set) {
423450 ALOGW("Code cache is not a directory %s.", app_code_cache_dir);
424451 ReleaseAppCodeCacheDir();
425452 }
453+#ifdef _COMPATIBILITY_ENHANCEMENT_HOUDINI_
454+ }
455+#endif
426456
427457 // If we're still PreInitialized (dind't fail the code cache checks) try to initialize.
428458 if (state == NativeBridgeState::kPreInitialized) {
429459 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
430465 SetupEnvironment(callbacks, env, instruction_set);
466+#endif
431467 state = NativeBridgeState::kInitialized;
432468 // We no longer need the code cache path, release the memory.
433469 ReleaseAppCodeCacheDir();