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 20 #include <android-base/unique_fd.h> 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 { 29 public: 30 static status_t start(); getServiceName()31 static char const* getServiceName() { return "vold"; } 32 virtual status_t dump(int fd, const Vector<String16>& args) override; 33 34 binder::Status setListener(const android::sp<android::os::IVoldListener>& listener); 35 36 binder::Status monitor(); 37 binder::Status reset(); 38 binder::Status shutdown(); 39 binder::Status abortFuse(); 40 41 binder::Status onUserAdded(int32_t userId, int32_t userSerial); 42 binder::Status onUserRemoved(int32_t userId); 43 binder::Status onUserStarted(int32_t userId); 44 binder::Status onUserStopped(int32_t userId); 45 46 binder::Status addAppIds(const std::vector<std::string>& packageNames, 47 const std::vector<int32_t>& appIds); 48 binder::Status addSandboxIds(const std::vector<int32_t>& appIds, 49 const std::vector<std::string>& sandboxIds); 50 51 binder::Status onSecureKeyguardStateChanged(bool isShowing); 52 53 binder::Status partition(const std::string& diskId, int32_t partitionType, int32_t ratio); 54 binder::Status forgetPartition(const std::string& partGuid, const std::string& fsUuid); 55 56 binder::Status mount(const std::string& volId, int32_t mountFlags, int32_t mountUserId, 57 const android::sp<android::os::IVoldMountCallback>& callback); 58 binder::Status unmount(const std::string& volId); 59 binder::Status format(const std::string& volId, const std::string& fsType); 60 binder::Status benchmark(const std::string& volId, 61 const android::sp<android::os::IVoldTaskListener>& listener); 62 63 binder::Status moveStorage(const std::string& fromVolId, const std::string& toVolId, 64 const android::sp<android::os::IVoldTaskListener>& listener); 65 66 binder::Status remountUid(int32_t uid, int32_t remountMode); 67 binder::Status remountAppStorageDirs(int uid, int pid, 68 const std::vector<std::string>& packageNames); 69 binder::Status unmountAppStorageDirs(int uid, int pid, 70 const std::vector<std::string>& packageNames); 71 72 binder::Status ensureAppDirsCreated(const std::vector<std::string>& paths, int32_t appUid); 73 binder::Status setupAppDir(const std::string& path, int32_t appUid); 74 binder::Status fixupAppDir(const std::string& path, int32_t appUid); 75 76 binder::Status createObb(const std::string& sourcePath, const std::string& sourceKey, 77 int32_t ownerGid, std::string* _aidl_return); 78 binder::Status destroyObb(const std::string& volId); 79 80 binder::Status createStubVolume(const std::string& sourcePath, const std::string& mountPath, 81 const std::string& fsType, const std::string& fsUuid, 82 const std::string& fsLabel, int32_t flags, 83 std::string* _aidl_return); 84 binder::Status destroyStubVolume(const std::string& volId); 85 86 binder::Status fstrim(int32_t fstrimFlags, 87 const android::sp<android::os::IVoldTaskListener>& listener); 88 binder::Status runIdleMaint(const android::sp<android::os::IVoldTaskListener>& listener); 89 binder::Status abortIdleMaint(const android::sp<android::os::IVoldTaskListener>& listener); 90 91 binder::Status mountAppFuse(int32_t uid, int32_t mountId, 92 android::base::unique_fd* _aidl_return); 93 binder::Status unmountAppFuse(int32_t uid, int32_t mountId); 94 binder::Status openAppFuseFile(int32_t uid, int32_t mountId, int32_t fileId, int32_t flags, 95 android::base::unique_fd* _aidl_return); 96 97 binder::Status fdeCheckPassword(const std::string& password); 98 binder::Status fdeRestart(); 99 binder::Status fdeComplete(int32_t* _aidl_return); 100 binder::Status fdeEnable(int32_t passwordType, const std::string& password, 101 int32_t encryptionFlags); 102 binder::Status fdeChangePassword(int32_t passwordType, const std::string& password); 103 binder::Status fdeVerifyPassword(const std::string& password); 104 binder::Status fdeGetField(const std::string& key, std::string* _aidl_return); 105 binder::Status fdeSetField(const std::string& key, const std::string& value); 106 binder::Status fdeGetPasswordType(int32_t* _aidl_return); 107 binder::Status fdeGetPassword(std::string* _aidl_return); 108 binder::Status fdeClearPassword(); 109 110 binder::Status fbeEnable(); 111 112 binder::Status mountDefaultEncrypted(); 113 binder::Status initUser0(); 114 binder::Status isConvertibleToFbe(bool* _aidl_return); 115 binder::Status mountFstab(const std::string& blkDevice, const std::string& mountPoint); 116 binder::Status encryptFstab(const std::string& blkDevice, const std::string& mountPoint, 117 bool shouldFormat, const std::string& fsType); 118 119 binder::Status setStorageBindingSeed(const std::vector<uint8_t>& seed); 120 121 binder::Status createUserKey(int32_t userId, int32_t userSerial, bool ephemeral); 122 binder::Status destroyUserKey(int32_t userId); 123 124 binder::Status addUserKeyAuth(int32_t userId, int32_t userSerial, const std::string& token, 125 const std::string& secret); 126 binder::Status clearUserKeyAuth(int32_t userId, int32_t userSerial, const std::string& token, 127 const std::string& secret); 128 binder::Status fixateNewestUserKeyAuth(int32_t userId); 129 130 binder::Status getUnlockedUsers(std::vector<int>* _aidl_return); 131 binder::Status unlockUserKey(int32_t userId, int32_t userSerial, const std::string& token, 132 const std::string& secret); 133 binder::Status lockUserKey(int32_t userId); 134 135 binder::Status prepareUserStorage(const std::optional<std::string>& uuid, int32_t userId, 136 int32_t userSerial, int32_t flags); 137 binder::Status destroyUserStorage(const std::optional<std::string>& uuid, int32_t userId, 138 int32_t flags); 139 140 binder::Status prepareSandboxForApp(const std::string& packageName, int32_t appId, 141 const std::string& sandboxId, int32_t userId); 142 binder::Status destroySandboxForApp(const std::string& packageName, 143 const std::string& sandboxId, int32_t userId); 144 145 binder::Status startCheckpoint(int32_t retry); 146 binder::Status needsCheckpoint(bool* _aidl_return); 147 binder::Status needsRollback(bool* _aidl_return); 148 binder::Status isCheckpointing(bool* _aidl_return); 149 binder::Status commitChanges(); 150 binder::Status prepareCheckpoint(); 151 binder::Status restoreCheckpoint(const std::string& mountPoint); 152 binder::Status restoreCheckpointPart(const std::string& mountPoint, int count); 153 binder::Status markBootAttempt(); 154 binder::Status abortChanges(const std::string& message, bool retry); 155 binder::Status supportsCheckpoint(bool* _aidl_return); 156 binder::Status supportsBlockCheckpoint(bool* _aidl_return); 157 binder::Status supportsFileCheckpoint(bool* _aidl_return); 158 binder::Status resetCheckpoint(); 159 160 binder::Status earlyBootEnded(); 161 162 binder::Status incFsEnabled(bool* _aidl_return) override; 163 binder::Status mountIncFs( 164 const std::string& backingPath, const std::string& targetDir, int32_t flags, 165 const std::string& sysfsName, 166 ::android::os::incremental::IncrementalFileSystemControlParcel* _aidl_return) override; 167 binder::Status unmountIncFs(const std::string& dir) override; 168 binder::Status setIncFsMountOptions( 169 const ::android::os::incremental::IncrementalFileSystemControlParcel& control, 170 bool enableReadLogs, bool enableReadTimeouts, const std::string& sysfsName) override; 171 binder::Status bindMount(const std::string& sourceDir, const std::string& targetDir) override; 172 173 binder::Status destroyDsuMetadataKey(const std::string& dsuSlot) override; 174 }; 175 176 } // namespace vold 177 } // namespace android 178 179 #endif // _VOLD_NATIVE_SERVICE_H_ 180