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 | |
Josh Gao | 5fc8bbe | 2018-07-17 15:00:31 -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 | |
Nick Kralevich | 4b3a08c | 2019-01-28 10:39:10 -0800 | [diff] [blame] | 128 | int fd = TEMP_FAILURE_RETRY(open(filePath, O_RDONLY | O_CLOEXEC)); |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 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]; |
Dmitriy Ivanov | dec4688 | 2014-09-30 15:10:48 -0700 | [diff] [blame] | 179 | |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 180 | ScopedUtfChars nativeLibPath(env, *javaNativeLibPath); |
| 181 | |
Narayan Kamath | 407753c | 2015-06-16 12:02:57 +0100 | [diff] [blame] | 182 | uint32_t uncompLen; |
| 183 | uint32_t when; |
| 184 | uint32_t crc; |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 185 | |
Narayan Kamath | 407753c | 2015-06-16 12:02:57 +0100 | [diff] [blame] | 186 | uint16_t method; |
Dmitriy Ivanov | dec4688 | 2014-09-30 15:10:48 -0700 | [diff] [blame] | 187 | off64_t offset; |
| 188 | |
| 189 | if (!zipFile->getEntryInfo(zipEntry, &method, &uncompLen, NULL, &offset, &when, &crc)) { |
Victor Hsieh | 38e9c4a | 2019-03-07 13:27:59 -0800 | [diff] [blame] | 190 | ALOGE("Couldn't read zip entry info\n"); |
Kenny Root | 1ebd74a | 2011-08-03 15:09:44 -0700 | [diff] [blame] | 191 | return INSTALL_FAILED_INVALID_APK; |
Dmitriy Ivanov | dec4688 | 2014-09-30 15:10:48 -0700 | [diff] [blame] | 192 | } |
| 193 | |
| 194 | if (!extractNativeLibs) { |
| 195 | // check if library is uncompressed and page-aligned |
| 196 | if (method != ZipFileRO::kCompressStored) { |
Victor Hsieh | 38e9c4a | 2019-03-07 13:27:59 -0800 | [diff] [blame] | 197 | ALOGE("Library '%s' is compressed - will not be able to open it directly from apk.\n", |
Dmitriy Ivanov | dec4688 | 2014-09-30 15:10:48 -0700 | [diff] [blame] | 198 | fileName); |
| 199 | return INSTALL_FAILED_INVALID_APK; |
| 200 | } |
| 201 | |
| 202 | if (offset % PAGE_SIZE != 0) { |
Victor Hsieh | 38e9c4a | 2019-03-07 13:27:59 -0800 | [diff] [blame] | 203 | ALOGE("Library '%s' is not page-aligned - will not be able to open it directly from" |
Dmitriy Ivanov | dec4688 | 2014-09-30 15:10:48 -0700 | [diff] [blame] | 204 | " apk.\n", fileName); |
| 205 | return INSTALL_FAILED_INVALID_APK; |
| 206 | } |
| 207 | |
dimitry | 6e44c30 | 2018-10-04 15:57:14 +0200 | [diff] [blame] | 208 | return INSTALL_SUCCEEDED; |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | // Build local file path |
| 212 | const size_t fileNameLen = strlen(fileName); |
| 213 | char localFileName[nativeLibPath.size() + fileNameLen + 2]; |
| 214 | |
| 215 | if (strlcpy(localFileName, nativeLibPath.c_str(), sizeof(localFileName)) != nativeLibPath.size()) { |
Victor Hsieh | 38e9c4a | 2019-03-07 13:27:59 -0800 | [diff] [blame] | 216 | ALOGE("Couldn't allocate local file name for library"); |
Kenny Root | 1ebd74a | 2011-08-03 15:09:44 -0700 | [diff] [blame] | 217 | return INSTALL_FAILED_INTERNAL_ERROR; |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 218 | } |
| 219 | |
| 220 | *(localFileName + nativeLibPath.size()) = '/'; |
| 221 | |
| 222 | if (strlcpy(localFileName + nativeLibPath.size() + 1, fileName, sizeof(localFileName) |
| 223 | - nativeLibPath.size() - 1) != fileNameLen) { |
Victor Hsieh | 38e9c4a | 2019-03-07 13:27:59 -0800 | [diff] [blame] | 224 | ALOGE("Couldn't allocate local file name for library"); |
Kenny Root | 1ebd74a | 2011-08-03 15:09:44 -0700 | [diff] [blame] | 225 | return INSTALL_FAILED_INTERNAL_ERROR; |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 226 | } |
| 227 | |
| 228 | // Only copy out the native file if it's different. |
Dmitriy Ivanov | dec4688 | 2014-09-30 15:10:48 -0700 | [diff] [blame] | 229 | struct tm t; |
| 230 | ZipUtils::zipTimeToTimespec(when, &t); |
Narayan Kamath | 407753c | 2015-06-16 12:02:57 +0100 | [diff] [blame] | 231 | const time_t modTime = mktime(&t); |
Elliott Hughes | ad07628 | 2014-01-17 18:27:27 -0800 | [diff] [blame] | 232 | struct stat64 st; |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 233 | if (!isFileDifferent(localFileName, uncompLen, modTime, crc, &st)) { |
Kenny Root | 1ebd74a | 2011-08-03 15:09:44 -0700 | [diff] [blame] | 234 | return INSTALL_SUCCEEDED; |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 235 | } |
| 236 | |
Ivan Lozano | 62fc148 | 2017-12-14 19:03:56 -0800 | [diff] [blame] | 237 | char localTmpFileName[nativeLibPath.size() + TMP_FILE_PATTERN_LEN + 1]; |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 238 | if (strlcpy(localTmpFileName, nativeLibPath.c_str(), sizeof(localTmpFileName)) |
| 239 | != nativeLibPath.size()) { |
Victor Hsieh | 38e9c4a | 2019-03-07 13:27:59 -0800 | [diff] [blame] | 240 | ALOGE("Couldn't allocate local file name for library"); |
Kenny Root | 1ebd74a | 2011-08-03 15:09:44 -0700 | [diff] [blame] | 241 | return INSTALL_FAILED_INTERNAL_ERROR; |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 242 | } |
| 243 | |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 244 | if (strlcpy(localTmpFileName + nativeLibPath.size(), TMP_FILE_PATTERN, |
Ivan Lozano | 62fc148 | 2017-12-14 19:03:56 -0800 | [diff] [blame] | 245 | TMP_FILE_PATTERN_LEN + 1) != TMP_FILE_PATTERN_LEN) { |
Victor Hsieh | 38e9c4a | 2019-03-07 13:27:59 -0800 | [diff] [blame] | 246 | ALOGE("Couldn't allocate temporary file name for library"); |
Kenny Root | 1ebd74a | 2011-08-03 15:09:44 -0700 | [diff] [blame] | 247 | return INSTALL_FAILED_INTERNAL_ERROR; |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 248 | } |
| 249 | |
| 250 | int fd = mkstemp(localTmpFileName); |
| 251 | if (fd < 0) { |
Victor Hsieh | 38e9c4a | 2019-03-07 13:27:59 -0800 | [diff] [blame] | 252 | ALOGE("Couldn't open temporary file name: %s: %s\n", localTmpFileName, strerror(errno)); |
Kenny Root | 1ebd74a | 2011-08-03 15:09:44 -0700 | [diff] [blame] | 253 | return INSTALL_FAILED_CONTAINER_ERROR; |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 254 | } |
| 255 | |
| 256 | if (!zipFile->uncompressEntry(zipEntry, fd)) { |
Victor Hsieh | 38e9c4a | 2019-03-07 13:27:59 -0800 | [diff] [blame] | 257 | ALOGE("Failed uncompressing %s to %s\n", fileName, localTmpFileName); |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 258 | close(fd); |
| 259 | unlink(localTmpFileName); |
Kenny Root | 1ebd74a | 2011-08-03 15:09:44 -0700 | [diff] [blame] | 260 | return INSTALL_FAILED_CONTAINER_ERROR; |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 261 | } |
| 262 | |
| 263 | close(fd); |
| 264 | |
| 265 | // Set the modification time for this file to the ZIP's mod time. |
| 266 | struct timeval times[2]; |
| 267 | times[0].tv_sec = st.st_atime; |
| 268 | times[1].tv_sec = modTime; |
| 269 | times[0].tv_usec = times[1].tv_usec = 0; |
| 270 | if (utimes(localTmpFileName, times) < 0) { |
Victor Hsieh | 38e9c4a | 2019-03-07 13:27:59 -0800 | [diff] [blame] | 271 | ALOGE("Couldn't change modification time on %s: %s\n", localTmpFileName, strerror(errno)); |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 272 | unlink(localTmpFileName); |
Kenny Root | 1ebd74a | 2011-08-03 15:09:44 -0700 | [diff] [blame] | 273 | return INSTALL_FAILED_CONTAINER_ERROR; |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 274 | } |
| 275 | |
| 276 | // Set the mode to 755 |
| 277 | static const mode_t mode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; |
| 278 | if (chmod(localTmpFileName, mode) < 0) { |
Victor Hsieh | 38e9c4a | 2019-03-07 13:27:59 -0800 | [diff] [blame] | 279 | ALOGE("Couldn't change permissions on %s: %s\n", localTmpFileName, strerror(errno)); |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 280 | unlink(localTmpFileName); |
Kenny Root | 1ebd74a | 2011-08-03 15:09:44 -0700 | [diff] [blame] | 281 | return INSTALL_FAILED_CONTAINER_ERROR; |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 282 | } |
| 283 | |
| 284 | // Finally, rename it to the final name. |
| 285 | if (rename(localTmpFileName, localFileName) < 0) { |
Victor Hsieh | 38e9c4a | 2019-03-07 13:27:59 -0800 | [diff] [blame] | 286 | ALOGE("Couldn't rename %s to %s: %s\n", localTmpFileName, localFileName, strerror(errno)); |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 287 | unlink(localTmpFileName); |
Kenny Root | 1ebd74a | 2011-08-03 15:09:44 -0700 | [diff] [blame] | 288 | return INSTALL_FAILED_CONTAINER_ERROR; |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 289 | } |
| 290 | |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 291 | ALOGV("Successfully moved %s to %s\n", localTmpFileName, localFileName); |
Kenny Root | 1ebd74a | 2011-08-03 15:09:44 -0700 | [diff] [blame] | 292 | |
| 293 | return INSTALL_SUCCEEDED; |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 294 | } |
| 295 | |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 296 | /* |
| 297 | * An iterator over all shared libraries in a zip file. An entry is |
| 298 | * considered to be a shared library if all of the conditions below are |
| 299 | * satisfied : |
| 300 | * |
| 301 | * - The entry is under the lib/ directory. |
| 302 | * - The entry name ends with ".so" and the entry name starts with "lib", |
| 303 | * an exception is made for entries whose name is "gdbserver". |
| 304 | * - The entry filename is "safe" (as determined by isFilenameSafe). |
| 305 | * |
| 306 | */ |
| 307 | class NativeLibrariesIterator { |
| 308 | private: |
Tamas Berghammer | d6dd6b8 | 2016-10-07 19:12:51 +0100 | [diff] [blame] | 309 | NativeLibrariesIterator(ZipFileRO* zipFile, bool debuggable, void* cookie) |
| 310 | : mZipFile(zipFile), mDebuggable(debuggable), mCookie(cookie), mLastSlash(NULL) { |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 311 | fileName[0] = '\0'; |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 312 | } |
| 313 | |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 314 | public: |
Tamas Berghammer | d6dd6b8 | 2016-10-07 19:12:51 +0100 | [diff] [blame] | 315 | static NativeLibrariesIterator* create(ZipFileRO* zipFile, bool debuggable) { |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 316 | void* cookie = NULL; |
Yusuke Sato | 957c237 | 2015-08-03 16:17:16 -0700 | [diff] [blame] | 317 | // Do not specify a suffix to find both .so files and gdbserver. |
| 318 | if (!zipFile->startIteration(&cookie, APK_LIB, NULL /* suffix */)) { |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 319 | return NULL; |
| 320 | } |
| 321 | |
Tamas Berghammer | d6dd6b8 | 2016-10-07 19:12:51 +0100 | [diff] [blame] | 322 | return new NativeLibrariesIterator(zipFile, debuggable, cookie); |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 323 | } |
| 324 | |
| 325 | ZipEntryRO next() { |
| 326 | ZipEntryRO next = NULL; |
| 327 | while ((next = mZipFile->nextEntry(mCookie)) != NULL) { |
| 328 | // Make sure this entry has a filename. |
| 329 | if (mZipFile->getEntryFileName(next, fileName, sizeof(fileName))) { |
| 330 | continue; |
| 331 | } |
| 332 | |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 333 | // Make sure the filename is at least to the minimum library name size. |
| 334 | const size_t fileNameLen = strlen(fileName); |
| 335 | static const size_t minLength = APK_LIB_LEN + 2 + LIB_PREFIX_LEN + 1 + LIB_SUFFIX_LEN; |
| 336 | if (fileNameLen < minLength) { |
| 337 | continue; |
| 338 | } |
| 339 | |
| 340 | const char* lastSlash = strrchr(fileName, '/'); |
| 341 | ALOG_ASSERT(lastSlash != NULL, "last slash was null somehow for %s\n", fileName); |
| 342 | |
Andreas Gampe | c012ae3 | 2016-12-15 16:12:39 -0800 | [diff] [blame] | 343 | // Skip directories. |
| 344 | if (*(lastSlash + 1) == 0) { |
| 345 | continue; |
| 346 | } |
| 347 | |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 348 | // Make sure the filename is safe. |
| 349 | if (!isFilenameSafe(lastSlash + 1)) { |
| 350 | continue; |
| 351 | } |
| 352 | |
Tamas Berghammer | d6dd6b8 | 2016-10-07 19:12:51 +0100 | [diff] [blame] | 353 | if (!mDebuggable) { |
| 354 | // Make sure the filename starts with lib and ends with ".so". |
| 355 | if (strncmp(fileName + fileNameLen - LIB_SUFFIX_LEN, LIB_SUFFIX, LIB_SUFFIX_LEN) |
| 356 | || strncmp(lastSlash, LIB_PREFIX, LIB_PREFIX_LEN)) { |
| 357 | continue; |
| 358 | } |
| 359 | } |
| 360 | |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 361 | mLastSlash = lastSlash; |
| 362 | break; |
| 363 | } |
| 364 | |
| 365 | return next; |
| 366 | } |
| 367 | |
| 368 | inline const char* currentEntry() const { |
| 369 | return fileName; |
| 370 | } |
| 371 | |
| 372 | inline const char* lastSlash() const { |
| 373 | return mLastSlash; |
| 374 | } |
| 375 | |
| 376 | virtual ~NativeLibrariesIterator() { |
| 377 | mZipFile->endIteration(mCookie); |
| 378 | } |
| 379 | private: |
| 380 | |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 381 | char fileName[PATH_MAX]; |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 382 | ZipFileRO* const mZipFile; |
Tamas Berghammer | d6dd6b8 | 2016-10-07 19:12:51 +0100 | [diff] [blame] | 383 | const bool mDebuggable; |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 384 | void* mCookie; |
| 385 | const char* mLastSlash; |
| 386 | }; |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 387 | |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 388 | static install_status_t |
| 389 | iterateOverNativeFiles(JNIEnv *env, jlong apkHandle, jstring javaCpuAbi, |
Tamas Berghammer | d6dd6b8 | 2016-10-07 19:12:51 +0100 | [diff] [blame] | 390 | jboolean debuggable, iterFunc callFunc, void* callArg) { |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 391 | ZipFileRO* zipFile = reinterpret_cast<ZipFileRO*>(apkHandle); |
| 392 | if (zipFile == NULL) { |
Narayan Kamath | afd31e0 | 2013-12-03 13:16:03 +0000 | [diff] [blame] | 393 | return INSTALL_FAILED_INVALID_APK; |
| 394 | } |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 395 | |
Tamas Berghammer | d6dd6b8 | 2016-10-07 19:12:51 +0100 | [diff] [blame] | 396 | std::unique_ptr<NativeLibrariesIterator> it( |
| 397 | NativeLibrariesIterator::create(zipFile, debuggable)); |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 398 | if (it.get() == NULL) { |
| 399 | return INSTALL_FAILED_INVALID_APK; |
| 400 | } |
| 401 | |
| 402 | const ScopedUtfChars cpuAbi(env, javaCpuAbi); |
| 403 | if (cpuAbi.c_str() == NULL) { |
| 404 | // This would've thrown, so this return code isn't observable by |
| 405 | // Java. |
| 406 | return INSTALL_FAILED_INVALID_APK; |
| 407 | } |
Narayan Kamath | afd31e0 | 2013-12-03 13:16:03 +0000 | [diff] [blame] | 408 | ZipEntryRO entry = NULL; |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 409 | while ((entry = it->next()) != NULL) { |
| 410 | const char* fileName = it->currentEntry(); |
| 411 | const char* lastSlash = it->lastSlash(); |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 412 | |
| 413 | // Check to make sure the CPU ABI of this file is one we support. |
| 414 | const char* cpuAbiOffset = fileName + APK_LIB_LEN; |
| 415 | const size_t cpuAbiRegionSize = lastSlash - cpuAbiOffset; |
| 416 | |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 417 | if (cpuAbi.size() == cpuAbiRegionSize && !strncmp(cpuAbiOffset, cpuAbi.c_str(), cpuAbiRegionSize)) { |
| 418 | install_status_t ret = callFunc(env, callArg, zipFile, entry, lastSlash + 1); |
Kenny Root | 1ebd74a | 2011-08-03 15:09:44 -0700 | [diff] [blame] | 419 | |
| 420 | if (ret != INSTALL_SUCCEEDED) { |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 421 | ALOGV("Failure for entry %s", lastSlash + 1); |
Kenny Root | 1ebd74a | 2011-08-03 15:09:44 -0700 | [diff] [blame] | 422 | return ret; |
| 423 | } |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 424 | } |
| 425 | } |
| 426 | |
| 427 | return INSTALL_SUCCEEDED; |
| 428 | } |
| 429 | |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 430 | |
Tamas Berghammer | d6dd6b8 | 2016-10-07 19:12:51 +0100 | [diff] [blame] | 431 | static int findSupportedAbi(JNIEnv *env, jlong apkHandle, jobjectArray supportedAbisArray, |
| 432 | jboolean debuggable) { |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 433 | const int numAbis = env->GetArrayLength(supportedAbisArray); |
| 434 | Vector<ScopedUtfChars*> supportedAbis; |
| 435 | |
| 436 | for (int i = 0; i < numAbis; ++i) { |
| 437 | supportedAbis.add(new ScopedUtfChars(env, |
| 438 | (jstring) env->GetObjectArrayElement(supportedAbisArray, i))); |
| 439 | } |
| 440 | |
| 441 | ZipFileRO* zipFile = reinterpret_cast<ZipFileRO*>(apkHandle); |
| 442 | if (zipFile == NULL) { |
| 443 | return INSTALL_FAILED_INVALID_APK; |
| 444 | } |
| 445 | |
Tamas Berghammer | d6dd6b8 | 2016-10-07 19:12:51 +0100 | [diff] [blame] | 446 | std::unique_ptr<NativeLibrariesIterator> it( |
| 447 | NativeLibrariesIterator::create(zipFile, debuggable)); |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 448 | if (it.get() == NULL) { |
| 449 | return INSTALL_FAILED_INVALID_APK; |
| 450 | } |
| 451 | |
| 452 | ZipEntryRO entry = NULL; |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 453 | int status = NO_NATIVE_LIBRARIES; |
| 454 | while ((entry = it->next()) != NULL) { |
| 455 | // We're currently in the lib/ directory of the APK, so it does have some native |
| 456 | // code. We should return INSTALL_FAILED_NO_MATCHING_ABIS if none of the |
| 457 | // libraries match. |
| 458 | if (status == NO_NATIVE_LIBRARIES) { |
| 459 | status = INSTALL_FAILED_NO_MATCHING_ABIS; |
| 460 | } |
| 461 | |
| 462 | const char* fileName = it->currentEntry(); |
| 463 | const char* lastSlash = it->lastSlash(); |
| 464 | |
| 465 | // Check to see if this CPU ABI matches what we are looking for. |
| 466 | const char* abiOffset = fileName + APK_LIB_LEN; |
| 467 | const size_t abiSize = lastSlash - abiOffset; |
| 468 | for (int i = 0; i < numAbis; i++) { |
| 469 | const ScopedUtfChars* abi = supportedAbis[i]; |
| 470 | if (abi->size() == abiSize && !strncmp(abiOffset, abi->c_str(), abiSize)) { |
| 471 | // The entry that comes in first (i.e. with a lower index) has the higher priority. |
| 472 | if (((i < status) && (status >= 0)) || (status < 0) ) { |
| 473 | status = i; |
| 474 | } |
| 475 | } |
| 476 | } |
| 477 | } |
| 478 | |
| 479 | for (int i = 0; i < numAbis; ++i) { |
| 480 | delete supportedAbis[i]; |
| 481 | } |
| 482 | |
| 483 | return status; |
| 484 | } |
| 485 | |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 486 | static jint |
| 487 | com_android_internal_content_NativeLibraryHelper_copyNativeBinaries(JNIEnv *env, jclass clazz, |
Dmitriy Ivanov | dec4688 | 2014-09-30 15:10:48 -0700 | [diff] [blame] | 488 | jlong apkHandle, jstring javaNativeLibPath, jstring javaCpuAbi, |
dimitry | 6e44c30 | 2018-10-04 15:57:14 +0200 | [diff] [blame] | 489 | jboolean extractNativeLibs, jboolean debuggable) |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 490 | { |
dimitry | 6e44c30 | 2018-10-04 15:57:14 +0200 | [diff] [blame] | 491 | void* args[] = { &javaNativeLibPath, &extractNativeLibs }; |
Tamas Berghammer | d6dd6b8 | 2016-10-07 19:12:51 +0100 | [diff] [blame] | 492 | return (jint) iterateOverNativeFiles(env, apkHandle, javaCpuAbi, debuggable, |
Dmitriy Ivanov | dec4688 | 2014-09-30 15:10:48 -0700 | [diff] [blame] | 493 | copyFileIfChanged, reinterpret_cast<void*>(args)); |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 494 | } |
| 495 | |
| 496 | static jlong |
| 497 | com_android_internal_content_NativeLibraryHelper_sumNativeBinaries(JNIEnv *env, jclass clazz, |
Tamas Berghammer | d6dd6b8 | 2016-10-07 19:12:51 +0100 | [diff] [blame] | 498 | jlong apkHandle, jstring javaCpuAbi, jboolean debuggable) |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 499 | { |
| 500 | size_t totalSize = 0; |
| 501 | |
Tamas Berghammer | d6dd6b8 | 2016-10-07 19:12:51 +0100 | [diff] [blame] | 502 | iterateOverNativeFiles(env, apkHandle, javaCpuAbi, debuggable, sumFiles, &totalSize); |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 503 | |
| 504 | return totalSize; |
| 505 | } |
| 506 | |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 507 | static jint |
| 508 | com_android_internal_content_NativeLibraryHelper_findSupportedAbi(JNIEnv *env, jclass clazz, |
Tamas Berghammer | d6dd6b8 | 2016-10-07 19:12:51 +0100 | [diff] [blame] | 509 | jlong apkHandle, jobjectArray javaCpuAbisToSearch, jboolean debuggable) |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 510 | { |
Tamas Berghammer | d6dd6b8 | 2016-10-07 19:12:51 +0100 | [diff] [blame] | 511 | return (jint) findSupportedAbi(env, apkHandle, javaCpuAbisToSearch, debuggable); |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 512 | } |
| 513 | |
Narayan Kamath | d47e38b | 2014-05-16 16:45:56 +0100 | [diff] [blame] | 514 | enum bitcode_scan_result_t { |
| 515 | APK_SCAN_ERROR = -1, |
| 516 | NO_BITCODE_PRESENT = 0, |
| 517 | BITCODE_PRESENT = 1, |
| 518 | }; |
| 519 | |
| 520 | static jint |
| 521 | com_android_internal_content_NativeLibraryHelper_hasRenderscriptBitcode(JNIEnv *env, jclass clazz, |
| 522 | jlong apkHandle) { |
| 523 | ZipFileRO* zipFile = reinterpret_cast<ZipFileRO*>(apkHandle); |
| 524 | void* cookie = NULL; |
Yusuke Sato | 957c237 | 2015-08-03 16:17:16 -0700 | [diff] [blame] | 525 | if (!zipFile->startIteration(&cookie, NULL /* prefix */, RS_BITCODE_SUFFIX)) { |
Narayan Kamath | d47e38b | 2014-05-16 16:45:56 +0100 | [diff] [blame] | 526 | return APK_SCAN_ERROR; |
| 527 | } |
| 528 | |
| 529 | char fileName[PATH_MAX]; |
| 530 | ZipEntryRO next = NULL; |
| 531 | while ((next = zipFile->nextEntry(cookie)) != NULL) { |
| 532 | if (zipFile->getEntryFileName(next, fileName, sizeof(fileName))) { |
| 533 | continue; |
| 534 | } |
Narayan Kamath | d47e38b | 2014-05-16 16:45:56 +0100 | [diff] [blame] | 535 | const char* lastSlash = strrchr(fileName, '/'); |
| 536 | const char* baseName = (lastSlash == NULL) ? fileName : fileName + 1; |
Yusuke Sato | 957c237 | 2015-08-03 16:17:16 -0700 | [diff] [blame] | 537 | if (isFilenameSafe(baseName)) { |
Narayan Kamath | d47e38b | 2014-05-16 16:45:56 +0100 | [diff] [blame] | 538 | zipFile->endIteration(cookie); |
| 539 | return BITCODE_PRESENT; |
| 540 | } |
| 541 | } |
| 542 | |
| 543 | zipFile->endIteration(cookie); |
| 544 | return NO_BITCODE_PRESENT; |
| 545 | } |
| 546 | |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 547 | static jlong |
| 548 | com_android_internal_content_NativeLibraryHelper_openApk(JNIEnv *env, jclass, jstring apkPath) |
| 549 | { |
| 550 | ScopedUtfChars filePath(env, apkPath); |
| 551 | ZipFileRO* zipFile = ZipFileRO::open(filePath.c_str()); |
| 552 | |
| 553 | return reinterpret_cast<jlong>(zipFile); |
| 554 | } |
| 555 | |
Dianne Hackborn | 1704e3c | 2017-10-31 19:55:42 +0000 | [diff] [blame] | 556 | static jlong |
| 557 | com_android_internal_content_NativeLibraryHelper_openApkFd(JNIEnv *env, jclass, |
| 558 | jobject fileDescriptor, jstring debugPathName) |
| 559 | { |
| 560 | ScopedUtfChars debugFilePath(env, debugPathName); |
| 561 | |
| 562 | int fd = jniGetFDFromFileDescriptor(env, fileDescriptor); |
| 563 | if (fd < 0) { |
| 564 | jniThrowException(env, "java/lang/IllegalArgumentException", "Bad FileDescriptor"); |
| 565 | return 0; |
| 566 | } |
| 567 | |
Nick Kralevich | 4b3a08c | 2019-01-28 10:39:10 -0800 | [diff] [blame] | 568 | int dupedFd = fcntl(fd, F_DUPFD_CLOEXEC, 0); |
Josh Gao | 5fc8bbe | 2018-07-17 15:00:31 -0700 | [diff] [blame] | 569 | if (dupedFd == -1) { |
| 570 | jniThrowExceptionFmt(env, "java/lang/IllegalArgumentException", |
| 571 | "Failed to dup FileDescriptor: %s", strerror(errno)); |
| 572 | return 0; |
| 573 | } |
| 574 | |
| 575 | ZipFileRO* zipFile = ZipFileRO::openFd(dupedFd, debugFilePath.c_str()); |
Dianne Hackborn | 1704e3c | 2017-10-31 19:55:42 +0000 | [diff] [blame] | 576 | |
| 577 | return reinterpret_cast<jlong>(zipFile); |
| 578 | } |
| 579 | |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 580 | static void |
| 581 | com_android_internal_content_NativeLibraryHelper_close(JNIEnv *env, jclass, jlong apkHandle) |
| 582 | { |
| 583 | delete reinterpret_cast<ZipFileRO*>(apkHandle); |
| 584 | } |
| 585 | |
Daniel Micay | 76f6a86 | 2015-09-19 17:31:01 -0400 | [diff] [blame] | 586 | static const JNINativeMethod gMethods[] = { |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 587 | {"nativeOpenApk", |
| 588 | "(Ljava/lang/String;)J", |
| 589 | (void *)com_android_internal_content_NativeLibraryHelper_openApk}, |
Dianne Hackborn | 1704e3c | 2017-10-31 19:55:42 +0000 | [diff] [blame] | 590 | {"nativeOpenApkFd", |
| 591 | "(Ljava/io/FileDescriptor;Ljava/lang/String;)J", |
| 592 | (void *)com_android_internal_content_NativeLibraryHelper_openApkFd}, |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 593 | {"nativeClose", |
| 594 | "(J)V", |
| 595 | (void *)com_android_internal_content_NativeLibraryHelper_close}, |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 596 | {"nativeCopyNativeBinaries", |
dimitry | 6e44c30 | 2018-10-04 15:57:14 +0200 | [diff] [blame] | 597 | "(JLjava/lang/String;Ljava/lang/String;ZZ)I", |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 598 | (void *)com_android_internal_content_NativeLibraryHelper_copyNativeBinaries}, |
| 599 | {"nativeSumNativeBinaries", |
Tamas Berghammer | d6dd6b8 | 2016-10-07 19:12:51 +0100 | [diff] [blame] | 600 | "(JLjava/lang/String;Z)J", |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 601 | (void *)com_android_internal_content_NativeLibraryHelper_sumNativeBinaries}, |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 602 | {"nativeFindSupportedAbi", |
Tamas Berghammer | d6dd6b8 | 2016-10-07 19:12:51 +0100 | [diff] [blame] | 603 | "(J[Ljava/lang/String;Z)I", |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 604 | (void *)com_android_internal_content_NativeLibraryHelper_findSupportedAbi}, |
Narayan Kamath | d47e38b | 2014-05-16 16:45:56 +0100 | [diff] [blame] | 605 | {"hasRenderscriptBitcode", "(J)I", |
| 606 | (void *)com_android_internal_content_NativeLibraryHelper_hasRenderscriptBitcode}, |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 607 | }; |
| 608 | |
| 609 | |
| 610 | int register_com_android_internal_content_NativeLibraryHelper(JNIEnv *env) |
| 611 | { |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 612 | return RegisterMethodsOrDie(env, |
| 613 | "com/android/internal/content/NativeLibraryHelper", gMethods, NELEM(gMethods)); |
Kenny Root | 66269ea | 2011-07-12 14:14:01 -0700 | [diff] [blame] | 614 | } |
| 615 | |
| 616 | }; |