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 #ifndef OHOS_STORAGE_MANAGER_VOLUME_MANAGER_SERVICE_H 17 #define OHOS_STORAGE_MANAGER_VOLUME_MANAGER_SERVICE_H 18 19 #include "volume_external.h" 20 #include "storage_rl_map.h" 21 22 namespace OHOS { 23 namespace StorageManager { 24 class VolumeManagerService { 25 public: GetInstance(void)26 static VolumeManagerService &GetInstance(void) 27 { 28 static VolumeManagerService instance; 29 return instance; 30 } 31 int32_t Mount(std::string volumeId); 32 int32_t Unmount(std::string volumeId); 33 int32_t MountUsbFuse(const std::string &volumeId); 34 int32_t TryToFix(std::string volumeId); 35 void OnVolumeCreated(VolumeCore vc); 36 void OnVolumeMounted(const std::string &volumeId, const std::string &fsTypeStr, 37 const std::string &fsUuid, const std::string &path, 38 const std::string &description); 39 void OnVolumeDamaged(const std::string &volumeId, const std::string &fsTypeStr, 40 const std::string &fsUuid, const std::string &path, 41 const std::string &description); 42 void OnVolumeStateChanged(std::string volumeId, VolumeState state); 43 std::vector<VolumeExternal> GetAllVolumes(); 44 std::shared_ptr<VolumeExternal> GetVolumeByUuid(std::string volumeUuid); 45 int32_t GetVolumeByUuid(std::string fsUuid, VolumeExternal &vc); 46 int32_t GetVolumeById(std::string volumeId, VolumeExternal &vc); 47 int32_t SetVolumeDescription(std::string fsUuid, std::string description); 48 int32_t Format(std::string volumeId, std::string fsType); 49 void NotifyMtpMounted(const std::string &id, const std::string &path, const std::string &desc, 50 const std::string &uuid); 51 void NotifyMtpUnmounted(const std::string &id, const std::string &path, const bool isBadRemove); 52 53 private: 54 VolumeManagerService(); 55 ~VolumeManagerService(); 56 VolumeManagerService(const VolumeManagerService &) = delete; 57 VolumeManagerService &operator=(const VolumeManagerService &) = delete; 58 VolumeManagerService(const VolumeManagerService &&) = delete; 59 VolumeManagerService &operator=(const VolumeManagerService &&) = delete; 60 StorageService::StorageRlMap<std::string, std::shared_ptr<VolumeExternal>> volumeMap_; 61 void VolumeStateNotify(VolumeState state, std::shared_ptr<VolumeExternal> volume); 62 int32_t Check(std::string volumeId); 63 }; 64 } // StorageManager 65 } // OHOS 66 67 #endif // OHOS_STORAGE_MANAGER_VOLUME_MANAGER_SERVICE_H 68