vold: const-ify some of the API
We make some of the C++ member functions 'const', to reflect how they (don't) affect the state of the class. Test: TreeHugger Change-Id: Iec1c2801bfe721e2741406ed1ac0ef95662840a6
This commit is contained in:
parent
c608caca3d
commit
2bc201e6bb
8 changed files with 33 additions and 32 deletions
|
@ -46,8 +46,8 @@ class KeymasterOperation {
|
|||
~KeymasterOperation();
|
||||
// Is this instance valid? This is false if creation fails, and becomes
|
||||
// false on finish or if an update fails.
|
||||
explicit operator bool() { return mError == km::ErrorCode::OK; }
|
||||
km::ErrorCode errorCode() { return mError; }
|
||||
explicit operator bool() const { return mError == km::ErrorCode::OK; }
|
||||
km::ErrorCode errorCode() const { return mError; }
|
||||
// Call "update" repeatedly until all of the input is consumed, and
|
||||
// concatenate the output. Return true on success.
|
||||
template <class TI, class TO>
|
||||
|
|
|
@ -327,7 +327,8 @@ std::shared_ptr<android::vold::VolumeBase> VolumeManager::findVolume(const std::
|
|||
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();
|
||||
for (const auto& disk : mDisks) {
|
||||
disk->listVolumes(type, list);
|
||||
|
|
|
@ -52,7 +52,7 @@ class VolumeManager {
|
|||
std::mutex& getCryptLock() { return mCryptLock; }
|
||||
|
||||
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 stop();
|
||||
|
@ -68,8 +68,8 @@ class VolumeManager {
|
|||
return !fnmatch(mSysPattern.c_str(), sysPath.c_str(), 0);
|
||||
}
|
||||
|
||||
const std::string& getNickname() { return mNickname; }
|
||||
int getFlags() { return mFlags; }
|
||||
const std::string& getNickname() const { return mNickname; }
|
||||
int getFlags() const { return mFlags; }
|
||||
|
||||
private:
|
||||
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::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);
|
||||
|
||||
|
|
|
@ -153,7 +153,7 @@ std::shared_ptr<VolumeBase> Disk::findVolume(const std::string& id) {
|
|||
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) {
|
||||
if (vol->getType() == type) {
|
||||
list.push_back(vol->getId());
|
||||
|
|
18
model/Disk.h
18
model/Disk.h
|
@ -54,18 +54,18 @@ class Disk {
|
|||
kEmmc = 1 << 4,
|
||||
};
|
||||
|
||||
const std::string& getId() { return mId; }
|
||||
const std::string& getEventPath() { return mEventPath; }
|
||||
const std::string& getSysPath() { return mSysPath; }
|
||||
const std::string& getDevPath() { return mDevPath; }
|
||||
dev_t getDevice() { return mDevice; }
|
||||
uint64_t getSize() { return mSize; }
|
||||
const std::string& getLabel() { return mLabel; }
|
||||
int getFlags() { return mFlags; }
|
||||
const std::string& getId() const { return mId; }
|
||||
const std::string& getEventPath() const { return mEventPath; }
|
||||
const std::string& getSysPath() const { return mSysPath; }
|
||||
const std::string& getDevPath() const { return mDevPath; }
|
||||
dev_t getDevice() const { return mDevice; }
|
||||
uint64_t getSize() const { return mSize; }
|
||||
const std::string& getLabel() const { return mLabel; }
|
||||
int getFlags() const { return mFlags; }
|
||||
|
||||
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 destroy();
|
||||
|
|
|
@ -39,9 +39,9 @@ class PrivateVolume : public VolumeBase {
|
|||
public:
|
||||
PrivateVolume(dev_t device, const std::string& keyRaw);
|
||||
virtual ~PrivateVolume();
|
||||
const std::string& getFsType() { return mFsType; };
|
||||
const std::string& getRawDevPath() { return mRawDevPath; };
|
||||
const std::string& getRawDmDevPath() { return mDmDevPath; };
|
||||
const std::string& getFsType() const { return mFsType; };
|
||||
const std::string& getRawDevPath() const { return mRawDevPath; };
|
||||
const std::string& getRawDmDevPath() const { return mDmDevPath; };
|
||||
|
||||
protected:
|
||||
status_t doCreate() override;
|
||||
|
|
|
@ -153,7 +153,7 @@ status_t VolumeBase::setLabel(const std::string& label) {
|
|||
return OK;
|
||||
}
|
||||
|
||||
android::sp<android::os::IVoldListener> VolumeBase::getListener() {
|
||||
android::sp<android::os::IVoldListener> VolumeBase::getListener() const {
|
||||
if (mSilent) {
|
||||
return nullptr;
|
||||
} else {
|
||||
|
|
|
@ -78,16 +78,16 @@ class VolumeBase {
|
|||
kBadRemoval,
|
||||
};
|
||||
|
||||
const std::string& getId() { return mId; }
|
||||
const std::string& getDiskId() { return mDiskId; }
|
||||
const std::string& getPartGuid() { return mPartGuid; }
|
||||
Type getType() { return mType; }
|
||||
int getMountFlags() { return mMountFlags; }
|
||||
userid_t getMountUserId() { return mMountUserId; }
|
||||
State getState() { return mState; }
|
||||
const std::string& getPath() { return mPath; }
|
||||
const std::string& getInternalPath() { return mInternalPath; }
|
||||
const std::string& getLabel() { return mLabel; }
|
||||
const std::string& getId() const { return mId; }
|
||||
const std::string& getDiskId() const { return mDiskId; }
|
||||
const std::string& getPartGuid() const { return mPartGuid; }
|
||||
Type getType() const { return mType; }
|
||||
int getMountFlags() const { return mMountFlags; }
|
||||
userid_t getMountUserId() const { return mMountUserId; }
|
||||
State getState() const { return mState; }
|
||||
const std::string& getPath() const { return mPath; }
|
||||
const std::string& getInternalPath() const { return mInternalPath; }
|
||||
const std::string& getLabel() const { return mLabel; }
|
||||
|
||||
status_t setDiskId(const std::string& diskId);
|
||||
status_t setPartGuid(const std::string& partGuid);
|
||||
|
@ -124,7 +124,7 @@ class VolumeBase {
|
|||
status_t setInternalPath(const std::string& internalPath);
|
||||
status_t setLabel(const std::string& label);
|
||||
|
||||
android::sp<android::os::IVoldListener> getListener();
|
||||
android::sp<android::os::IVoldListener> getListener() const;
|
||||
|
||||
private:
|
||||
/* ID that uniquely references volume while alive */
|
||||
|
|
Loading…
Reference in a new issue