blob: 13456fbadbc7fbe72fd6b13efcf6c53390e3e24e [file] [log] [blame]
Ryan Mitchell1a48fa62021-01-10 08:36:36 -08001/*
2 * Copyright (C) 2021 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#include "androidfw/AssetsProvider.h"
18
19#include <sys/stat.h>
20
21#include <android-base/errors.h>
22#include <android-base/stringprintf.h>
23#include <android-base/utf8.h>
24#include <ziparchive/zip_archive.h>
25
26namespace android {
Yurii Zubrytskyi36147b02025-02-06 15:41:54 -080027
28static constexpr std::string_view kEmptyDebugString = "<empty>";
29
30std::unique_ptr<AssetsProvider> AssetsProvider::CreateWithOverride(
31 std::unique_ptr<AssetsProvider> provider, std::unique_ptr<AssetsProvider> override) {
32 if (provider == nullptr) {
33 return {};
34 }
35 if (override == nullptr) {
36 return provider;
37 }
38 return MultiAssetsProvider::Create(std::move(override), std::move(provider));
39}
40
41std::unique_ptr<AssetsProvider> AssetsProvider::CreateFromNullable(
42 std::unique_ptr<AssetsProvider> nullable) {
43 if (nullable) {
44 return nullable;
45 }
46 return EmptyAssetsProvider::Create();
47}
Ryan Mitchell1a48fa62021-01-10 08:36:36 -080048
49std::unique_ptr<Asset> AssetsProvider::Open(const std::string& path, Asset::AccessMode mode,
50 bool* file_exists) const {
51 return OpenInternal(path, mode, file_exists);
52}
53
54std::unique_ptr<Asset> AssetsProvider::CreateAssetFromFile(const std::string& path) {
55 base::unique_fd fd(base::utf8::open(path.c_str(), O_RDONLY | O_CLOEXEC));
56 if (!fd.ok()) {
57 LOG(ERROR) << "Failed to open file '" << path << "': " << base::SystemErrorCodeToString(errno);
58 return {};
59 }
60
61 return CreateAssetFromFd(std::move(fd), path.c_str());
62}
63
64std::unique_ptr<Asset> AssetsProvider::CreateAssetFromFd(base::unique_fd fd,
65 const char* path,
66 off64_t offset,
67 off64_t length) {
68 CHECK(length >= kUnknownLength) << "length must be greater than or equal to " << kUnknownLength;
69 CHECK(length != kUnknownLength || offset == 0) << "offset must be 0 if length is "
70 << kUnknownLength;
71 if (length == kUnknownLength) {
72 length = lseek64(fd, 0, SEEK_END);
73 if (length < 0) {
74 LOG(ERROR) << "Failed to get size of file '" << ((path) ? path : "anon") << "': "
75 << base::SystemErrorCodeToString(errno);
76 return {};
77 }
78 }
79
80 incfs::IncFsFileMap file_map;
81 if (!file_map.Create(fd, offset, static_cast<size_t>(length), path)) {
82 LOG(ERROR) << "Failed to mmap file '" << ((path != nullptr) ? path : "anon") << "': "
83 << base::SystemErrorCodeToString(errno);
84 return {};
85 }
86
87 // If `path` is set, do not pass ownership of the `fd` to the new Asset since
88 // Asset::openFileDescriptor can use `path` to create new file descriptors.
89 return Asset::createFromUncompressedMap(std::move(file_map),
90 Asset::AccessMode::ACCESS_RANDOM,
91 (path != nullptr) ? base::unique_fd(-1) : std::move(fd));
92}
93
Ryan Mitchell1a48fa62021-01-10 08:36:36 -080094const std::string* ZipAssetsProvider::PathOrDebugName::GetPath() const {
95 return is_path_ ? &value_ : nullptr;
96}
97
98const std::string& ZipAssetsProvider::PathOrDebugName::GetDebugName() const {
99 return value_;
100}
101
Yurii Zubrytskyia5bc9582022-11-30 23:53:59 -0800102void ZipAssetsProvider::ZipCloser::operator()(ZipArchive* a) const {
103 ::CloseArchive(a);
104}
105
Ryan Mitchell2ed8bfa2021-01-08 13:34:28 -0800106ZipAssetsProvider::ZipAssetsProvider(ZipArchiveHandle handle, PathOrDebugName&& path,
Yurii Zubrytskyi1144bca2025-04-17 16:31:27 -0700107 package_property_t flags, time_t last_mod_time)
108 : zip_handle_(handle), name_(std::move(path)), flags_(flags), last_mod_time_(last_mod_time) {
109 LOG(ERROR) << "This function is not supported and will result in "
110 "poor performance and/or crashes. Stop calling it.";
111}
112
113ZipAssetsProvider::ZipAssetsProvider(ZipArchiveHandle handle, PathOrDebugName&& path,
114 ModDate last_mod_time, package_property_t flags)
Yurii Zubrytskyi548c1ab2025-02-06 15:41:54 -0800115 : zip_handle_(handle), name_(std::move(path)), flags_(flags), last_mod_time_(last_mod_time) {
116}
Ryan Mitchell1a48fa62021-01-10 08:36:36 -0800117
Ryan Mitchellc0416692021-05-11 12:21:29 -0700118std::unique_ptr<ZipAssetsProvider> ZipAssetsProvider::Create(std::string path,
Yurii Zubrytskyi801c4412022-11-30 16:47:23 -0800119 package_property_t flags,
120 base::unique_fd fd) {
121 const auto released_fd = fd.ok() ? fd.release() : -1;
Ryan Mitchell1a48fa62021-01-10 08:36:36 -0800122 ZipArchiveHandle handle;
Yurii Zubrytskyi801c4412022-11-30 16:47:23 -0800123 if (int32_t result = released_fd < 0 ? OpenArchive(path.c_str(), &handle)
124 : OpenArchiveFd(released_fd, path.c_str(), &handle)) {
Ryan Mitchell2ed8bfa2021-01-08 13:34:28 -0800125 LOG(ERROR) << "Failed to open APK '" << path << "': " << ::ErrorCodeString(result);
Ryan Mitchell1a48fa62021-01-10 08:36:36 -0800126 CloseArchive(handle);
127 return {};
128 }
129
Yurii Zubrytskyi548c1ab2025-02-06 15:41:54 -0800130 ModDate mod_date = kInvalidModDate;
Yurii Zubrytskyi2ab44472022-11-30 00:56:22 -0800131 // Skip all up-to-date checks if the file won't ever change.
Yurii Zubrytskyi548c1ab2025-02-06 15:41:54 -0800132 if (isKnownWritablePath(path.c_str()) || !isReadonlyFilesystem(GetFileDescriptor(handle))) {
133 if (mod_date = getFileModDate(GetFileDescriptor(handle)); mod_date == kInvalidModDate) {
Yurii Zubrytskyi2ab44472022-11-30 00:56:22 -0800134 // Stat requires execute permissions on all directories path to the file. If the process does
135 // not have execute permissions on this file, allow the zip to be opened but IsUpToDate() will
136 // always have to return true.
Yurii Zubrytskyia5bc9582022-11-30 23:53:59 -0800137 PLOG(WARNING) << "Failed to stat file '" << path << "'";
Yurii Zubrytskyi2ab44472022-11-30 00:56:22 -0800138 }
Ryan Mitchell1a48fa62021-01-10 08:36:36 -0800139 }
140
141 return std::unique_ptr<ZipAssetsProvider>(
Yurii Zubrytskyi1144bca2025-04-17 16:31:27 -0700142 new ZipAssetsProvider(handle, PathOrDebugName::Path(std::move(path)), mod_date, flags));
Ryan Mitchell1a48fa62021-01-10 08:36:36 -0800143}
144
145std::unique_ptr<ZipAssetsProvider> ZipAssetsProvider::Create(base::unique_fd fd,
146 std::string friendly_name,
Ryan Mitchellc0416692021-05-11 12:21:29 -0700147 package_property_t flags,
Ryan Mitchell1a48fa62021-01-10 08:36:36 -0800148 off64_t offset,
149 off64_t len) {
150 ZipArchiveHandle handle;
151 const int released_fd = fd.release();
152 const int32_t result = (len == AssetsProvider::kUnknownLength)
153 ? ::OpenArchiveFd(released_fd, friendly_name.c_str(), &handle)
154 : ::OpenArchiveFdRange(released_fd, friendly_name.c_str(), &handle, len, offset);
155
156 if (result != 0) {
157 LOG(ERROR) << "Failed to open APK '" << friendly_name << "' through FD with offset " << offset
158 << " and length " << len << ": " << ::ErrorCodeString(result);
159 CloseArchive(handle);
160 return {};
161 }
162
Yurii Zubrytskyi548c1ab2025-02-06 15:41:54 -0800163 ModDate mod_date = kInvalidModDate;
Yurii Zubrytskyi2ab44472022-11-30 00:56:22 -0800164 // Skip all up-to-date checks if the file won't ever change.
165 if (!isReadonlyFilesystem(released_fd)) {
Yurii Zubrytskyi548c1ab2025-02-06 15:41:54 -0800166 if (mod_date = getFileModDate(released_fd); mod_date == kInvalidModDate) {
Yurii Zubrytskyi2ab44472022-11-30 00:56:22 -0800167 // Stat requires execute permissions on all directories path to the file. If the process does
168 // not have execute permissions on this file, allow the zip to be opened but IsUpToDate() will
169 // always have to return true.
170 LOG(WARNING) << "Failed to fstat file '" << friendly_name
171 << "': " << base::SystemErrorCodeToString(errno);
172 }
Ryan Mitchell1a48fa62021-01-10 08:36:36 -0800173 }
174
Yurii Zubrytskyia5bc9582022-11-30 23:53:59 -0800175 return std::unique_ptr<ZipAssetsProvider>(new ZipAssetsProvider(
Yurii Zubrytskyi1144bca2025-04-17 16:31:27 -0700176 handle, PathOrDebugName::DebugName(std::move(friendly_name)), mod_date, flags));
Ryan Mitchell1a48fa62021-01-10 08:36:36 -0800177}
178
179std::unique_ptr<Asset> ZipAssetsProvider::OpenInternal(const std::string& path,
180 Asset::AccessMode mode,
181 bool* file_exists) const {
182 if (file_exists != nullptr) {
183 *file_exists = false;
184 }
185
186 ZipEntry entry;
187 if (FindEntry(zip_handle_.get(), path, &entry) != 0) {
188 return {};
189 }
190
191 if (file_exists != nullptr) {
192 *file_exists = true;
193 }
194
195 const int fd = GetFileDescriptor(zip_handle_.get());
196 const off64_t fd_offset = GetFileDescriptorOffset(zip_handle_.get());
Ryan Mitchellc0416692021-05-11 12:21:29 -0700197 const bool incremental_hardening = (flags_ & PROPERTY_DISABLE_INCREMENTAL_HARDENING) == 0U;
Ryan Mitchell1a48fa62021-01-10 08:36:36 -0800198 incfs::IncFsFileMap asset_map;
199 if (entry.method == kCompressDeflated) {
200 if (!asset_map.Create(fd, entry.offset + fd_offset, entry.compressed_length,
Ryan Mitchellc0416692021-05-11 12:21:29 -0700201 name_.GetDebugName().c_str(), incremental_hardening)) {
Ryan Mitchell1a48fa62021-01-10 08:36:36 -0800202 LOG(ERROR) << "Failed to mmap file '" << path << "' in APK '" << name_.GetDebugName()
203 << "'";
204 return {};
205 }
206
207 std::unique_ptr<Asset> asset =
208 Asset::createFromCompressedMap(std::move(asset_map), entry.uncompressed_length, mode);
209 if (asset == nullptr) {
210 LOG(ERROR) << "Failed to decompress '" << path << "' in APK '" << name_.GetDebugName()
211 << "'";
212 return {};
213 }
214 return asset;
215 }
216
217 if (!asset_map.Create(fd, entry.offset + fd_offset, entry.uncompressed_length,
Ryan Mitchellc0416692021-05-11 12:21:29 -0700218 name_.GetDebugName().c_str(), incremental_hardening)) {
Ryan Mitchell1a48fa62021-01-10 08:36:36 -0800219 LOG(ERROR) << "Failed to mmap file '" << path << "' in APK '" << name_.GetDebugName() << "'";
220 return {};
221 }
222
223 base::unique_fd ufd;
224 if (name_.GetPath() == nullptr) {
225 // If the zip name does not represent a path, create a new `fd` for the new Asset to own in
226 // order to create new file descriptors using Asset::openFileDescriptor. If the zip name is a
227 // path, it will be used to create new file descriptors.
228 ufd = base::unique_fd(dup(fd));
229 if (!ufd.ok()) {
230 LOG(ERROR) << "Unable to dup fd '" << path << "' in APK '" << name_.GetDebugName() << "'";
231 return {};
232 }
233 }
234
235 auto asset = Asset::createFromUncompressedMap(std::move(asset_map), mode, std::move(ufd));
236 if (asset == nullptr) {
237 LOG(ERROR) << "Failed to mmap file '" << path << "' in APK '" << name_.GetDebugName() << "'";
238 return {};
239 }
240 return asset;
241}
242
Yurii Zubrytskyia5bc9582022-11-30 23:53:59 -0800243bool ZipAssetsProvider::ForEachFile(
244 const std::string& root_path,
245 base::function_ref<void(StringPiece, FileType)> f) const {
Ryan Mitchell1a48fa62021-01-10 08:36:36 -0800246 std::string root_path_full = root_path;
247 if (root_path_full.back() != '/') {
248 root_path_full += '/';
249 }
250
251 void* cookie;
252 if (StartIteration(zip_handle_.get(), &cookie, root_path_full, "") != 0) {
253 return false;
254 }
255
256 std::string name;
257 ::ZipEntry entry{};
258
259 // We need to hold back directories because many paths will contain them and we want to only
260 // surface one.
261 std::set<std::string> dirs{};
262
263 int32_t result;
264 while ((result = Next(cookie, &entry, &name)) == 0) {
265 StringPiece full_file_path(name);
266 StringPiece leaf_file_path = full_file_path.substr(root_path_full.size());
267
268 if (!leaf_file_path.empty()) {
269 auto iter = std::find(leaf_file_path.begin(), leaf_file_path.end(), '/');
270 if (iter != leaf_file_path.end()) {
Yurii Zubrytskyia5775142022-11-02 17:49:49 -0700271 std::string dir(leaf_file_path.substr(0, std::distance(leaf_file_path.begin(), iter)));
Ryan Mitchell1a48fa62021-01-10 08:36:36 -0800272 dirs.insert(std::move(dir));
273 } else {
274 f(leaf_file_path, kFileTypeRegular);
275 }
276 }
277 }
278 EndIteration(cookie);
279
280 // Now present the unique directories.
281 for (const std::string& dir : dirs) {
282 f(dir, kFileTypeDirectory);
283 }
284
285 // -1 is end of iteration, anything else is an error.
286 return result == -1;
287}
288
Ryan Mitchell2ed8bfa2021-01-08 13:34:28 -0800289std::optional<uint32_t> ZipAssetsProvider::GetCrc(std::string_view path) const {
290 ::ZipEntry entry;
291 if (FindEntry(zip_handle_.get(), path, &entry) != 0) {
292 return {};
293 }
294 return entry.crc32;
295}
296
Ryan Mitchellef538432021-03-01 14:52:14 -0800297std::optional<std::string_view> ZipAssetsProvider::GetPath() const {
298 if (name_.GetPath() != nullptr) {
299 return *name_.GetPath();
300 }
301 return {};
302}
303
Ryan Mitchell1a48fa62021-01-10 08:36:36 -0800304const std::string& ZipAssetsProvider::GetDebugName() const {
305 return name_.GetDebugName();
306}
307
Yurii Zubrytskyi548c1ab2025-02-06 15:41:54 -0800308UpToDate ZipAssetsProvider::IsUpToDate() const {
309 if (last_mod_time_ == kInvalidModDate) {
310 return UpToDate::Always;
Yurii Zubrytskyi2ab44472022-11-30 00:56:22 -0800311 }
Yurii Zubrytskyi548c1ab2025-02-06 15:41:54 -0800312 return fromBool(last_mod_time_ == getFileModDate(GetFileDescriptor(zip_handle_.get())));
Ryan Mitchell1a48fa62021-01-10 08:36:36 -0800313}
314
Yurii Zubrytskyi548c1ab2025-02-06 15:41:54 -0800315DirectoryAssetsProvider::DirectoryAssetsProvider(std::string&& path, ModDate last_mod_time)
316 : dir_(std::move(path)), last_mod_time_(last_mod_time) {
317}
Ryan Mitchell1a48fa62021-01-10 08:36:36 -0800318
319std::unique_ptr<DirectoryAssetsProvider> DirectoryAssetsProvider::Create(std::string path) {
Yurii Zubrytskyi2ab44472022-11-30 00:56:22 -0800320 struct stat sb;
Ryan Mitchell1a48fa62021-01-10 08:36:36 -0800321 const int result = stat(path.c_str(), &sb);
322 if (result == -1) {
323 LOG(ERROR) << "Failed to find directory '" << path << "'.";
324 return nullptr;
325 }
326
327 if (!S_ISDIR(sb.st_mode)) {
328 LOG(ERROR) << "Path '" << path << "' is not a directory.";
329 return nullptr;
330 }
331
Yurii Zubrytskyia5bc9582022-11-30 23:53:59 -0800332 if (path.back() != OS_PATH_SEPARATOR) {
Ryan Mitchell1a48fa62021-01-10 08:36:36 -0800333 path += OS_PATH_SEPARATOR;
334 }
335
Yurii Zubrytskyi2ab44472022-11-30 00:56:22 -0800336 const bool isReadonly = isReadonlyFilesystem(path.c_str());
337 return std::unique_ptr<DirectoryAssetsProvider>(
Yurii Zubrytskyi548c1ab2025-02-06 15:41:54 -0800338 new DirectoryAssetsProvider(std::move(path), isReadonly ? kInvalidModDate : getModDate(sb)));
Ryan Mitchell1a48fa62021-01-10 08:36:36 -0800339}
340
341std::unique_ptr<Asset> DirectoryAssetsProvider::OpenInternal(const std::string& path,
342 Asset::AccessMode /* mode */,
343 bool* file_exists) const {
344 const std::string resolved_path = dir_ + path;
345 if (file_exists != nullptr) {
346 struct stat sb{};
347 *file_exists = (stat(resolved_path.c_str(), &sb) != -1) && S_ISREG(sb.st_mode);
348 }
349
350 return CreateAssetFromFile(resolved_path);
351}
352
353bool DirectoryAssetsProvider::ForEachFile(
354 const std::string& /* root_path */,
Yurii Zubrytskyia5bc9582022-11-30 23:53:59 -0800355 base::function_ref<void(StringPiece, FileType)> /* f */) const {
Ryan Mitchell1a48fa62021-01-10 08:36:36 -0800356 return true;
357}
358
Ryan Mitchellef538432021-03-01 14:52:14 -0800359std::optional<std::string_view> DirectoryAssetsProvider::GetPath() const {
360 return dir_;
361}
362
Ryan Mitchell1a48fa62021-01-10 08:36:36 -0800363const std::string& DirectoryAssetsProvider::GetDebugName() const {
364 return dir_;
365}
366
Yurii Zubrytskyi548c1ab2025-02-06 15:41:54 -0800367UpToDate DirectoryAssetsProvider::IsUpToDate() const {
368 if (last_mod_time_ == kInvalidModDate) {
369 return UpToDate::Always;
Yurii Zubrytskyi2ab44472022-11-30 00:56:22 -0800370 }
Yurii Zubrytskyi548c1ab2025-02-06 15:41:54 -0800371 return fromBool(last_mod_time_ == getFileModDate(dir_.c_str()));
Ryan Mitchell1a48fa62021-01-10 08:36:36 -0800372}
373
374MultiAssetsProvider::MultiAssetsProvider(std::unique_ptr<AssetsProvider>&& primary,
375 std::unique_ptr<AssetsProvider>&& secondary)
Yurii Zubrytskyia5bc9582022-11-30 23:53:59 -0800376 : primary_(std::move(primary)), secondary_(std::move(secondary)) {
Ryan Mitchellef538432021-03-01 14:52:14 -0800377 debug_name_ = primary_->GetDebugName() + " and " + secondary_->GetDebugName();
378 path_ = (primary_->GetDebugName() != kEmptyDebugString) ? primary_->GetPath()
379 : secondary_->GetPath();
Ryan Mitchell1a48fa62021-01-10 08:36:36 -0800380}
381
382std::unique_ptr<AssetsProvider> MultiAssetsProvider::Create(
383 std::unique_ptr<AssetsProvider>&& primary, std::unique_ptr<AssetsProvider>&& secondary) {
ESWAR MAGATAPALLI (xWF)eb759ec2025-01-08 05:57:41 -0800384 if (primary == nullptr || secondary == nullptr) {
385 return nullptr;
Ryan Mitchell1a48fa62021-01-10 08:36:36 -0800386 }
387 return std::unique_ptr<MultiAssetsProvider>(new MultiAssetsProvider(std::move(primary),
388 std::move(secondary)));
389}
390
391std::unique_ptr<Asset> MultiAssetsProvider::OpenInternal(const std::string& path,
392 Asset::AccessMode mode,
393 bool* file_exists) const {
394 auto asset = primary_->Open(path, mode, file_exists);
395 return (asset) ? std::move(asset) : secondary_->Open(path, mode, file_exists);
396}
397
Yurii Zubrytskyia5bc9582022-11-30 23:53:59 -0800398bool MultiAssetsProvider::ForEachFile(
399 const std::string& root_path,
400 base::function_ref<void(StringPiece, FileType)> f) const {
Ryan Mitchell1a48fa62021-01-10 08:36:36 -0800401 return primary_->ForEachFile(root_path, f) && secondary_->ForEachFile(root_path, f);
402}
403
Ryan Mitchellef538432021-03-01 14:52:14 -0800404std::optional<std::string_view> MultiAssetsProvider::GetPath() const {
405 return path_;
406}
407
Ryan Mitchell1a48fa62021-01-10 08:36:36 -0800408const std::string& MultiAssetsProvider::GetDebugName() const {
409 return debug_name_;
410}
411
Yurii Zubrytskyi548c1ab2025-02-06 15:41:54 -0800412UpToDate MultiAssetsProvider::IsUpToDate() const {
413 return combine(primary_->IsUpToDate(), [this] { return secondary_->IsUpToDate(); });
Ryan Mitchell1a48fa62021-01-10 08:36:36 -0800414}
415
Ryan Mitchellbdc0ae12021-03-01 15:18:15 -0800416EmptyAssetsProvider::EmptyAssetsProvider(std::optional<std::string>&& path) :
417 path_(std::move(path)) {}
418
Ryan Mitchell1a48fa62021-01-10 08:36:36 -0800419std::unique_ptr<AssetsProvider> EmptyAssetsProvider::Create() {
Ryan Mitchellbdc0ae12021-03-01 15:18:15 -0800420 return std::unique_ptr<EmptyAssetsProvider>(new EmptyAssetsProvider({}));
421}
422
Yurii Zubrytskyid0c22cc2022-11-10 14:11:05 -0800423std::unique_ptr<AssetsProvider> EmptyAssetsProvider::Create(std::string path) {
424 return std::unique_ptr<EmptyAssetsProvider>(new EmptyAssetsProvider(std::move(path)));
Ryan Mitchell1a48fa62021-01-10 08:36:36 -0800425}
426
427std::unique_ptr<Asset> EmptyAssetsProvider::OpenInternal(const std::string& /* path */,
428 Asset::AccessMode /* mode */,
429 bool* file_exists) const {
430 if (file_exists) {
431 *file_exists = false;
432 }
433 return nullptr;
434}
435
436bool EmptyAssetsProvider::ForEachFile(
437 const std::string& /* root_path */,
Yurii Zubrytskyia5bc9582022-11-30 23:53:59 -0800438 base::function_ref<void(StringPiece, FileType)> /* f */) const {
Ryan Mitchell1a48fa62021-01-10 08:36:36 -0800439 return true;
440}
441
Ryan Mitchellef538432021-03-01 14:52:14 -0800442std::optional<std::string_view> EmptyAssetsProvider::GetPath() const {
Ryan Mitchellbdc0ae12021-03-01 15:18:15 -0800443 if (path_.has_value()) {
444 return *path_;
445 }
Ryan Mitchellef538432021-03-01 14:52:14 -0800446 return {};
447}
448
Ryan Mitchell1a48fa62021-01-10 08:36:36 -0800449const std::string& EmptyAssetsProvider::GetDebugName() const {
Ryan Mitchellbdc0ae12021-03-01 15:18:15 -0800450 if (path_.has_value()) {
451 return *path_;
452 }
Yurii Zubrytskyi36147b02025-02-06 15:41:54 -0800453 constexpr static std::string kEmpty{kEmptyDebugString};
Ryan Mitchell1a48fa62021-01-10 08:36:36 -0800454 return kEmpty;
455}
456
Yurii Zubrytskyi548c1ab2025-02-06 15:41:54 -0800457UpToDate EmptyAssetsProvider::IsUpToDate() const {
458 return UpToDate::Always;
Ryan Mitchell1a48fa62021-01-10 08:36:36 -0800459}
460
Yurii Zubrytskyia5bc9582022-11-30 23:53:59 -0800461} // namespace android