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