Merge "vold: const-ify some of the API"

This commit is contained in:
TreeHugger Robot 2018-12-20 21:19:55 +00:00 committed by Android (Google) Code Review
commit 37fd66f19d
8 changed files with 33 additions and 32 deletions

View file

@ -46,8 +46,8 @@ class KeymasterOperation {
~KeymasterOperation(); ~KeymasterOperation();
// Is this instance valid? This is false if creation fails, and becomes // Is this instance valid? This is false if creation fails, and becomes
// false on finish or if an update fails. // false on finish or if an update fails.
explicit operator bool() { return mError == km::ErrorCode::OK; } explicit operator bool() const { return mError == km::ErrorCode::OK; }
km::ErrorCode errorCode() { return mError; } km::ErrorCode errorCode() const { return mError; }
// Call "update" repeatedly until all of the input is consumed, and // Call "update" repeatedly until all of the input is consumed, and
// concatenate the output. Return true on success. // concatenate the output. Return true on success.
template <class TI, class TO> template <class TI, class TO>

View file

@ -327,7 +327,8 @@ std::shared_ptr<android::vold::VolumeBase> VolumeManager::findVolume(const std::
return nullptr; return nullptr;
} }
void VolumeManager::listVolumes(android::vold::VolumeBase::Type type, std::list<std::string>& list) { void VolumeManager::listVolumes(android::vold::VolumeBase::Type type,
std::list<std::string>& list) const {
list.clear(); list.clear();
for (const auto& disk : mDisks) { for (const auto& disk : mDisks) {
disk->listVolumes(type, list); disk->listVolumes(type, list);

View file

@ -52,7 +52,7 @@ class VolumeManager {
std::mutex& getCryptLock() { return mCryptLock; } std::mutex& getCryptLock() { return mCryptLock; }
void setListener(android::sp<android::os::IVoldListener> listener) { mListener = listener; } void setListener(android::sp<android::os::IVoldListener> listener) { mListener = listener; }
android::sp<android::os::IVoldListener> getListener() { return mListener; } android::sp<android::os::IVoldListener> getListener() const { return mListener; }
int start(); int start();
int stop(); int stop();
@ -68,8 +68,8 @@ class VolumeManager {
return !fnmatch(mSysPattern.c_str(), sysPath.c_str(), 0); return !fnmatch(mSysPattern.c_str(), sysPath.c_str(), 0);
} }
const std::string& getNickname() { return mNickname; } const std::string& getNickname() const { return mNickname; }
int getFlags() { return mFlags; } int getFlags() const { return mFlags; }
private: private:
std::string mSysPattern; std::string mSysPattern;
@ -82,7 +82,7 @@ class VolumeManager {
std::shared_ptr<android::vold::Disk> findDisk(const std::string& id); std::shared_ptr<android::vold::Disk> findDisk(const std::string& id);
std::shared_ptr<android::vold::VolumeBase> findVolume(const std::string& id); std::shared_ptr<android::vold::VolumeBase> findVolume(const std::string& id);
void listVolumes(android::vold::VolumeBase::Type type, std::list<std::string>& list); void listVolumes(android::vold::VolumeBase::Type type, std::list<std::string>& list) const;
int forgetPartition(const std::string& partGuid, const std::string& fsUuid); int forgetPartition(const std::string& partGuid, const std::string& fsUuid);

View file

@ -153,7 +153,7 @@ std::shared_ptr<VolumeBase> Disk::findVolume(const std::string& id) {
return nullptr; return nullptr;
} }
void Disk::listVolumes(VolumeBase::Type type, std::list<std::string>& list) { void Disk::listVolumes(VolumeBase::Type type, std::list<std::string>& list) const {
for (const auto& vol : mVolumes) { for (const auto& vol : mVolumes) {
if (vol->getType() == type) { if (vol->getType() == type) {
list.push_back(vol->getId()); list.push_back(vol->getId());

View file

@ -54,18 +54,18 @@ class Disk {
kEmmc = 1 << 4, kEmmc = 1 << 4,
}; };
const std::string& getId() { return mId; } const std::string& getId() const { return mId; }
const std::string& getEventPath() { return mEventPath; } const std::string& getEventPath() const { return mEventPath; }
const std::string& getSysPath() { return mSysPath; } const std::string& getSysPath() const { return mSysPath; }
const std::string& getDevPath() { return mDevPath; } const std::string& getDevPath() const { return mDevPath; }
dev_t getDevice() { return mDevice; } dev_t getDevice() const { return mDevice; }
uint64_t getSize() { return mSize; } uint64_t getSize() const { return mSize; }
const std::string& getLabel() { return mLabel; } const std::string& getLabel() const { return mLabel; }
int getFlags() { return mFlags; } int getFlags() const { return mFlags; }
std::shared_ptr<VolumeBase> findVolume(const std::string& id); std::shared_ptr<VolumeBase> findVolume(const std::string& id);
void listVolumes(VolumeBase::Type type, std::list<std::string>& list); void listVolumes(VolumeBase::Type type, std::list<std::string>& list) const;
status_t create(); status_t create();
status_t destroy(); status_t destroy();

View file

@ -39,9 +39,9 @@ class PrivateVolume : public VolumeBase {
public: public:
PrivateVolume(dev_t device, const std::string& keyRaw); PrivateVolume(dev_t device, const std::string& keyRaw);
virtual ~PrivateVolume(); virtual ~PrivateVolume();
const std::string& getFsType() { return mFsType; }; const std::string& getFsType() const { return mFsType; };
const std::string& getRawDevPath() { return mRawDevPath; }; const std::string& getRawDevPath() const { return mRawDevPath; };
const std::string& getRawDmDevPath() { return mDmDevPath; }; const std::string& getRawDmDevPath() const { return mDmDevPath; };
protected: protected:
status_t doCreate() override; status_t doCreate() override;

View file

@ -153,7 +153,7 @@ status_t VolumeBase::setLabel(const std::string& label) {
return OK; return OK;
} }
android::sp<android::os::IVoldListener> VolumeBase::getListener() { android::sp<android::os::IVoldListener> VolumeBase::getListener() const {
if (mSilent) { if (mSilent) {
return nullptr; return nullptr;
} else { } else {

View file

@ -78,16 +78,16 @@ class VolumeBase {
kBadRemoval, kBadRemoval,
}; };
const std::string& getId() { return mId; } const std::string& getId() const { return mId; }
const std::string& getDiskId() { return mDiskId; } const std::string& getDiskId() const { return mDiskId; }
const std::string& getPartGuid() { return mPartGuid; } const std::string& getPartGuid() const { return mPartGuid; }
Type getType() { return mType; } Type getType() const { return mType; }
int getMountFlags() { return mMountFlags; } int getMountFlags() const { return mMountFlags; }
userid_t getMountUserId() { return mMountUserId; } userid_t getMountUserId() const { return mMountUserId; }
State getState() { return mState; } State getState() const { return mState; }
const std::string& getPath() { return mPath; } const std::string& getPath() const { return mPath; }
const std::string& getInternalPath() { return mInternalPath; } const std::string& getInternalPath() const { return mInternalPath; }
const std::string& getLabel() { return mLabel; } const std::string& getLabel() const { return mLabel; }
status_t setDiskId(const std::string& diskId); status_t setDiskId(const std::string& diskId);
status_t setPartGuid(const std::string& partGuid); status_t setPartGuid(const std::string& partGuid);
@ -124,7 +124,7 @@ class VolumeBase {
status_t setInternalPath(const std::string& internalPath); status_t setInternalPath(const std::string& internalPath);
status_t setLabel(const std::string& label); status_t setLabel(const std::string& label);
android::sp<android::os::IVoldListener> getListener(); android::sp<android::os::IVoldListener> getListener() const;
private: private:
/* ID that uniquely references volume while alive */ /* ID that uniquely references volume while alive */