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 | |
| 19 | #include <binder/BinderService.h> |
| 20 | #include <binder/IServiceManager.h> |
Songchun Fan | 1b76ccf | 2021-02-24 22:25:59 +0000 | [diff] [blame] | 21 | #include <binder/PersistableBundle.h> |
Yurii Zubrytskyi | 8632140 | 2020-04-09 19:22:30 -0700 | [diff] [blame] | 22 | #include <jni.h> |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 23 | |
| 24 | #include "IncrementalService.h" |
Alex Buynytskyy | 716588d | 2020-02-04 13:42:59 -0800 | [diff] [blame] | 25 | #include "android/os/incremental/BnIncrementalService.h" |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 26 | #include "incremental_service.h" |
| 27 | |
| 28 | namespace android::os::incremental { |
| 29 | |
Alex Buynytskyy | 716588d | 2020-02-04 13:42:59 -0800 | [diff] [blame] | 30 | class BinderIncrementalService : public BnIncrementalService, |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 31 | public BinderService<BinderIncrementalService> { |
| 32 | public: |
Yurii Zubrytskyi | 8632140 | 2020-04-09 19:22:30 -0700 | [diff] [blame] | 33 | BinderIncrementalService(const sp<IServiceManager>& sm, JNIEnv* env); |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 34 | |
Yurii Zubrytskyi | 8632140 | 2020-04-09 19:22:30 -0700 | [diff] [blame] | 35 | static BinderIncrementalService* start(JNIEnv* env); |
Songchun Fan | d1c62a4 | 2020-03-05 09:16:08 -0800 | [diff] [blame] | 36 | static const char16_t* getServiceName() { return u"incremental"; } |
Songchun Fan | 0f8b6fe | 2020-02-05 17:41:25 -0800 | [diff] [blame] | 37 | status_t dump(int fd, const Vector<String16>& args) final; |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 38 | |
| 39 | void onSystemReady(); |
| 40 | void onInvalidStorage(int mountId); |
| 41 | |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 42 | binder::Status openStorage(const std::string& path, int32_t* _aidl_return) final; |
Alex Buynytskyy | 07694ed | 2021-01-27 06:58:55 -0800 | [diff] [blame] | 43 | binder::Status createStorage(const ::std::string& path, |
| 44 | const ::android::content::pm::DataLoaderParamsParcel& params, |
| 45 | int32_t createMode, int32_t* _aidl_return) final; |
| 46 | binder::Status createLinkedStorage(const std::string& path, int32_t otherStorageId, |
| 47 | int32_t createMode, int32_t* _aidl_return) final; |
| 48 | binder::Status startLoading( |
| 49 | int32_t storageId, const ::android::content::pm::DataLoaderParamsParcel& params, |
Alex Buynytskyy | 8ef61ae | 2020-05-08 16:18:52 -0700 | [diff] [blame] | 50 | const ::android::sp<::android::content::pm::IDataLoaderStatusListener>& statusListener, |
| 51 | const ::android::os::incremental::StorageHealthCheckParams& healthCheckParams, |
| 52 | const ::android::sp<IStorageHealthListener>& healthListener, |
Alex Buynytskyy | aa8e95e | 2020-12-14 21:50:04 -0800 | [diff] [blame] | 53 | const ::std::vector<::android::os::incremental::PerUidReadTimeouts>& perUidReadTimeouts, |
Alex Buynytskyy | 07694ed | 2021-01-27 06:58:55 -0800 | [diff] [blame] | 54 | bool* _aidl_return) final; |
Alex Buynytskyy | c144cc4 | 2021-03-31 22:19:42 -0700 | [diff] [blame] | 55 | binder::Status onInstallationComplete(int32_t storageId) final; |
| 56 | |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 57 | binder::Status makeBindMount(int32_t storageId, const std::string& sourcePath, |
| 58 | const std::string& targetFullPath, int32_t bindType, |
| 59 | int32_t* _aidl_return) final; |
| 60 | binder::Status deleteBindMount(int32_t storageId, const std::string& targetFullPath, |
| 61 | int32_t* _aidl_return) final; |
| 62 | binder::Status makeDirectory(int32_t storageId, const std::string& path, |
| 63 | int32_t* _aidl_return) final; |
| 64 | binder::Status makeDirectories(int32_t storageId, const std::string& path, |
| 65 | int32_t* _aidl_return) final; |
William Loh | b84e5aa | 2023-02-14 04:45:54 +0000 | [diff] [blame] | 66 | binder::Status makeFile(int32_t storageId, const std::string& path, int32_t mode, |
Alex Buynytskyy | b39d13e | 2020-09-12 16:12:36 -0700 | [diff] [blame] | 67 | const IncrementalNewFileParams& params, |
| 68 | const ::std::optional<::std::vector<uint8_t>>& content, |
| 69 | int32_t* _aidl_return) final; |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 70 | binder::Status makeFileFromRange(int32_t storageId, const std::string& targetPath, |
| 71 | const std::string& sourcePath, int64_t start, int64_t end, |
| 72 | int32_t* _aidl_return) final; |
| 73 | binder::Status makeLink(int32_t sourceStorageId, const std::string& sourcePath, |
| 74 | int32_t destStorageId, const std::string& destPath, |
| 75 | int32_t* _aidl_return) final; |
| 76 | binder::Status unlink(int32_t storageId, const std::string& path, int32_t* _aidl_return) final; |
Alex Buynytskyy | bc0a7e6 | 2020-08-25 12:45:22 -0700 | [diff] [blame] | 77 | binder::Status isFileFullyLoaded(int32_t storageId, const std::string& path, |
| 78 | int32_t* _aidl_return) final; |
Alex Buynytskyy | 07694ed | 2021-01-27 06:58:55 -0800 | [diff] [blame] | 79 | binder::Status isFullyLoaded(int32_t storageId, int32_t* _aidl_return) final; |
Songchun Fan | 374f765 | 2020-08-20 08:40:29 -0700 | [diff] [blame] | 80 | binder::Status getLoadingProgress(int32_t storageId, float* _aidl_return) final; |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 81 | binder::Status getMetadataByPath(int32_t storageId, const std::string& path, |
| 82 | std::vector<uint8_t>* _aidl_return) final; |
| 83 | binder::Status getMetadataById(int32_t storageId, const std::vector<uint8_t>& id, |
| 84 | std::vector<uint8_t>* _aidl_return) final; |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 85 | binder::Status deleteStorage(int32_t storageId) final; |
Alex Buynytskyy | aa8e95e | 2020-12-14 21:50:04 -0800 | [diff] [blame] | 86 | binder::Status disallowReadLogs(int32_t storageId) final; |
Songchun Fan | 0f8b6fe | 2020-02-05 17:41:25 -0800 | [diff] [blame] | 87 | binder::Status configureNativeBinaries(int32_t storageId, const std::string& apkFullPath, |
| 88 | const std::string& libDirRelativePath, |
Songchun Fan | 14f6c3c | 2020-05-21 18:19:07 -0700 | [diff] [blame] | 89 | const std::string& abi, bool extractNativeLibs, |
| 90 | bool* _aidl_return) final; |
Yurii Zubrytskyi | da20801 | 2020-04-07 15:35:21 -0700 | [diff] [blame] | 91 | binder::Status waitForNativeBinariesExtraction(int storageId, bool* _aidl_return) final; |
Songchun Fan | a709859 | 2020-09-03 11:45:53 -0700 | [diff] [blame] | 92 | binder::Status registerLoadingProgressListener( |
| 93 | int32_t storageId, |
| 94 | const ::android::sp<::android::os::incremental::IStorageLoadingProgressListener>& |
| 95 | progressListener, |
| 96 | bool* _aidl_return) final; |
| 97 | binder::Status unregisterLoadingProgressListener(int32_t storageId, bool* _aidl_return) final; |
Songchun Fan | 1b76ccf | 2021-02-24 22:25:59 +0000 | [diff] [blame] | 98 | binder::Status getMetrics(int32_t storageId, |
| 99 | android::os::PersistableBundle* _aidl_return) final; |
Songchun Fan | 3c82a30 | 2019-11-29 14:23:45 -0800 | [diff] [blame] | 100 | |
| 101 | private: |
| 102 | android::incremental::IncrementalService mImpl; |
| 103 | }; |
| 104 | |
| 105 | } // namespace android::os::incremental |