1*f40fafd4SAndroid Build Coastguard Worker /* 2*f40fafd4SAndroid Build Coastguard Worker * Copyright (C) 2017 The Android Open Source Project 3*f40fafd4SAndroid Build Coastguard Worker * 4*f40fafd4SAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*f40fafd4SAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*f40fafd4SAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*f40fafd4SAndroid Build Coastguard Worker * 8*f40fafd4SAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*f40fafd4SAndroid Build Coastguard Worker * 10*f40fafd4SAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*f40fafd4SAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*f40fafd4SAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*f40fafd4SAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*f40fafd4SAndroid Build Coastguard Worker * limitations under the License. 15*f40fafd4SAndroid Build Coastguard Worker */ 16*f40fafd4SAndroid Build Coastguard Worker 17*f40fafd4SAndroid Build Coastguard Worker #ifndef _VOLD_NATIVE_SERVICE_H_ 18*f40fafd4SAndroid Build Coastguard Worker #define _VOLD_NATIVE_SERVICE_H_ 19*f40fafd4SAndroid Build Coastguard Worker 20*f40fafd4SAndroid Build Coastguard Worker #include <android-base/unique_fd.h> 21*f40fafd4SAndroid Build Coastguard Worker #include <binder/BinderService.h> 22*f40fafd4SAndroid Build Coastguard Worker 23*f40fafd4SAndroid Build Coastguard Worker #include "android/os/BnVold.h" 24*f40fafd4SAndroid Build Coastguard Worker 25*f40fafd4SAndroid Build Coastguard Worker namespace android { 26*f40fafd4SAndroid Build Coastguard Worker namespace vold { 27*f40fafd4SAndroid Build Coastguard Worker 28*f40fafd4SAndroid Build Coastguard Worker class VoldNativeService : public BinderService<VoldNativeService>, public os::BnVold { 29*f40fafd4SAndroid Build Coastguard Worker public: 30*f40fafd4SAndroid Build Coastguard Worker static status_t start(); getServiceName()31*f40fafd4SAndroid Build Coastguard Worker static char const* getServiceName() { return "vold"; } 32*f40fafd4SAndroid Build Coastguard Worker virtual status_t dump(int fd, const Vector<String16>& args) override; 33*f40fafd4SAndroid Build Coastguard Worker 34*f40fafd4SAndroid Build Coastguard Worker binder::Status setListener(const android::sp<android::os::IVoldListener>& listener); 35*f40fafd4SAndroid Build Coastguard Worker 36*f40fafd4SAndroid Build Coastguard Worker binder::Status monitor(); 37*f40fafd4SAndroid Build Coastguard Worker binder::Status reset(); 38*f40fafd4SAndroid Build Coastguard Worker binder::Status shutdown(); 39*f40fafd4SAndroid Build Coastguard Worker binder::Status abortFuse(); 40*f40fafd4SAndroid Build Coastguard Worker 41*f40fafd4SAndroid Build Coastguard Worker binder::Status onUserAdded(int32_t userId, int32_t userSerial, int32_t sharesStorageWithUserId); 42*f40fafd4SAndroid Build Coastguard Worker binder::Status onUserRemoved(int32_t userId); 43*f40fafd4SAndroid Build Coastguard Worker binder::Status onUserStarted(int32_t userId); 44*f40fafd4SAndroid Build Coastguard Worker binder::Status onUserStopped(int32_t userId); 45*f40fafd4SAndroid Build Coastguard Worker 46*f40fafd4SAndroid Build Coastguard Worker binder::Status addAppIds(const std::vector<std::string>& packageNames, 47*f40fafd4SAndroid Build Coastguard Worker const std::vector<int32_t>& appIds); 48*f40fafd4SAndroid Build Coastguard Worker binder::Status addSandboxIds(const std::vector<int32_t>& appIds, 49*f40fafd4SAndroid Build Coastguard Worker const std::vector<std::string>& sandboxIds); 50*f40fafd4SAndroid Build Coastguard Worker 51*f40fafd4SAndroid Build Coastguard Worker binder::Status onSecureKeyguardStateChanged(bool isShowing); 52*f40fafd4SAndroid Build Coastguard Worker 53*f40fafd4SAndroid Build Coastguard Worker binder::Status partition(const std::string& diskId, int32_t partitionType, int32_t ratio); 54*f40fafd4SAndroid Build Coastguard Worker binder::Status forgetPartition(const std::string& partGuid, const std::string& fsUuid); 55*f40fafd4SAndroid Build Coastguard Worker 56*f40fafd4SAndroid Build Coastguard Worker binder::Status mount(const std::string& volId, int32_t mountFlags, int32_t mountUserId, 57*f40fafd4SAndroid Build Coastguard Worker const android::sp<android::os::IVoldMountCallback>& callback); 58*f40fafd4SAndroid Build Coastguard Worker binder::Status unmount(const std::string& volId); 59*f40fafd4SAndroid Build Coastguard Worker binder::Status format(const std::string& volId, const std::string& fsType); 60*f40fafd4SAndroid Build Coastguard Worker binder::Status benchmark(const std::string& volId, 61*f40fafd4SAndroid Build Coastguard Worker const android::sp<android::os::IVoldTaskListener>& listener); 62*f40fafd4SAndroid Build Coastguard Worker 63*f40fafd4SAndroid Build Coastguard Worker binder::Status moveStorage(const std::string& fromVolId, const std::string& toVolId, 64*f40fafd4SAndroid Build Coastguard Worker const android::sp<android::os::IVoldTaskListener>& listener); 65*f40fafd4SAndroid Build Coastguard Worker 66*f40fafd4SAndroid Build Coastguard Worker binder::Status remountUid(int32_t uid, int32_t remountMode); 67*f40fafd4SAndroid Build Coastguard Worker binder::Status remountAppStorageDirs(int uid, int pid, 68*f40fafd4SAndroid Build Coastguard Worker const std::vector<std::string>& packageNames); 69*f40fafd4SAndroid Build Coastguard Worker binder::Status unmountAppStorageDirs(int uid, int pid, 70*f40fafd4SAndroid Build Coastguard Worker const std::vector<std::string>& packageNames); 71*f40fafd4SAndroid Build Coastguard Worker 72*f40fafd4SAndroid Build Coastguard Worker binder::Status ensureAppDirsCreated(const std::vector<std::string>& paths, int32_t appUid); 73*f40fafd4SAndroid Build Coastguard Worker binder::Status setupAppDir(const std::string& path, int32_t appUid); 74*f40fafd4SAndroid Build Coastguard Worker binder::Status fixupAppDir(const std::string& path, int32_t appUid); 75*f40fafd4SAndroid Build Coastguard Worker 76*f40fafd4SAndroid Build Coastguard Worker binder::Status createObb(const std::string& sourcePath, int32_t ownerGid, 77*f40fafd4SAndroid Build Coastguard Worker std::string* _aidl_return); 78*f40fafd4SAndroid Build Coastguard Worker binder::Status destroyObb(const std::string& volId); 79*f40fafd4SAndroid Build Coastguard Worker 80*f40fafd4SAndroid Build Coastguard Worker binder::Status createStubVolume(const std::string& sourcePath, const std::string& mountPath, 81*f40fafd4SAndroid Build Coastguard Worker const std::string& fsType, const std::string& fsUuid, 82*f40fafd4SAndroid Build Coastguard Worker const std::string& fsLabel, int32_t flags, 83*f40fafd4SAndroid Build Coastguard Worker std::string* _aidl_return); 84*f40fafd4SAndroid Build Coastguard Worker binder::Status destroyStubVolume(const std::string& volId); 85*f40fafd4SAndroid Build Coastguard Worker 86*f40fafd4SAndroid Build Coastguard Worker binder::Status fstrim(int32_t fstrimFlags, 87*f40fafd4SAndroid Build Coastguard Worker const android::sp<android::os::IVoldTaskListener>& listener); 88*f40fafd4SAndroid Build Coastguard Worker binder::Status runIdleMaint(bool needGC, 89*f40fafd4SAndroid Build Coastguard Worker const android::sp<android::os::IVoldTaskListener>& listener); 90*f40fafd4SAndroid Build Coastguard Worker binder::Status abortIdleMaint(const android::sp<android::os::IVoldTaskListener>& listener); 91*f40fafd4SAndroid Build Coastguard Worker binder::Status getStorageLifeTime(int32_t* _aidl_return); 92*f40fafd4SAndroid Build Coastguard Worker binder::Status getStorageRemainingLifetime(int32_t* _aidl_return); 93*f40fafd4SAndroid Build Coastguard Worker binder::Status setGCUrgentPace(int32_t neededSegments, int32_t minSegmentThreshold, 94*f40fafd4SAndroid Build Coastguard Worker float dirtyReclaimRate, float reclaimWeight, int32_t gcPeriod, 95*f40fafd4SAndroid Build Coastguard Worker int32_t minGCSleepTime, int32_t targetDirtyRatio); 96*f40fafd4SAndroid Build Coastguard Worker binder::Status refreshLatestWrite(); 97*f40fafd4SAndroid Build Coastguard Worker binder::Status getWriteAmount(int32_t* _aidl_return); 98*f40fafd4SAndroid Build Coastguard Worker 99*f40fafd4SAndroid Build Coastguard Worker binder::Status mountAppFuse(int32_t uid, int32_t mountId, 100*f40fafd4SAndroid Build Coastguard Worker android::base::unique_fd* _aidl_return); 101*f40fafd4SAndroid Build Coastguard Worker binder::Status unmountAppFuse(int32_t uid, int32_t mountId); 102*f40fafd4SAndroid Build Coastguard Worker binder::Status openAppFuseFile(int32_t uid, int32_t mountId, int32_t fileId, int32_t flags, 103*f40fafd4SAndroid Build Coastguard Worker android::base::unique_fd* _aidl_return); 104*f40fafd4SAndroid Build Coastguard Worker 105*f40fafd4SAndroid Build Coastguard Worker binder::Status fbeEnable(); 106*f40fafd4SAndroid Build Coastguard Worker 107*f40fafd4SAndroid Build Coastguard Worker binder::Status initUser0(); 108*f40fafd4SAndroid Build Coastguard Worker binder::Status mountFstab(const std::string& blkDevice, const std::string& mountPoint, 109*f40fafd4SAndroid Build Coastguard Worker bool isZoned, const std::vector<std::string>& userDevices); 110*f40fafd4SAndroid Build Coastguard Worker 111*f40fafd4SAndroid Build Coastguard Worker binder::Status encryptFstab(const std::string& blkDevice, const std::string& mountPoint, 112*f40fafd4SAndroid Build Coastguard Worker bool shouldFormat, const std::string& fsType, bool isZoned, 113*f40fafd4SAndroid Build Coastguard Worker const std::vector<std::string>& userDevices, 114*f40fafd4SAndroid Build Coastguard Worker const std::vector<bool>& deviceAliased, int64_t length); 115*f40fafd4SAndroid Build Coastguard Worker 116*f40fafd4SAndroid Build Coastguard Worker binder::Status setStorageBindingSeed(const std::vector<uint8_t>& seed); 117*f40fafd4SAndroid Build Coastguard Worker 118*f40fafd4SAndroid Build Coastguard Worker binder::Status createUserStorageKeys(int32_t userId, bool ephemeral); 119*f40fafd4SAndroid Build Coastguard Worker binder::Status destroyUserStorageKeys(int32_t userId); 120*f40fafd4SAndroid Build Coastguard Worker 121*f40fafd4SAndroid Build Coastguard Worker binder::Status setCeStorageProtection(int32_t userId, const std::vector<uint8_t>& secret); 122*f40fafd4SAndroid Build Coastguard Worker 123*f40fafd4SAndroid Build Coastguard Worker binder::Status getUnlockedUsers(std::vector<int>* _aidl_return); 124*f40fafd4SAndroid Build Coastguard Worker binder::Status unlockCeStorage(int32_t userId, const std::vector<uint8_t>& secret); 125*f40fafd4SAndroid Build Coastguard Worker binder::Status lockCeStorage(int32_t userId); 126*f40fafd4SAndroid Build Coastguard Worker 127*f40fafd4SAndroid Build Coastguard Worker binder::Status prepareUserStorage(const std::optional<std::string>& uuid, int32_t userId, 128*f40fafd4SAndroid Build Coastguard Worker int32_t flags); 129*f40fafd4SAndroid Build Coastguard Worker binder::Status destroyUserStorage(const std::optional<std::string>& uuid, int32_t userId, 130*f40fafd4SAndroid Build Coastguard Worker int32_t flags); 131*f40fafd4SAndroid Build Coastguard Worker 132*f40fafd4SAndroid Build Coastguard Worker binder::Status prepareSandboxForApp(const std::string& packageName, int32_t appId, 133*f40fafd4SAndroid Build Coastguard Worker const std::string& sandboxId, int32_t userId); 134*f40fafd4SAndroid Build Coastguard Worker binder::Status destroySandboxForApp(const std::string& packageName, 135*f40fafd4SAndroid Build Coastguard Worker const std::string& sandboxId, int32_t userId); 136*f40fafd4SAndroid Build Coastguard Worker 137*f40fafd4SAndroid Build Coastguard Worker binder::Status startCheckpoint(int32_t retry); 138*f40fafd4SAndroid Build Coastguard Worker binder::Status needsCheckpoint(bool* _aidl_return); 139*f40fafd4SAndroid Build Coastguard Worker binder::Status needsRollback(bool* _aidl_return); 140*f40fafd4SAndroid Build Coastguard Worker binder::Status isCheckpointing(bool* _aidl_return); 141*f40fafd4SAndroid Build Coastguard Worker binder::Status commitChanges(); 142*f40fafd4SAndroid Build Coastguard Worker binder::Status prepareCheckpoint(); 143*f40fafd4SAndroid Build Coastguard Worker binder::Status restoreCheckpoint(const std::string& mountPoint); 144*f40fafd4SAndroid Build Coastguard Worker binder::Status restoreCheckpointPart(const std::string& mountPoint, int count); 145*f40fafd4SAndroid Build Coastguard Worker binder::Status markBootAttempt(); 146*f40fafd4SAndroid Build Coastguard Worker binder::Status abortChanges(const std::string& message, bool retry); 147*f40fafd4SAndroid Build Coastguard Worker binder::Status supportsCheckpoint(bool* _aidl_return); 148*f40fafd4SAndroid Build Coastguard Worker binder::Status supportsBlockCheckpoint(bool* _aidl_return); 149*f40fafd4SAndroid Build Coastguard Worker binder::Status supportsFileCheckpoint(bool* _aidl_return); 150*f40fafd4SAndroid Build Coastguard Worker binder::Status resetCheckpoint(); 151*f40fafd4SAndroid Build Coastguard Worker 152*f40fafd4SAndroid Build Coastguard Worker binder::Status earlyBootEnded(); 153*f40fafd4SAndroid Build Coastguard Worker 154*f40fafd4SAndroid Build Coastguard Worker binder::Status incFsEnabled(bool* _aidl_return) override; 155*f40fafd4SAndroid Build Coastguard Worker binder::Status mountIncFs( 156*f40fafd4SAndroid Build Coastguard Worker const std::string& backingPath, const std::string& targetDir, int32_t flags, 157*f40fafd4SAndroid Build Coastguard Worker const std::string& sysfsName, 158*f40fafd4SAndroid Build Coastguard Worker ::android::os::incremental::IncrementalFileSystemControlParcel* _aidl_return) override; 159*f40fafd4SAndroid Build Coastguard Worker binder::Status unmountIncFs(const std::string& dir) override; 160*f40fafd4SAndroid Build Coastguard Worker binder::Status setIncFsMountOptions( 161*f40fafd4SAndroid Build Coastguard Worker const ::android::os::incremental::IncrementalFileSystemControlParcel& control, 162*f40fafd4SAndroid Build Coastguard Worker bool enableReadLogs, bool enableReadTimeouts, const std::string& sysfsName) override; 163*f40fafd4SAndroid Build Coastguard Worker binder::Status bindMount(const std::string& sourceDir, const std::string& targetDir) override; 164*f40fafd4SAndroid Build Coastguard Worker 165*f40fafd4SAndroid Build Coastguard Worker binder::Status destroyDsuMetadataKey(const std::string& dsuSlot) override; 166*f40fafd4SAndroid Build Coastguard Worker 167*f40fafd4SAndroid Build Coastguard Worker binder::Status getStorageSize(int64_t* storageSize) override; 168*f40fafd4SAndroid Build Coastguard Worker }; 169*f40fafd4SAndroid Build Coastguard Worker 170*f40fafd4SAndroid Build Coastguard Worker } // namespace vold 171*f40fafd4SAndroid Build Coastguard Worker } // namespace android 172*f40fafd4SAndroid Build Coastguard Worker 173*f40fafd4SAndroid Build Coastguard Worker #endif // _VOLD_NATIVE_SERVICE_H_ 174