Jeff Sharkey | 068c6be | 2017-09-06 13:47:40 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 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 | #ifndef _VOLD_NATIVE_SERVICE_H_ |
| 18 | #define _VOLD_NATIVE_SERVICE_H_ |
| 19 | |
Jeff Sharkey | 11c2d38 | 2017-09-11 10:32:01 -0600 | [diff] [blame] | 20 | #include <android-base/unique_fd.h> |
Jeff Sharkey | 068c6be | 2017-09-06 13:47:40 -0600 | [diff] [blame] | 21 | #include <binder/BinderService.h> |
| 22 | |
| 23 | #include "android/os/BnVold.h" |
| 24 | |
| 25 | namespace android { |
| 26 | namespace vold { |
| 27 | |
| 28 | class VoldNativeService : public BinderService<VoldNativeService>, public os::BnVold { |
Paul Crowley | edf7a4e | 2018-09-18 15:14:18 -0700 | [diff] [blame] | 29 | public: |
Jeff Sharkey | 068c6be | 2017-09-06 13:47:40 -0600 | [diff] [blame] | 30 | static status_t start(); |
| 31 | static char const* getServiceName() { return "vold"; } |
Paul Crowley | edf7a4e | 2018-09-18 15:14:18 -0700 | [diff] [blame] | 32 | virtual status_t dump(int fd, const Vector<String16>& args) override; |
Jeff Sharkey | 068c6be | 2017-09-06 13:47:40 -0600 | [diff] [blame] | 33 | |
Jeff Sharkey | 814e9d3 | 2017-09-13 11:49:44 -0600 | [diff] [blame] | 34 | binder::Status setListener(const android::sp<android::os::IVoldListener>& listener); |
| 35 | |
Jeff Sharkey | cbe69fc | 2017-09-15 16:50:28 -0600 | [diff] [blame] | 36 | binder::Status monitor(); |
Jeff Sharkey | 068c6be | 2017-09-06 13:47:40 -0600 | [diff] [blame] | 37 | binder::Status reset(); |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 38 | binder::Status shutdown(); |
Martijn Coenen | 23c0445 | 2020-04-29 07:49:41 +0200 | [diff] [blame] | 39 | binder::Status abortFuse(); |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 40 | |
| 41 | binder::Status onUserAdded(int32_t userId, int32_t userSerial); |
| 42 | binder::Status onUserRemoved(int32_t userId); |
Sudheer Shanka | 5fceb48 | 2019-04-29 10:46:35 -0700 | [diff] [blame] | 43 | binder::Status onUserStarted(int32_t userId); |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 44 | binder::Status onUserStopped(int32_t userId); |
| 45 | |
Sudheer Shanka | d484aa9 | 2018-07-31 10:07:34 -0700 | [diff] [blame] | 46 | binder::Status addAppIds(const std::vector<std::string>& packageNames, |
Paul Crowley | edf7a4e | 2018-09-18 15:14:18 -0700 | [diff] [blame] | 47 | const std::vector<int32_t>& appIds); |
Sudheer Shanka | d484aa9 | 2018-07-31 10:07:34 -0700 | [diff] [blame] | 48 | binder::Status addSandboxIds(const std::vector<int32_t>& appIds, |
Paul Crowley | edf7a4e | 2018-09-18 15:14:18 -0700 | [diff] [blame] | 49 | const std::vector<std::string>& sandboxIds); |
Sudheer Shanka | d484aa9 | 2018-07-31 10:07:34 -0700 | [diff] [blame] | 50 | |
Jeff Sharkey | 401b260 | 2017-12-14 22:15:20 -0700 | [diff] [blame] | 51 | binder::Status onSecureKeyguardStateChanged(bool isShowing); |
| 52 | |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 53 | binder::Status partition(const std::string& diskId, int32_t partitionType, int32_t ratio); |
Jeff Sharkey | 3ce1825 | 2017-10-24 11:08:45 -0600 | [diff] [blame] | 54 | binder::Status forgetPartition(const std::string& partGuid, const std::string& fsUuid); |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 55 | |
Zim | 3623a21 | 2019-07-19 16:46:53 +0100 | [diff] [blame] | 56 | binder::Status mount(const std::string& volId, int32_t mountFlags, int32_t mountUserId, |
Zim | 5048b4b | 2019-11-19 09:16:03 +0000 | [diff] [blame] | 57 | const android::sp<android::os::IVoldMountCallback>& callback); |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 58 | binder::Status unmount(const std::string& volId); |
| 59 | binder::Status format(const std::string& volId, const std::string& fsType); |
Jeff Sharkey | 52f7a91 | 2017-09-15 12:57:44 -0600 | [diff] [blame] | 60 | binder::Status benchmark(const std::string& volId, |
Paul Crowley | edf7a4e | 2018-09-18 15:14:18 -0700 | [diff] [blame] | 61 | const android::sp<android::os::IVoldTaskListener>& listener); |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 62 | |
Jeff Sharkey | 52f7a91 | 2017-09-15 12:57:44 -0600 | [diff] [blame] | 63 | binder::Status moveStorage(const std::string& fromVolId, const std::string& toVolId, |
Paul Crowley | edf7a4e | 2018-09-18 15:14:18 -0700 | [diff] [blame] | 64 | const android::sp<android::os::IVoldTaskListener>& listener); |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 65 | |
| 66 | binder::Status remountUid(int32_t uid, int32_t remountMode); |
Ricky Wai | 6b12257 | 2020-02-28 16:30:47 +0000 | [diff] [blame] | 67 | binder::Status remountAppStorageDirs(int uid, int pid, |
| 68 | const std::vector<std::string>& packageNames); |
Ricky Wai | a2ca11e | 2021-01-15 14:03:23 +0000 | [diff] [blame] | 69 | binder::Status unmountAppStorageDirs(int uid, int pid, |
| 70 | const std::vector<std::string>& packageNames); |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 71 | |
Ricky Wai | bbfb6ea | 2020-12-03 15:32:52 +0000 | [diff] [blame] | 72 | binder::Status ensureAppDirsCreated(const std::vector<std::string>& paths, int32_t appUid); |
Martijn Coenen | 8a68a07 | 2020-02-12 15:29:02 +0100 | [diff] [blame] | 73 | binder::Status setupAppDir(const std::string& path, int32_t appUid); |
Martijn Coenen | 816f4d9 | 2020-02-18 15:06:37 +0100 | [diff] [blame] | 74 | binder::Status fixupAppDir(const std::string& path, int32_t appUid); |
Jeff Sharkey | 11c2d38 | 2017-09-11 10:32:01 -0600 | [diff] [blame] | 75 | |
Eric Biggers | 7e79a43 | 2022-03-01 21:19:18 +0000 | [diff] [blame] | 76 | binder::Status createObb(const std::string& sourcePath, int32_t ownerGid, |
| 77 | std::string* _aidl_return); |
Jeff Sharkey | 11c2d38 | 2017-09-11 10:32:01 -0600 | [diff] [blame] | 78 | binder::Status destroyObb(const std::string& volId); |
| 79 | |
Risan | 8c9f332 | 2018-10-29 08:52:56 +0900 | [diff] [blame] | 80 | binder::Status createStubVolume(const std::string& sourcePath, const std::string& mountPath, |
| 81 | const std::string& fsType, const std::string& fsUuid, |
Risan | 82e90de | 2020-02-04 16:07:21 +0900 | [diff] [blame] | 82 | const std::string& fsLabel, int32_t flags, |
| 83 | std::string* _aidl_return); |
Risan | 8c9f332 | 2018-10-29 08:52:56 +0900 | [diff] [blame] | 84 | binder::Status destroyStubVolume(const std::string& volId); |
| 85 | |
Jeff Sharkey | 52f7a91 | 2017-09-15 12:57:44 -0600 | [diff] [blame] | 86 | binder::Status fstrim(int32_t fstrimFlags, |
Paul Crowley | edf7a4e | 2018-09-18 15:14:18 -0700 | [diff] [blame] | 87 | const android::sp<android::os::IVoldTaskListener>& listener); |
Daeho Jeong | 999fceb | 2022-01-04 11:37:39 -0800 | [diff] [blame] | 88 | binder::Status runIdleMaint(bool needGC, |
| 89 | const android::sp<android::os::IVoldTaskListener>& listener); |
Paul Crowley | edf7a4e | 2018-09-18 15:14:18 -0700 | [diff] [blame] | 90 | binder::Status abortIdleMaint(const android::sp<android::os::IVoldTaskListener>& listener); |
Daeho Jeong | 999fceb | 2022-01-04 11:37:39 -0800 | [diff] [blame] | 91 | binder::Status getStorageLifeTime(int32_t* _aidl_return); |
| 92 | binder::Status setGCUrgentPace(int32_t neededSegments, int32_t minSegmentThreshold, |
Daeho Jeong | a26a56a | 2022-06-23 16:19:58 -0700 | [diff] [blame^] | 93 | float dirtyReclaimRate, float reclaimWeight, int32_t gcPeriod, |
| 94 | int32_t minGCSleepTime); |
Daeho Jeong | 999fceb | 2022-01-04 11:37:39 -0800 | [diff] [blame] | 95 | binder::Status refreshLatestWrite(); |
| 96 | binder::Status getWriteAmount(int32_t* _aidl_return); |
Jeff Sharkey | 11c2d38 | 2017-09-11 10:32:01 -0600 | [diff] [blame] | 97 | |
Risan | 8f6198d | 2018-10-26 20:56:45 -0600 | [diff] [blame] | 98 | binder::Status mountAppFuse(int32_t uid, int32_t mountId, |
Paul Crowley | edf7a4e | 2018-09-18 15:14:18 -0700 | [diff] [blame] | 99 | android::base::unique_fd* _aidl_return); |
Risan | 8f6198d | 2018-10-26 20:56:45 -0600 | [diff] [blame] | 100 | binder::Status unmountAppFuse(int32_t uid, int32_t mountId); |
| 101 | binder::Status openAppFuseFile(int32_t uid, int32_t mountId, int32_t fileId, int32_t flags, |
| 102 | android::base::unique_fd* _aidl_return); |
Jeff Sharkey | 83b559c | 2017-09-12 16:30:52 -0600 | [diff] [blame] | 103 | |
Jeff Sharkey | 83b559c | 2017-09-12 16:30:52 -0600 | [diff] [blame] | 104 | binder::Status fbeEnable(); |
| 105 | |
Jeff Sharkey | 83b559c | 2017-09-12 16:30:52 -0600 | [diff] [blame] | 106 | binder::Status initUser0(); |
Paul Lawrence | 236e5e8 | 2019-06-25 14:44:33 -0700 | [diff] [blame] | 107 | binder::Status mountFstab(const std::string& blkDevice, const std::string& mountPoint); |
Jaegeuk Kim | 0c52c71 | 2020-12-15 09:00:49 -0800 | [diff] [blame] | 108 | binder::Status encryptFstab(const std::string& blkDevice, const std::string& mountPoint, |
| 109 | bool shouldFormat, const std::string& fsType); |
Jeff Sharkey | 83b559c | 2017-09-12 16:30:52 -0600 | [diff] [blame] | 110 | |
Seth Moore | 5a43d61 | 2021-01-19 17:51:51 +0000 | [diff] [blame] | 111 | binder::Status setStorageBindingSeed(const std::vector<uint8_t>& seed); |
| 112 | |
Jeff Sharkey | 83b559c | 2017-09-12 16:30:52 -0600 | [diff] [blame] | 113 | binder::Status createUserKey(int32_t userId, int32_t userSerial, bool ephemeral); |
| 114 | binder::Status destroyUserKey(int32_t userId); |
| 115 | |
Eric Biggers | 90a3052 | 2022-01-25 19:21:37 +0000 | [diff] [blame] | 116 | binder::Status addUserKeyAuth(int32_t userId, int32_t userSerial, const std::string& secret); |
| 117 | binder::Status clearUserKeyAuth(int32_t userId, int32_t userSerial, const std::string& secret); |
Jeff Sharkey | 83b559c | 2017-09-12 16:30:52 -0600 | [diff] [blame] | 118 | binder::Status fixateNewestUserKeyAuth(int32_t userId); |
| 119 | |
Eric Biggers | 1799deb | 2021-04-06 12:02:56 -0700 | [diff] [blame] | 120 | binder::Status getUnlockedUsers(std::vector<int>* _aidl_return); |
Eric Biggers | 90a3052 | 2022-01-25 19:21:37 +0000 | [diff] [blame] | 121 | binder::Status unlockUserKey(int32_t userId, int32_t userSerial, const std::string& secret); |
Jeff Sharkey | 83b559c | 2017-09-12 16:30:52 -0600 | [diff] [blame] | 122 | binder::Status lockUserKey(int32_t userId); |
| 123 | |
Jooyung Han | 4fcb707 | 2020-01-23 13:23:26 +0900 | [diff] [blame] | 124 | binder::Status prepareUserStorage(const std::optional<std::string>& uuid, int32_t userId, |
Paul Crowley | edf7a4e | 2018-09-18 15:14:18 -0700 | [diff] [blame] | 125 | int32_t userSerial, int32_t flags); |
Jooyung Han | 4fcb707 | 2020-01-23 13:23:26 +0900 | [diff] [blame] | 126 | binder::Status destroyUserStorage(const std::optional<std::string>& uuid, int32_t userId, |
Paul Crowley | edf7a4e | 2018-09-18 15:14:18 -0700 | [diff] [blame] | 127 | int32_t flags); |
Sudheer Shanka | c756209 | 2018-08-24 10:20:56 -0700 | [diff] [blame] | 128 | |
Sudheer Shanka | fa6a174 | 2018-10-04 16:26:22 -0700 | [diff] [blame] | 129 | binder::Status prepareSandboxForApp(const std::string& packageName, int32_t appId, |
| 130 | const std::string& sandboxId, int32_t userId); |
Sudheer Shanka | 69bc40f | 2018-10-25 11:06:55 -0700 | [diff] [blame] | 131 | binder::Status destroySandboxForApp(const std::string& packageName, |
Sudheer Shanka | fa6a174 | 2018-10-04 16:26:22 -0700 | [diff] [blame] | 132 | const std::string& sandboxId, int32_t userId); |
Daniel Rosenberg | 4f68471 | 2018-08-28 01:58:49 -0700 | [diff] [blame] | 133 | |
Daniel Rosenberg | e334aab | 2018-10-10 18:52:04 -0700 | [diff] [blame] | 134 | binder::Status startCheckpoint(int32_t retry); |
Daniel Rosenberg | 4f68471 | 2018-08-28 01:58:49 -0700 | [diff] [blame] | 135 | binder::Status needsCheckpoint(bool* _aidl_return); |
Daniel Rosenberg | d399249 | 2018-10-02 17:40:44 -0700 | [diff] [blame] | 136 | binder::Status needsRollback(bool* _aidl_return); |
David Anderson | 23850d3 | 2020-06-10 23:51:17 -0700 | [diff] [blame] | 137 | binder::Status isCheckpointing(bool* _aidl_return); |
Daniel Rosenberg | e334aab | 2018-10-10 18:52:04 -0700 | [diff] [blame] | 138 | binder::Status commitChanges(); |
| 139 | binder::Status prepareCheckpoint(); |
| 140 | binder::Status restoreCheckpoint(const std::string& mountPoint); |
Daniel Rosenberg | dda5981 | 2019-03-06 17:45:17 -0800 | [diff] [blame] | 141 | binder::Status restoreCheckpointPart(const std::string& mountPoint, int count); |
Daniel Rosenberg | e334aab | 2018-10-10 18:52:04 -0700 | [diff] [blame] | 142 | binder::Status markBootAttempt(); |
Daniel Rosenberg | a59e439 | 2019-03-20 17:02:47 -0700 | [diff] [blame] | 143 | binder::Status abortChanges(const std::string& message, bool retry); |
Daniel Rosenberg | 9b667fb | 2019-01-22 17:27:25 -0800 | [diff] [blame] | 144 | binder::Status supportsCheckpoint(bool* _aidl_return); |
Paul Lawrence | c5c79c5 | 2019-03-18 13:36:40 -0700 | [diff] [blame] | 145 | binder::Status supportsBlockCheckpoint(bool* _aidl_return); |
| 146 | binder::Status supportsFileCheckpoint(bool* _aidl_return); |
Nikita Ioffe | a5798fc | 2019-10-11 16:38:21 +0100 | [diff] [blame] | 147 | binder::Status resetCheckpoint(); |
Songchun Fan | ab55cec | 2019-12-02 10:50:12 -0800 | [diff] [blame] | 148 | |
Martijn Coenen | eed957f | 2020-11-12 10:59:13 +0100 | [diff] [blame] | 149 | binder::Status earlyBootEnded(); |
| 150 | |
Yurii Zubrytskyi | 3497cb5 | 2020-01-10 11:54:06 -0800 | [diff] [blame] | 151 | binder::Status incFsEnabled(bool* _aidl_return) override; |
Songchun Fan | ab55cec | 2019-12-02 10:50:12 -0800 | [diff] [blame] | 152 | binder::Status mountIncFs( |
Yurii Zubrytskyi | 3497cb5 | 2020-01-10 11:54:06 -0800 | [diff] [blame] | 153 | const std::string& backingPath, const std::string& targetDir, int32_t flags, |
Songchun Fan | 046e68a | 2021-04-27 12:46:02 -0700 | [diff] [blame] | 154 | const std::string& sysfsName, |
Songchun Fan | ab55cec | 2019-12-02 10:50:12 -0800 | [diff] [blame] | 155 | ::android::os::incremental::IncrementalFileSystemControlParcel* _aidl_return) override; |
| 156 | binder::Status unmountIncFs(const std::string& dir) override; |
Alex Buynytskyy | 91e0bf4 | 2020-03-31 14:46:25 -0700 | [diff] [blame] | 157 | binder::Status setIncFsMountOptions( |
| 158 | const ::android::os::incremental::IncrementalFileSystemControlParcel& control, |
Songchun Fan | 0e53c1c | 2021-05-10 16:19:38 -0700 | [diff] [blame] | 159 | bool enableReadLogs, bool enableReadTimeouts, const std::string& sysfsName) override; |
Songchun Fan | ab55cec | 2019-12-02 10:50:12 -0800 | [diff] [blame] | 160 | binder::Status bindMount(const std::string& sourceDir, const std::string& targetDir) override; |
Yo Chiang | 0af25a3 | 2020-10-07 14:20:00 +0800 | [diff] [blame] | 161 | |
| 162 | binder::Status destroyDsuMetadataKey(const std::string& dsuSlot) override; |
Jeff Sharkey | 068c6be | 2017-09-06 13:47:40 -0600 | [diff] [blame] | 163 | }; |
| 164 | |
| 165 | } // namespace vold |
| 166 | } // namespace android |
| 167 | |
| 168 | #endif // _VOLD_NATIVE_SERVICE_H_ |