Mike Lockwood | 5bae7f6 | 2010-05-19 10:33:39 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 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 | |
Mike Lockwood | 90f4873 | 2010-06-05 22:45:01 -0400 | [diff] [blame] | 17 | #define LOG_TAG "MtpStorageInfo" |
Mike Lockwood | 5bae7f6 | 2010-05-19 10:33:39 -0400 | [diff] [blame] | 18 | |
Mike Lockwood | 3e6616d | 2010-06-29 18:11:52 -0400 | [diff] [blame] | 19 | #include "MtpDebug.h" |
Mike Lockwood | 5bae7f6 | 2010-05-19 10:33:39 -0400 | [diff] [blame] | 20 | #include "MtpDataPacket.h" |
| 21 | #include "MtpStorageInfo.h" |
| 22 | #include "MtpStringBuffer.h" |
| 23 | |
| 24 | namespace android { |
| 25 | |
| 26 | MtpStorageInfo::MtpStorageInfo(MtpStorageID id) |
| 27 | : mStorageID(id), |
| 28 | mStorageType(0), |
| 29 | mFileSystemType(0), |
| 30 | mAccessCapability(0), |
| 31 | mMaxCapacity(0), |
| 32 | mFreeSpaceBytes(0), |
| 33 | mFreeSpaceObjects(0), |
| 34 | mStorageDescription(NULL), |
| 35 | mVolumeIdentifier(NULL) |
| 36 | { |
| 37 | } |
| 38 | |
| 39 | MtpStorageInfo::~MtpStorageInfo() { |
| 40 | if (mStorageDescription) |
| 41 | free(mStorageDescription); |
| 42 | if (mVolumeIdentifier) |
| 43 | free(mVolumeIdentifier); |
| 44 | } |
| 45 | |
| 46 | void MtpStorageInfo::read(MtpDataPacket& packet) { |
| 47 | MtpStringBuffer string; |
| 48 | |
| 49 | // read the device info |
| 50 | mStorageType = packet.getUInt16(); |
| 51 | mFileSystemType = packet.getUInt16(); |
| 52 | mAccessCapability = packet.getUInt16(); |
| 53 | mMaxCapacity = packet.getUInt64(); |
| 54 | mFreeSpaceBytes = packet.getUInt64(); |
| 55 | mFreeSpaceObjects = packet.getUInt32(); |
| 56 | |
| 57 | packet.getString(string); |
| 58 | mStorageDescription = strdup((const char *)string); |
| 59 | packet.getString(string); |
| 60 | mVolumeIdentifier = strdup((const char *)string); |
| 61 | } |
| 62 | |
| 63 | void MtpStorageInfo::print() { |
Mike Lockwood | 90f4873 | 2010-06-05 22:45:01 -0400 | [diff] [blame] | 64 | LOGD("Storage Info %08X:\n\tmStorageType: %d\n\tmFileSystemType: %d\n\tmAccessCapability: %d\n", |
Mike Lockwood | 5bae7f6 | 2010-05-19 10:33:39 -0400 | [diff] [blame] | 65 | mStorageID, mStorageType, mFileSystemType, mAccessCapability); |
Mike Lockwood | 90f4873 | 2010-06-05 22:45:01 -0400 | [diff] [blame] | 66 | LOGD("\tmMaxCapacity: %lld\n\tmFreeSpaceBytes: %lld\n\tmFreeSpaceObjects: %d\n", |
Mike Lockwood | 5bae7f6 | 2010-05-19 10:33:39 -0400 | [diff] [blame] | 67 | mMaxCapacity, mFreeSpaceBytes, mFreeSpaceObjects); |
Mike Lockwood | 90f4873 | 2010-06-05 22:45:01 -0400 | [diff] [blame] | 68 | LOGD("\tmStorageDescription: %s\n\tmVolumeIdentifier: %s\n", |
Mike Lockwood | 5bae7f6 | 2010-05-19 10:33:39 -0400 | [diff] [blame] | 69 | mStorageDescription, mVolumeIdentifier); |
| 70 | } |
| 71 | |
| 72 | } // namespace android |