8.1 mtp模式,查看手机容量大小修改
mt6580v178\frameworks\av\media\mtp\MtpStorage.h
namespace android {
class MtpDatabase;
class MtpStorage {
private:
MtpStorageID mStorageID;
MtpString mFilePath;
MtpString mDescription;
uint64_t mMaxCapacity;
uint64_t mMaxFileSize;
// amount of free space to leave unallocated
uint64_t mReserveSpace;
bool mRemovable;
public:
MtpStorage(MtpStorageID id, const char* filePath,
const char* description, uint64_t reserveSpace,
bool removable, uint64_t maxFileSize);
virtual ~MtpStorage();
inline MtpStorageID getStorageID() const { return mStorageID; }
int getType() const;
int getFileSystemType() const;
int getAccessCapability() const;
uint64_t getMaxCapacity();
uint64_t getFreeSpace();
const char* getDescription() const;
inline const char* getPath() const { return (const char *)mFilePath; }
inline bool isRemovable() const { return mRemovable; }
inline uint64_t getMaxFileSize() const { return mMaxFileSize; }
bool isInternalStorage(); //zxw add for frameworks/av/media/mtp/MtpStorage.cpp:64:18: error: out-of-line definition of 'isInternalStorage' does not match any declaration in 'android::MtpStorage'
};
}; // namespace android
mt6580v178\frameworks\av\media\mtp\MtpStorage.cpp
//zxw add start
bool MtpStorage::isInternalStorage() {
bool isInternalStorage = false;
ALOGE("zxw MtpStorage isInternalStorage=>path = %s \n", getPath());
const char* token = "/storage/emulated/0";
if (strcmp(getPath(), token) == 0)
{
isInternalStorage = true;
}
ALOGE("zxw MtpStorage isInternalStorage = %d \n", isInternalStorage);
return isInternalStorage;
}
//zxw add end
uint64_t MtpStorage::getMaxCapacity() {
if (mMaxCapacity == 0) {
struct statfs stat;
if (statfs(getPath(), &stat))
return -1;
mMaxCapacity = (uint64_t)stat.f_blocks * (uint64_t)stat.f_bsize;
}
//zxw add start
if(isInternalStorage()){ //noly modify for cellphone internalstorage not sd
ALOGE("zxw interstorage MtpStorage mMaxCapacity\n");
struct statfs stat;
if (statfs(getPath(), &stat))
return -1;
return (uint64_t) 16L * 1024 * 1024 * 1024;
}else{
return mMaxCapacity;
}
//zxw add end
}