shafik | c3f6267 | 2019-08-30 11:15:48 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2019 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 specic language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef MEDIAPROVIDER_FUSE_MEDIAPROVIDERWRAPPER_H_ |
| 18 | #define MEDIAPROVIDER_FUSE_MEDIAPROVIDERWRAPPER_H_ |
| 19 | |
Zim | ded1ab9 | 2021-01-15 10:36:17 +0000 | [diff] [blame] | 20 | #include <android-base/logging.h> |
shafik | c3f6267 | 2019-08-30 11:15:48 +0100 | [diff] [blame] | 21 | #include <jni.h> |
| 22 | #include <sys/types.h> |
| 23 | |
Sahana Rao | 7169344 | 2019-11-13 13:48:07 +0000 | [diff] [blame] | 24 | #include <dirent.h> |
shafik | cdb6b2b | 2019-09-30 12:49:26 +0100 | [diff] [blame] | 25 | #include <atomic> |
| 26 | #include <condition_variable> |
| 27 | #include <functional> |
| 28 | #include <mutex> |
| 29 | #include <queue> |
shafik | c3f6267 | 2019-08-30 11:15:48 +0100 | [diff] [blame] | 30 | #include <string> |
shafik | cdb6b2b | 2019-09-30 12:49:26 +0100 | [diff] [blame] | 31 | #include <thread> |
shafik | c3f6267 | 2019-08-30 11:15:48 +0100 | [diff] [blame] | 32 | |
Sahana Rao | a82bd6a | 2019-10-10 18:10:37 +0100 | [diff] [blame] | 33 | #include "libfuse_jni/ReaddirHelper.h" |
shafik | c3f6267 | 2019-08-30 11:15:48 +0100 | [diff] [blame] | 34 | #include "libfuse_jni/RedactionInfo.h" |
| 35 | |
| 36 | namespace mediaprovider { |
| 37 | namespace fuse { |
| 38 | |
Zim | 73895ba | 2021-01-13 12:51:20 +0000 | [diff] [blame] | 39 | /** Represents file open result from MediaProvider */ |
| 40 | struct FileOpenResult { |
Manish Singh | 9a6ccce | 2021-02-05 23:50:08 +0000 | [diff] [blame] | 41 | FileOpenResult(const int status, const int uid, uid_t transforms_uid, |
| 42 | const RedactionInfo* redaction_info) |
| 43 | : status(status), uid(uid), transforms_uid(transforms_uid), redaction_info(redaction_info) {} |
Zim | 73895ba | 2021-01-13 12:51:20 +0000 | [diff] [blame] | 44 | |
| 45 | const int status; |
| 46 | const int uid; |
Manish Singh | 9a6ccce | 2021-02-05 23:50:08 +0000 | [diff] [blame] | 47 | const uid_t transforms_uid; |
Zim | 73895ba | 2021-01-13 12:51:20 +0000 | [diff] [blame] | 48 | std::unique_ptr<const RedactionInfo> redaction_info; |
| 49 | }; |
| 50 | |
shafik | c3f6267 | 2019-08-30 11:15:48 +0100 | [diff] [blame] | 51 | /** |
Biswarup Pal | 63901f3 | 2021-01-07 14:57:23 +0000 | [diff] [blame] | 52 | * Represents transform info for a file, containing the transforms, the transforms completion |
| 53 | * status and the ioPath. Provided by MediaProvider.java via a JNI call. |
| 54 | */ |
| 55 | struct FileLookupResult { |
Zim | 801d985 | 2021-01-26 18:30:53 +0000 | [diff] [blame] | 56 | FileLookupResult(int transforms, int transforms_reason, uid_t uid, bool transforms_complete, |
| 57 | bool transforms_supported, const std::string& io_path) |
Zim | ded1ab9 | 2021-01-15 10:36:17 +0000 | [diff] [blame] | 58 | : transforms(transforms), |
Zim | 801d985 | 2021-01-26 18:30:53 +0000 | [diff] [blame] | 59 | transforms_reason(transforms_reason), |
Zim | ded1ab9 | 2021-01-15 10:36:17 +0000 | [diff] [blame] | 60 | uid(uid), |
| 61 | transforms_complete(transforms_complete), |
| 62 | transforms_supported(transforms_supported), |
| 63 | io_path(io_path) { |
| 64 | if (transforms != 0) { |
| 65 | CHECK(transforms_supported); |
| 66 | } |
| 67 | } |
Biswarup Pal | 63901f3 | 2021-01-07 14:57:23 +0000 | [diff] [blame] | 68 | |
| 69 | /** |
Manish Singh | 9a6ccce | 2021-02-05 23:50:08 +0000 | [diff] [blame] | 70 | * These fields are not to be interpreted, they are determined and populated from MediaProvider |
Biswarup Pal | 63901f3 | 2021-01-07 14:57:23 +0000 | [diff] [blame] | 71 | * via a JNI call. |
| 72 | */ |
| 73 | const int transforms; |
Zim | 801d985 | 2021-01-26 18:30:53 +0000 | [diff] [blame] | 74 | const int transforms_reason; |
Zim | ded1ab9 | 2021-01-15 10:36:17 +0000 | [diff] [blame] | 75 | const uid_t uid; |
Biswarup Pal | 63901f3 | 2021-01-07 14:57:23 +0000 | [diff] [blame] | 76 | const bool transforms_complete; |
Zim | ded1ab9 | 2021-01-15 10:36:17 +0000 | [diff] [blame] | 77 | const bool transforms_supported; |
Biswarup Pal | 63901f3 | 2021-01-07 14:57:23 +0000 | [diff] [blame] | 78 | const std::string io_path; |
| 79 | }; |
| 80 | |
| 81 | /** |
shafik | c3f6267 | 2019-08-30 11:15:48 +0100 | [diff] [blame] | 82 | * Class that wraps MediaProvider.java and all of the needed JNI calls to make |
| 83 | * interaction with MediaProvider easier. |
| 84 | */ |
| 85 | class MediaProviderWrapper final { |
| 86 | public: |
shafik | cdb6b2b | 2019-09-30 12:49:26 +0100 | [diff] [blame] | 87 | MediaProviderWrapper(JNIEnv* env, jobject media_provider); |
shafik | c3f6267 | 2019-08-30 11:15:48 +0100 | [diff] [blame] | 88 | ~MediaProviderWrapper(); |
| 89 | |
| 90 | /** |
shafik | c580b6d | 2019-12-10 18:45:17 +0000 | [diff] [blame] | 91 | * Computes and returns the RedactionInfo for a given file and UID. |
shafik | c3f6267 | 2019-08-30 11:15:48 +0100 | [diff] [blame] | 92 | * |
| 93 | * @param uid UID of the app requesting the read |
Zim | e9ae6ee | 2020-11-26 15:38:13 +0000 | [diff] [blame] | 94 | * @param path path of the requested file that will be used for database operations |
| 95 | * @param io_path path of the requested file that will be used for IO |
shafik | c3f6267 | 2019-08-30 11:15:48 +0100 | [diff] [blame] | 96 | * @return RedactionInfo on success, nullptr on failure to calculate |
| 97 | * redaction ranges (e.g. exception was thrown in Java world) |
| 98 | */ |
Zim | e9ae6ee | 2020-11-26 15:38:13 +0000 | [diff] [blame] | 99 | std::unique_ptr<RedactionInfo> GetRedactionInfo(const std::string& path, |
| 100 | const std::string& io_path, uid_t uid, |
| 101 | pid_t tid); |
shafik | c3f6267 | 2019-08-30 11:15:48 +0100 | [diff] [blame] | 102 | |
shafik | a51f3ce | 2019-10-10 17:06:41 +0100 | [diff] [blame] | 103 | /** |
shafik | 9edfb14 | 2019-11-06 11:01:40 +0000 | [diff] [blame] | 104 | * Inserts a new entry for the given path and UID. |
shafik | a51f3ce | 2019-10-10 17:06:41 +0100 | [diff] [blame] | 105 | * |
| 106 | * @param path the path of the file to be created |
| 107 | * @param uid UID of the calling app |
shafik | 9edfb14 | 2019-11-06 11:01:40 +0000 | [diff] [blame] | 108 | * @return 0 if the operation succeeded, |
shafik | e4fb146 | 2020-01-29 16:25:23 +0000 | [diff] [blame] | 109 | * or errno error code if operation fails. |
shafik | a51f3ce | 2019-10-10 17:06:41 +0100 | [diff] [blame] | 110 | */ |
shafik | 9edfb14 | 2019-11-06 11:01:40 +0000 | [diff] [blame] | 111 | int InsertFile(const std::string& path, uid_t uid); |
shafik | a51f3ce | 2019-10-10 17:06:41 +0100 | [diff] [blame] | 112 | |
shafik | 0c0e0d7 | 2019-10-16 17:34:17 +0100 | [diff] [blame] | 113 | /** |
| 114 | * Delete the file denoted by the given path on behalf of the given UID. |
| 115 | * |
| 116 | * @param path the path of the file to be deleted |
| 117 | * @param uid UID of the calling app |
shafik | e4fb146 | 2020-01-29 16:25:23 +0000 | [diff] [blame] | 118 | * @return 0 upon success, or errno error code if operation fails. |
shafik | 0c0e0d7 | 2019-10-16 17:34:17 +0100 | [diff] [blame] | 119 | */ |
| 120 | int DeleteFile(const std::string& path, uid_t uid); |
| 121 | |
shafik | 15e2d61 | 2019-10-31 20:10:25 +0000 | [diff] [blame] | 122 | /** |
Sahana Rao | 8a588e7 | 2019-12-06 11:32:56 +0000 | [diff] [blame] | 123 | * Gets directory entries for given path from MediaProvider database and lower file system |
Sahana Rao | a82bd6a | 2019-10-10 18:10:37 +0100 | [diff] [blame] | 124 | * |
| 125 | * @param uid UID of the calling app. |
| 126 | * @param path Relative path of the directory. |
Sahana Rao | 7169344 | 2019-11-13 13:48:07 +0000 | [diff] [blame] | 127 | * @param dirp Pointer to directory stream, used to query lower file system. |
Sahana Rao | 8a588e7 | 2019-12-06 11:32:56 +0000 | [diff] [blame] | 128 | * @return DirectoryEntries with list of directory entries on success. |
| 129 | * File names in a directory are obtained from MediaProvider. If a path is unknown to |
| 130 | * MediaProvider, file names are obtained from lower file system. All directory names in the |
| 131 | * given directory are obtained from lower file system. |
Sahana Rao | 7169344 | 2019-11-13 13:48:07 +0000 | [diff] [blame] | 132 | * An empty string in first directory entry name indicates the error occurred while obtaining |
| 133 | * directory entries, directory entry type will hold the corresponding errno information. |
Sahana Rao | a82bd6a | 2019-10-10 18:10:37 +0100 | [diff] [blame] | 134 | */ |
| 135 | std::vector<std::shared_ptr<DirectoryEntry>> GetDirectoryEntries(uid_t uid, |
| 136 | const std::string& path, |
| 137 | DIR* dirp); |
| 138 | |
| 139 | /** |
shafik | 15e2d61 | 2019-10-31 20:10:25 +0000 | [diff] [blame] | 140 | * Determines if the given UID is allowed to open the file denoted by the given path. |
| 141 | * |
Zim | 73895ba | 2021-01-13 12:51:20 +0000 | [diff] [blame] | 142 | * Also computes and returns the RedactionInfo for a given file and |uid| |
| 143 | * |
| 144 | * @param path path of the requested file that will be used for database operations |
| 145 | * @param io_path path of the requested file that will be used for IO |
shafik | 15e2d61 | 2019-10-31 20:10:25 +0000 | [diff] [blame] | 146 | * @param uid UID of the calling app |
Zim | 73895ba | 2021-01-13 12:51:20 +0000 | [diff] [blame] | 147 | * @param tid UID of the calling app |
shafik | 15e2d61 | 2019-10-31 20:10:25 +0000 | [diff] [blame] | 148 | * @param for_write specifies if the file is to be opened for write |
Zim | 73895ba | 2021-01-13 12:51:20 +0000 | [diff] [blame] | 149 | * @param redact specifies whether to attempt redaction |
| 150 | * @return FileOpenResult containing status, uid and redaction_info |
shafik | 15e2d61 | 2019-10-31 20:10:25 +0000 | [diff] [blame] | 151 | */ |
Zim | 73895ba | 2021-01-13 12:51:20 +0000 | [diff] [blame] | 152 | std::unique_ptr<FileOpenResult> OnFileOpen(const std::string& path, const std::string& io_path, |
Zim | 801d985 | 2021-01-26 18:30:53 +0000 | [diff] [blame] | 153 | uid_t uid, pid_t tid, int transforms_reason, |
| 154 | bool for_write, bool redact, |
| 155 | bool log_transforms_metrics); |
shafik | 15e2d61 | 2019-10-31 20:10:25 +0000 | [diff] [blame] | 156 | |
| 157 | /** |
shafik | bba5b67 | 2019-11-15 16:52:51 +0000 | [diff] [blame] | 158 | * Determines if the given UID is allowed to create a directory with the given path. |
| 159 | * |
| 160 | * @param path the path of the directory to be created |
| 161 | * @param uid UID of the calling app |
shafik | e4fb146 | 2020-01-29 16:25:23 +0000 | [diff] [blame] | 162 | * @return 0 if it's allowed, or errno error code if operation isn't allowed. |
shafik | bba5b67 | 2019-11-15 16:52:51 +0000 | [diff] [blame] | 163 | */ |
| 164 | int IsCreatingDirAllowed(const std::string& path, uid_t uid); |
| 165 | |
| 166 | /** |
| 167 | * Determines if the given UID is allowed to delete the directory with the given path. |
| 168 | * |
| 169 | * @param path the path of the directory to be deleted |
| 170 | * @param uid UID of the calling app |
shafik | e4fb146 | 2020-01-29 16:25:23 +0000 | [diff] [blame] | 171 | * @return 0 if it's allowed, or errno error code if operation isn't allowed. |
shafik | bba5b67 | 2019-11-15 16:52:51 +0000 | [diff] [blame] | 172 | */ |
| 173 | int IsDeletingDirAllowed(const std::string& path, uid_t uid); |
| 174 | |
shafik | 824c108 | 2019-11-22 12:00:52 +0000 | [diff] [blame] | 175 | /** |
| 176 | * Determines if the given UID is allowed to open the directory with the given path. |
| 177 | * |
| 178 | * @param path the path of the directory to be opened |
| 179 | * @param uid UID of the calling app |
Nandana Dutt | 5fc3201 | 2020-06-25 10:55:52 +0100 | [diff] [blame] | 180 | * @param forWrite if it's a write access |
shafik | e4fb146 | 2020-01-29 16:25:23 +0000 | [diff] [blame] | 181 | * @return 0 if it's allowed, or errno error code if operation isn't allowed. |
shafik | 824c108 | 2019-11-22 12:00:52 +0000 | [diff] [blame] | 182 | */ |
Nandana Dutt | 5fc3201 | 2020-06-25 10:55:52 +0100 | [diff] [blame] | 183 | int IsOpendirAllowed(const std::string& path, uid_t uid, bool forWrite); |
shafik | 824c108 | 2019-11-22 12:00:52 +0000 | [diff] [blame] | 184 | |
Sahana Rao | 2c41603 | 2019-12-31 13:41:00 +0000 | [diff] [blame] | 185 | /** |
Abhijeet Kaur | b3ac280 | 2020-10-07 16:42:42 +0100 | [diff] [blame] | 186 | * Determines if one of the follows is true: |
| 187 | * 1. The package name of the given private path matches the given uid, |
| 188 | then this uid has access to private-app directories for this package. |
| 189 | * 2. The calling uid has special access to private-app directories: |
| 190 | * * DownloadProvider and ExternalStorageProvider has access to private |
| 191 | * app directories. |
| 192 | * * Installer apps have access to Android/obb directories |
Ricky Wai | f40c402 | 2020-04-15 19:00:06 +0100 | [diff] [blame] | 193 | * |
Ricky Wai | f40c402 | 2020-04-15 19:00:06 +0100 | [diff] [blame] | 194 | * @param uid UID of the app |
Abhijeet Kaur | b3ac280 | 2020-10-07 16:42:42 +0100 | [diff] [blame] | 195 | * @param path the private path that the UID wants to access |
Ricky Wai | f40c402 | 2020-04-15 19:00:06 +0100 | [diff] [blame] | 196 | * @return true if it matches, otherwise return false. |
| 197 | */ |
Abhijeet Kaur | b3ac280 | 2020-10-07 16:42:42 +0100 | [diff] [blame] | 198 | bool isUidAllowedAccessToDataOrObbPath(uid_t uid, const std::string& path); |
Ricky Wai | f40c402 | 2020-04-15 19:00:06 +0100 | [diff] [blame] | 199 | |
| 200 | /** |
Sahana Rao | 2c41603 | 2019-12-31 13:41:00 +0000 | [diff] [blame] | 201 | * Renames a file or directory to new path. |
| 202 | * |
| 203 | * @param old_path path of the file or directory to be renamed. |
| 204 | * @param new_path new path of the file or directory to be renamed. |
| 205 | * @param uid UID of the calling app. |
shafik | e4fb146 | 2020-01-29 16:25:23 +0000 | [diff] [blame] | 206 | * @return 0 if rename is successful, errno if one of the rename fails. If return |
Sahana Rao | 2c41603 | 2019-12-31 13:41:00 +0000 | [diff] [blame] | 207 | * value is 0, it's guaranteed that file/directory is moved to new_path. For any other errno |
| 208 | * except EFAULT/EIO, it's guaranteed that file/directory is not renamed. |
| 209 | */ |
| 210 | int Rename(const std::string& old_path, const std::string& new_path, uid_t uid); |
| 211 | |
Narayan Kamath | de3fe17 | 2020-02-18 12:14:51 +0000 | [diff] [blame] | 212 | /** |
Martijn Coenen | af2d34d | 2020-06-19 12:52:20 +0200 | [diff] [blame] | 213 | * Called whenever a file has been created through FUSE. |
| 214 | * |
| 215 | * @param path path of the file that has been created. |
| 216 | */ |
| 217 | void OnFileCreated(const std::string& path); |
| 218 | |
Biswarup Pal | 63901f3 | 2021-01-07 14:57:23 +0000 | [diff] [blame] | 219 | /** |
| 220 | * Returns FileLookupResult to determine transform info for a path and uid. |
| 221 | */ |
Zim | ded1ab9 | 2021-01-15 10:36:17 +0000 | [diff] [blame] | 222 | std::unique_ptr<FileLookupResult> FileLookup(const std::string& path, uid_t uid, pid_t tid); |
Zim | bb91fef | 2020-09-23 14:32:27 +0100 | [diff] [blame] | 223 | |
| 224 | /** Transforms from src to dst file */ |
Zim | 801d985 | 2021-01-26 18:30:53 +0000 | [diff] [blame] | 225 | bool Transform(const std::string& src, const std::string& dst, int transforms, |
Manish Singh | 9a6ccce | 2021-02-05 23:50:08 +0000 | [diff] [blame] | 226 | int transforms_reason, uid_t read_uid, uid_t open_uid, uid_t transforms_uid); |
Zim | bb91fef | 2020-09-23 14:32:27 +0100 | [diff] [blame] | 227 | |
Martijn Coenen | af2d34d | 2020-06-19 12:52:20 +0200 | [diff] [blame] | 228 | /** |
Zim | 5077a89 | 2020-09-08 12:55:12 +0100 | [diff] [blame] | 229 | * Determines if to allow FUSE_LOOKUP for uid. Might allow uids that don't belong to the |
| 230 | * MediaProvider user, depending on OEM configuration. |
| 231 | * |
| 232 | * @param uid linux uid to check |
| 233 | */ |
| 234 | bool ShouldAllowLookup(uid_t uid, int path_user_id); |
| 235 | |
| 236 | /** |
Martijn Coenen | 8713309 | 2020-10-14 17:00:28 +0200 | [diff] [blame] | 237 | * Determines if the passed in user ID is an app clone user (paired with user 0) |
| 238 | * |
| 239 | * @param userId the user ID to check |
| 240 | */ |
| 241 | bool IsAppCloneUser(uid_t userId); |
| 242 | |
| 243 | /** |
Narayan Kamath | de3fe17 | 2020-02-18 12:14:51 +0000 | [diff] [blame] | 244 | * Initializes per-process static variables associated with the lifetime of |
| 245 | * a managed runtime. |
| 246 | */ |
| 247 | static void OneTimeInit(JavaVM* vm); |
| 248 | |
Zim | c0e65bd | 2020-03-09 15:22:59 +0000 | [diff] [blame] | 249 | /** TLS Key to map a given thread to its JNIEnv. */ |
| 250 | static pthread_key_t gJniEnvKey; |
| 251 | |
shafik | c3f6267 | 2019-08-30 11:15:48 +0100 | [diff] [blame] | 252 | private: |
Biswarup Pal | 63901f3 | 2021-01-07 14:57:23 +0000 | [diff] [blame] | 253 | jclass file_lookup_result_class_; |
Zim | 73895ba | 2021-01-13 12:51:20 +0000 | [diff] [blame] | 254 | jclass file_open_result_class_; |
shafik | cdb6b2b | 2019-09-30 12:49:26 +0100 | [diff] [blame] | 255 | jclass media_provider_class_; |
| 256 | jobject media_provider_object_; |
shafik | 0c0e0d7 | 2019-10-16 17:34:17 +0100 | [diff] [blame] | 257 | /** Cached MediaProvider method IDs **/ |
shafik | 9edfb14 | 2019-11-06 11:01:40 +0000 | [diff] [blame] | 258 | jmethodID mid_insert_file_; |
shafik | 0c0e0d7 | 2019-10-16 17:34:17 +0100 | [diff] [blame] | 259 | jmethodID mid_delete_file_; |
Zim | 73895ba | 2021-01-13 12:51:20 +0000 | [diff] [blame] | 260 | jmethodID mid_on_file_open_; |
shafik | 15e2d61 | 2019-10-31 20:10:25 +0000 | [diff] [blame] | 261 | jmethodID mid_scan_file_; |
shafik | f0fea69 | 2020-02-14 15:49:17 +0000 | [diff] [blame] | 262 | jmethodID mid_is_mkdir_or_rmdir_allowed_; |
shafik | 824c108 | 2019-11-22 12:00:52 +0000 | [diff] [blame] | 263 | jmethodID mid_is_opendir_allowed_; |
Sahana Rao | 8a588e7 | 2019-12-06 11:32:56 +0000 | [diff] [blame] | 264 | jmethodID mid_get_files_in_dir_; |
Sahana Rao | 2c41603 | 2019-12-31 13:41:00 +0000 | [diff] [blame] | 265 | jmethodID mid_rename_; |
Abhijeet Kaur | b3ac280 | 2020-10-07 16:42:42 +0100 | [diff] [blame] | 266 | jmethodID mid_is_uid_allowed_access_to_data_or_obb_path_; |
Martijn Coenen | af2d34d | 2020-06-19 12:52:20 +0200 | [diff] [blame] | 267 | jmethodID mid_on_file_created_; |
Zim | 5077a89 | 2020-09-08 12:55:12 +0100 | [diff] [blame] | 268 | jmethodID mid_should_allow_lookup_; |
Martijn Coenen | 8713309 | 2020-10-14 17:00:28 +0200 | [diff] [blame] | 269 | jmethodID mid_is_app_clone_user_; |
Zim | bb91fef | 2020-09-23 14:32:27 +0100 | [diff] [blame] | 270 | jmethodID mid_transform_; |
Biswarup Pal | 63901f3 | 2021-01-07 14:57:23 +0000 | [diff] [blame] | 271 | jmethodID mid_file_lookup_; |
| 272 | /** Cached FileLookupResult field IDs **/ |
| 273 | jfieldID fid_file_lookup_transforms_; |
Zim | 801d985 | 2021-01-26 18:30:53 +0000 | [diff] [blame] | 274 | jfieldID fid_file_lookup_transforms_reason_; |
Zim | ded1ab9 | 2021-01-15 10:36:17 +0000 | [diff] [blame] | 275 | jfieldID fid_file_lookup_uid_; |
Biswarup Pal | 63901f3 | 2021-01-07 14:57:23 +0000 | [diff] [blame] | 276 | jfieldID fid_file_lookup_transforms_complete_; |
Zim | ded1ab9 | 2021-01-15 10:36:17 +0000 | [diff] [blame] | 277 | jfieldID fid_file_lookup_transforms_supported_; |
Biswarup Pal | 63901f3 | 2021-01-07 14:57:23 +0000 | [diff] [blame] | 278 | jfieldID fid_file_lookup_io_path_; |
Zim | 73895ba | 2021-01-13 12:51:20 +0000 | [diff] [blame] | 279 | /** Cached FileOpenResult field IDs **/ |
| 280 | jfieldID fid_file_open_status_; |
| 281 | jfieldID fid_file_open_uid_; |
Manish Singh | 9a6ccce | 2021-02-05 23:50:08 +0000 | [diff] [blame] | 282 | jfieldID fid_file_open_transforms_uid_; |
Zim | 73895ba | 2021-01-13 12:51:20 +0000 | [diff] [blame] | 283 | jfieldID fid_file_open_redaction_ranges_; |
Sahana Rao | 2c41603 | 2019-12-31 13:41:00 +0000 | [diff] [blame] | 284 | |
shafik | cdb6b2b | 2019-09-30 12:49:26 +0100 | [diff] [blame] | 285 | /** |
shafik | 15e2d61 | 2019-10-31 20:10:25 +0000 | [diff] [blame] | 286 | * Auxiliary for caching MediaProvider methods. |
shafik | cdb6b2b | 2019-09-30 12:49:26 +0100 | [diff] [blame] | 287 | */ |
| 288 | jmethodID CacheMethod(JNIEnv* env, const char method_name[], const char signature[], |
| 289 | bool is_static); |
Narayan Kamath | de3fe17 | 2020-02-18 12:14:51 +0000 | [diff] [blame] | 290 | |
| 291 | // Attaches the current thread (if necessary) and returns the JNIEnv |
| 292 | // associated with it. |
| 293 | static JNIEnv* MaybeAttachCurrentThread(); |
| 294 | // Destructor function for a given native thread. Called precisely once |
| 295 | // by the pthreads library. |
| 296 | static void DetachThreadFunction(void* unused); |
| 297 | |
| 298 | static JavaVM* gJavaVm; |
shafik | c3f6267 | 2019-08-30 11:15:48 +0100 | [diff] [blame] | 299 | }; |
| 300 | |
| 301 | } // namespace fuse |
| 302 | } // namespace mediaprovider |
| 303 | |
| 304 | #endif // MEDIAPROVIDER_FUSE_MEDIAPROVIDERWRAPPER_H_ |