blob: ca64ac08f617e38482e8385131a69c1c33334d6f [file] [log] [blame]
Mike Lockwood5bae7f62010-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
Mike Lockwood90f48732010-06-05 22:45:01 -040017#define LOG_TAG "MtpStorageInfo"
Mike Lockwood5bae7f62010-05-19 10:33:39 -040018
Mike Lockwood3e6616d2010-06-29 18:11:52 -040019#include "MtpDebug.h"
Mike Lockwood5bae7f62010-05-19 10:33:39 -040020#include "MtpDataPacket.h"
21#include "MtpStorageInfo.h"
22#include "MtpStringBuffer.h"
23
24namespace android {
25
26MtpStorageInfo::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
39MtpStorageInfo::~MtpStorageInfo() {
40 if (mStorageDescription)
41 free(mStorageDescription);
42 if (mVolumeIdentifier)
43 free(mVolumeIdentifier);
44}
45
46void 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
63void MtpStorageInfo::print() {
Mike Lockwood90f48732010-06-05 22:45:01 -040064 LOGD("Storage Info %08X:\n\tmStorageType: %d\n\tmFileSystemType: %d\n\tmAccessCapability: %d\n",
Mike Lockwood5bae7f62010-05-19 10:33:39 -040065 mStorageID, mStorageType, mFileSystemType, mAccessCapability);
Mike Lockwood90f48732010-06-05 22:45:01 -040066 LOGD("\tmMaxCapacity: %lld\n\tmFreeSpaceBytes: %lld\n\tmFreeSpaceObjects: %d\n",
Mike Lockwood5bae7f62010-05-19 10:33:39 -040067 mMaxCapacity, mFreeSpaceBytes, mFreeSpaceObjects);
Mike Lockwood90f48732010-06-05 22:45:01 -040068 LOGD("\tmStorageDescription: %s\n\tmVolumeIdentifier: %s\n",
Mike Lockwood5bae7f62010-05-19 10:33:39 -040069 mStorageDescription, mVolumeIdentifier);
70}
71
72} // namespace android