Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 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 | |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 20 | #include "core_jni_helpers.h" |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 21 | |
Steven Moreland | 2279b25 | 2017-07-19 09:50:45 -0700 | [diff] [blame] | 22 | #include <nativehelper/ScopedUtfChars.h> |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 23 | #include <androidfw/ZipFileRO.h> |
| 24 | #include <androidfw/ZipUtils.h> |
| 25 | #include <utils/Log.h> |
| 26 | #include <utils/Vector.h> |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 27 | |
| 28 | #include <zlib.h> |
| 29 | |
Bill Peckham | a74879d | 2018-09-08 10:06:40 -0700 | [diff] [blame^] | 30 | #include <errno.h> |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 31 | #include <fcntl.h> |
| 32 | #include <stdlib.h> |
| 33 | #include <string.h> |
| 34 | #include <time.h> |
| 35 | #include <unistd.h> |
Dmitriy Ivanov | dec4688 | 2014-09-30 15:10:48 -0700 | [diff] [blame] | 36 | #include <inttypes.h> |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 37 | #include <sys/stat.h> |
| 38 | #include <sys/types.h> |
| 39 | |
Elliott Hughes | 93bb56e | 2016-09-11 14:50:12 -0700 | [diff] [blame] | 40 | #include <memory> |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 41 | |
| 42 | #define APK_LIB "lib/" |
| 43 | #define APK_LIB_LEN (sizeof(APK_LIB) - 1) |
| 44 | |
| 45 | #define LIB_PREFIX "/lib" |
| 46 | #define LIB_PREFIX_LEN (sizeof(LIB_PREFIX) - 1) |
| 47 | |
| 48 | #define LIB_SUFFIX ".so" |
| 49 | #define LIB_SUFFIX_LEN (sizeof(LIB_SUFFIX) - 1) |
| 50 | |
Narayan Kamath | d47e38b | 2014-05-16 16:45:56 +0100 | [diff] [blame] | 51 | #define RS_BITCODE_SUFFIX ".bc" |
Narayan Kamath | d47e38b | 2014-05-16 16:45:56 +0100 | [diff] [blame] | 52 | |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 53 | #define TMP_FILE_PATTERN "/tmp.XXXXXX" |
| 54 | #define TMP_FILE_PATTERN_LEN (sizeof(TMP_FILE_PATTERN) - 1) |
| 55 | |
| 56 | namespace android { |
| 57 | |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 58 | // These match PackageManager.java install codes |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 59 | enum install_status_t { |
Kenny Root | 1ebd74a | 2011-08-03 15:09:44 -0700 | [diff] [blame] | 60 | INSTALL_SUCCEEDED = 1, |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 61 | INSTALL_FAILED_INVALID_APK = -2, |
| 62 | INSTALL_FAILED_INSUFFICIENT_STORAGE = -4, |
Kenny Root | 1ebd74a | 2011-08-03 15:09:44 -0700 | [diff] [blame] | 63 | INSTALL_FAILED_CONTAINER_ERROR = -18, |
| 64 | INSTALL_FAILED_INTERNAL_ERROR = -110, |
Narayan Kamath | d11f223 | 2014-04-10 10:37:17 +0100 | [diff] [blame] | 65 | INSTALL_FAILED_NO_MATCHING_ABIS = -113, |
| 66 | NO_NATIVE_LIBRARIES = -114 |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 67 | }; |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 68 | |
Kenny Root | 1ebd74a | 2011-08-03 15:09:44 -0700 | [diff] [blame] | 69 | typedef install_status_t (*iterFunc)(JNIEnv*, void*, ZipFileRO*, ZipEntryRO, const char*); |
| 70 | |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 71 | // Equivalent to android.os.FileUtils.isFilenameSafe |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 72 | static bool |
| 73 | isFilenameSafe(const char* filename) |
| 74 | { |
| 75 | off_t offset = 0; |
| 76 | for (;;) { |
| 77 | switch (*(filename + offset)) { |
| 78 | case 0: |
| 79 | // Null. |
| 80 | // If we've reached the end, all the other characters are good. |
| 81 | return true; |
| 82 | |
| 83 | case 'A' ... 'Z': |
| 84 | case 'a' ... 'z': |
| 85 | case '0' ... '9': |
| 86 | case '+': |
| 87 | case ',': |
| 88 | case '-': |
| 89 | case '.': |
| 90 | case '/': |
| 91 | case '=': |
| 92 | case '_': |
| 93 | offset++; |
| 94 | break; |
| 95 | |
| 96 | default: |
| 97 | // We found something that is not good. |
| 98 | return false; |
| 99 | } |
| 100 | } |
| 101 | // Should not reach here. |
| 102 | } |
| 103 | |
| 104 | static bool |
Narayan Kamath | 407753c | 2015-06-16 12:02:57 +0100 | [diff] [blame] | 105 | isFileDifferent(const char* filePath, uint32_t fileSize, time_t modifiedTime, |
| 106 | uint32_t zipCrc, struct stat64* st) |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 107 | { |
| 108 | if (lstat64(filePath, st) < 0) { |
| 109 | // File is not found or cannot be read. |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 110 | ALOGV("Couldn't stat %s, copying: %s\n", filePath, strerror(errno)); |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 111 | return true; |
| 112 | } |
| 113 | |
| 114 | if (!S_ISREG(st->st_mode)) { |
| 115 | return true; |
| 116 | } |
| 117 | |
Andreas Gampe | 0f0b491 | 2014-11-12 08:03:48 -0800 | [diff] [blame] | 118 | if (static_cast<uint64_t>(st->st_size) != static_cast<uint64_t>(fileSize)) { |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 119 | return true; |
| 120 | } |
| 121 | |
| 122 | // For some reason, bionic doesn't define st_mtime as time_t |
| 123 | if (time_t(st->st_mtime) != modifiedTime) { |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 124 | ALOGV("mod time doesn't match: %ld vs. %ld\n", st->st_mtime, modifiedTime); |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 125 | return true; |
| 126 | } |
| 127 | |
| 128 | int fd = TEMP_FAILURE_RETRY(open(filePath, O_RDONLY)); |
| 129 | if (fd < 0) { |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 130 | ALOGV("Couldn't open file %s: %s", filePath, strerror(errno)); |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 131 | return true; |
| 132 | } |
| 133 | |
Narayan Kamath | 407753c | 2015-06-16 12:02:57 +0100 | [diff] [blame] | 134 | // uLong comes from zlib.h. It's a bit of a wart that they're |
| 135 | // potentially using a 64-bit type for a 32-bit CRC. |
| 136 | uLong crc = crc32(0L, Z_NULL, 0); |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 137 | unsigned char crcBuffer[16384]; |
| 138 | ssize_t numBytes; |
| 139 | while ((numBytes = TEMP_FAILURE_RETRY(read(fd, crcBuffer, sizeof(crcBuffer)))) > 0) { |
| 140 | crc = crc32(crc, crcBuffer, numBytes); |
| 141 | } |
| 142 | close(fd); |
| 143 | |
Narayan Kamath | 407753c | 2015-06-16 12:02:57 +0100 | [diff] [blame] | 144 | ALOGV("%s: crc = %lx, zipCrc = %" PRIu32 "\n", filePath, crc, zipCrc); |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 145 | |
Narayan Kamath | 407753c | 2015-06-16 12:02:57 +0100 | [diff] [blame] | 146 | if (crc != static_cast<uLong>(zipCrc)) { |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 147 | return true; |
| 148 | } |
| 149 | |
| 150 | return false; |
| 151 | } |
| 152 | |
Kenny Root | 1ebd74a | 2011-08-03 15:09:44 -0700 | [diff] [blame] | 153 | static install_status_t |
Narayan Kamath | afd31e0 | 2013-12-03 13:16:03 +0000 | [diff] [blame] | 154 | sumFiles(JNIEnv*, void* arg, ZipFileRO* zipFile, ZipEntryRO zipEntry, const char*) |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 155 | { |
| 156 | size_t* total = (size_t*) arg; |
Narayan Kamath | 407753c | 2015-06-16 12:02:57 +0100 | [diff] [blame] | 157 | uint32_t uncompLen; |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 158 | |
| 159 | if (!zipFile->getEntryInfo(zipEntry, NULL, &uncompLen, NULL, NULL, NULL, NULL)) { |
Kenny Root | 1ebd74a | 2011-08-03 15:09:44 -0700 | [diff] [blame] | 160 | return INSTALL_FAILED_INVALID_APK; |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 161 | } |
| 162 | |
Narayan Kamath | 407753c | 2015-06-16 12:02:57 +0100 | [diff] [blame] | 163 | *total += static_cast<size_t>(uncompLen); |
Kenny Root | 1ebd74a | 2011-08-03 15:09:44 -0700 | [diff] [blame] | 164 | |
| 165 | return INSTALL_SUCCEEDED; |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | /* |
| 169 | * Copy the native library if needed. |
| 170 | * |
| 171 | * This function assumes the library and path names passed in are considered safe. |
| 172 | */ |
Kenny Root | 1ebd74a | 2011-08-03 15:09:44 -0700 | [diff] [blame] | 173 | static install_status_t |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 174 | copyFileIfChanged(JNIEnv *env, void* arg, ZipFileRO* zipFile, ZipEntryRO zipEntry, const char* fileName) |
| 175 | { |
Dmitriy Ivanov | dec4688 | 2014-09-30 15:10:48 -0700 | [diff] [blame] | 176 | void** args = reinterpret_cast<void**>(arg); |
| 177 | jstring* javaNativeLibPath = (jstring*) args[0]; |
| 178 | jboolean extractNativeLibs = *(jboolean*) args[1]; |
| 179 | jboolean hasNativeBridge = *(jboolean*) args[2]; |
| 180 | |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 181 | ScopedUtfChars nativeLibPath(env, *javaNativeLibPath); |
| 182 | |
Narayan Kamath | 407753c | 2015-06-16 12:02:57 +0100 | [diff] [blame] | 183 | uint32_t uncompLen; |
| 184 | uint32_t when; |
| 185 | uint32_t crc; |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 186 | |
Narayan Kamath | 407753c | 2015-06-16 12:02:57 +0100 | [diff] [blame] | 187 | uint16_t method; |
Dmitriy Ivanov | dec4688 | 2014-09-30 15:10:48 -0700 | [diff] [blame] | 188 | off64_t offset; |
| 189 | |
| 190 | if (!zipFile->getEntryInfo(zipEntry, &method, &uncompLen, NULL, &offset, &when, &crc)) { |
Steve Block | 5baa3a6 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 191 | ALOGD("Couldn't read zip entry info\n"); |
Kenny Root | 1ebd74a | 2011-08-03 15:09:44 -0700 | [diff] [blame] | 192 | return INSTALL_FAILED_INVALID_APK; |
Dmitriy Ivanov | dec4688 | 2014-09-30 15:10:48 -0700 | [diff] [blame] | 193 | } |
| 194 | |
| 195 | if (!extractNativeLibs) { |
| 196 | // check if library is uncompressed and page-aligned |
| 197 | if (method != ZipFileRO::kCompressStored) { |
| 198 | ALOGD("Library '%s' is compressed - will not be able to open it directly from apk.\n", |
| 199 | fileName); |
| 200 | return INSTALL_FAILED_INVALID_APK; |
| 201 | } |
| 202 | |
| 203 | if (offset % PAGE_SIZE != 0) { |
| 204 | ALOGD("Library '%s' is not page-aligned - will not be able to open it directly from" |
| 205 | " apk.\n", fileName); |
| 206 | return INSTALL_FAILED_INVALID_APK; |
| 207 | } |
| 208 | |
| 209 | if (!hasNativeBridge) { |
| 210 | return INSTALL_SUCCEEDED; |
| 211 | } |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 212 | } |
| 213 | |
| 214 | // Build local file path |
| 215 | const size_t fileNameLen = strlen(fileName); |
| 216 | char localFileName[nativeLibPath.size() + fileNameLen + 2]; |
| 217 | |
| 218 | if (strlcpy(localFileName, nativeLibPath.c_str(), sizeof(localFileName)) != nativeLibPath.size()) { |
Steve Block | 5baa3a6 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 219 | ALOGD("Couldn't allocate local file name for library"); |
Kenny Root | 1ebd74a | 2011-08-03 15:09:44 -0700 | [diff] [blame] | 220 | return INSTALL_FAILED_INTERNAL_ERROR; |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | *(localFileName + nativeLibPath.size()) = '/'; |
| 224 | |
| 225 | if (strlcpy(localFileName + nativeLibPath.size() + 1, fileName, sizeof(localFileName) |
| 226 | - nativeLibPath.size() - 1) != fileNameLen) { |
Steve Block | 5baa3a6 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 227 | ALOGD("Couldn't allocate local file name for library"); |
Kenny Root | 1ebd74a | 2011-08-03 15:09:44 -0700 | [diff] [blame] | 228 | return INSTALL_FAILED_INTERNAL_ERROR; |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 229 | } |
| 230 | |
| 231 | // Only copy out the native file if it's different. |
Dmitriy Ivanov | dec4688 | 2014-09-30 15:10:48 -0700 | [diff] [blame] | 232 | struct tm t; |
| 233 | ZipUtils::zipTimeToTimespec(when, &t); |
Narayan Kamath | 407753c | 2015-06-16 12:02:57 +0100 | [diff] [blame] | 234 | const time_t modTime = mktime(&t); |
Elliott Hughes | ad07628 | 2014-01-17 18:27:27 -0800 | [diff] [blame] | 235 | struct stat64 st; |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 236 | if (!isFileDifferent(localFileName, uncompLen, modTime, crc, &st)) { |
Kenny Root | 1ebd74a | 2011-08-03 15:09:44 -0700 | [diff] [blame] | 237 | return INSTALL_SUCCEEDED; |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 238 | } |
| 239 | |
Ivan Lozano | 62fc148 | 2017-12-14 19:03:56 -0800 | [diff] [blame] | 240 | char localTmpFileName[nativeLibPath.size() + TMP_FILE_PATTERN_LEN + 1]; |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 241 | if (strlcpy(localTmpFileName, nativeLibPath.c_str(), sizeof(localTmpFileName)) |
| 242 | != nativeLibPath.size()) { |
Steve Block | 5baa3a6 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 243 | ALOGD("Couldn't allocate local file name for library"); |
Kenny Root | 1ebd74a | 2011-08-03 15:09:44 -0700 | [diff] [blame] | 244 | return INSTALL_FAILED_INTERNAL_ERROR; |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 245 | } |
| 246 | |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 247 | if (strlcpy(localTmpFileName + nativeLibPath.size(), TMP_FILE_PATTERN, |
Ivan Lozano | 62fc148 | 2017-12-14 19:03:56 -0800 | [diff] [blame] | 248 | TMP_FILE_PATTERN_LEN + 1) != TMP_FILE_PATTERN_LEN) { |
Steve Block | 6215d3f | 2012-01-04 20:05:49 +0000 | [diff] [blame] | 249 | ALOGI("Couldn't allocate temporary file name for library"); |
Kenny Root | 1ebd74a | 2011-08-03 15:09:44 -0700 | [diff] [blame] | 250 | return INSTALL_FAILED_INTERNAL_ERROR; |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 251 | } |
| 252 | |
| 253 | int fd = mkstemp(localTmpFileName); |
| 254 | if (fd < 0) { |
Steve Block | 6215d3f | 2012-01-04 20:05:49 +0000 | [diff] [blame] | 255 | ALOGI("Couldn't open temporary file name: %s: %s\n", localTmpFileName, strerror(errno)); |
Kenny Root | 1ebd74a | 2011-08-03 15:09:44 -0700 | [diff] [blame] | 256 | return INSTALL_FAILED_CONTAINER_ERROR; |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | if (!zipFile->uncompressEntry(zipEntry, fd)) { |
Steve Block | 6215d3f | 2012-01-04 20:05:49 +0000 | [diff] [blame] | 260 | ALOGI("Failed uncompressing %s to %s\n", fileName, localTmpFileName); |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 261 | close(fd); |
| 262 | unlink(localTmpFileName); |
Kenny Root | 1ebd74a | 2011-08-03 15:09:44 -0700 | [diff] [blame] | 263 | return INSTALL_FAILED_CONTAINER_ERROR; |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | close(fd); |
| 267 | |
| 268 | // Set the modification time for this file to the ZIP's mod time. |
| 269 | struct timeval times[2]; |
| 270 | times[0].tv_sec = st.st_atime; |
| 271 | times[1].tv_sec = modTime; |
| 272 | times[0].tv_usec = times[1].tv_usec = 0; |
| 273 | if (utimes(localTmpFileName, times) < 0) { |
Steve Block | 6215d3f | 2012-01-04 20:05:49 +0000 | [diff] [blame] | 274 | ALOGI("Couldn't change modification time on %s: %s\n", localTmpFileName, strerror(errno)); |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 275 | unlink(localTmpFileName); |
Kenny Root | 1ebd74a | 2011-08-03 15:09:44 -0700 | [diff] [blame] | 276 | return INSTALL_FAILED_CONTAINER_ERROR; |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 277 | } |
| 278 | |
| 279 | // Set the mode to 755 |
| 280 | static const mode_t mode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; |
| 281 | if (chmod(localTmpFileName, mode) < 0) { |
Steve Block | 6215d3f | 2012-01-04 20:05:49 +0000 | [diff] [blame] | 282 | ALOGI("Couldn't change permissions on %s: %s\n", localTmpFileName, strerror(errno)); |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 283 | unlink(localTmpFileName); |
Kenny Root | 1ebd74a | 2011-08-03 15:09:44 -0700 | [diff] [blame] | 284 | return INSTALL_FAILED_CONTAINER_ERROR; |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 285 | } |
| 286 | |
| 287 | // Finally, rename it to the final name. |
| 288 | if (rename(localTmpFileName, localFileName) < 0) { |
Steve Block | 6215d3f | 2012-01-04 20:05:49 +0000 | [diff] [blame] | 289 | ALOGI("Couldn't rename %s to %s: %s\n", localTmpFileName, localFileName, strerror(errno)); |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 290 | unlink(localTmpFileName); |
Kenny Root | 1ebd74a | 2011-08-03 15:09:44 -0700 | [diff] [blame] | 291 | return INSTALL_FAILED_CONTAINER_ERROR; |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 292 | } |
| 293 | |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 294 | ALOGV("Successfully moved %s to %s\n", localTmpFileName, localFileName); |
Kenny Root | 1ebd74a | 2011-08-03 15:09:44 -0700 | [diff] [blame] | 295 | |
| 296 | return INSTALL_SUCCEEDED; |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 297 | } |
| 298 | |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 299 | /* |
| 300 | * An iterator over all shared libraries in a zip file. An entry is |
| 301 | * considered to be a shared library if all of the conditions below are |
| 302 | * satisfied : |
| 303 | * |
| 304 | * - The entry is under the lib/ directory. |
| 305 | * - The entry name ends with ".so" and the entry name starts with "lib", |
| 306 | * an exception is made for entries whose name is "gdbserver". |
| 307 | * - The entry filename is "safe" (as determined by isFilenameSafe). |
| 308 | * |
| 309 | */ |
| 310 | class NativeLibrariesIterator { |
| 311 | private: |
Tamas Berghammer | d6dd6b8 | 2016-10-07 19:12:51 +0100 | [diff] [blame] | 312 | NativeLibrariesIterator(ZipFileRO* zipFile, bool debuggable, void* cookie) |
| 313 | : mZipFile(zipFile), mDebuggable(debuggable), mCookie(cookie), mLastSlash(NULL) { |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 314 | fileName[0] = '\0'; |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 315 | } |
| 316 | |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 317 | public: |
Tamas Berghammer | d6dd6b8 | 2016-10-07 19:12:51 +0100 | [diff] [blame] | 318 | static NativeLibrariesIterator* create(ZipFileRO* zipFile, bool debuggable) { |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 319 | void* cookie = NULL; |
Yusuke Sato | 957c237 | 2015-08-03 16:17:16 -0700 | [diff] [blame] | 320 | // Do not specify a suffix to find both .so files and gdbserver. |
| 321 | if (!zipFile->startIteration(&cookie, APK_LIB, NULL /* suffix */)) { |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 322 | return NULL; |
| 323 | } |
| 324 | |
Tamas Berghammer | d6dd6b8 | 2016-10-07 19:12:51 +0100 | [diff] [blame] | 325 | return new NativeLibrariesIterator(zipFile, debuggable, cookie); |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 326 | } |
| 327 | |
| 328 | ZipEntryRO next() { |
| 329 | ZipEntryRO next = NULL; |
| 330 | while ((next = mZipFile->nextEntry(mCookie)) != NULL) { |
| 331 | // Make sure this entry has a filename. |
| 332 | if (mZipFile->getEntryFileName(next, fileName, sizeof(fileName))) { |
| 333 | continue; |
| 334 | } |
| 335 | |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 336 | // Make sure the filename is at least to the minimum library name size. |
| 337 | const size_t fileNameLen = strlen(fileName); |
| 338 | static const size_t minLength = APK_LIB_LEN + 2 + LIB_PREFIX_LEN + 1 + LIB_SUFFIX_LEN; |
| 339 | if (fileNameLen < minLength) { |
| 340 | continue; |
| 341 | } |
| 342 | |
| 343 | const char* lastSlash = strrchr(fileName, '/'); |
| 344 | ALOG_ASSERT(lastSlash != NULL, "last slash was null somehow for %s\n", fileName); |
| 345 | |
Andreas Gampe | c012ae3 | 2016-12-15 16:12:39 -0800 | [diff] [blame] | 346 | // Skip directories. |
| 347 | if (*(lastSlash + 1) == 0) { |
| 348 | continue; |
| 349 | } |
| 350 | |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 351 | // Make sure the filename is safe. |
| 352 | if (!isFilenameSafe(lastSlash + 1)) { |
| 353 | continue; |
| 354 | } |
| 355 | |
Tamas Berghammer | d6dd6b8 | 2016-10-07 19:12:51 +0100 | [diff] [blame] | 356 | if (!mDebuggable) { |
| 357 | // Make sure the filename starts with lib and ends with ".so". |
| 358 | if (strncmp(fileName + fileNameLen - LIB_SUFFIX_LEN, LIB_SUFFIX, LIB_SUFFIX_LEN) |
| 359 | || strncmp(lastSlash, LIB_PREFIX, LIB_PREFIX_LEN)) { |
| 360 | continue; |
| 361 | } |
| 362 | } |
| 363 | |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 364 | mLastSlash = lastSlash; |
| 365 | break; |
| 366 | } |
| 367 | |
| 368 | return next; |
| 369 | } |
| 370 | |
| 371 | inline const char* currentEntry() const { |
| 372 | return fileName; |
| 373 | } |
| 374 | |
| 375 | inline const char* lastSlash() const { |
| 376 | return mLastSlash; |
| 377 | } |
| 378 | |
| 379 | virtual ~NativeLibrariesIterator() { |
| 380 | mZipFile->endIteration(mCookie); |
| 381 | } |
| 382 | private: |
| 383 | |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 384 | char fileName[PATH_MAX]; |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 385 | ZipFileRO* const mZipFile; |
Tamas Berghammer | d6dd6b8 | 2016-10-07 19:12:51 +0100 | [diff] [blame] | 386 | const bool mDebuggable; |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 387 | void* mCookie; |
| 388 | const char* mLastSlash; |
| 389 | }; |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 390 | |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 391 | static install_status_t |
| 392 | iterateOverNativeFiles(JNIEnv *env, jlong apkHandle, jstring javaCpuAbi, |
Tamas Berghammer | d6dd6b8 | 2016-10-07 19:12:51 +0100 | [diff] [blame] | 393 | jboolean debuggable, iterFunc callFunc, void* callArg) { |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 394 | ZipFileRO* zipFile = reinterpret_cast<ZipFileRO*>(apkHandle); |
| 395 | if (zipFile == NULL) { |
Narayan Kamath | afd31e0 | 2013-12-03 13:16:03 +0000 | [diff] [blame] | 396 | return INSTALL_FAILED_INVALID_APK; |
| 397 | } |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 398 | |
Tamas Berghammer | d6dd6b8 | 2016-10-07 19:12:51 +0100 | [diff] [blame] | 399 | std::unique_ptr<NativeLibrariesIterator> it( |
| 400 | NativeLibrariesIterator::create(zipFile, debuggable)); |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 401 | if (it.get() == NULL) { |
| 402 | return INSTALL_FAILED_INVALID_APK; |
| 403 | } |
| 404 | |
| 405 | const ScopedUtfChars cpuAbi(env, javaCpuAbi); |
| 406 | if (cpuAbi.c_str() == NULL) { |
| 407 | // This would've thrown, so this return code isn't observable by |
| 408 | // Java. |
| 409 | return INSTALL_FAILED_INVALID_APK; |
| 410 | } |
Narayan Kamath | afd31e0 | 2013-12-03 13:16:03 +0000 | [diff] [blame] | 411 | ZipEntryRO entry = NULL; |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 412 | while ((entry = it->next()) != NULL) { |
| 413 | const char* fileName = it->currentEntry(); |
| 414 | const char* lastSlash = it->lastSlash(); |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 415 | |
| 416 | // Check to make sure the CPU ABI of this file is one we support. |
| 417 | const char* cpuAbiOffset = fileName + APK_LIB_LEN; |
| 418 | const size_t cpuAbiRegionSize = lastSlash - cpuAbiOffset; |
| 419 | |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 420 | if (cpuAbi.size() == cpuAbiRegionSize && !strncmp(cpuAbiOffset, cpuAbi.c_str(), cpuAbiRegionSize)) { |
| 421 | install_status_t ret = callFunc(env, callArg, zipFile, entry, lastSlash + 1); |
Kenny Root | 1ebd74a | 2011-08-03 15:09:44 -0700 | [diff] [blame] | 422 | |
| 423 | if (ret != INSTALL_SUCCEEDED) { |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 424 | ALOGV("Failure for entry %s", lastSlash + 1); |
Kenny Root | 1ebd74a | 2011-08-03 15:09:44 -0700 | [diff] [blame] | 425 | return ret; |
| 426 | } |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 427 | } |
| 428 | } |
| 429 | |
| 430 | return INSTALL_SUCCEEDED; |
| 431 | } |
| 432 | |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 433 | |
Tamas Berghammer | d6dd6b8 | 2016-10-07 19:12:51 +0100 | [diff] [blame] | 434 | static int findSupportedAbi(JNIEnv *env, jlong apkHandle, jobjectArray supportedAbisArray, |
| 435 | jboolean debuggable) { |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 436 | const int numAbis = env->GetArrayLength(supportedAbisArray); |
| 437 | Vector<ScopedUtfChars*> supportedAbis; |
| 438 | |
| 439 | for (int i = 0; i < numAbis; ++i) { |
| 440 | supportedAbis.add(new ScopedUtfChars(env, |
| 441 | (jstring) env->GetObjectArrayElement(supportedAbisArray, i))); |
| 442 | } |
| 443 | |
| 444 | ZipFileRO* zipFile = reinterpret_cast<ZipFileRO*>(apkHandle); |
| 445 | if (zipFile == NULL) { |
| 446 | return INSTALL_FAILED_INVALID_APK; |
| 447 | } |
| 448 | |
Tamas Berghammer | d6dd6b8 | 2016-10-07 19:12:51 +0100 | [diff] [blame] | 449 | std::unique_ptr<NativeLibrariesIterator> it( |
| 450 | NativeLibrariesIterator::create(zipFile, debuggable)); |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 451 | if (it.get() == NULL) { |
| 452 | return INSTALL_FAILED_INVALID_APK; |
| 453 | } |
| 454 | |
| 455 | ZipEntryRO entry = NULL; |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 456 | int status = NO_NATIVE_LIBRARIES; |
| 457 | while ((entry = it->next()) != NULL) { |
| 458 | // We're currently in the lib/ directory of the APK, so it does have some native |
| 459 | // code. We should return INSTALL_FAILED_NO_MATCHING_ABIS if none of the |
| 460 | // libraries match. |
| 461 | if (status == NO_NATIVE_LIBRARIES) { |
| 462 | status = INSTALL_FAILED_NO_MATCHING_ABIS; |
| 463 | } |
| 464 | |
| 465 | const char* fileName = it->currentEntry(); |
| 466 | const char* lastSlash = it->lastSlash(); |
| 467 | |
| 468 | // Check to see if this CPU ABI matches what we are looking for. |
| 469 | const char* abiOffset = fileName + APK_LIB_LEN; |
| 470 | const size_t abiSize = lastSlash - abiOffset; |
| 471 | for (int i = 0; i < numAbis; i++) { |
| 472 | const ScopedUtfChars* abi = supportedAbis[i]; |
| 473 | if (abi->size() == abiSize && !strncmp(abiOffset, abi->c_str(), abiSize)) { |
| 474 | // The entry that comes in first (i.e. with a lower index) has the higher priority. |
| 475 | if (((i < status) && (status >= 0)) || (status < 0) ) { |
| 476 | status = i; |
| 477 | } |
| 478 | } |
| 479 | } |
| 480 | } |
| 481 | |
| 482 | for (int i = 0; i < numAbis; ++i) { |
| 483 | delete supportedAbis[i]; |
| 484 | } |
| 485 | |
| 486 | return status; |
| 487 | } |
| 488 | |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 489 | static jint |
| 490 | com_android_internal_content_NativeLibraryHelper_copyNativeBinaries(JNIEnv *env, jclass clazz, |
Dmitriy Ivanov | dec4688 | 2014-09-30 15:10:48 -0700 | [diff] [blame] | 491 | jlong apkHandle, jstring javaNativeLibPath, jstring javaCpuAbi, |
Tamas Berghammer | d6dd6b8 | 2016-10-07 19:12:51 +0100 | [diff] [blame] | 492 | jboolean extractNativeLibs, jboolean hasNativeBridge, jboolean debuggable) |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 493 | { |
Dmitriy Ivanov | dec4688 | 2014-09-30 15:10:48 -0700 | [diff] [blame] | 494 | void* args[] = { &javaNativeLibPath, &extractNativeLibs, &hasNativeBridge }; |
Tamas Berghammer | d6dd6b8 | 2016-10-07 19:12:51 +0100 | [diff] [blame] | 495 | return (jint) iterateOverNativeFiles(env, apkHandle, javaCpuAbi, debuggable, |
Dmitriy Ivanov | dec4688 | 2014-09-30 15:10:48 -0700 | [diff] [blame] | 496 | copyFileIfChanged, reinterpret_cast<void*>(args)); |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 497 | } |
| 498 | |
| 499 | static jlong |
| 500 | com_android_internal_content_NativeLibraryHelper_sumNativeBinaries(JNIEnv *env, jclass clazz, |
Tamas Berghammer | d6dd6b8 | 2016-10-07 19:12:51 +0100 | [diff] [blame] | 501 | jlong apkHandle, jstring javaCpuAbi, jboolean debuggable) |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 502 | { |
| 503 | size_t totalSize = 0; |
| 504 | |
Tamas Berghammer | d6dd6b8 | 2016-10-07 19:12:51 +0100 | [diff] [blame] | 505 | iterateOverNativeFiles(env, apkHandle, javaCpuAbi, debuggable, sumFiles, &totalSize); |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 506 | |
| 507 | return totalSize; |
| 508 | } |
| 509 | |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 510 | static jint |
| 511 | com_android_internal_content_NativeLibraryHelper_findSupportedAbi(JNIEnv *env, jclass clazz, |
Tamas Berghammer | d6dd6b8 | 2016-10-07 19:12:51 +0100 | [diff] [blame] | 512 | jlong apkHandle, jobjectArray javaCpuAbisToSearch, jboolean debuggable) |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 513 | { |
Tamas Berghammer | d6dd6b8 | 2016-10-07 19:12:51 +0100 | [diff] [blame] | 514 | return (jint) findSupportedAbi(env, apkHandle, javaCpuAbisToSearch, debuggable); |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 515 | } |
| 516 | |
Narayan Kamath | d47e38b | 2014-05-16 16:45:56 +0100 | [diff] [blame] | 517 | enum bitcode_scan_result_t { |
| 518 | APK_SCAN_ERROR = -1, |
| 519 | NO_BITCODE_PRESENT = 0, |
| 520 | BITCODE_PRESENT = 1, |
| 521 | }; |
| 522 | |
| 523 | static jint |
| 524 | com_android_internal_content_NativeLibraryHelper_hasRenderscriptBitcode(JNIEnv *env, jclass clazz, |
| 525 | jlong apkHandle) { |
| 526 | ZipFileRO* zipFile = reinterpret_cast<ZipFileRO*>(apkHandle); |
| 527 | void* cookie = NULL; |
Yusuke Sato | 957c237 | 2015-08-03 16:17:16 -0700 | [diff] [blame] | 528 | if (!zipFile->startIteration(&cookie, NULL /* prefix */, RS_BITCODE_SUFFIX)) { |
Narayan Kamath | d47e38b | 2014-05-16 16:45:56 +0100 | [diff] [blame] | 529 | return APK_SCAN_ERROR; |
| 530 | } |
| 531 | |
| 532 | char fileName[PATH_MAX]; |
| 533 | ZipEntryRO next = NULL; |
| 534 | while ((next = zipFile->nextEntry(cookie)) != NULL) { |
| 535 | if (zipFile->getEntryFileName(next, fileName, sizeof(fileName))) { |
| 536 | continue; |
| 537 | } |
Narayan Kamath | d47e38b | 2014-05-16 16:45:56 +0100 | [diff] [blame] | 538 | const char* lastSlash = strrchr(fileName, '/'); |
| 539 | const char* baseName = (lastSlash == NULL) ? fileName : fileName + 1; |
Yusuke Sato | 957c237 | 2015-08-03 16:17:16 -0700 | [diff] [blame] | 540 | if (isFilenameSafe(baseName)) { |
Narayan Kamath | d47e38b | 2014-05-16 16:45:56 +0100 | [diff] [blame] | 541 | zipFile->endIteration(cookie); |
| 542 | return BITCODE_PRESENT; |
| 543 | } |
| 544 | } |
| 545 | |
| 546 | zipFile->endIteration(cookie); |
| 547 | return NO_BITCODE_PRESENT; |
| 548 | } |
| 549 | |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 550 | static jlong |
| 551 | com_android_internal_content_NativeLibraryHelper_openApk(JNIEnv *env, jclass, jstring apkPath) |
| 552 | { |
| 553 | ScopedUtfChars filePath(env, apkPath); |
| 554 | ZipFileRO* zipFile = ZipFileRO::open(filePath.c_str()); |
| 555 | |
| 556 | return reinterpret_cast<jlong>(zipFile); |
| 557 | } |
| 558 | |
Dianne Hackborn | 1704e3c | 2017-10-31 19:55:42 +0000 | [diff] [blame] | 559 | static jlong |
| 560 | com_android_internal_content_NativeLibraryHelper_openApkFd(JNIEnv *env, jclass, |
| 561 | jobject fileDescriptor, jstring debugPathName) |
| 562 | { |
| 563 | ScopedUtfChars debugFilePath(env, debugPathName); |
| 564 | |
| 565 | int fd = jniGetFDFromFileDescriptor(env, fileDescriptor); |
| 566 | if (fd < 0) { |
| 567 | jniThrowException(env, "java/lang/IllegalArgumentException", "Bad FileDescriptor"); |
| 568 | return 0; |
| 569 | } |
| 570 | |
Bill Peckham | a74879d | 2018-09-08 10:06:40 -0700 | [diff] [blame^] | 571 | int dupedFd = dup(fd); |
| 572 | if (dupedFd == -1) { |
| 573 | jniThrowExceptionFmt(env, "java/lang/IllegalArgumentException", |
| 574 | "Failed to dup FileDescriptor: %s", strerror(errno)); |
| 575 | return 0; |
| 576 | } |
| 577 | |
| 578 | ZipFileRO* zipFile = ZipFileRO::openFd(dupedFd, debugFilePath.c_str()); |
Dianne Hackborn | 1704e3c | 2017-10-31 19:55:42 +0000 | [diff] [blame] | 579 | |
| 580 | return reinterpret_cast<jlong>(zipFile); |
| 581 | } |
| 582 | |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 583 | static void |
| 584 | com_android_internal_content_NativeLibraryHelper_close(JNIEnv *env, jclass, jlong apkHandle) |
| 585 | { |
| 586 | delete reinterpret_cast<ZipFileRO*>(apkHandle); |
| 587 | } |
| 588 | |
Daniel Micay | 76f6a86 | 2015-09-19 17:31:01 -0400 | [diff] [blame] | 589 | static const JNINativeMethod gMethods[] = { |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 590 | {"nativeOpenApk", |
| 591 | "(Ljava/lang/String;)J", |
| 592 | (void *)com_android_internal_content_NativeLibraryHelper_openApk}, |
Dianne Hackborn | 1704e3c | 2017-10-31 19:55:42 +0000 | [diff] [blame] | 593 | {"nativeOpenApkFd", |
| 594 | "(Ljava/io/FileDescriptor;Ljava/lang/String;)J", |
| 595 | (void *)com_android_internal_content_NativeLibraryHelper_openApkFd}, |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 596 | {"nativeClose", |
| 597 | "(J)V", |
| 598 | (void *)com_android_internal_content_NativeLibraryHelper_close}, |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 599 | {"nativeCopyNativeBinaries", |
Tamas Berghammer | d6dd6b8 | 2016-10-07 19:12:51 +0100 | [diff] [blame] | 600 | "(JLjava/lang/String;Ljava/lang/String;ZZZ)I", |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 601 | (void *)com_android_internal_content_NativeLibraryHelper_copyNativeBinaries}, |
| 602 | {"nativeSumNativeBinaries", |
Tamas Berghammer | d6dd6b8 | 2016-10-07 19:12:51 +0100 | [diff] [blame] | 603 | "(JLjava/lang/String;Z)J", |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 604 | (void *)com_android_internal_content_NativeLibraryHelper_sumNativeBinaries}, |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 605 | {"nativeFindSupportedAbi", |
Tamas Berghammer | d6dd6b8 | 2016-10-07 19:12:51 +0100 | [diff] [blame] | 606 | "(J[Ljava/lang/String;Z)I", |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 607 | (void *)com_android_internal_content_NativeLibraryHelper_findSupportedAbi}, |
Narayan Kamath | d47e38b | 2014-05-16 16:45:56 +0100 | [diff] [blame] | 608 | {"hasRenderscriptBitcode", "(J)I", |
| 609 | (void *)com_android_internal_content_NativeLibraryHelper_hasRenderscriptBitcode}, |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 610 | }; |
| 611 | |
| 612 | |
| 613 | int register_com_android_internal_content_NativeLibraryHelper(JNIEnv *env) |
| 614 | { |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 615 | return RegisterMethodsOrDie(env, |
| 616 | "com/android/internal/content/NativeLibraryHelper", gMethods, NELEM(gMethods)); |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 617 | } |
| 618 | |
| 619 | }; |