1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include "volume_external.h" 17 #include "volume/notification.h" 18 #include "disk.h" 19 #include "disk/disk_manager_service.h" 20 21 namespace OHOS { 22 namespace StorageManager { VolumeExternal()23VolumeExternal::VolumeExternal() {} 24 VolumeExternal(VolumeCore vc)25VolumeExternal::VolumeExternal(VolumeCore vc) 26 : VolumeExternal::VolumeCore(vc.GetId(), vc.GetType(), vc.GetDiskId(), vc.GetState()) {} 27 SetFsType(int32_t fsType)28void VolumeExternal::SetFsType(int32_t fsType) 29 { 30 fsType_ = fsType; 31 } 32 SetFsUuid(std::string fsUuid)33void VolumeExternal::SetFsUuid(std::string fsUuid) 34 { 35 fsUuid_ = fsUuid; 36 } 37 SetPath(std::string path)38void VolumeExternal::SetPath(std::string path) 39 { 40 path_ = path; 41 } 42 SetDescription(std::string description)43void VolumeExternal::SetDescription(std::string description) 44 { 45 description_ = description; 46 } 47 GetFsType()48int32_t VolumeExternal::GetFsType() 49 { 50 return fsType_; 51 } 52 GetUuid()53std::string VolumeExternal::GetUuid() 54 { 55 return fsUuid_; 56 } 57 GetPath()58std::string VolumeExternal::GetPath() 59 { 60 return path_; 61 } 62 GetDescription()63std::string VolumeExternal::GetDescription() 64 { 65 return description_; 66 } 67 Reset()68void VolumeExternal::Reset() 69 { 70 fsType_ = UNDEFINED; 71 fsUuid_ = ""; 72 path_ = ""; 73 } 74 Marshalling(Parcel & parcel) const75bool VolumeExternal::Marshalling(Parcel &parcel) const 76 { 77 VolumeCore::Marshalling(parcel); 78 parcel.WriteInt32(fsType_); 79 parcel.WriteString(fsUuid_); 80 parcel.WriteString(path_); 81 parcel.WriteString(description_); 82 return true; 83 } 84 Unmarshalling(Parcel & parcel)85std::unique_ptr<VolumeExternal> VolumeExternal::Unmarshalling(Parcel &parcel) 86 { 87 auto obj = std::make_unique<VolumeExternal>(*VolumeCore::Unmarshalling(parcel)); 88 obj->fsType_ = parcel.ReadInt32(); 89 obj->fsUuid_ = parcel.ReadString(); 90 obj->path_ = parcel.ReadString(); 91 obj->description_ = parcel.ReadString(); 92 return obj; 93 } 94 } 95 }