Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [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 specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #pragma once |
| 18 | |
Yurii Zubrytskyi | 629051fd | 2020-04-17 23:13:47 -0700 | [diff] [blame] | 19 | #include <android/content/pm/BnDataLoaderStatusListener.h> |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 20 | #include <android/content/pm/DataLoaderParamsParcel.h> |
Alex Buynytskyy | cca2c11 | 2020-05-05 12:48:41 -0700 | [diff] [blame] | 21 | #include <android/content/pm/FileSystemControlParcel.h> |
Yurii Zubrytskyi | 629051fd | 2020-04-17 23:13:47 -0700 | [diff] [blame] | 22 | #include <android/content/pm/IDataLoaderStatusListener.h> |
Songchun Fan | 1b76ccf | 2021-02-24 22:25:59 +0000 | [diff] [blame] | 23 | #include <android/os/incremental/BnIncrementalService.h> |
Yurii Zubrytskyi | 629051fd | 2020-04-17 23:13:47 -0700 | [diff] [blame] | 24 | #include <android/os/incremental/BnIncrementalServiceConnector.h> |
Alex Buynytskyy | 8ef61ae | 2020-05-08 16:18:52 -0700 | [diff] [blame] | 25 | #include <android/os/incremental/BnStorageHealthListener.h> |
Songchun Fan | a709859 | 2020-09-03 11:45:53 -0700 | [diff] [blame] | 26 | #include <android/os/incremental/BnStorageLoadingProgressListener.h> |
Alex Buynytskyy | aa8e95e | 2020-12-14 21:50:04 -0800 | [diff] [blame] | 27 | #include <android/os/incremental/PerUidReadTimeouts.h> |
Alex Buynytskyy | 8ef61ae | 2020-05-08 16:18:52 -0700 | [diff] [blame] | 28 | #include <android/os/incremental/StorageHealthCheckParams.h> |
Yurii Zubrytskyi | 629051fd | 2020-04-17 23:13:47 -0700 | [diff] [blame] | 29 | #include <binder/IAppOpsCallback.h> |
Songchun Fan | 1b76ccf | 2021-02-24 22:25:59 +0000 | [diff] [blame] | 30 | #include <binder/PersistableBundle.h> |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 31 | #include <utils/String16.h> |
| 32 | #include <utils/StrongPointer.h> |
Yurii Zubrytskyi | da20801 | 2020-04-07 15:35:21 -0700 | [diff] [blame] | 33 | #include <ziparchive/zip_archive.h> |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 34 | |
| 35 | #include <atomic> |
| 36 | #include <chrono> |
Yurii Zubrytskyi | da20801 | 2020-04-07 15:35:21 -0700 | [diff] [blame] | 37 | #include <condition_variable> |
| 38 | #include <functional> |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 39 | #include <limits> |
| 40 | #include <map> |
| 41 | #include <mutex> |
Alex Buynytskyy | 4760d8f | 2020-05-08 16:18:52 -0700 | [diff] [blame] | 42 | #include <set> |
Songchun Fan | 9b75308 | 2020-02-26 13:08:06 -0800 | [diff] [blame] | 43 | #include <span> |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 44 | #include <string> |
| 45 | #include <string_view> |
Yurii Zubrytskyi | da20801 | 2020-04-07 15:35:21 -0700 | [diff] [blame] | 46 | #include <thread> |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 47 | #include <unordered_map> |
Yurii Zubrytskyi | 629051fd | 2020-04-17 23:13:47 -0700 | [diff] [blame] | 48 | #include <unordered_set> |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 49 | #include <utility> |
| 50 | #include <vector> |
| 51 | |
| 52 | #include "ServiceWrappers.h" |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 53 | #include "incfs.h" |
| 54 | #include "path.h" |
| 55 | |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 56 | namespace android::incremental { |
| 57 | |
| 58 | using MountId = int; |
| 59 | using StorageId = int; |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 60 | using FileId = incfs::FileId; |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 61 | using BlockIndex = incfs::BlockIndex; |
| 62 | using RawMetadata = incfs::RawMetadata; |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 63 | using Seconds = std::chrono::seconds; |
Alex Buynytskyy | 8ef61ae | 2020-05-08 16:18:52 -0700 | [diff] [blame] | 64 | using BootClockTsUs = uint64_t; |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 65 | |
Alex Buynytskyy | 0ea4ff4 | 2020-04-09 17:25:42 -0700 | [diff] [blame] | 66 | using IDataLoaderStatusListener = ::android::content::pm::IDataLoaderStatusListener; |
| 67 | using DataLoaderStatusListener = ::android::sp<IDataLoaderStatusListener>; |
Alex Buynytskyy | 04f7391 | 2020-02-10 08:34:18 -0800 | [diff] [blame] | 68 | |
Alex Buynytskyy | 8ef61ae | 2020-05-08 16:18:52 -0700 | [diff] [blame] | 69 | using StorageHealthCheckParams = ::android::os::incremental::StorageHealthCheckParams; |
| 70 | using IStorageHealthListener = ::android::os::incremental::IStorageHealthListener; |
| 71 | using StorageHealthListener = ::android::sp<IStorageHealthListener>; |
Songchun Fan | a709859 | 2020-09-03 11:45:53 -0700 | [diff] [blame] | 72 | using IStorageLoadingProgressListener = ::android::os::incremental::IStorageLoadingProgressListener; |
| 73 | using StorageLoadingProgressListener = ::android::sp<IStorageLoadingProgressListener>; |
Alex Buynytskyy | 8ef61ae | 2020-05-08 16:18:52 -0700 | [diff] [blame] | 74 | |
Alex Buynytskyy | aa8e95e | 2020-12-14 21:50:04 -0800 | [diff] [blame] | 75 | using PerUidReadTimeouts = ::android::os::incremental::PerUidReadTimeouts; |
| 76 | |
Alex Buynytskyy | cb163f9 | 2021-03-18 21:21:27 -0700 | [diff] [blame^] | 77 | struct IfsState { |
| 78 | // If mount is fully loaded. |
| 79 | bool fullyLoaded = false; |
| 80 | // If read logs are enabled on this mount. Populated only if fullyLoaded == true. |
| 81 | bool readLogsEnabled = false; |
| 82 | // If there was an error fetching any of the above. |
| 83 | bool error = false; |
| 84 | }; |
| 85 | // Returns true if wants to be called again. |
| 86 | using IfsStateCallback = std::function<bool(StorageId, IfsState)>; |
| 87 | |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 88 | class IncrementalService final { |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 89 | public: |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 90 | explicit IncrementalService(ServiceManagerWrapper&& sm, std::string_view rootDir); |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 91 | |
| 92 | #pragma GCC diagnostic push |
| 93 | #pragma GCC diagnostic ignored "-Wnon-virtual-dtor" |
| 94 | ~IncrementalService(); |
| 95 | #pragma GCC diagnostic pop |
| 96 | |
| 97 | static constexpr StorageId kInvalidStorageId = -1; |
| 98 | static constexpr StorageId kMaxStorageId = std::numeric_limits<int>::max(); |
| 99 | |
Alex Buynytskyy | 8ef61ae | 2020-05-08 16:18:52 -0700 | [diff] [blame] | 100 | static constexpr BootClockTsUs kMaxBootClockTsUs = std::numeric_limits<BootClockTsUs>::max(); |
| 101 | |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 102 | enum CreateOptions { |
| 103 | TemporaryBind = 1, |
| 104 | PermanentBind = 2, |
| 105 | CreateNew = 4, |
| 106 | OpenExisting = 8, |
| 107 | |
| 108 | Default = TemporaryBind | CreateNew |
| 109 | }; |
| 110 | |
| 111 | enum class BindKind { |
| 112 | Temporary = 0, |
| 113 | Permanent = 1, |
| 114 | }; |
| 115 | |
Alex Buynytskyy | 3697d9e | 2020-06-06 20:15:58 -0700 | [diff] [blame] | 116 | enum StorageFlags { |
Alex Buynytskyy | aa8e95e | 2020-12-14 21:50:04 -0800 | [diff] [blame] | 117 | ReadLogsAllowed = 1 << 0, |
| 118 | ReadLogsEnabled = 1 << 1, |
| 119 | }; |
| 120 | |
| 121 | struct LoadingProgress { |
| 122 | ssize_t filledBlocks; |
| 123 | ssize_t totalBlocks; |
| 124 | |
| 125 | bool isError() const { return totalBlocks < 0; } |
| 126 | bool started() const { return totalBlocks > 0; } |
| 127 | bool fullyLoaded() const { return !isError() && (totalBlocks == filledBlocks); } |
| 128 | |
Alex Buynytskyy | 07694ed | 2021-01-27 06:58:55 -0800 | [diff] [blame] | 129 | int blocksRemainingOrError() const { |
| 130 | return totalBlocks <= 0 ? totalBlocks : totalBlocks - filledBlocks; |
| 131 | } |
| 132 | |
Alex Buynytskyy | aa8e95e | 2020-12-14 21:50:04 -0800 | [diff] [blame] | 133 | float getProgress() const { |
| 134 | return totalBlocks < 0 |
| 135 | ? totalBlocks |
| 136 | : totalBlocks > 0 ? double(filledBlocks) / double(totalBlocks) : 1.f; |
| 137 | } |
Alex Buynytskyy | 3697d9e | 2020-06-06 20:15:58 -0700 | [diff] [blame] | 138 | }; |
| 139 | |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 140 | static FileId idFromMetadata(std::span<const uint8_t> metadata); |
| 141 | static inline FileId idFromMetadata(std::span<const char> metadata) { |
| 142 | return idFromMetadata({(const uint8_t*)metadata.data(), metadata.size()}); |
| 143 | } |
| 144 | |
Alex Buynytskyy | 18b07a4 | 2020-02-03 20:06:00 -0800 | [diff] [blame] | 145 | void onDump(int fd); |
| 146 | |
Alex Buynytskyy | 0ea4ff4 | 2020-04-09 17:25:42 -0700 | [diff] [blame] | 147 | void onSystemReady(); |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 148 | |
Yurii Zubrytskyi | 629051fd | 2020-04-17 23:13:47 -0700 | [diff] [blame] | 149 | StorageId createStorage(std::string_view mountPoint, |
Yurii Zubrytskyi | f4769e2 | 2021-03-18 20:37:45 -0700 | [diff] [blame] | 150 | content::pm::DataLoaderParamsParcel dataLoaderParams, |
Alex Buynytskyy | 07694ed | 2021-01-27 06:58:55 -0800 | [diff] [blame] | 151 | CreateOptions options); |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 152 | StorageId createLinkedStorage(std::string_view mountPoint, StorageId linkedStorage, |
| 153 | CreateOptions options = CreateOptions::Default); |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 154 | StorageId openStorage(std::string_view path); |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 155 | |
Yurii Zubrytskyi | f4769e2 | 2021-03-18 20:37:45 -0700 | [diff] [blame] | 156 | bool startLoading(StorageId storage, content::pm::DataLoaderParamsParcel dataLoaderParams, |
| 157 | DataLoaderStatusListener statusListener, |
| 158 | const StorageHealthCheckParams& healthCheckParams, |
| 159 | StorageHealthListener healthListener, |
| 160 | std::vector<PerUidReadTimeouts> perUidReadTimeouts); |
Alex Buynytskyy | 07694ed | 2021-01-27 06:58:55 -0800 | [diff] [blame] | 161 | |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 162 | int bind(StorageId storage, std::string_view source, std::string_view target, BindKind kind); |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 163 | int unbind(StorageId storage, std::string_view target); |
| 164 | void deleteStorage(StorageId storage); |
| 165 | |
Alex Buynytskyy | aa8e95e | 2020-12-14 21:50:04 -0800 | [diff] [blame] | 166 | void disallowReadLogs(StorageId storage); |
Alex Buynytskyy | 5e860ba | 2020-03-31 15:30:21 -0700 | [diff] [blame] | 167 | int setStorageParams(StorageId storage, bool enableReadLogs); |
| 168 | |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 169 | int makeFile(StorageId storage, std::string_view path, int mode, FileId id, |
Alex Buynytskyy | b39d13e | 2020-09-12 16:12:36 -0700 | [diff] [blame] | 170 | incfs::NewFileParams params, std::span<const uint8_t> data); |
Songchun Fan | 9610093 | 2020-02-03 19:20:58 -0800 | [diff] [blame] | 171 | int makeDir(StorageId storage, std::string_view path, int mode = 0755); |
| 172 | int makeDirs(StorageId storage, std::string_view path, int mode = 0755); |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 173 | |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 174 | int link(StorageId sourceStorageId, std::string_view oldPath, StorageId destStorageId, |
| 175 | std::string_view newPath); |
| 176 | int unlink(StorageId storage, std::string_view path); |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 177 | |
Yurii Zubrytskyi | 256a1a4 | 2021-03-18 14:21:54 -0700 | [diff] [blame] | 178 | incfs::LoadingState isFileFullyLoaded(StorageId storage, std::string_view filePath) const; |
| 179 | incfs::LoadingState isMountFullyLoaded(StorageId storage) const; |
Alex Buynytskyy | 07694ed | 2021-01-27 06:58:55 -0800 | [diff] [blame] | 180 | |
Yurii Zubrytskyi | 883a27a | 2021-03-18 19:30:56 -0700 | [diff] [blame] | 181 | LoadingProgress getLoadingProgress(StorageId storage) const; |
Alex Buynytskyy | 07694ed | 2021-01-27 06:58:55 -0800 | [diff] [blame] | 182 | |
Songchun Fan | a709859 | 2020-09-03 11:45:53 -0700 | [diff] [blame] | 183 | bool registerLoadingProgressListener(StorageId storage, |
Yurii Zubrytskyi | f4769e2 | 2021-03-18 20:37:45 -0700 | [diff] [blame] | 184 | StorageLoadingProgressListener progressListener); |
Songchun Fan | a709859 | 2020-09-03 11:45:53 -0700 | [diff] [blame] | 185 | bool unregisterLoadingProgressListener(StorageId storage); |
Songchun Fan | 2570ec0 | 2020-10-08 17:22:33 -0700 | [diff] [blame] | 186 | bool registerStorageHealthListener(StorageId storage, |
Yurii Zubrytskyi | f4769e2 | 2021-03-18 20:37:45 -0700 | [diff] [blame] | 187 | const StorageHealthCheckParams& healthCheckParams, |
| 188 | StorageHealthListener healthListener); |
Songchun Fan | 2570ec0 | 2020-10-08 17:22:33 -0700 | [diff] [blame] | 189 | void unregisterStorageHealthListener(StorageId storage); |
Yurii Zubrytskyi | 629051fd | 2020-04-17 23:13:47 -0700 | [diff] [blame] | 190 | RawMetadata getMetadata(StorageId storage, std::string_view path) const; |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 191 | RawMetadata getMetadata(StorageId storage, FileId node) const; |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 192 | |
Songchun Fan | 0f8b6fe | 2020-02-05 17:41:25 -0800 | [diff] [blame] | 193 | bool configureNativeBinaries(StorageId storage, std::string_view apkFullPath, |
Songchun Fan | 14f6c3c | 2020-05-21 18:19:07 -0700 | [diff] [blame] | 194 | std::string_view libDirRelativePath, std::string_view abi, |
| 195 | bool extractNativeLibs); |
Yurii Zubrytskyi | da20801 | 2020-04-07 15:35:21 -0700 | [diff] [blame] | 196 | bool waitForNativeBinariesExtraction(StorageId storage); |
Alex Buynytskyy | 96e350b | 2020-04-02 20:03:47 -0700 | [diff] [blame] | 197 | |
Songchun Fan | 1b76ccf | 2021-02-24 22:25:59 +0000 | [diff] [blame] | 198 | void getMetrics(int32_t storageId, android::os::PersistableBundle* _aidl_return); |
| 199 | |
Alex Buynytskyy | 96e350b | 2020-04-02 20:03:47 -0700 | [diff] [blame] | 200 | class AppOpsListener : public android::BnAppOpsCallback { |
| 201 | public: |
Yurii Zubrytskyi | da20801 | 2020-04-07 15:35:21 -0700 | [diff] [blame] | 202 | AppOpsListener(IncrementalService& incrementalService, std::string packageName) |
| 203 | : incrementalService(incrementalService), packageName(std::move(packageName)) {} |
Alex Buynytskyy | f415679 | 2020-04-07 14:26:55 -0700 | [diff] [blame] | 204 | void opChanged(int32_t op, const String16& packageName) final; |
Alex Buynytskyy | 96e350b | 2020-04-02 20:03:47 -0700 | [diff] [blame] | 205 | |
| 206 | private: |
| 207 | IncrementalService& incrementalService; |
| 208 | const std::string packageName; |
| 209 | }; |
| 210 | |
Yurii Zubrytskyi | 629051fd | 2020-04-17 23:13:47 -0700 | [diff] [blame] | 211 | class IncrementalServiceConnector : public os::incremental::BnIncrementalServiceConnector { |
Alex Buynytskyy | f415679 | 2020-04-07 14:26:55 -0700 | [diff] [blame] | 212 | public: |
| 213 | IncrementalServiceConnector(IncrementalService& incrementalService, int32_t storage) |
Alex Buynytskyy | 5f9e3a0 | 2020-04-07 21:13:41 -0700 | [diff] [blame] | 214 | : incrementalService(incrementalService), storage(storage) {} |
Alex Buynytskyy | f415679 | 2020-04-07 14:26:55 -0700 | [diff] [blame] | 215 | binder::Status setStorageParams(bool enableReadLogs, int32_t* _aidl_return) final; |
| 216 | |
| 217 | private: |
| 218 | IncrementalService& incrementalService; |
Alex Buynytskyy | 5f9e3a0 | 2020-04-07 21:13:41 -0700 | [diff] [blame] | 219 | int32_t const storage; |
Alex Buynytskyy | f415679 | 2020-04-07 14:26:55 -0700 | [diff] [blame] | 220 | }; |
| 221 | |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 222 | private: |
Alex Buynytskyy | 0ea4ff4 | 2020-04-09 17:25:42 -0700 | [diff] [blame] | 223 | struct IncFsMount; |
| 224 | |
Yurii Zubrytskyi | 629051fd | 2020-04-17 23:13:47 -0700 | [diff] [blame] | 225 | class DataLoaderStub : public content::pm::BnDataLoaderStatusListener { |
Alex Buynytskyy | 0ea4ff4 | 2020-04-09 17:25:42 -0700 | [diff] [blame] | 226 | public: |
Yurii Zubrytskyi | 629051fd | 2020-04-17 23:13:47 -0700 | [diff] [blame] | 227 | DataLoaderStub(IncrementalService& service, MountId id, |
| 228 | content::pm::DataLoaderParamsParcel&& params, |
| 229 | content::pm::FileSystemControlParcel&& control, |
Yurii Zubrytskyi | f4769e2 | 2021-03-18 20:37:45 -0700 | [diff] [blame] | 230 | DataLoaderStatusListener&& statusListener, |
| 231 | const StorageHealthCheckParams& healthCheckParams, |
| 232 | StorageHealthListener&& healthListener, std::string&& healthPath); |
Alex Buynytskyy | 0ea4ff4 | 2020-04-09 17:25:42 -0700 | [diff] [blame] | 233 | ~DataLoaderStub(); |
Alex Buynytskyy | 9a54579a | 2020-04-17 15:34:47 -0700 | [diff] [blame] | 234 | // Cleans up the internal state and invalidates DataLoaderStub. Any subsequent calls will |
| 235 | // result in an error. |
| 236 | void cleanupResources(); |
Alex Buynytskyy | 0ea4ff4 | 2020-04-09 17:25:42 -0700 | [diff] [blame] | 237 | |
Alex Buynytskyy | ab65cb1 | 2020-04-17 10:01:47 -0700 | [diff] [blame] | 238 | bool requestCreate(); |
Alex Buynytskyy | 0b20266 | 2020-04-13 09:53:04 -0700 | [diff] [blame] | 239 | bool requestStart(); |
Alex Buynytskyy | ab65cb1 | 2020-04-17 10:01:47 -0700 | [diff] [blame] | 240 | bool requestDestroy(); |
Alex Buynytskyy | 0ea4ff4 | 2020-04-09 17:25:42 -0700 | [diff] [blame] | 241 | |
Alex Buynytskyy | ab65cb1 | 2020-04-17 10:01:47 -0700 | [diff] [blame] | 242 | void onDump(int fd); |
| 243 | |
Alex Buynytskyy | 4760d8f | 2020-05-08 16:18:52 -0700 | [diff] [blame] | 244 | MountId id() const { return mId.load(std::memory_order_relaxed); } |
Yurii Zubrytskyi | 629051fd | 2020-04-17 23:13:47 -0700 | [diff] [blame] | 245 | const content::pm::DataLoaderParamsParcel& params() const { return mParams; } |
Alex Buynytskyy | d7aa346 | 2021-03-14 22:20:20 -0700 | [diff] [blame] | 246 | bool isSystemDataLoader() const; |
Yurii Zubrytskyi | f4769e2 | 2021-03-18 20:37:45 -0700 | [diff] [blame] | 247 | void setHealthListener(const StorageHealthCheckParams& healthCheckParams, |
| 248 | StorageHealthListener&& healthListener); |
Songchun Fan | 1b76ccf | 2021-02-24 22:25:59 +0000 | [diff] [blame] | 249 | long elapsedMsSinceOldestPendingRead(); |
Alex Buynytskyy | 0ea4ff4 | 2020-04-09 17:25:42 -0700 | [diff] [blame] | 250 | |
| 251 | private: |
| 252 | binder::Status onStatusChanged(MountId mount, int newStatus) final; |
Songchun Fan | 3309398 | 2020-09-10 13:12:39 -0700 | [diff] [blame] | 253 | binder::Status reportStreamHealth(MountId mount, int newStatus) final; |
Alex Buynytskyy | 0ea4ff4 | 2020-04-09 17:25:42 -0700 | [diff] [blame] | 254 | |
Alex Buynytskyy | 060c9d6 | 2021-02-18 20:55:17 -0800 | [diff] [blame] | 255 | void setCurrentStatus(int newStatus); |
| 256 | |
Alex Buynytskyy | 0bdbccf | 2020-04-23 20:36:42 -0700 | [diff] [blame] | 257 | sp<content::pm::IDataLoader> getDataLoader(); |
Alex Buynytskyy | 9a54579a | 2020-04-17 15:34:47 -0700 | [diff] [blame] | 258 | |
Alex Buynytskyy | ea1390f | 2020-04-22 16:08:50 -0700 | [diff] [blame] | 259 | bool bind(); |
Alex Buynytskyy | ab65cb1 | 2020-04-17 10:01:47 -0700 | [diff] [blame] | 260 | bool create(); |
Alex Buynytskyy | 0b20266 | 2020-04-13 09:53:04 -0700 | [diff] [blame] | 261 | bool start(); |
Alex Buynytskyy | ab65cb1 | 2020-04-17 10:01:47 -0700 | [diff] [blame] | 262 | bool destroy(); |
| 263 | |
| 264 | bool setTargetStatus(int status); |
Alex Buynytskyy | 7e0a1a8 | 2020-04-27 17:06:10 -0700 | [diff] [blame] | 265 | void setTargetStatusLocked(int status); |
Alex Buynytskyy | ab65cb1 | 2020-04-17 10:01:47 -0700 | [diff] [blame] | 266 | |
| 267 | bool fsmStep(); |
Alex Buynytskyy | 0b20266 | 2020-04-13 09:53:04 -0700 | [diff] [blame] | 268 | |
Yurii Zubrytskyi | 883a27a | 2021-03-18 19:30:56 -0700 | [diff] [blame] | 269 | void onHealthStatus(const StorageHealthListener& healthListener, int healthStatus); |
Alex Buynytskyy | 4760d8f | 2020-05-08 16:18:52 -0700 | [diff] [blame] | 270 | void updateHealthStatus(bool baseline = false); |
| 271 | |
| 272 | bool isValid() const { return id() != kInvalidStorageId; } |
| 273 | |
| 274 | bool isHealthParamsValid() const; |
| 275 | |
| 276 | const incfs::UniqueControl& initializeHealthControl(); |
| 277 | void resetHealthControl(); |
| 278 | |
| 279 | BootClockTsUs getOldestPendingReadTs(); |
Songchun Fan | 1b76ccf | 2021-02-24 22:25:59 +0000 | [diff] [blame] | 280 | BootClockTsUs getOldestTsFromLastPendingReads(); |
| 281 | Milliseconds elapsedMsSinceKernelTs(TimePoint now, BootClockTsUs kernelTsUs); |
Alex Buynytskyy | 4760d8f | 2020-05-08 16:18:52 -0700 | [diff] [blame] | 282 | |
Alex Buynytskyy | 7e06d71 | 2021-03-09 19:24:23 -0800 | [diff] [blame] | 283 | // If the stub has to bind to the DL. |
| 284 | // Returns {} if bind operation is already in progress. |
| 285 | // Or bind delay in ms. |
| 286 | std::optional<Milliseconds> needToBind(); |
Alex Buynytskyy | b19ee3e | 2021-02-06 20:31:43 -0800 | [diff] [blame] | 287 | |
Alex Buynytskyy | 4760d8f | 2020-05-08 16:18:52 -0700 | [diff] [blame] | 288 | void registerForPendingReads(); |
| 289 | void unregisterFromPendingReads(); |
Alex Buynytskyy | d0855a3 | 2020-05-07 18:40:51 -0700 | [diff] [blame] | 290 | |
Alex Buynytskyy | 0ea4ff4 | 2020-04-09 17:25:42 -0700 | [diff] [blame] | 291 | IncrementalService& mService; |
Alex Buynytskyy | b0ea448 | 2020-05-04 18:39:58 -0700 | [diff] [blame] | 292 | |
| 293 | std::mutex mMutex; |
Alex Buynytskyy | 4760d8f | 2020-05-08 16:18:52 -0700 | [diff] [blame] | 294 | std::atomic<MountId> mId = kInvalidStorageId; |
Yurii Zubrytskyi | 629051fd | 2020-04-17 23:13:47 -0700 | [diff] [blame] | 295 | content::pm::DataLoaderParamsParcel mParams; |
| 296 | content::pm::FileSystemControlParcel mControl; |
Alex Buynytskyy | 8ef61ae | 2020-05-08 16:18:52 -0700 | [diff] [blame] | 297 | DataLoaderStatusListener mStatusListener; |
| 298 | StorageHealthListener mHealthListener; |
Alex Buynytskyy | 0ea4ff4 | 2020-04-09 17:25:42 -0700 | [diff] [blame] | 299 | |
Alex Buynytskyy | 0b20266 | 2020-04-13 09:53:04 -0700 | [diff] [blame] | 300 | std::condition_variable mStatusCondition; |
Yurii Zubrytskyi | 629051fd | 2020-04-17 23:13:47 -0700 | [diff] [blame] | 301 | int mCurrentStatus = content::pm::IDataLoaderStatusListener::DATA_LOADER_DESTROYED; |
Alex Buynytskyy | 7e06d71 | 2021-03-09 19:24:23 -0800 | [diff] [blame] | 302 | TimePoint mCurrentStatusTs = {}; |
Yurii Zubrytskyi | 629051fd | 2020-04-17 23:13:47 -0700 | [diff] [blame] | 303 | int mTargetStatus = content::pm::IDataLoaderStatusListener::DATA_LOADER_DESTROYED; |
Alex Buynytskyy | ab65cb1 | 2020-04-17 10:01:47 -0700 | [diff] [blame] | 304 | TimePoint mTargetStatusTs = {}; |
Alex Buynytskyy | cca2c11 | 2020-05-05 12:48:41 -0700 | [diff] [blame] | 305 | |
Alex Buynytskyy | b19ee3e | 2021-02-06 20:31:43 -0800 | [diff] [blame] | 306 | TimePoint mPreviousBindTs = {}; |
| 307 | Milliseconds mPreviousBindDelay = {}; |
| 308 | |
Alex Buynytskyy | d0855a3 | 2020-05-07 18:40:51 -0700 | [diff] [blame] | 309 | std::string mHealthPath; |
| 310 | incfs::UniqueControl mHealthControl; |
Alex Buynytskyy | 4760d8f | 2020-05-08 16:18:52 -0700 | [diff] [blame] | 311 | struct { |
| 312 | TimePoint userTs; |
| 313 | BootClockTsUs kernelTsUs; |
| 314 | } mHealthBase = {TimePoint::max(), kMaxBootClockTsUs}; |
| 315 | StorageHealthCheckParams mHealthCheckParams; |
Songchun Fan | 2570ec0 | 2020-10-08 17:22:33 -0700 | [diff] [blame] | 316 | int mStreamStatus = content::pm::IDataLoaderStatusListener::STREAM_HEALTHY; |
Songchun Fan | 6944f1e | 2020-11-06 15:24:24 -0800 | [diff] [blame] | 317 | std::vector<incfs::ReadInfo> mLastPendingReads; |
Alex Buynytskyy | 0ea4ff4 | 2020-04-09 17:25:42 -0700 | [diff] [blame] | 318 | }; |
| 319 | using DataLoaderStubPtr = sp<DataLoaderStub>; |
| 320 | |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 321 | struct IncFsMount { |
| 322 | struct Bind { |
| 323 | StorageId storage; |
| 324 | std::string savedFilename; |
| 325 | std::string sourceDir; |
| 326 | BindKind kind; |
| 327 | }; |
| 328 | |
| 329 | struct Storage { |
| 330 | std::string name; |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 331 | }; |
| 332 | |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 333 | using Control = incfs::UniqueControl; |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 334 | |
Yurii Zubrytskyi | 629051fd | 2020-04-17 23:13:47 -0700 | [diff] [blame] | 335 | using BindMap = std::map<std::string, Bind, path::PathLess>; |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 336 | using StorageMap = std::unordered_map<StorageId, Storage>; |
| 337 | |
| 338 | mutable std::mutex lock; |
| 339 | const std::string root; |
| 340 | Control control; |
| 341 | /*const*/ MountId mountId; |
Alex Buynytskyy | aa8e95e | 2020-12-14 21:50:04 -0800 | [diff] [blame] | 342 | int32_t flags = StorageFlags::ReadLogsAllowed; |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 343 | StorageMap storages; |
| 344 | BindMap bindPoints; |
Alex Buynytskyy | 0ea4ff4 | 2020-04-09 17:25:42 -0700 | [diff] [blame] | 345 | DataLoaderStubPtr dataLoaderStub; |
Alex Buynytskyy | d7aa346 | 2021-03-14 22:20:20 -0700 | [diff] [blame] | 346 | TimePoint startLoadingTs = {}; |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 347 | std::atomic<int> nextStorageDirNo{0}; |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 348 | const IncrementalService& incrementalService; |
| 349 | |
| 350 | IncFsMount(std::string root, MountId mountId, Control control, |
| 351 | const IncrementalService& incrementalService) |
| 352 | : root(std::move(root)), |
| 353 | control(std::move(control)), |
| 354 | mountId(mountId), |
Alex Buynytskyy | 1d89216 | 2020-04-03 23:00:19 -0700 | [diff] [blame] | 355 | incrementalService(incrementalService) {} |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 356 | IncFsMount(IncFsMount&&) = delete; |
| 357 | IncFsMount& operator=(IncFsMount&&) = delete; |
| 358 | ~IncFsMount(); |
| 359 | |
| 360 | StorageMap::iterator makeStorage(StorageId id); |
| 361 | |
Alex Buynytskyy | aa8e95e | 2020-12-14 21:50:04 -0800 | [diff] [blame] | 362 | void disallowReadLogs() { flags &= ~StorageFlags::ReadLogsAllowed; } |
| 363 | int32_t readLogsAllowed() const { return (flags & StorageFlags::ReadLogsAllowed); } |
| 364 | |
Alex Buynytskyy | d7aa346 | 2021-03-14 22:20:20 -0700 | [diff] [blame] | 365 | void setReadLogsEnabled(bool value); |
Alex Buynytskyy | 3697d9e | 2020-06-06 20:15:58 -0700 | [diff] [blame] | 366 | int32_t readLogsEnabled() const { return (flags & StorageFlags::ReadLogsEnabled); } |
| 367 | |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 368 | static void cleanupFilesystem(std::string_view root); |
| 369 | }; |
| 370 | |
| 371 | using IfsMountPtr = std::shared_ptr<IncFsMount>; |
| 372 | using MountMap = std::unordered_map<MountId, IfsMountPtr>; |
| 373 | using BindPathMap = std::map<std::string, IncFsMount::BindMap::iterator, path::PathLess>; |
| 374 | |
Yurii Zubrytskyi | 629051fd | 2020-04-17 23:13:47 -0700 | [diff] [blame] | 375 | static bool perfLoggingEnabled(); |
| 376 | |
Alex Buynytskyy | aa8e95e | 2020-12-14 21:50:04 -0800 | [diff] [blame] | 377 | void setUidReadTimeouts(StorageId storage, |
Yurii Zubrytskyi | f4769e2 | 2021-03-18 20:37:45 -0700 | [diff] [blame] | 378 | std::vector<PerUidReadTimeouts>&& perUidReadTimeouts); |
Alex Buynytskyy | aa8e95e | 2020-12-14 21:50:04 -0800 | [diff] [blame] | 379 | void clearUidReadTimeouts(StorageId storage); |
Alex Buynytskyy | cb163f9 | 2021-03-18 21:21:27 -0700 | [diff] [blame^] | 380 | bool checkUidReadTimeouts(StorageId storage, IfsState state, Clock::time_point timeLimit); |
Alex Buynytskyy | aa8e95e | 2020-12-14 21:50:04 -0800 | [diff] [blame] | 381 | |
Yurii Zubrytskyi | 629051fd | 2020-04-17 23:13:47 -0700 | [diff] [blame] | 382 | std::unordered_set<std::string_view> adoptMountedInstances(); |
| 383 | void mountExistingImages(const std::unordered_set<std::string_view>& mountedRootNames); |
Yurii Zubrytskyi | 107ae35 | 2020-04-03 13:12:51 -0700 | [diff] [blame] | 384 | bool mountExistingImage(std::string_view root); |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 385 | |
| 386 | IfsMountPtr getIfs(StorageId storage) const; |
| 387 | const IfsMountPtr& getIfsLocked(StorageId storage) const; |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 388 | int addBindMount(IncFsMount& ifs, StorageId storage, std::string_view storageRoot, |
| 389 | std::string&& source, std::string&& target, BindKind kind, |
| 390 | std::unique_lock<std::mutex>& mainLock); |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 391 | |
| 392 | int addBindMountWithMd(IncFsMount& ifs, StorageId storage, std::string&& metadataName, |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 393 | std::string&& source, std::string&& target, BindKind kind, |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 394 | std::unique_lock<std::mutex>& mainLock); |
| 395 | |
Yurii Zubrytskyi | 629051fd | 2020-04-17 23:13:47 -0700 | [diff] [blame] | 396 | void addBindMountRecordLocked(IncFsMount& ifs, StorageId storage, std::string&& metadataName, |
| 397 | std::string&& source, std::string&& target, BindKind kind); |
| 398 | |
Alex Buynytskyy | b19ee3e | 2021-02-06 20:31:43 -0800 | [diff] [blame] | 399 | bool needStartDataLoaderLocked(IncFsMount& ifs); |
| 400 | |
Yurii Zubrytskyi | 629051fd | 2020-04-17 23:13:47 -0700 | [diff] [blame] | 401 | void prepareDataLoaderLocked(IncFsMount& ifs, content::pm::DataLoaderParamsParcel&& params, |
Yurii Zubrytskyi | f4769e2 | 2021-03-18 20:37:45 -0700 | [diff] [blame] | 402 | DataLoaderStatusListener&& statusListener = {}, |
| 403 | const StorageHealthCheckParams& healthCheckParams = {}, |
| 404 | StorageHealthListener&& healthListener = {}); |
Alex Buynytskyy | bf1c063 | 2020-03-10 15:49:29 -0700 | [diff] [blame] | 405 | |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 406 | BindPathMap::const_iterator findStorageLocked(std::string_view path) const; |
| 407 | StorageId findStorageId(std::string_view path) const; |
| 408 | |
| 409 | void deleteStorage(IncFsMount& ifs); |
| 410 | void deleteStorageLocked(IncFsMount& ifs, std::unique_lock<std::mutex>&& ifsLock); |
| 411 | MountMap::iterator getStorageSlotLocked(); |
Yurii Zubrytskyi | efebb45 | 2020-04-22 13:59:06 -0700 | [diff] [blame] | 412 | std::string normalizePathToStorage(const IncFsMount& incfs, StorageId storage, |
Yurii Zubrytskyi | 629051fd | 2020-04-17 23:13:47 -0700 | [diff] [blame] | 413 | std::string_view path) const; |
Yurii Zubrytskyi | efebb45 | 2020-04-22 13:59:06 -0700 | [diff] [blame] | 414 | std::string normalizePathToStorageLocked(const IncFsMount& incfs, |
| 415 | IncFsMount::StorageMap::const_iterator storageIt, |
Yurii Zubrytskyi | 629051fd | 2020-04-17 23:13:47 -0700 | [diff] [blame] | 416 | std::string_view path) const; |
Yurii Zubrytskyi | efebb45 | 2020-04-22 13:59:06 -0700 | [diff] [blame] | 417 | int makeDirs(const IncFsMount& ifs, StorageId storageId, std::string_view path, int mode); |
Alex Buynytskyy | d7aa346 | 2021-03-14 22:20:20 -0700 | [diff] [blame] | 418 | |
Alex Buynytskyy | cb163f9 | 2021-03-18 21:21:27 -0700 | [diff] [blame^] | 419 | int disableReadLogsLocked(IncFsMount& ifs); |
| 420 | int applyStorageParamsLocked(IncFsMount& ifs, bool enableReadLogs); |
Alex Buynytskyy | 96e350b | 2020-04-02 20:03:47 -0700 | [diff] [blame] | 421 | |
Yurii Zubrytskyi | 883a27a | 2021-03-18 19:30:56 -0700 | [diff] [blame] | 422 | LoadingProgress getLoadingProgressFromPath(const IncFsMount& ifs, std::string_view path) const; |
Songchun Fan | 374f765 | 2020-08-20 08:40:29 -0700 | [diff] [blame] | 423 | |
Alex Buynytskyy | b39d13e | 2020-09-12 16:12:36 -0700 | [diff] [blame] | 424 | int setFileContent(const IfsMountPtr& ifs, const incfs::FileId& fileId, |
| 425 | std::string_view debugFilePath, std::span<const uint8_t> data) const; |
| 426 | |
Alex Buynytskyy | 96e350b | 2020-04-02 20:03:47 -0700 | [diff] [blame] | 427 | void registerAppOpsCallback(const std::string& packageName); |
Alex Buynytskyy | 1d89216 | 2020-04-03 23:00:19 -0700 | [diff] [blame] | 428 | bool unregisterAppOpsCallback(const std::string& packageName); |
| 429 | void onAppOpChanged(const std::string& packageName); |
Alex Buynytskyy | 96e350b | 2020-04-02 20:03:47 -0700 | [diff] [blame] | 430 | |
Yurii Zubrytskyi | da20801 | 2020-04-07 15:35:21 -0700 | [diff] [blame] | 431 | void runJobProcessing(); |
| 432 | void extractZipFile(const IfsMountPtr& ifs, ZipArchiveHandle zipFile, ZipEntry& entry, |
Alex Buynytskyy | b39d13e | 2020-09-12 16:12:36 -0700 | [diff] [blame] | 433 | const incfs::FileId& libFileId, std::string_view debugLibPath, |
Yurii Zubrytskyi | da20801 | 2020-04-07 15:35:21 -0700 | [diff] [blame] | 434 | Clock::time_point scheduledTs); |
| 435 | |
Alex Buynytskyy | cca2c11 | 2020-05-05 12:48:41 -0700 | [diff] [blame] | 436 | void runCmdLooper(); |
| 437 | |
Songchun Fan | a709859 | 2020-09-03 11:45:53 -0700 | [diff] [blame] | 438 | bool addTimedJob(TimedQueueWrapper& timedQueue, MountId id, Milliseconds after, Job what); |
| 439 | bool removeTimedJobs(TimedQueueWrapper& timedQueue, MountId id); |
Alex Buynytskyy | cb163f9 | 2021-03-18 21:21:27 -0700 | [diff] [blame^] | 440 | |
| 441 | void addIfsStateCallback(StorageId storageId, IfsStateCallback callback); |
| 442 | void removeIfsStateCallbacks(StorageId storageId); |
| 443 | void processIfsStateCallbacks(); |
| 444 | void processIfsStateCallbacks(StorageId storageId, std::vector<IfsStateCallback>& callbacks); |
| 445 | |
Songchun Fan | a709859 | 2020-09-03 11:45:53 -0700 | [diff] [blame] | 446 | bool updateLoadingProgress(int32_t storageId, |
Yurii Zubrytskyi | f4769e2 | 2021-03-18 20:37:45 -0700 | [diff] [blame] | 447 | StorageLoadingProgressListener&& progressListener); |
Songchun Fan | 1b76ccf | 2021-02-24 22:25:59 +0000 | [diff] [blame] | 448 | long getMillsSinceOldestPendingRead(StorageId storage); |
Alex Buynytskyy | 4760d8f | 2020-05-08 16:18:52 -0700 | [diff] [blame] | 449 | |
Yurii Zubrytskyi | da20801 | 2020-04-07 15:35:21 -0700 | [diff] [blame] | 450 | private: |
Yurii Zubrytskyi | 8632140 | 2020-04-09 19:22:30 -0700 | [diff] [blame] | 451 | const std::unique_ptr<VoldServiceWrapper> mVold; |
| 452 | const std::unique_ptr<DataLoaderManagerWrapper> mDataLoaderManager; |
| 453 | const std::unique_ptr<IncFsWrapper> mIncFs; |
| 454 | const std::unique_ptr<AppOpsManagerWrapper> mAppOpsManager; |
| 455 | const std::unique_ptr<JniWrapper> mJni; |
Alex Buynytskyy | cca2c11 | 2020-05-05 12:48:41 -0700 | [diff] [blame] | 456 | const std::unique_ptr<LooperWrapper> mLooper; |
Alex Buynytskyy | 46d3ddb | 2020-05-29 12:05:05 -0700 | [diff] [blame] | 457 | const std::unique_ptr<TimedQueueWrapper> mTimedQueue; |
Songchun Fan | a709859 | 2020-09-03 11:45:53 -0700 | [diff] [blame] | 458 | const std::unique_ptr<TimedQueueWrapper> mProgressUpdateJobQueue; |
Songchun Fan | 374f765 | 2020-08-20 08:40:29 -0700 | [diff] [blame] | 459 | const std::unique_ptr<FsWrapper> mFs; |
Alex Buynytskyy | 7e06d71 | 2021-03-09 19:24:23 -0800 | [diff] [blame] | 460 | const std::unique_ptr<ClockWrapper> mClock; |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 461 | const std::string mIncrementalDir; |
| 462 | |
| 463 | mutable std::mutex mLock; |
| 464 | mutable std::mutex mMountOperationLock; |
| 465 | MountMap mMounts; |
| 466 | BindPathMap mBindsByPath; |
| 467 | |
Alex Buynytskyy | 96e350b | 2020-04-02 20:03:47 -0700 | [diff] [blame] | 468 | std::mutex mCallbacksLock; |
Yurii Zubrytskyi | f4769e2 | 2021-03-18 20:37:45 -0700 | [diff] [blame] | 469 | std::unordered_map<std::string, sp<AppOpsListener>> mCallbackRegistered; |
Alex Buynytskyy | 96e350b | 2020-04-02 20:03:47 -0700 | [diff] [blame] | 470 | |
Alex Buynytskyy | cb163f9 | 2021-03-18 21:21:27 -0700 | [diff] [blame^] | 471 | using IfsStateCallbacks = std::unordered_map<StorageId, std::vector<IfsStateCallback>>; |
| 472 | std::mutex mIfsStateCallbacksLock; |
| 473 | IfsStateCallbacks mIfsStateCallbacks; |
| 474 | |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 475 | std::atomic_bool mSystemReady = false; |
| 476 | StorageId mNextId = 0; |
Yurii Zubrytskyi | da20801 | 2020-04-07 15:35:21 -0700 | [diff] [blame] | 477 | |
Alex Buynytskyy | cca2c11 | 2020-05-05 12:48:41 -0700 | [diff] [blame] | 478 | std::atomic_bool mRunning{true}; |
| 479 | |
Yurii Zubrytskyi | 721ac4d | 2020-04-13 11:34:32 -0700 | [diff] [blame] | 480 | std::unordered_map<MountId, std::vector<Job>> mJobQueue; |
| 481 | MountId mPendingJobsMount = kInvalidStorageId; |
Yurii Zubrytskyi | da20801 | 2020-04-07 15:35:21 -0700 | [diff] [blame] | 482 | std::condition_variable mJobCondition; |
| 483 | std::mutex mJobMutex; |
| 484 | std::thread mJobProcessor; |
Alex Buynytskyy | cca2c11 | 2020-05-05 12:48:41 -0700 | [diff] [blame] | 485 | |
| 486 | std::thread mCmdLooperThread; |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 487 | }; |
| 488 | |
| 489 | } // namespace android::incremental |