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 40 binder::Status onUserAdded(int32_t userId, int32_t userSerial); 41 binder::Status onUserRemoved(int32_t userId); 42 binder::Status onUserStarted(int32_t userId); 43 binder::Status onUserStopped(int32_t userId); 44 45 binder::Status addAppIds(const std::vector<std::string>& packageNames, 46 const std::vector<int32_t>& appIds); 47 binder::Status addSandboxIds(const std::vector<int32_t>& appIds, 48 const std::vector<std::string>& sandboxIds); 49 50 binder::Status onSecureKeyguardStateChanged(bool isShowing); 51 52 binder::Status partition(const std::string& diskId, int32_t partitionType, int32_t ratio); 53 binder::Status forgetPartition(const std::string& partGuid, const std::string& fsUuid); 54 55 binder::Status mount(const std::string& volId, int32_t mountFlags, int32_t mountUserId); 56 binder::Status unmount(const std::string& volId); 57 binder::Status format(const std::string& volId, const std::string& fsType); 58 binder::Status benchmark(const std::string& volId, 59 const android::sp<android::os::IVoldTaskListener>& listener); 60 binder::Status checkEncryption(const std::string& volId); 61 62 binder::Status moveStorage(const std::string& fromVolId, const std::string& toVolId, 63 const android::sp<android::os::IVoldTaskListener>& listener); 64 65 binder::Status remountUid(int32_t uid, int32_t remountMode); 66 67 binder::Status mkdirs(const std::string& path); 68 69 binder::Status createObb(const std::string& sourcePath, const std::string& sourceKey, 70 int32_t ownerGid, std::string* _aidl_return); 71 binder::Status destroyObb(const std::string& volId); 72 73 binder::Status createStubVolume(const std::string& sourcePath, const std::string& mountPath, 74 const std::string& fsType, const std::string& fsUuid, 75 const std::string& fsLabel, std::string* _aidl_return); 76 binder::Status destroyStubVolume(const std::string& volId); 77 78 binder::Status fstrim(int32_t fstrimFlags, 79 const android::sp<android::os::IVoldTaskListener>& listener); 80 binder::Status runIdleMaint(const android::sp<android::os::IVoldTaskListener>& listener); 81 binder::Status abortIdleMaint(const android::sp<android::os::IVoldTaskListener>& listener); 82 83 binder::Status mountAppFuse(int32_t uid, int32_t mountId, 84 android::base::unique_fd* _aidl_return); 85 binder::Status unmountAppFuse(int32_t uid, int32_t mountId); 86 binder::Status openAppFuseFile(int32_t uid, int32_t mountId, int32_t fileId, int32_t flags, 87 android::base::unique_fd* _aidl_return); 88 89 binder::Status fdeCheckPassword(const std::string& password); 90 binder::Status fdeRestart(); 91 binder::Status fdeComplete(int32_t* _aidl_return); 92 binder::Status fdeEnable(int32_t passwordType, const std::string& password, 93 int32_t encryptionFlags); 94 binder::Status fdeChangePassword(int32_t passwordType, const std::string& password); 95 binder::Status fdeVerifyPassword(const std::string& password); 96 binder::Status fdeGetField(const std::string& key, std::string* _aidl_return); 97 binder::Status fdeSetField(const std::string& key, const std::string& value); 98 binder::Status fdeGetPasswordType(int32_t* _aidl_return); 99 binder::Status fdeGetPassword(std::string* _aidl_return); 100 binder::Status fdeClearPassword(); 101 102 binder::Status fbeEnable(); 103 104 binder::Status mountDefaultEncrypted(); 105 binder::Status initUser0(); 106 binder::Status isConvertibleToFbe(bool* _aidl_return); 107 binder::Status mountFstab(const std::string& blkDevice, const std::string& mountPoint); 108 binder::Status encryptFstab(const std::string& blkDevice, const std::string& mountPoint); 109 110 binder::Status createUserKey(int32_t userId, int32_t userSerial, bool ephemeral); 111 binder::Status destroyUserKey(int32_t userId); 112 113 binder::Status addUserKeyAuth(int32_t userId, int32_t userSerial, const std::string& token, 114 const std::string& secret); 115 binder::Status fixateNewestUserKeyAuth(int32_t userId); 116 117 binder::Status unlockUserKey(int32_t userId, int32_t userSerial, const std::string& token, 118 const std::string& secret); 119 binder::Status lockUserKey(int32_t userId); 120 121 binder::Status prepareUserStorage(const std::unique_ptr<std::string>& uuid, int32_t userId, 122 int32_t userSerial, int32_t flags); 123 binder::Status destroyUserStorage(const std::unique_ptr<std::string>& uuid, int32_t userId, 124 int32_t flags); 125 126 binder::Status prepareSandboxForApp(const std::string& packageName, int32_t appId, 127 const std::string& sandboxId, int32_t userId); 128 binder::Status destroySandboxForApp(const std::string& packageName, 129 const std::string& sandboxId, int32_t userId); 130 131 binder::Status startCheckpoint(int32_t retry); 132 binder::Status needsCheckpoint(bool* _aidl_return); 133 binder::Status needsRollback(bool* _aidl_return); 134 binder::Status commitChanges(); 135 binder::Status prepareCheckpoint(); 136 binder::Status restoreCheckpoint(const std::string& mountPoint); 137 binder::Status restoreCheckpointPart(const std::string& mountPoint, int count); 138 binder::Status markBootAttempt(); 139 binder::Status abortChanges(const std::string& message, bool retry); 140 binder::Status supportsCheckpoint(bool* _aidl_return); 141 binder::Status supportsBlockCheckpoint(bool* _aidl_return); 142 binder::Status supportsFileCheckpoint(bool* _aidl_return); 143 }; 144 145 } // namespace vold 146 } // namespace android 147 148 #endif // _VOLD_NATIVE_SERVICE_H_ 149