blob: eb204c5466e04009aa3f4eac6a1fbe0d45377c14 [file] [log] [blame]
Songchun Fan3c82a302019-11-29 14:23:45 -08001/*
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 specific language governing permissions and
14 * limitations under the License.
15 */
16
Yurii Zubrytskyi86321402020-04-09 19:22:30 -070017#define LOG_TAG "IncrementalService"
18
Songchun Fan3c82a302019-11-29 14:23:45 -080019#include "ServiceWrappers.h"
20
Yurii Zubrytskyi629051fd2020-04-17 23:13:47 -070021#include <MountRegistry.h>
Yurii Zubrytskyi86321402020-04-09 19:22:30 -070022#include <android-base/logging.h>
Yurii Zubrytskyi629051fd2020-04-17 23:13:47 -070023#include <android/content/pm/IDataLoaderManager.h>
24#include <android/os/IVold.h>
25#include <binder/AppOpsManager.h>
Songchun Fan3c82a302019-11-29 14:23:45 -080026#include <utils/String16.h>
27
Songchun Fan374f7652020-08-20 08:40:29 -070028#include <filesystem>
Alex Buynytskyy46d3ddb2020-05-29 12:05:05 -070029#include <thread>
30
Yurii Zubrytskyi629051fd2020-04-17 23:13:47 -070031#include "IncrementalServiceValidation.h"
32
Songchun Fan3c82a302019-11-29 14:23:45 -080033using namespace std::literals;
34
Yurii Zubrytskyi629051fd2020-04-17 23:13:47 -070035namespace android::incremental {
Songchun Fan3c82a302019-11-29 14:23:45 -080036
37static constexpr auto kVoldServiceName = "vold"sv;
Songchun Fan68645c42020-02-27 15:57:35 -080038static constexpr auto kDataLoaderManagerName = "dataloader_manager"sv;
Songchun Fan3c82a302019-11-29 14:23:45 -080039
Yurii Zubrytskyi86321402020-04-09 19:22:30 -070040class RealVoldService : public VoldServiceWrapper {
41public:
Yurii Zubrytskyi510037b2020-04-22 15:46:21 -070042 RealVoldService(sp<os::IVold> vold) : mInterface(std::move(vold)) {}
Yurii Zubrytskyi86321402020-04-09 19:22:30 -070043 ~RealVoldService() = default;
Yurii Zubrytskyi629051fd2020-04-17 23:13:47 -070044 binder::Status mountIncFs(
45 const std::string& backingPath, const std::string& targetDir, int32_t flags,
46 os::incremental::IncrementalFileSystemControlParcel* _aidl_return) const final {
Yurii Zubrytskyi86321402020-04-09 19:22:30 -070047 return mInterface->mountIncFs(backingPath, targetDir, flags, _aidl_return);
48 }
49 binder::Status unmountIncFs(const std::string& dir) const final {
50 return mInterface->unmountIncFs(dir);
51 }
52 binder::Status bindMount(const std::string& sourceDir,
53 const std::string& targetDir) const final {
54 return mInterface->bindMount(sourceDir, targetDir);
55 }
56 binder::Status setIncFsMountOptions(
57 const ::android::os::incremental::IncrementalFileSystemControlParcel& control,
58 bool enableReadLogs) const final {
59 return mInterface->setIncFsMountOptions(control, enableReadLogs);
60 }
61
62private:
63 sp<os::IVold> mInterface;
64};
65
66class RealDataLoaderManager : public DataLoaderManagerWrapper {
67public:
Yurii Zubrytskyi629051fd2020-04-17 23:13:47 -070068 RealDataLoaderManager(sp<content::pm::IDataLoaderManager> manager)
69 : mInterface(std::move(manager)) {}
Yurii Zubrytskyi86321402020-04-09 19:22:30 -070070 ~RealDataLoaderManager() = default;
Alex Buynytskyyea1390f2020-04-22 16:08:50 -070071 binder::Status bindToDataLoader(MountId mountId,
72 const content::pm::DataLoaderParamsParcel& params,
Alex Buynytskyyb19ee3e2021-02-06 20:31:43 -080073 int bindDelayMs,
Alex Buynytskyyea1390f2020-04-22 16:08:50 -070074 const sp<content::pm::IDataLoaderStatusListener>& listener,
75 bool* _aidl_return) const final {
Alex Buynytskyyb19ee3e2021-02-06 20:31:43 -080076 return mInterface->bindToDataLoader(mountId, params, bindDelayMs, listener, _aidl_return);
Yurii Zubrytskyi86321402020-04-09 19:22:30 -070077 }
Yurii Zubrytskyi629051fd2020-04-17 23:13:47 -070078 binder::Status getDataLoader(MountId mountId,
79 sp<content::pm::IDataLoader>* _aidl_return) const final {
Yurii Zubrytskyi86321402020-04-09 19:22:30 -070080 return mInterface->getDataLoader(mountId, _aidl_return);
81 }
Alex Buynytskyyea1390f2020-04-22 16:08:50 -070082 binder::Status unbindFromDataLoader(MountId mountId) const final {
83 return mInterface->unbindFromDataLoader(mountId);
Yurii Zubrytskyi86321402020-04-09 19:22:30 -070084 }
85
86private:
87 sp<content::pm::IDataLoaderManager> mInterface;
88};
89
90class RealAppOpsManager : public AppOpsManagerWrapper {
91public:
92 ~RealAppOpsManager() = default;
93 binder::Status checkPermission(const char* permission, const char* operation,
94 const char* package) const final {
95 return android::incremental::CheckPermissionForDataDelivery(permission, operation, package);
96 }
97 void startWatchingMode(int32_t op, const String16& packageName,
98 const sp<IAppOpsCallback>& callback) final {
99 mAppOpsManager.startWatchingMode(op, packageName, callback);
100 }
101 void stopWatchingMode(const sp<IAppOpsCallback>& callback) final {
102 mAppOpsManager.stopWatchingMode(callback);
103 }
104
105private:
106 android::AppOpsManager mAppOpsManager;
107};
108
109class RealJniWrapper final : public JniWrapper {
110public:
111 RealJniWrapper(JavaVM* jvm);
112 void initializeForCurrentThread() const final;
113
114 static JavaVM* getJvm(JNIEnv* env);
115
116private:
117 JavaVM* const mJvm;
118};
119
Alex Buynytskyycca2c112020-05-05 12:48:41 -0700120class RealLooperWrapper final : public LooperWrapper {
121public:
122 int addFd(int fd, int ident, int events, android::Looper_callbackFunc callback,
123 void* data) final {
124 return mLooper.addFd(fd, ident, events, callback, data);
125 }
126 int removeFd(int fd) final { return mLooper.removeFd(fd); }
127 void wake() final { return mLooper.wake(); }
128 int pollAll(int timeoutMillis) final { return mLooper.pollAll(timeoutMillis); }
129
130private:
131 struct Looper : public android::Looper {
132 Looper() : android::Looper(/*allowNonCallbacks=*/false) {}
133 ~Looper() {}
134 } mLooper;
135};
136
Yurii Zubrytskyia5946f72021-02-17 14:24:14 -0800137class RealIncFs final : public IncFsWrapper {
Yurii Zubrytskyi86321402020-04-09 19:22:30 -0700138public:
139 RealIncFs() = default;
Yurii Zubrytskyi629051fd2020-04-17 23:13:47 -0700140 ~RealIncFs() final = default;
Yurii Zubrytskyia5946f72021-02-17 14:24:14 -0800141 Features features() const final { return incfs::features(); }
Yurii Zubrytskyi629051fd2020-04-17 23:13:47 -0700142 void listExistingMounts(const ExistingMountCallback& cb) const final {
143 for (auto mount : incfs::defaultMountRegistry().copyMounts()) {
144 auto binds = mount.binds(); // span() doesn't like rvalue containers, needs to save it.
145 cb(mount.root(), mount.backingDir(), binds);
146 }
147 }
148 Control openMount(std::string_view path) const final { return incfs::open(path); }
Yurii Zubrytskyi5f692922020-12-08 07:35:24 -0800149 Control createControl(IncFsFd cmd, IncFsFd pendingReads, IncFsFd logs,
150 IncFsFd blocksWritten) const final {
151 return incfs::createControl(cmd, pendingReads, logs, blocksWritten);
Yurii Zubrytskyi86321402020-04-09 19:22:30 -0700152 }
153 ErrorCode makeFile(const Control& control, std::string_view path, int mode, FileId id,
Yurii Zubrytskyi629051fd2020-04-17 23:13:47 -0700154 incfs::NewFileParams params) const final {
Yurii Zubrytskyi86321402020-04-09 19:22:30 -0700155 return incfs::makeFile(control, path, mode, id, params);
156 }
Yurii Zubrytskyia5946f72021-02-17 14:24:14 -0800157 ErrorCode makeMappedFile(const Control& control, std::string_view path, int mode,
158 incfs::NewMappedFileParams params) const final {
159 return incfs::makeMappedFile(control, path, mode, params);
160 }
Yurii Zubrytskyi86321402020-04-09 19:22:30 -0700161 ErrorCode makeDir(const Control& control, std::string_view path, int mode) const final {
162 return incfs::makeDir(control, path, mode);
163 }
Yurii Zubrytskyiefebb452020-04-22 13:59:06 -0700164 ErrorCode makeDirs(const Control& control, std::string_view path, int mode) const final {
165 return incfs::makeDirs(control, path, mode);
166 }
Yurii Zubrytskyi629051fd2020-04-17 23:13:47 -0700167 incfs::RawMetadata getMetadata(const Control& control, FileId fileid) const final {
Yurii Zubrytskyi86321402020-04-09 19:22:30 -0700168 return incfs::getMetadata(control, fileid);
169 }
Yurii Zubrytskyi629051fd2020-04-17 23:13:47 -0700170 incfs::RawMetadata getMetadata(const Control& control, std::string_view path) const final {
Yurii Zubrytskyi86321402020-04-09 19:22:30 -0700171 return incfs::getMetadata(control, path);
172 }
173 FileId getFileId(const Control& control, std::string_view path) const final {
174 return incfs::getFileId(control, path);
175 }
Songchun Fan6944f1e2020-11-06 15:24:24 -0800176 std::string toString(FileId fileId) const final { return incfs::toString(fileId); }
Songchun Fan374f7652020-08-20 08:40:29 -0700177 std::pair<IncFsBlockIndex, IncFsBlockIndex> countFilledBlocks(
178 const Control& control, std::string_view path) const final {
179 const auto fileId = incfs::getFileId(control, path);
180 const auto fd = incfs::openForSpecialOps(control, fileId);
181 int res = fd.get();
182 if (!fd.ok()) {
183 return {res, res};
184 }
185 const auto ranges = incfs::getFilledRanges(res);
186 res = ranges.first;
187 if (res) {
188 return {res, res};
189 }
190 const auto totalBlocksCount = ranges.second.internalRawRanges().endIndex;
191 int filledBlockCount = 0;
192 for (const auto& dataRange : ranges.second.dataRanges()) {
193 filledBlockCount += dataRange.size();
194 }
195 for (const auto& hashRange : ranges.second.hashRanges()) {
196 filledBlockCount += hashRange.size();
197 }
198 return {filledBlockCount, totalBlocksCount};
199 }
Yurii Zubrytskyi256a1a42021-03-18 14:21:54 -0700200 incfs::LoadingState isFileFullyLoaded(const Control& control,
201 std::string_view path) const final {
202 return incfs::isFullyLoaded(control, path);
203 }
204 incfs::LoadingState isEverythingFullyLoaded(const Control& control) const final {
205 return incfs::isEverythingFullyLoaded(control);
206 }
Yurii Zubrytskyi86321402020-04-09 19:22:30 -0700207 ErrorCode link(const Control& control, std::string_view from, std::string_view to) const final {
208 return incfs::link(control, from, to);
209 }
210 ErrorCode unlink(const Control& control, std::string_view path) const final {
211 return incfs::unlink(control, path);
212 }
Alex Buynytskyybc0a7e62020-08-25 12:45:22 -0700213 incfs::UniqueFd openForSpecialOps(const Control& control, FileId id) const final {
214 return incfs::openForSpecialOps(control, id);
Yurii Zubrytskyi86321402020-04-09 19:22:30 -0700215 }
Yurii Zubrytskyi629051fd2020-04-17 23:13:47 -0700216 ErrorCode writeBlocks(std::span<const incfs::DataBlock> blocks) const final {
217 return incfs::writeBlocks({blocks.data(), size_t(blocks.size())});
Yurii Zubrytskyi86321402020-04-09 19:22:30 -0700218 }
Yurii Zubrytskyi65fc38a2021-03-17 13:18:30 -0700219 ErrorCode reserveSpace(const Control& control, std::string_view path,
220 IncFsSize size) const final {
221 return incfs::reserveSpace(control, path, size);
222 }
Alex Buynytskyy8ef61ae2020-05-08 16:18:52 -0700223 WaitResult waitForPendingReads(const Control& control, std::chrono::milliseconds timeout,
224 std::vector<incfs::ReadInfo>* pendingReadsBuffer) const final {
225 return incfs::waitForPendingReads(control, timeout, pendingReadsBuffer);
226 }
Alex Buynytskyyaa8e95e2020-12-14 21:50:04 -0800227 ErrorCode setUidReadTimeouts(const Control& control,
228 const std::vector<android::os::incremental::PerUidReadTimeouts>&
229 perUidReadTimeouts) const final {
Alex Buynytskyyfe6b4c02021-01-26 13:29:24 -0800230 std::vector<incfs::UidReadTimeouts> timeouts;
231 timeouts.resize(perUidReadTimeouts.size());
232 for (int i = 0, size = perUidReadTimeouts.size(); i < size; ++i) {
233 auto&& timeout = timeouts[i];
234 const auto& perUidTimeout = perUidReadTimeouts[i];
235 timeout.uid = perUidTimeout.uid;
236 timeout.minTimeUs = perUidTimeout.minTimeUs;
237 timeout.minPendingTimeUs = perUidTimeout.minPendingTimeUs;
238 timeout.maxPendingTimeUs = perUidTimeout.maxPendingTimeUs;
239 }
Alex Buynytskyy07694ed2021-01-27 06:58:55 -0800240
Alex Buynytskyyfe6b4c02021-01-26 13:29:24 -0800241 return incfs::setUidReadTimeouts(control, timeouts);
Alex Buynytskyyaa8e95e2020-12-14 21:50:04 -0800242 }
Yurii Zubrytskyi86321402020-04-09 19:22:30 -0700243};
244
Alex Buynytskyy46d3ddb2020-05-29 12:05:05 -0700245static JNIEnv* getOrAttachJniEnv(JavaVM* jvm);
246
247class RealTimedQueueWrapper : public TimedQueueWrapper {
248public:
249 RealTimedQueueWrapper(JavaVM* jvm) {
250 mThread = std::thread([this, jvm]() {
251 (void)getOrAttachJniEnv(jvm);
252 runTimers();
253 });
254 }
255 ~RealTimedQueueWrapper() final {
256 CHECK(!mRunning) << "call stop first";
257 CHECK(!mThread.joinable()) << "call stop first";
258 }
259
260 void addJob(MountId id, Milliseconds after, Job what) final {
261 const auto now = Clock::now();
262 {
263 std::unique_lock lock(mMutex);
264 mJobs.insert(TimedJob{id, now + after, std::move(what)});
265 }
266 mCondition.notify_all();
267 }
268 void removeJobs(MountId id) final {
269 std::unique_lock lock(mMutex);
270 std::erase_if(mJobs, [id](auto&& item) { return item.id == id; });
271 }
272 void stop() final {
273 {
274 std::unique_lock lock(mMutex);
275 mRunning = false;
276 }
277 mCondition.notify_all();
278 mThread.join();
279 mJobs.clear();
280 }
281
282private:
283 void runTimers() {
284 static constexpr TimePoint kInfinityTs{Clock::duration::max()};
285 TimePoint nextJobTs = kInfinityTs;
286 std::unique_lock lock(mMutex);
287 for (;;) {
288 mCondition.wait_until(lock, nextJobTs, [this, nextJobTs]() {
289 const auto now = Clock::now();
290 const auto firstJobTs = !mJobs.empty() ? mJobs.begin()->when : kInfinityTs;
291 return !mRunning || firstJobTs <= now || firstJobTs < nextJobTs;
292 });
293 if (!mRunning) {
294 return;
295 }
296
297 const auto now = Clock::now();
298 auto it = mJobs.begin();
299 // Always acquire begin(). We can't use it after unlock as mTimedJobs can change.
300 for (; it != mJobs.end() && it->when <= now; it = mJobs.begin()) {
Yurii Zubrytskyi3fde5722021-02-19 00:08:36 -0800301 auto jobNode = mJobs.extract(it);
Alex Buynytskyy46d3ddb2020-05-29 12:05:05 -0700302
303 lock.unlock();
Yurii Zubrytskyi3fde5722021-02-19 00:08:36 -0800304 jobNode.value().what();
Alex Buynytskyy46d3ddb2020-05-29 12:05:05 -0700305 lock.lock();
306 }
307 nextJobTs = it != mJobs.end() ? it->when : kInfinityTs;
308 }
309 }
310
311 struct TimedJob {
312 MountId id;
313 TimePoint when;
314 Job what;
315 friend bool operator<(const TimedJob& lhs, const TimedJob& rhs) {
316 return lhs.when < rhs.when;
317 }
318 };
319 bool mRunning = true;
320 std::set<TimedJob> mJobs;
321 std::condition_variable mCondition;
322 std::mutex mMutex;
323 std::thread mThread;
324};
325
Yurii Zubrytskyi3fde5722021-02-19 00:08:36 -0800326class RealFsWrapper final : public FsWrapper {
Songchun Fan374f7652020-08-20 08:40:29 -0700327public:
328 RealFsWrapper() = default;
329 ~RealFsWrapper() = default;
330
Yurii Zubrytskyi3fde5722021-02-19 00:08:36 -0800331 void listFilesRecursive(std::string_view directoryPath, FileCallback onFile) const final {
Songchun Fan374f7652020-08-20 08:40:29 -0700332 for (const auto& entry : std::filesystem::recursive_directory_iterator(directoryPath)) {
333 if (!entry.is_regular_file()) {
334 continue;
335 }
Yurii Zubrytskyi3fde5722021-02-19 00:08:36 -0800336 if (!onFile(entry.path().native())) {
337 break;
338 }
Songchun Fan374f7652020-08-20 08:40:29 -0700339 }
Songchun Fan374f7652020-08-20 08:40:29 -0700340 }
341};
342
Alex Buynytskyy7e06d712021-03-09 19:24:23 -0800343class RealClockWrapper final : public ClockWrapper {
344public:
345 RealClockWrapper() = default;
346 ~RealClockWrapper() = default;
347
348 TimePoint now() const final { return Clock::now(); }
349};
350
Yurii Zubrytskyi86321402020-04-09 19:22:30 -0700351RealServiceManager::RealServiceManager(sp<IServiceManager> serviceManager, JNIEnv* env)
352 : mServiceManager(std::move(serviceManager)), mJvm(RealJniWrapper::getJvm(env)) {}
Songchun Fan3c82a302019-11-29 14:23:45 -0800353
354template <class INTERFACE>
355sp<INTERFACE> RealServiceManager::getRealService(std::string_view serviceName) const {
Yurii Zubrytskyi4a25dfb2020-01-10 11:53:24 -0800356 sp<IBinder> binder =
357 mServiceManager->getService(String16(serviceName.data(), serviceName.size()));
358 if (!binder) {
359 return nullptr;
Songchun Fan3c82a302019-11-29 14:23:45 -0800360 }
361 return interface_cast<INTERFACE>(binder);
362}
363
Yurii Zubrytskyi4a25dfb2020-01-10 11:53:24 -0800364std::unique_ptr<VoldServiceWrapper> RealServiceManager::getVoldService() {
Songchun Fan3c82a302019-11-29 14:23:45 -0800365 sp<os::IVold> vold = RealServiceManager::getRealService<os::IVold>(kVoldServiceName);
366 if (vold != 0) {
Yurii Zubrytskyi4a25dfb2020-01-10 11:53:24 -0800367 return std::make_unique<RealVoldService>(vold);
Songchun Fan3c82a302019-11-29 14:23:45 -0800368 }
369 return nullptr;
370}
371
Songchun Fan68645c42020-02-27 15:57:35 -0800372std::unique_ptr<DataLoaderManagerWrapper> RealServiceManager::getDataLoaderManager() {
Yurii Zubrytskyi629051fd2020-04-17 23:13:47 -0700373 sp<content::pm::IDataLoaderManager> manager =
374 RealServiceManager::getRealService<content::pm::IDataLoaderManager>(
375 kDataLoaderManagerName);
Yurii Zubrytskyi4a25dfb2020-01-10 11:53:24 -0800376 if (manager) {
Songchun Fan68645c42020-02-27 15:57:35 -0800377 return std::make_unique<RealDataLoaderManager>(manager);
Songchun Fan3c82a302019-11-29 14:23:45 -0800378 }
379 return nullptr;
380}
381
Yurii Zubrytskyi4a25dfb2020-01-10 11:53:24 -0800382std::unique_ptr<IncFsWrapper> RealServiceManager::getIncFs() {
383 return std::make_unique<RealIncFs>();
Songchun Fan3c82a302019-11-29 14:23:45 -0800384}
385
Alex Buynytskyy96e350b2020-04-02 20:03:47 -0700386std::unique_ptr<AppOpsManagerWrapper> RealServiceManager::getAppOpsManager() {
387 return std::make_unique<RealAppOpsManager>();
388}
389
Yurii Zubrytskyi86321402020-04-09 19:22:30 -0700390std::unique_ptr<JniWrapper> RealServiceManager::getJni() {
391 return std::make_unique<RealJniWrapper>(mJvm);
392}
393
Alex Buynytskyycca2c112020-05-05 12:48:41 -0700394std::unique_ptr<LooperWrapper> RealServiceManager::getLooper() {
395 return std::make_unique<RealLooperWrapper>();
396}
397
Alex Buynytskyy46d3ddb2020-05-29 12:05:05 -0700398std::unique_ptr<TimedQueueWrapper> RealServiceManager::getTimedQueue() {
399 return std::make_unique<RealTimedQueueWrapper>(mJvm);
400}
401
Songchun Fana7098592020-09-03 11:45:53 -0700402std::unique_ptr<TimedQueueWrapper> RealServiceManager::getProgressUpdateJobQueue() {
403 return std::make_unique<RealTimedQueueWrapper>(mJvm);
404}
405
Songchun Fan374f7652020-08-20 08:40:29 -0700406std::unique_ptr<FsWrapper> RealServiceManager::getFs() {
407 return std::make_unique<RealFsWrapper>();
408}
409
Alex Buynytskyy7e06d712021-03-09 19:24:23 -0800410std::unique_ptr<ClockWrapper> RealServiceManager::getClock() {
411 return std::make_unique<RealClockWrapper>();
412}
413
Yurii Zubrytskyi86321402020-04-09 19:22:30 -0700414static JavaVM* getJavaVm(JNIEnv* env) {
415 CHECK(env);
416 JavaVM* jvm = nullptr;
417 env->GetJavaVM(&jvm);
418 CHECK(jvm);
419 return jvm;
420}
421
422static JNIEnv* getJniEnv(JavaVM* vm) {
423 JNIEnv* env;
424 if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
425 return nullptr;
426 }
427 return env;
428}
429
430static JNIEnv* getOrAttachJniEnv(JavaVM* jvm) {
431 if (!jvm) {
432 LOG(ERROR) << "No JVM instance";
433 return nullptr;
434 }
435
436 JNIEnv* env = getJniEnv(jvm);
437 if (!env) {
438 int result = jvm->AttachCurrentThread(&env, nullptr);
439 if (result != JNI_OK) {
440 LOG(ERROR) << "JVM thread attach failed: " << result;
441 return nullptr;
442 }
443 struct VmDetacher {
444 VmDetacher(JavaVM* vm) : mVm(vm) {}
445 ~VmDetacher() { mVm->DetachCurrentThread(); }
446
447 private:
448 JavaVM* const mVm;
449 };
450 static thread_local VmDetacher detacher(jvm);
451 }
452
453 return env;
454}
455
456RealJniWrapper::RealJniWrapper(JavaVM* jvm) : mJvm(jvm) {
457 CHECK(!!mJvm) << "JVM is unavailable";
458}
459
460void RealJniWrapper::initializeForCurrentThread() const {
461 (void)getOrAttachJniEnv(mJvm);
462}
463
464JavaVM* RealJniWrapper::getJvm(JNIEnv* env) {
465 return getJavaVm(env);
466}
467
Yurii Zubrytskyi629051fd2020-04-17 23:13:47 -0700468} // namespace android::incremental