1 /*
2  * Copyright (C) 2011 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #define LOG_TAG "NativeLibraryHelper"
18 //#define LOG_NDEBUG 0
19 
20 #include <androidfw/ApkParsing.h>
21 #include <androidfw/ZipFileRO.h>
22 #include <androidfw/ZipUtils.h>
23 #include <errno.h>
24 #include <fcntl.h>
25 #include <inttypes.h>
26 #include <linux/fs.h>
27 #include <nativehelper/ScopedUtfChars.h>
28 #include <stdlib.h>
29 #include <string.h>
30 #include <sys/stat.h>
31 #include <sys/types.h>
32 #include <time.h>
33 #include <unistd.h>
34 #include <utils/Log.h>
35 #include <zlib.h>
36 
37 #include <memory>
38 
39 #include "core_jni_helpers.h"
40 
41 #define RS_BITCODE_SUFFIX ".bc"
42 
43 #define TMP_FILE_PATTERN "/tmp.XXXXXX"
44 #define TMP_FILE_PATTERN_LEN (sizeof(TMP_FILE_PATTERN) - 1)
45 
46 namespace android {
47 
48 // These match PackageManager.java install codes
49 enum install_status_t {
50     INSTALL_SUCCEEDED = 1,
51     INSTALL_FAILED_INVALID_APK = -2,
52     INSTALL_FAILED_INSUFFICIENT_STORAGE = -4,
53     INSTALL_FAILED_CONTAINER_ERROR = -18,
54     INSTALL_FAILED_INTERNAL_ERROR = -110,
55     INSTALL_FAILED_NO_MATCHING_ABIS = -113,
56     NO_NATIVE_LIBRARIES = -114
57 };
58 
59 typedef install_status_t (*iterFunc)(JNIEnv*, void*, ZipFileRO*, ZipEntryRO, const char*);
60 
61 static bool
isFileDifferent(const char * filePath,uint32_t fileSize,time_t modifiedTime,uint32_t zipCrc,struct stat64 * st)62 isFileDifferent(const char* filePath, uint32_t fileSize, time_t modifiedTime,
63         uint32_t zipCrc, struct stat64* st)
64 {
65     if (lstat64(filePath, st) < 0) {
66         // File is not found or cannot be read.
67         ALOGV("Couldn't stat %s, copying: %s\n", filePath, strerror(errno));
68         return true;
69     }
70 
71     if (!S_ISREG(st->st_mode)) {
72         return true;
73     }
74 
75     if (static_cast<uint64_t>(st->st_size) != static_cast<uint64_t>(fileSize)) {
76         return true;
77     }
78 
79     // For some reason, bionic doesn't define st_mtime as time_t
80     if (time_t(st->st_mtime) != modifiedTime) {
81         ALOGV("mod time doesn't match: %ld vs. %ld\n", st->st_mtime, modifiedTime);
82         return true;
83     }
84 
85     int fd = TEMP_FAILURE_RETRY(open(filePath, O_RDONLY | O_CLOEXEC));
86     if (fd < 0) {
87         ALOGV("Couldn't open file %s: %s", filePath, strerror(errno));
88         return true;
89     }
90 
91     // uLong comes from zlib.h. It's a bit of a wart that they're
92     // potentially using a 64-bit type for a 32-bit CRC.
93     uLong crc = crc32(0L, Z_NULL, 0);
94     unsigned char crcBuffer[16384];
95     ssize_t numBytes;
96     while ((numBytes = TEMP_FAILURE_RETRY(read(fd, crcBuffer, sizeof(crcBuffer)))) > 0) {
97         crc = crc32(crc, crcBuffer, numBytes);
98     }
99     close(fd);
100 
101     ALOGV("%s: crc = %lx, zipCrc = %" PRIu32 "\n", filePath, crc, zipCrc);
102 
103     if (crc != static_cast<uLong>(zipCrc)) {
104         return true;
105     }
106 
107     return false;
108 }
109 
110 static install_status_t
sumFiles(JNIEnv *,void * arg,ZipFileRO * zipFile,ZipEntryRO zipEntry,const char *)111 sumFiles(JNIEnv*, void* arg, ZipFileRO* zipFile, ZipEntryRO zipEntry, const char*)
112 {
113     size_t* total = (size_t*) arg;
114     uint32_t uncompLen;
115 
116     if (!zipFile->getEntryInfo(zipEntry, nullptr, &uncompLen, nullptr, nullptr, nullptr, nullptr)) {
117         return INSTALL_FAILED_INVALID_APK;
118     }
119 
120     *total += static_cast<size_t>(uncompLen);
121 
122     return INSTALL_SUCCEEDED;
123 }
124 
125 /*
126  * Copy the native library if needed.
127  *
128  * This function assumes the library and path names passed in are considered safe.
129  */
130 static install_status_t
copyFileIfChanged(JNIEnv * env,void * arg,ZipFileRO * zipFile,ZipEntryRO zipEntry,const char * fileName)131 copyFileIfChanged(JNIEnv *env, void* arg, ZipFileRO* zipFile, ZipEntryRO zipEntry, const char* fileName)
132 {
133     void** args = reinterpret_cast<void**>(arg);
134     jstring* javaNativeLibPath = (jstring*) args[0];
135     jboolean extractNativeLibs = *(jboolean*) args[1];
136 
137     ScopedUtfChars nativeLibPath(env, *javaNativeLibPath);
138 
139     uint32_t uncompLen;
140     uint32_t when;
141     uint32_t crc;
142 
143     uint16_t method;
144     off64_t offset;
145 
146     if (!zipFile->getEntryInfo(zipEntry, &method, &uncompLen, nullptr, &offset, &when, &crc)) {
147         ALOGE("Couldn't read zip entry info\n");
148         return INSTALL_FAILED_INVALID_APK;
149     }
150 
151     if (!extractNativeLibs) {
152         // check if library is uncompressed and page-aligned
153         if (method != ZipFileRO::kCompressStored) {
154             ALOGE("Library '%s' is compressed - will not be able to open it directly from apk.\n",
155                 fileName);
156             return INSTALL_FAILED_INVALID_APK;
157         }
158 
159         if (offset % PAGE_SIZE != 0) {
160             ALOGE("Library '%s' is not page-aligned - will not be able to open it directly from"
161                 " apk.\n", fileName);
162             return INSTALL_FAILED_INVALID_APK;
163         }
164 
165         return INSTALL_SUCCEEDED;
166     }
167 
168     // Build local file path
169     const size_t fileNameLen = strlen(fileName);
170     char localFileName[nativeLibPath.size() + fileNameLen + 2];
171 
172     if (strlcpy(localFileName, nativeLibPath.c_str(), sizeof(localFileName)) != nativeLibPath.size()) {
173         ALOGE("Couldn't allocate local file name for library");
174         return INSTALL_FAILED_INTERNAL_ERROR;
175     }
176 
177     *(localFileName + nativeLibPath.size()) = '/';
178 
179     if (strlcpy(localFileName + nativeLibPath.size() + 1, fileName, sizeof(localFileName)
180                     - nativeLibPath.size() - 1) != fileNameLen) {
181         ALOGE("Couldn't allocate local file name for library");
182         return INSTALL_FAILED_INTERNAL_ERROR;
183     }
184 
185     // Only copy out the native file if it's different.
186     struct tm t;
187     ZipUtils::zipTimeToTimespec(when, &t);
188     const time_t modTime = mktime(&t);
189     struct stat64 st;
190     if (!isFileDifferent(localFileName, uncompLen, modTime, crc, &st)) {
191         return INSTALL_SUCCEEDED;
192     }
193 
194     char localTmpFileName[nativeLibPath.size() + TMP_FILE_PATTERN_LEN + 1];
195     if (strlcpy(localTmpFileName, nativeLibPath.c_str(), sizeof(localTmpFileName))
196             != nativeLibPath.size()) {
197         ALOGE("Couldn't allocate local file name for library");
198         return INSTALL_FAILED_INTERNAL_ERROR;
199     }
200 
201     if (strlcpy(localTmpFileName + nativeLibPath.size(), TMP_FILE_PATTERN,
202                     TMP_FILE_PATTERN_LEN + 1) != TMP_FILE_PATTERN_LEN) {
203         ALOGE("Couldn't allocate temporary file name for library");
204         return INSTALL_FAILED_INTERNAL_ERROR;
205     }
206 
207     int fd = mkstemp(localTmpFileName);
208     if (fd < 0) {
209         ALOGE("Couldn't open temporary file name: %s: %s\n", localTmpFileName, strerror(errno));
210         return INSTALL_FAILED_CONTAINER_ERROR;
211     }
212 
213     // If a filesystem like f2fs supports per-file compression, set the compression bit before data
214     // writes
215     unsigned int flags;
216     if (ioctl(fd, FS_IOC_GETFLAGS, &flags) == -1) {
217         ALOGE("Failed to call FS_IOC_GETFLAGS on %s: %s\n", localTmpFileName, strerror(errno));
218     } else if ((flags & FS_COMPR_FL) == 0) {
219         flags |= FS_COMPR_FL;
220         ioctl(fd, FS_IOC_SETFLAGS, &flags);
221     }
222 
223     if (!zipFile->uncompressEntry(zipEntry, fd)) {
224         ALOGE("Failed uncompressing %s to %s\n", fileName, localTmpFileName);
225         close(fd);
226         unlink(localTmpFileName);
227         return INSTALL_FAILED_CONTAINER_ERROR;
228     }
229 
230     if (fsync(fd) < 0) {
231         ALOGE("Coulnd't fsync temporary file name: %s: %s\n", localTmpFileName, strerror(errno));
232         close(fd);
233         unlink(localTmpFileName);
234         return INSTALL_FAILED_INTERNAL_ERROR;
235     }
236 
237     close(fd);
238 
239     // Set the modification time for this file to the ZIP's mod time.
240     struct timeval times[2];
241     times[0].tv_sec = st.st_atime;
242     times[1].tv_sec = modTime;
243     times[0].tv_usec = times[1].tv_usec = 0;
244     if (utimes(localTmpFileName, times) < 0) {
245         ALOGE("Couldn't change modification time on %s: %s\n", localTmpFileName, strerror(errno));
246         unlink(localTmpFileName);
247         return INSTALL_FAILED_CONTAINER_ERROR;
248     }
249 
250     // Set the mode to 755
251     static const mode_t mode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP |  S_IXGRP | S_IROTH | S_IXOTH;
252     if (chmod(localTmpFileName, mode) < 0) {
253         ALOGE("Couldn't change permissions on %s: %s\n", localTmpFileName, strerror(errno));
254         unlink(localTmpFileName);
255         return INSTALL_FAILED_CONTAINER_ERROR;
256     }
257 
258     // Finally, rename it to the final name.
259     if (rename(localTmpFileName, localFileName) < 0) {
260         ALOGE("Couldn't rename %s to %s: %s\n", localTmpFileName, localFileName, strerror(errno));
261         unlink(localTmpFileName);
262         return INSTALL_FAILED_CONTAINER_ERROR;
263     }
264 
265     ALOGV("Successfully moved %s to %s\n", localTmpFileName, localFileName);
266 
267     return INSTALL_SUCCEEDED;
268 }
269 
270 /*
271  * An iterator over all shared libraries in a zip file. An entry is
272  * considered to be a shared library if all of the conditions below are
273  * satisfied :
274  *
275  * - The entry is under the lib/ directory.
276  * - The entry name ends with ".so" and the entry name starts with "lib",
277  *   an exception is made for entries whose name is "gdbserver".
278  * - The entry filename is "safe" (as determined by isFilenameSafe).
279  *
280  */
281 class NativeLibrariesIterator {
282 private:
NativeLibrariesIterator(ZipFileRO * zipFile,bool debuggable,void * cookie)283     NativeLibrariesIterator(ZipFileRO* zipFile, bool debuggable, void* cookie)
284           : mZipFile(zipFile), mDebuggable(debuggable), mCookie(cookie), mLastSlash(nullptr) {
285         fileName[0] = '\0';
286     }
287 
288 public:
create(ZipFileRO * zipFile,bool debuggable)289     static NativeLibrariesIterator* create(ZipFileRO* zipFile, bool debuggable) {
290         void* cookie = nullptr;
291         // Do not specify a suffix to find both .so files and gdbserver.
292         if (!zipFile->startIteration(&cookie, APK_LIB.data(), nullptr /* suffix */)) {
293             return nullptr;
294         }
295 
296         return new NativeLibrariesIterator(zipFile, debuggable, cookie);
297     }
298 
next()299     ZipEntryRO next() {
300         ZipEntryRO next = nullptr;
301         while ((next = mZipFile->nextEntry(mCookie)) != nullptr) {
302             // Make sure this entry has a filename.
303             if (mZipFile->getEntryFileName(next, fileName, sizeof(fileName))) {
304                 continue;
305             }
306 
307             const char* lastSlash = util::ValidLibraryPathLastSlash(fileName, false, mDebuggable);
308             if (lastSlash) {
309                 mLastSlash = lastSlash;
310                 break;
311             }
312         }
313 
314         return next;
315     }
316 
currentEntry() const317     inline const char* currentEntry() const {
318         return fileName;
319     }
320 
lastSlash() const321     inline const char* lastSlash() const {
322         return mLastSlash;
323     }
324 
~NativeLibrariesIterator()325     virtual ~NativeLibrariesIterator() {
326         mZipFile->endIteration(mCookie);
327     }
328 private:
329 
330     char fileName[PATH_MAX];
331     ZipFileRO* const mZipFile;
332     const bool mDebuggable;
333     void* mCookie;
334     const char* mLastSlash;
335 };
336 
337 static install_status_t
iterateOverNativeFiles(JNIEnv * env,jlong apkHandle,jstring javaCpuAbi,jboolean debuggable,iterFunc callFunc,void * callArg)338 iterateOverNativeFiles(JNIEnv *env, jlong apkHandle, jstring javaCpuAbi,
339                        jboolean debuggable, iterFunc callFunc, void* callArg) {
340     ZipFileRO* zipFile = reinterpret_cast<ZipFileRO*>(apkHandle);
341     if (zipFile == nullptr) {
342         return INSTALL_FAILED_INVALID_APK;
343     }
344 
345     std::unique_ptr<NativeLibrariesIterator> it(
346             NativeLibrariesIterator::create(zipFile, debuggable));
347     if (it.get() == nullptr) {
348         return INSTALL_FAILED_INVALID_APK;
349     }
350 
351     const ScopedUtfChars cpuAbi(env, javaCpuAbi);
352     if (cpuAbi.c_str() == nullptr) {
353         // This would've thrown, so this return code isn't observable by Java.
354         return INSTALL_FAILED_INVALID_APK;
355     }
356     ZipEntryRO entry = nullptr;
357     while ((entry = it->next()) != nullptr) {
358         const char* fileName = it->currentEntry();
359         const char* lastSlash = it->lastSlash();
360 
361         // Check to make sure the CPU ABI of this file is one we support.
362         const char* cpuAbiOffset = fileName + APK_LIB_LEN;
363         const size_t cpuAbiRegionSize = lastSlash - cpuAbiOffset;
364 
365         if (cpuAbi.size() == cpuAbiRegionSize && !strncmp(cpuAbiOffset, cpuAbi.c_str(), cpuAbiRegionSize)) {
366             install_status_t ret = callFunc(env, callArg, zipFile, entry, lastSlash + 1);
367 
368             if (ret != INSTALL_SUCCEEDED) {
369                 ALOGV("Failure for entry %s", lastSlash + 1);
370                 return ret;
371             }
372         }
373     }
374 
375     return INSTALL_SUCCEEDED;
376 }
377 
findSupportedAbi(JNIEnv * env,jlong apkHandle,jobjectArray supportedAbisArray,jboolean debuggable)378 static int findSupportedAbi(JNIEnv* env, jlong apkHandle, jobjectArray supportedAbisArray,
379                             jboolean debuggable) {
380     ZipFileRO* zipFile = reinterpret_cast<ZipFileRO*>(apkHandle);
381     if (zipFile == nullptr) {
382         return INSTALL_FAILED_INVALID_APK;
383     }
384 
385     std::unique_ptr<NativeLibrariesIterator> it(
386             NativeLibrariesIterator::create(zipFile, debuggable));
387     if (it.get() == nullptr) {
388         return INSTALL_FAILED_INVALID_APK;
389     }
390 
391     const int numAbis = env->GetArrayLength(supportedAbisArray);
392 
393     std::vector<ScopedUtfChars> supportedAbis;
394     supportedAbis.reserve(numAbis);
395     for (int i = 0; i < numAbis; ++i) {
396         supportedAbis.emplace_back(env, (jstring)env->GetObjectArrayElement(supportedAbisArray, i));
397     }
398 
399     ZipEntryRO entry = nullptr;
400     int status = NO_NATIVE_LIBRARIES;
401     while ((entry = it->next()) != nullptr) {
402         // We're currently in the lib/ directory of the APK, so it does have some native
403         // code. We should return INSTALL_FAILED_NO_MATCHING_ABIS if none of the
404         // libraries match.
405         if (status == NO_NATIVE_LIBRARIES) {
406             status = INSTALL_FAILED_NO_MATCHING_ABIS;
407         }
408 
409         const char* fileName = it->currentEntry();
410         const char* lastSlash = it->lastSlash();
411 
412         // Check to see if this CPU ABI matches what we are looking for.
413         const char* abiOffset = fileName + APK_LIB_LEN;
414         const size_t abiSize = lastSlash - abiOffset;
415         for (int i = 0; i < numAbis; i++) {
416             const ScopedUtfChars& abi = supportedAbis[i];
417             if (abi.size() == abiSize && !strncmp(abiOffset, abi.c_str(), abiSize)) {
418                 // The entry that comes in first (i.e. with a lower index) has the higher priority.
419                 if (((i < status) && (status >= 0)) || (status < 0) ) {
420                     status = i;
421                 }
422             }
423         }
424     }
425 
426     return status;
427 }
428 
429 static jint
com_android_internal_content_NativeLibraryHelper_copyNativeBinaries(JNIEnv * env,jclass clazz,jlong apkHandle,jstring javaNativeLibPath,jstring javaCpuAbi,jboolean extractNativeLibs,jboolean debuggable)430 com_android_internal_content_NativeLibraryHelper_copyNativeBinaries(JNIEnv *env, jclass clazz,
431         jlong apkHandle, jstring javaNativeLibPath, jstring javaCpuAbi,
432         jboolean extractNativeLibs, jboolean debuggable)
433 {
434     void* args[] = { &javaNativeLibPath, &extractNativeLibs };
435     return (jint) iterateOverNativeFiles(env, apkHandle, javaCpuAbi, debuggable,
436             copyFileIfChanged, reinterpret_cast<void*>(args));
437 }
438 
439 static jlong
com_android_internal_content_NativeLibraryHelper_sumNativeBinaries(JNIEnv * env,jclass clazz,jlong apkHandle,jstring javaCpuAbi,jboolean debuggable)440 com_android_internal_content_NativeLibraryHelper_sumNativeBinaries(JNIEnv *env, jclass clazz,
441         jlong apkHandle, jstring javaCpuAbi, jboolean debuggable)
442 {
443     size_t totalSize = 0;
444 
445     iterateOverNativeFiles(env, apkHandle, javaCpuAbi, debuggable, sumFiles, &totalSize);
446 
447     return totalSize;
448 }
449 
450 static jint
com_android_internal_content_NativeLibraryHelper_findSupportedAbi(JNIEnv * env,jclass clazz,jlong apkHandle,jobjectArray javaCpuAbisToSearch,jboolean debuggable)451 com_android_internal_content_NativeLibraryHelper_findSupportedAbi(JNIEnv *env, jclass clazz,
452         jlong apkHandle, jobjectArray javaCpuAbisToSearch, jboolean debuggable)
453 {
454     return (jint) findSupportedAbi(env, apkHandle, javaCpuAbisToSearch, debuggable);
455 }
456 
457 enum bitcode_scan_result_t {
458   APK_SCAN_ERROR = -1,
459   NO_BITCODE_PRESENT = 0,
460   BITCODE_PRESENT = 1,
461 };
462 
463 static jint
com_android_internal_content_NativeLibraryHelper_hasRenderscriptBitcode(JNIEnv * env,jclass clazz,jlong apkHandle)464 com_android_internal_content_NativeLibraryHelper_hasRenderscriptBitcode(JNIEnv *env, jclass clazz,
465         jlong apkHandle) {
466     ZipFileRO* zipFile = reinterpret_cast<ZipFileRO*>(apkHandle);
467     void* cookie = nullptr;
468     if (!zipFile->startIteration(&cookie, nullptr /* prefix */, RS_BITCODE_SUFFIX)) {
469         return APK_SCAN_ERROR;
470     }
471 
472     char fileName[PATH_MAX];
473     ZipEntryRO next = nullptr;
474     while ((next = zipFile->nextEntry(cookie)) != nullptr) {
475         if (zipFile->getEntryFileName(next, fileName, sizeof(fileName))) {
476             continue;
477         }
478         const char* lastSlash = strrchr(fileName, '/');
479         const char* baseName = (lastSlash == nullptr) ? fileName : fileName + 1;
480         if (util::isFilenameSafe(baseName)) {
481             zipFile->endIteration(cookie);
482             return BITCODE_PRESENT;
483         }
484     }
485 
486     zipFile->endIteration(cookie);
487     return NO_BITCODE_PRESENT;
488 }
489 
490 static jlong
com_android_internal_content_NativeLibraryHelper_openApk(JNIEnv * env,jclass,jstring apkPath)491 com_android_internal_content_NativeLibraryHelper_openApk(JNIEnv *env, jclass, jstring apkPath)
492 {
493     ScopedUtfChars filePath(env, apkPath);
494     ZipFileRO* zipFile = ZipFileRO::open(filePath.c_str());
495 
496     return reinterpret_cast<jlong>(zipFile);
497 }
498 
499 static jlong
com_android_internal_content_NativeLibraryHelper_openApkFd(JNIEnv * env,jclass,jobject fileDescriptor,jstring debugPathName)500 com_android_internal_content_NativeLibraryHelper_openApkFd(JNIEnv *env, jclass,
501         jobject fileDescriptor, jstring debugPathName)
502 {
503     ScopedUtfChars debugFilePath(env, debugPathName);
504 
505     int fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
506     if (fd < 0) {
507         jniThrowException(env, "java/lang/IllegalArgumentException", "Bad FileDescriptor");
508         return 0;
509     }
510 
511     int dupedFd = fcntl(fd, F_DUPFD_CLOEXEC, 0);
512     if (dupedFd == -1) {
513         jniThrowExceptionFmt(env, "java/lang/IllegalArgumentException",
514                              "Failed to dup FileDescriptor: %s", strerror(errno));
515         return 0;
516     }
517 
518     ZipFileRO* zipFile = ZipFileRO::openFd(dupedFd, debugFilePath.c_str());
519 
520     return reinterpret_cast<jlong>(zipFile);
521 }
522 
523 static void
com_android_internal_content_NativeLibraryHelper_close(JNIEnv * env,jclass,jlong apkHandle)524 com_android_internal_content_NativeLibraryHelper_close(JNIEnv *env, jclass, jlong apkHandle)
525 {
526     delete reinterpret_cast<ZipFileRO*>(apkHandle);
527 }
528 
529 static const JNINativeMethod gMethods[] = {
530     {"nativeOpenApk",
531             "(Ljava/lang/String;)J",
532             (void *)com_android_internal_content_NativeLibraryHelper_openApk},
533     {"nativeOpenApkFd",
534             "(Ljava/io/FileDescriptor;Ljava/lang/String;)J",
535             (void *)com_android_internal_content_NativeLibraryHelper_openApkFd},
536     {"nativeClose",
537             "(J)V",
538             (void *)com_android_internal_content_NativeLibraryHelper_close},
539     {"nativeCopyNativeBinaries",
540             "(JLjava/lang/String;Ljava/lang/String;ZZ)I",
541             (void *)com_android_internal_content_NativeLibraryHelper_copyNativeBinaries},
542     {"nativeSumNativeBinaries",
543             "(JLjava/lang/String;Z)J",
544             (void *)com_android_internal_content_NativeLibraryHelper_sumNativeBinaries},
545     {"nativeFindSupportedAbi",
546             "(J[Ljava/lang/String;Z)I",
547             (void *)com_android_internal_content_NativeLibraryHelper_findSupportedAbi},
548     {"hasRenderscriptBitcode", "(J)I",
549             (void *)com_android_internal_content_NativeLibraryHelper_hasRenderscriptBitcode},
550 };
551 
552 
register_com_android_internal_content_NativeLibraryHelper(JNIEnv * env)553 int register_com_android_internal_content_NativeLibraryHelper(JNIEnv *env)
554 {
555     return RegisterMethodsOrDie(env,
556             "com/android/internal/content/NativeLibraryHelper", gMethods, NELEM(gMethods));
557 }
558 
559 };
560