| 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 | #include "BinderIncrementalService.h" | 
|  | 18 |  | 
| Songchun Fan | 0f8b6fe | 2020-02-05 17:41:25 -0800 | [diff] [blame] | 19 | #include <android-base/logging.h> | 
| Yurii Zubrytskyi | 0cd8012 | 2020-04-09 23:08:31 -0700 | [diff] [blame] | 20 | #include <android-base/no_destructor.h> | 
| Yurii Zubrytskyi | 629051fd | 2020-04-17 23:13:47 -0700 | [diff] [blame] | 21 | #include <android/os/IVold.h> | 
| Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 22 | #include <binder/IResultReceiver.h> | 
| Alex Buynytskyy | 18b07a4 | 2020-02-03 20:06:00 -0800 | [diff] [blame] | 23 | #include <binder/PermissionCache.h> | 
| Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 24 | #include <incfs.h> | 
|  | 25 |  | 
|  | 26 | #include "ServiceWrappers.h" | 
|  | 27 | #include "jni.h" | 
| Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 28 | #include "path.h" | 
|  | 29 |  | 
|  | 30 | using namespace std::literals; | 
|  | 31 | using namespace android::incremental; | 
|  | 32 |  | 
|  | 33 | namespace android::os::incremental { | 
|  | 34 |  | 
|  | 35 | static constexpr auto kAndroidDataEnv = "ANDROID_DATA"sv; | 
|  | 36 | static constexpr auto kDataDir = "/data"sv; | 
|  | 37 | static constexpr auto kIncrementalSubDir = "incremental"sv; | 
|  | 38 |  | 
|  | 39 | static std::string getIncrementalDir() { | 
|  | 40 | const char* dataDir = getenv(kAndroidDataEnv.data()); | 
|  | 41 | if (!dataDir || !*dataDir) { | 
|  | 42 | dataDir = kDataDir.data(); | 
|  | 43 | } | 
|  | 44 | return path::normalize(path::join(dataDir, kIncrementalSubDir)); | 
|  | 45 | } | 
|  | 46 |  | 
|  | 47 | static bool incFsEnabled() { | 
|  | 48 | // TODO(b/136132412): use vold to check /sys/fs/incfs/version (per selinux compliance) | 
|  | 49 | return incfs::enabled(); | 
|  | 50 | } | 
|  | 51 |  | 
| Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 52 | static bool incFsValid(const sp<IVold>& vold) { | 
|  | 53 | bool enabled = false; | 
|  | 54 | auto status = vold->incFsEnabled(&enabled); | 
|  | 55 | if (!status.isOk() || !enabled) { | 
| Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 56 | return false; | 
|  | 57 | } | 
|  | 58 | return true; | 
|  | 59 | } | 
|  | 60 |  | 
| Yurii Zubrytskyi | 8632140 | 2020-04-09 19:22:30 -0700 | [diff] [blame] | 61 | BinderIncrementalService::BinderIncrementalService(const sp<IServiceManager>& sm, JNIEnv* env) | 
|  | 62 | : mImpl(RealServiceManager(sm, env), getIncrementalDir()) {} | 
| Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 63 |  | 
| Yurii Zubrytskyi | 8632140 | 2020-04-09 19:22:30 -0700 | [diff] [blame] | 64 | BinderIncrementalService* BinderIncrementalService::start(JNIEnv* env) { | 
| Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 65 | if (!incFsEnabled()) { | 
|  | 66 | return nullptr; | 
|  | 67 | } | 
|  | 68 |  | 
|  | 69 | IPCThreadState::self()->disableBackgroundScheduling(true); | 
|  | 70 | sp<IServiceManager> sm(defaultServiceManager()); | 
|  | 71 | if (!sm) { | 
|  | 72 | return nullptr; | 
|  | 73 | } | 
|  | 74 |  | 
|  | 75 | sp<IBinder> voldBinder(sm->getService(String16("vold"))); | 
|  | 76 | if (voldBinder == nullptr) { | 
|  | 77 | return nullptr; | 
|  | 78 | } | 
|  | 79 | sp<IVold> vold = interface_cast<IVold>(voldBinder); | 
| Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 80 | if (!incFsValid(vold)) { | 
| Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 81 | return nullptr; | 
|  | 82 | } | 
|  | 83 |  | 
| Yurii Zubrytskyi | 8632140 | 2020-04-09 19:22:30 -0700 | [diff] [blame] | 84 | sp<BinderIncrementalService> self(new BinderIncrementalService(sm, env)); | 
| Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 85 | status_t ret = sm->addService(String16{getServiceName()}, self); | 
|  | 86 | if (ret != android::OK) { | 
|  | 87 | return nullptr; | 
|  | 88 | } | 
|  | 89 | sp<ProcessState> ps(ProcessState::self()); | 
|  | 90 | ps->startThreadPool(); | 
| Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 91 | // sm->addService increments the reference count, and now we're OK with returning the pointer. | 
| Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 92 | return self.get(); | 
|  | 93 | } | 
|  | 94 |  | 
| Alex Buynytskyy | 18b07a4 | 2020-02-03 20:06:00 -0800 | [diff] [blame] | 95 | status_t BinderIncrementalService::dump(int fd, const Vector<String16>&) { | 
| Yurii Zubrytskyi | 0cd8012 | 2020-04-09 23:08:31 -0700 | [diff] [blame] | 96 | static const android::base::NoDestructor<String16> kDump("android.permission.DUMP"); | 
|  | 97 | if (!PermissionCache::checkCallingPermission(*kDump)) { | 
| Alex Buynytskyy | 18b07a4 | 2020-02-03 20:06:00 -0800 | [diff] [blame] | 98 | return PERMISSION_DENIED; | 
|  | 99 | } | 
|  | 100 | mImpl.onDump(fd); | 
|  | 101 | return NO_ERROR; | 
| Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 102 | } | 
|  | 103 |  | 
|  | 104 | void BinderIncrementalService::onSystemReady() { | 
|  | 105 | mImpl.onSystemReady(); | 
|  | 106 | } | 
|  | 107 |  | 
|  | 108 | static binder::Status ok() { | 
|  | 109 | return binder::Status::ok(); | 
|  | 110 | } | 
|  | 111 |  | 
|  | 112 | binder::Status BinderIncrementalService::openStorage(const std::string& path, | 
|  | 113 | int32_t* _aidl_return) { | 
|  | 114 | *_aidl_return = mImpl.openStorage(path); | 
|  | 115 | return ok(); | 
|  | 116 | } | 
|  | 117 |  | 
| Yurii Zubrytskyi | da20801 | 2020-04-07 15:35:21 -0700 | [diff] [blame] | 118 | binder::Status BinderIncrementalService::createStorage( | 
| Alex Buynytskyy | 8ef61ae | 2020-05-08 16:18:52 -0700 | [diff] [blame] | 119 | const ::std::string& path, const ::android::content::pm::DataLoaderParamsParcel& params, | 
| Alex Buynytskyy | 07694ed | 2021-01-27 06:58:55 -0800 | [diff] [blame] | 120 | int32_t createMode, int32_t* _aidl_return) { | 
| Yurii Zubrytskyi | f4769e2 | 2021-03-18 20:37:45 -0700 | [diff] [blame] | 121 | *_aidl_return = | 
|  | 122 | mImpl.createStorage(path, const_cast<content::pm::DataLoaderParamsParcel&&>(params), | 
|  | 123 | android::incremental::IncrementalService::CreateOptions( | 
|  | 124 | createMode)); | 
| Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 125 | return ok(); | 
|  | 126 | } | 
|  | 127 |  | 
|  | 128 | binder::Status BinderIncrementalService::createLinkedStorage(const std::string& path, | 
|  | 129 | int32_t otherStorageId, | 
|  | 130 | int32_t createMode, | 
|  | 131 | int32_t* _aidl_return) { | 
|  | 132 | *_aidl_return = | 
|  | 133 | mImpl.createLinkedStorage(path, otherStorageId, | 
|  | 134 | android::incremental::IncrementalService::CreateOptions( | 
|  | 135 | createMode)); | 
|  | 136 | return ok(); | 
|  | 137 | } | 
|  | 138 |  | 
| Alex Buynytskyy | 07694ed | 2021-01-27 06:58:55 -0800 | [diff] [blame] | 139 | binder::Status BinderIncrementalService::startLoading( | 
|  | 140 | int32_t storageId, const ::android::content::pm::DataLoaderParamsParcel& params, | 
|  | 141 | const ::android::sp<::android::content::pm::IDataLoaderStatusListener>& statusListener, | 
|  | 142 | const ::android::os::incremental::StorageHealthCheckParams& healthCheckParams, | 
|  | 143 | const ::android::sp<IStorageHealthListener>& healthListener, | 
|  | 144 | const ::std::vector<::android::os::incremental::PerUidReadTimeouts>& perUidReadTimeouts, | 
|  | 145 | bool* _aidl_return) { | 
|  | 146 | *_aidl_return = | 
|  | 147 | mImpl.startLoading(storageId, const_cast<content::pm::DataLoaderParamsParcel&&>(params), | 
| Yurii Zubrytskyi | f4769e2 | 2021-03-18 20:37:45 -0700 | [diff] [blame] | 148 | statusListener, healthCheckParams, healthListener, | 
|  | 149 | perUidReadTimeouts); | 
| Alex Buynytskyy | 07694ed | 2021-01-27 06:58:55 -0800 | [diff] [blame] | 150 | return ok(); | 
|  | 151 | } | 
|  | 152 |  | 
| Alex Buynytskyy | c144cc4 | 2021-03-31 22:19:42 -0700 | [diff] [blame] | 153 | binder::Status BinderIncrementalService::onInstallationComplete(int32_t storageId) { | 
|  | 154 | mImpl.onInstallationComplete(storageId); | 
|  | 155 | return ok(); | 
|  | 156 | } | 
|  | 157 |  | 
| Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 158 | binder::Status BinderIncrementalService::makeBindMount(int32_t storageId, | 
| Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 159 | const std::string& sourcePath, | 
| Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 160 | const std::string& targetFullPath, | 
|  | 161 | int32_t bindType, int32_t* _aidl_return) { | 
| Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 162 | *_aidl_return = mImpl.bind(storageId, sourcePath, targetFullPath, | 
| Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 163 | android::incremental::IncrementalService::BindKind(bindType)); | 
|  | 164 | return ok(); | 
|  | 165 | } | 
|  | 166 |  | 
|  | 167 | binder::Status BinderIncrementalService::deleteBindMount(int32_t storageId, | 
|  | 168 | const std::string& targetFullPath, | 
|  | 169 | int32_t* _aidl_return) { | 
|  | 170 | *_aidl_return = mImpl.unbind(storageId, targetFullPath); | 
|  | 171 | return ok(); | 
|  | 172 | } | 
|  | 173 |  | 
|  | 174 | binder::Status BinderIncrementalService::deleteStorage(int32_t storageId) { | 
|  | 175 | mImpl.deleteStorage(storageId); | 
|  | 176 | return ok(); | 
|  | 177 | } | 
|  | 178 |  | 
| Alex Buynytskyy | aa8e95e | 2020-12-14 21:50:04 -0800 | [diff] [blame] | 179 | binder::Status BinderIncrementalService::disallowReadLogs(int32_t storageId) { | 
|  | 180 | mImpl.disallowReadLogs(storageId); | 
| Alex Buynytskyy | 3697d9e | 2020-06-06 20:15:58 -0700 | [diff] [blame] | 181 | return ok(); | 
|  | 182 | } | 
|  | 183 |  | 
| Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 184 | binder::Status BinderIncrementalService::makeDirectory(int32_t storageId, const std::string& path, | 
| Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 185 | int32_t* _aidl_return) { | 
| Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 186 | *_aidl_return = mImpl.makeDir(storageId, path); | 
| Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 187 | return ok(); | 
|  | 188 | } | 
|  | 189 |  | 
| Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 190 | static std::tuple<int, incfs::FileId, incfs::NewFileParams> toMakeFileParams( | 
|  | 191 | const android::os::incremental::IncrementalNewFileParams& params) { | 
|  | 192 | incfs::FileId id; | 
|  | 193 | if (params.fileId.empty()) { | 
|  | 194 | if (params.metadata.empty()) { | 
|  | 195 | return {EINVAL, {}, {}}; | 
|  | 196 | } | 
|  | 197 | id = IncrementalService::idFromMetadata(params.metadata); | 
|  | 198 | } else if (params.fileId.size() != sizeof(id)) { | 
|  | 199 | return {EINVAL, {}, {}}; | 
|  | 200 | } else { | 
|  | 201 | memcpy(&id, params.fileId.data(), sizeof(id)); | 
|  | 202 | } | 
|  | 203 | incfs::NewFileParams nfp; | 
|  | 204 | nfp.size = params.size; | 
|  | 205 | nfp.metadata = {(const char*)params.metadata.data(), (IncFsSize)params.metadata.size()}; | 
|  | 206 | if (!params.signature) { | 
| Alex Buynytskyy | f5e605a | 2020-03-13 13:31:12 -0700 | [diff] [blame] | 207 | nfp.signature = {}; | 
| Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 208 | } else { | 
| Yurii Zubrytskyi | da20801 | 2020-04-07 15:35:21 -0700 | [diff] [blame] | 209 | nfp.signature = {(const char*)params.signature->data(), | 
|  | 210 | (IncFsSize)params.signature->size()}; | 
| Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 211 | } | 
|  | 212 | return {0, id, nfp}; | 
| Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 213 | } | 
|  | 214 |  | 
| Alex Buynytskyy | b39d13e | 2020-09-12 16:12:36 -0700 | [diff] [blame] | 215 | static std::span<const uint8_t> toSpan(const ::std::optional<::std::vector<uint8_t>>& content) { | 
|  | 216 | if (!content) { | 
|  | 217 | return {}; | 
|  | 218 | } | 
|  | 219 | return {content->data(), (int)content->size()}; | 
|  | 220 | } | 
|  | 221 |  | 
| Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 222 | binder::Status BinderIncrementalService::makeFile( | 
|  | 223 | int32_t storageId, const std::string& path, | 
| Alex Buynytskyy | b39d13e | 2020-09-12 16:12:36 -0700 | [diff] [blame] | 224 | const ::android::os::incremental::IncrementalNewFileParams& params, | 
|  | 225 | const ::std::optional<::std::vector<uint8_t>>& content, int32_t* _aidl_return) { | 
| Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 226 | auto [err, fileId, nfp] = toMakeFileParams(params); | 
|  | 227 | if (err) { | 
|  | 228 | *_aidl_return = err; | 
|  | 229 | return ok(); | 
|  | 230 | } | 
|  | 231 |  | 
| Alex Buynytskyy | b39d13e | 2020-09-12 16:12:36 -0700 | [diff] [blame] | 232 | *_aidl_return = mImpl.makeFile(storageId, path, 0777, fileId, nfp, toSpan(content)); | 
| Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 233 | return ok(); | 
|  | 234 | } | 
| Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 235 | binder::Status BinderIncrementalService::makeFileFromRange(int32_t storageId, | 
|  | 236 | const std::string& targetPath, | 
|  | 237 | const std::string& sourcePath, | 
| Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 238 | int64_t start, int64_t end, | 
| Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 239 | int32_t* _aidl_return) { | 
|  | 240 | // TODO(b/136132412): implement this | 
|  | 241 | *_aidl_return = ENOSYS; // not implemented | 
|  | 242 | return ok(); | 
|  | 243 | } | 
|  | 244 |  | 
|  | 245 | binder::Status BinderIncrementalService::makeLink(int32_t sourceStorageId, | 
|  | 246 | const std::string& sourcePath, | 
|  | 247 | int32_t destStorageId, | 
|  | 248 | const std::string& destPath, | 
|  | 249 | int32_t* _aidl_return) { | 
|  | 250 | *_aidl_return = mImpl.link(sourceStorageId, sourcePath, destStorageId, destPath); | 
|  | 251 | return ok(); | 
|  | 252 | } | 
|  | 253 |  | 
|  | 254 | binder::Status BinderIncrementalService::unlink(int32_t storageId, const std::string& path, | 
|  | 255 | int32_t* _aidl_return) { | 
|  | 256 | *_aidl_return = mImpl.unlink(storageId, path); | 
|  | 257 | return ok(); | 
|  | 258 | } | 
|  | 259 |  | 
| Alex Buynytskyy | bc0a7e6 | 2020-08-25 12:45:22 -0700 | [diff] [blame] | 260 | binder::Status BinderIncrementalService::isFileFullyLoaded(int32_t storageId, | 
|  | 261 | const std::string& path, | 
|  | 262 | int32_t* _aidl_return) { | 
| Yurii Zubrytskyi | 256a1a4 | 2021-03-18 14:21:54 -0700 | [diff] [blame] | 263 | *_aidl_return = (int)mImpl.isFileFullyLoaded(storageId, path); | 
| Alex Buynytskyy | bc0a7e6 | 2020-08-25 12:45:22 -0700 | [diff] [blame] | 264 | return ok(); | 
|  | 265 | } | 
|  | 266 |  | 
| Alex Buynytskyy | 07694ed | 2021-01-27 06:58:55 -0800 | [diff] [blame] | 267 | binder::Status BinderIncrementalService::isFullyLoaded(int32_t storageId, int32_t* _aidl_return) { | 
| Yurii Zubrytskyi | 256a1a4 | 2021-03-18 14:21:54 -0700 | [diff] [blame] | 268 | *_aidl_return = (int)mImpl.isMountFullyLoaded(storageId); | 
| Alex Buynytskyy | 07694ed | 2021-01-27 06:58:55 -0800 | [diff] [blame] | 269 | return ok(); | 
|  | 270 | } | 
|  | 271 |  | 
| Songchun Fan | 374f765 | 2020-08-20 08:40:29 -0700 | [diff] [blame] | 272 | binder::Status BinderIncrementalService::getLoadingProgress(int32_t storageId, | 
|  | 273 | float* _aidl_return) { | 
| Yurii Zubrytskyi | 883a27a | 2021-03-18 19:30:56 -0700 | [diff] [blame] | 274 | *_aidl_return = mImpl.getLoadingProgress(storageId).getProgress(); | 
| Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 275 | return ok(); | 
|  | 276 | } | 
| Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 277 |  | 
|  | 278 | binder::Status BinderIncrementalService::getMetadataByPath(int32_t storageId, | 
|  | 279 | const std::string& path, | 
|  | 280 | std::vector<uint8_t>* _aidl_return) { | 
| Yurii Zubrytskyi | 629051fd | 2020-04-17 23:13:47 -0700 | [diff] [blame] | 281 | auto metadata = mImpl.getMetadata(storageId, path); | 
|  | 282 | _aidl_return->assign(metadata.begin(), metadata.end()); | 
| Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 283 | return ok(); | 
|  | 284 | } | 
|  | 285 |  | 
|  | 286 | static FileId toFileId(const std::vector<uint8_t>& id) { | 
| Yurii Zubrytskyi | f5a6fb9 | 2021-03-18 19:29:19 -0700 | [diff] [blame] | 287 | FileId fid = {}; | 
|  | 288 | memcpy(&fid, id.data(), std::min(sizeof(fid), id.size())); | 
| Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 289 | return fid; | 
|  | 290 | } | 
|  | 291 |  | 
|  | 292 | binder::Status BinderIncrementalService::getMetadataById(int32_t storageId, | 
|  | 293 | const std::vector<uint8_t>& id, | 
| Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 294 | std::vector<uint8_t>* _aidl_return) { | 
| Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 295 | if (id.size() != sizeof(incfs::FileId)) { | 
|  | 296 | return ok(); | 
|  | 297 | } | 
|  | 298 | auto fid = toFileId(id); | 
|  | 299 | auto metadata = mImpl.getMetadata(storageId, fid); | 
| Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 300 | _aidl_return->assign(metadata.begin(), metadata.end()); | 
|  | 301 | return ok(); | 
|  | 302 | } | 
| Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 303 |  | 
|  | 304 | binder::Status BinderIncrementalService::makeDirectories(int32_t storageId, const std::string& path, | 
|  | 305 | int32_t* _aidl_return) { | 
|  | 306 | *_aidl_return = mImpl.makeDirs(storageId, path); | 
|  | 307 | return ok(); | 
|  | 308 | } | 
|  | 309 |  | 
| Songchun Fan | 0f8b6fe | 2020-02-05 17:41:25 -0800 | [diff] [blame] | 310 | binder::Status BinderIncrementalService::configureNativeBinaries( | 
|  | 311 | int32_t storageId, const std::string& apkFullPath, const std::string& libDirRelativePath, | 
| Songchun Fan | 14f6c3c | 2020-05-21 18:19:07 -0700 | [diff] [blame] | 312 | const std::string& abi, bool extractNativeLibs, bool* _aidl_return) { | 
|  | 313 | *_aidl_return = mImpl.configureNativeBinaries(storageId, apkFullPath, libDirRelativePath, abi, | 
|  | 314 | extractNativeLibs); | 
| Songchun Fan | 0f8b6fe | 2020-02-05 17:41:25 -0800 | [diff] [blame] | 315 | return ok(); | 
|  | 316 | } | 
|  | 317 |  | 
| Yurii Zubrytskyi | da20801 | 2020-04-07 15:35:21 -0700 | [diff] [blame] | 318 | binder::Status BinderIncrementalService::waitForNativeBinariesExtraction(int storageId, | 
|  | 319 | bool* _aidl_return) { | 
|  | 320 | *_aidl_return = mImpl.waitForNativeBinariesExtraction(storageId); | 
|  | 321 | return ok(); | 
|  | 322 | } | 
|  | 323 |  | 
| Songchun Fan | a709859 | 2020-09-03 11:45:53 -0700 | [diff] [blame] | 324 | binder::Status BinderIncrementalService::registerLoadingProgressListener( | 
|  | 325 | int32_t storageId, | 
|  | 326 | const ::android::sp<::android::os::incremental::IStorageLoadingProgressListener>& | 
|  | 327 | progressListener, | 
|  | 328 | bool* _aidl_return) { | 
|  | 329 | *_aidl_return = mImpl.registerLoadingProgressListener(storageId, progressListener); | 
|  | 330 | return ok(); | 
|  | 331 | } | 
|  | 332 | binder::Status BinderIncrementalService::unregisterLoadingProgressListener(int32_t storageId, | 
|  | 333 | bool* _aidl_return) { | 
|  | 334 | *_aidl_return = mImpl.unregisterLoadingProgressListener(storageId); | 
|  | 335 | return ok(); | 
|  | 336 | } | 
|  | 337 |  | 
| Songchun Fan | 1b76ccf | 2021-02-24 22:25:59 +0000 | [diff] [blame] | 338 | binder::Status BinderIncrementalService::getMetrics(int32_t storageId, | 
|  | 339 | android::os::PersistableBundle* _aidl_return) { | 
|  | 340 | mImpl.getMetrics(storageId, _aidl_return); | 
|  | 341 | return ok(); | 
|  | 342 | } | 
|  | 343 |  | 
| Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 344 | } // namespace android::os::incremental | 
|  | 345 |  | 
| Yurii Zubrytskyi | 8632140 | 2020-04-09 19:22:30 -0700 | [diff] [blame] | 346 | jlong Incremental_IncrementalService_Start(JNIEnv* env) { | 
|  | 347 | return (jlong)android::os::incremental::BinderIncrementalService::start(env); | 
| Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 348 | } | 
|  | 349 | void Incremental_IncrementalService_OnSystemReady(jlong self) { | 
|  | 350 | if (self) { | 
|  | 351 | ((android::os::incremental::BinderIncrementalService*)self)->onSystemReady(); | 
|  | 352 | } | 
|  | 353 | } | 
| Alex Buynytskyy | 18b07a4 | 2020-02-03 20:06:00 -0800 | [diff] [blame] | 354 | void Incremental_IncrementalService_OnDump(jlong self, jint fd) { | 
|  | 355 | if (self) { | 
|  | 356 | ((android::os::incremental::BinderIncrementalService*)self)->dump(fd, {}); | 
|  | 357 | } else { | 
|  | 358 | dprintf(fd, "BinderIncrementalService is stopped."); | 
|  | 359 | } | 
|  | 360 | } |