Skip to content

Commit 2ddf6ea

Browse files
krutonAndroid (Google) Code Review
authored andcommitted
Merge "Fix issue with selecting proper JNI libraries" into ics-mr1
2 parents 2e282f3 + 10410fc commit 2ddf6ea

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

core/jni/com_android_internal_content_NativeLibraryHelper.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ iterateOverNativeFiles(JNIEnv *env, jstring javaFilePath, jstring javaCpuAbi, js
283283
const int N = zipFile.getNumEntries();
284284

285285
char fileName[PATH_MAX];
286+
bool hasPrimaryAbi = false;
286287

287288
for (int i = 0; i < N; i++) {
288289
const ZipEntryRO entry = zipFile.findEntryByIndex(i);
@@ -318,11 +319,22 @@ iterateOverNativeFiles(JNIEnv *env, jstring javaFilePath, jstring javaCpuAbi, js
318319
if (cpuAbi.size() == cpuAbiRegionSize
319320
&& *(cpuAbiOffset + cpuAbi.size()) == '/'
320321
&& !strncmp(cpuAbiOffset, cpuAbi.c_str(), cpuAbiRegionSize)) {
321-
LOGV("Using ABI %s\n", cpuAbi.c_str());
322+
LOGV("Using primary ABI %s\n", cpuAbi.c_str());
323+
hasPrimaryAbi = true;
322324
} else if (cpuAbi2.size() == cpuAbiRegionSize
323325
&& *(cpuAbiOffset + cpuAbi2.size()) == '/'
324326
&& !strncmp(cpuAbiOffset, cpuAbi2.c_str(), cpuAbiRegionSize)) {
325-
LOGV("Using ABI %s\n", cpuAbi2.c_str());
327+
328+
/*
329+
* If this library matches both the primary and secondary ABIs,
330+
* only use the primary ABI.
331+
*/
332+
if (hasPrimaryAbi) {
333+
LOGV("Already saw primary ABI, skipping secondary ABI %s\n", cpuAbi2.c_str());
334+
continue;
335+
} else {
336+
LOGV("Using secondary ABI %s\n", cpuAbi2.c_str());
337+
}
326338
} else {
327339
LOGV("abi didn't match anything: %s (end at %zd)\n", cpuAbiOffset, cpuAbiRegionSize);
328340
continue;

0 commit comments

Comments
 (0)