blob: ac5d8526a61fd8a0653062653fe27b62dbcdc548 [file] [log] [blame]
Jeff Sharkey068c6be2017-09-06 13:47:40 -06001/*
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 Sharkey11c2d382017-09-11 10:32:01 -060020#include <android-base/unique_fd.h>
Jeff Sharkey068c6be2017-09-06 13:47:40 -060021#include <binder/BinderService.h>
22
23#include "android/os/BnVold.h"
24
25namespace android {
26namespace vold {
27
28class VoldNativeService : public BinderService<VoldNativeService>, public os::BnVold {
Paul Crowleyedf7a4e2018-09-18 15:14:18 -070029 public:
Jeff Sharkey068c6be2017-09-06 13:47:40 -060030 static status_t start();
31 static char const* getServiceName() { return "vold"; }
Paul Crowleyedf7a4e2018-09-18 15:14:18 -070032 virtual status_t dump(int fd, const Vector<String16>& args) override;
Jeff Sharkey068c6be2017-09-06 13:47:40 -060033
Jeff Sharkey814e9d32017-09-13 11:49:44 -060034 binder::Status setListener(const android::sp<android::os::IVoldListener>& listener);
35
Jeff Sharkeycbe69fc2017-09-15 16:50:28 -060036 binder::Status monitor();
Jeff Sharkey068c6be2017-09-06 13:47:40 -060037 binder::Status reset();
Jeff Sharkey9462bdd2017-09-07 15:27:28 -060038 binder::Status shutdown();
Martijn Coenen23c04452020-04-29 07:49:41 +020039 binder::Status abortFuse();
Jeff Sharkey9462bdd2017-09-07 15:27:28 -060040
41 binder::Status onUserAdded(int32_t userId, int32_t userSerial);
42 binder::Status onUserRemoved(int32_t userId);
Sudheer Shanka5fceb482019-04-29 10:46:35 -070043 binder::Status onUserStarted(int32_t userId);
Jeff Sharkey9462bdd2017-09-07 15:27:28 -060044 binder::Status onUserStopped(int32_t userId);
45
Sudheer Shankad484aa92018-07-31 10:07:34 -070046 binder::Status addAppIds(const std::vector<std::string>& packageNames,
Paul Crowleyedf7a4e2018-09-18 15:14:18 -070047 const std::vector<int32_t>& appIds);
Sudheer Shankad484aa92018-07-31 10:07:34 -070048 binder::Status addSandboxIds(const std::vector<int32_t>& appIds,
Paul Crowleyedf7a4e2018-09-18 15:14:18 -070049 const std::vector<std::string>& sandboxIds);
Sudheer Shankad484aa92018-07-31 10:07:34 -070050
Jeff Sharkey401b2602017-12-14 22:15:20 -070051 binder::Status onSecureKeyguardStateChanged(bool isShowing);
52
Jeff Sharkey9462bdd2017-09-07 15:27:28 -060053 binder::Status partition(const std::string& diskId, int32_t partitionType, int32_t ratio);
Jeff Sharkey3ce18252017-10-24 11:08:45 -060054 binder::Status forgetPartition(const std::string& partGuid, const std::string& fsUuid);
Jeff Sharkey9462bdd2017-09-07 15:27:28 -060055
Zim3623a212019-07-19 16:46:53 +010056 binder::Status mount(const std::string& volId, int32_t mountFlags, int32_t mountUserId,
Zim5048b4b2019-11-19 09:16:03 +000057 const android::sp<android::os::IVoldMountCallback>& callback);
Jeff Sharkey9462bdd2017-09-07 15:27:28 -060058 binder::Status unmount(const std::string& volId);
59 binder::Status format(const std::string& volId, const std::string& fsType);
Jeff Sharkey52f7a912017-09-15 12:57:44 -060060 binder::Status benchmark(const std::string& volId,
Paul Crowleyedf7a4e2018-09-18 15:14:18 -070061 const android::sp<android::os::IVoldTaskListener>& listener);
Jeff Sharkey9462bdd2017-09-07 15:27:28 -060062
Jeff Sharkey52f7a912017-09-15 12:57:44 -060063 binder::Status moveStorage(const std::string& fromVolId, const std::string& toVolId,
Paul Crowleyedf7a4e2018-09-18 15:14:18 -070064 const android::sp<android::os::IVoldTaskListener>& listener);
Jeff Sharkey9462bdd2017-09-07 15:27:28 -060065
66 binder::Status remountUid(int32_t uid, int32_t remountMode);
Ricky Wai6b122572020-02-28 16:30:47 +000067 binder::Status remountAppStorageDirs(int uid, int pid,
68 const std::vector<std::string>& packageNames);
Ricky Waia2ca11e2021-01-15 14:03:23 +000069 binder::Status unmountAppStorageDirs(int uid, int pid,
70 const std::vector<std::string>& packageNames);
Jeff Sharkey9462bdd2017-09-07 15:27:28 -060071
Ricky Waibbfb6ea2020-12-03 15:32:52 +000072 binder::Status ensureAppDirsCreated(const std::vector<std::string>& paths, int32_t appUid);
Martijn Coenen8a68a072020-02-12 15:29:02 +010073 binder::Status setupAppDir(const std::string& path, int32_t appUid);
Martijn Coenen816f4d92020-02-18 15:06:37 +010074 binder::Status fixupAppDir(const std::string& path, int32_t appUid);
Jeff Sharkey11c2d382017-09-11 10:32:01 -060075
Eric Biggers7e79a432022-03-01 21:19:18 +000076 binder::Status createObb(const std::string& sourcePath, int32_t ownerGid,
77 std::string* _aidl_return);
Jeff Sharkey11c2d382017-09-11 10:32:01 -060078 binder::Status destroyObb(const std::string& volId);
79
Risan8c9f3322018-10-29 08:52:56 +090080 binder::Status createStubVolume(const std::string& sourcePath, const std::string& mountPath,
81 const std::string& fsType, const std::string& fsUuid,
Risan82e90de2020-02-04 16:07:21 +090082 const std::string& fsLabel, int32_t flags,
83 std::string* _aidl_return);
Risan8c9f3322018-10-29 08:52:56 +090084 binder::Status destroyStubVolume(const std::string& volId);
85
Jeff Sharkey52f7a912017-09-15 12:57:44 -060086 binder::Status fstrim(int32_t fstrimFlags,
Paul Crowleyedf7a4e2018-09-18 15:14:18 -070087 const android::sp<android::os::IVoldTaskListener>& listener);
Daeho Jeong999fceb2022-01-04 11:37:39 -080088 binder::Status runIdleMaint(bool needGC,
89 const android::sp<android::os::IVoldTaskListener>& listener);
Paul Crowleyedf7a4e2018-09-18 15:14:18 -070090 binder::Status abortIdleMaint(const android::sp<android::os::IVoldTaskListener>& listener);
Daeho Jeong999fceb2022-01-04 11:37:39 -080091 binder::Status getStorageLifeTime(int32_t* _aidl_return);
92 binder::Status setGCUrgentPace(int32_t neededSegments, int32_t minSegmentThreshold,
Daeho Jeonga26a56a2022-06-23 16:19:58 -070093 float dirtyReclaimRate, float reclaimWeight, int32_t gcPeriod,
Daeho Jeong3f8e8552022-06-24 14:50:47 -070094 int32_t minGCSleepTime, int32_t targetDirtyRatio);
Daeho Jeong999fceb2022-01-04 11:37:39 -080095 binder::Status refreshLatestWrite();
96 binder::Status getWriteAmount(int32_t* _aidl_return);
Jeff Sharkey11c2d382017-09-11 10:32:01 -060097
Risan8f6198d2018-10-26 20:56:45 -060098 binder::Status mountAppFuse(int32_t uid, int32_t mountId,
Paul Crowleyedf7a4e2018-09-18 15:14:18 -070099 android::base::unique_fd* _aidl_return);
Risan8f6198d2018-10-26 20:56:45 -0600100 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 Sharkey83b559c2017-09-12 16:30:52 -0600103
Jeff Sharkey83b559c2017-09-12 16:30:52 -0600104 binder::Status fbeEnable();
105
Jeff Sharkey83b559c2017-09-12 16:30:52 -0600106 binder::Status initUser0();
Paul Lawrence236e5e82019-06-25 14:44:33 -0700107 binder::Status mountFstab(const std::string& blkDevice, const std::string& mountPoint);
Jaegeuk Kim0c52c712020-12-15 09:00:49 -0800108 binder::Status encryptFstab(const std::string& blkDevice, const std::string& mountPoint,
109 bool shouldFormat, const std::string& fsType);
Jeff Sharkey83b559c2017-09-12 16:30:52 -0600110
Seth Moore5a43d612021-01-19 17:51:51 +0000111 binder::Status setStorageBindingSeed(const std::vector<uint8_t>& seed);
112
Jeff Sharkey83b559c2017-09-12 16:30:52 -0600113 binder::Status createUserKey(int32_t userId, int32_t userSerial, bool ephemeral);
114 binder::Status destroyUserKey(int32_t userId);
115
Eric Biggers90a30522022-01-25 19:21:37 +0000116 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 Sharkey83b559c2017-09-12 16:30:52 -0600118 binder::Status fixateNewestUserKeyAuth(int32_t userId);
119
Eric Biggers1799deb2021-04-06 12:02:56 -0700120 binder::Status getUnlockedUsers(std::vector<int>* _aidl_return);
Eric Biggers90a30522022-01-25 19:21:37 +0000121 binder::Status unlockUserKey(int32_t userId, int32_t userSerial, const std::string& secret);
Jeff Sharkey83b559c2017-09-12 16:30:52 -0600122 binder::Status lockUserKey(int32_t userId);
123
Jooyung Han4fcb7072020-01-23 13:23:26 +0900124 binder::Status prepareUserStorage(const std::optional<std::string>& uuid, int32_t userId,
Paul Crowleyedf7a4e2018-09-18 15:14:18 -0700125 int32_t userSerial, int32_t flags);
Jooyung Han4fcb7072020-01-23 13:23:26 +0900126 binder::Status destroyUserStorage(const std::optional<std::string>& uuid, int32_t userId,
Paul Crowleyedf7a4e2018-09-18 15:14:18 -0700127 int32_t flags);
Sudheer Shankac7562092018-08-24 10:20:56 -0700128
Sudheer Shankafa6a1742018-10-04 16:26:22 -0700129 binder::Status prepareSandboxForApp(const std::string& packageName, int32_t appId,
130 const std::string& sandboxId, int32_t userId);
Sudheer Shanka69bc40f2018-10-25 11:06:55 -0700131 binder::Status destroySandboxForApp(const std::string& packageName,
Sudheer Shankafa6a1742018-10-04 16:26:22 -0700132 const std::string& sandboxId, int32_t userId);
Daniel Rosenberg4f684712018-08-28 01:58:49 -0700133
Daniel Rosenberge334aab2018-10-10 18:52:04 -0700134 binder::Status startCheckpoint(int32_t retry);
Daniel Rosenberg4f684712018-08-28 01:58:49 -0700135 binder::Status needsCheckpoint(bool* _aidl_return);
Daniel Rosenbergd3992492018-10-02 17:40:44 -0700136 binder::Status needsRollback(bool* _aidl_return);
David Anderson23850d32020-06-10 23:51:17 -0700137 binder::Status isCheckpointing(bool* _aidl_return);
Daniel Rosenberge334aab2018-10-10 18:52:04 -0700138 binder::Status commitChanges();
139 binder::Status prepareCheckpoint();
140 binder::Status restoreCheckpoint(const std::string& mountPoint);
Daniel Rosenbergdda59812019-03-06 17:45:17 -0800141 binder::Status restoreCheckpointPart(const std::string& mountPoint, int count);
Daniel Rosenberge334aab2018-10-10 18:52:04 -0700142 binder::Status markBootAttempt();
Daniel Rosenberga59e4392019-03-20 17:02:47 -0700143 binder::Status abortChanges(const std::string& message, bool retry);
Daniel Rosenberg9b667fb2019-01-22 17:27:25 -0800144 binder::Status supportsCheckpoint(bool* _aidl_return);
Paul Lawrencec5c79c52019-03-18 13:36:40 -0700145 binder::Status supportsBlockCheckpoint(bool* _aidl_return);
146 binder::Status supportsFileCheckpoint(bool* _aidl_return);
Nikita Ioffea5798fc2019-10-11 16:38:21 +0100147 binder::Status resetCheckpoint();
Songchun Fanab55cec2019-12-02 10:50:12 -0800148
Martijn Coeneneed957f2020-11-12 10:59:13 +0100149 binder::Status earlyBootEnded();
150
Yurii Zubrytskyi3497cb52020-01-10 11:54:06 -0800151 binder::Status incFsEnabled(bool* _aidl_return) override;
Songchun Fanab55cec2019-12-02 10:50:12 -0800152 binder::Status mountIncFs(
Yurii Zubrytskyi3497cb52020-01-10 11:54:06 -0800153 const std::string& backingPath, const std::string& targetDir, int32_t flags,
Songchun Fan046e68a2021-04-27 12:46:02 -0700154 const std::string& sysfsName,
Songchun Fanab55cec2019-12-02 10:50:12 -0800155 ::android::os::incremental::IncrementalFileSystemControlParcel* _aidl_return) override;
156 binder::Status unmountIncFs(const std::string& dir) override;
Alex Buynytskyy91e0bf42020-03-31 14:46:25 -0700157 binder::Status setIncFsMountOptions(
158 const ::android::os::incremental::IncrementalFileSystemControlParcel& control,
Songchun Fan0e53c1c2021-05-10 16:19:38 -0700159 bool enableReadLogs, bool enableReadTimeouts, const std::string& sysfsName) override;
Songchun Fanab55cec2019-12-02 10:50:12 -0800160 binder::Status bindMount(const std::string& sourceDir, const std::string& targetDir) override;
Yo Chiang0af25a32020-10-07 14:20:00 +0800161
162 binder::Status destroyDsuMetadataKey(const std::string& dsuSlot) override;
Jeff Sharkey068c6be2017-09-06 13:47:40 -0600163};
164
165} // namespace vold
166} // namespace android
167
168#endif // _VOLD_NATIVE_SERVICE_H_