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 <singleton.h> 20 #include "volume_external.h" 21 #include "storage_rl_map.h" 22 23 namespace OHOS { 24 namespace StorageManager { 25 class VolumeManagerService : public NoCopyable { 26 DECLARE_DELAYED_SINGLETON(VolumeManagerService); 27 public: 28 int32_t Mount(std::string volumeId); 29 int32_t Unmount(std::string volumeId); 30 void OnVolumeCreated(VolumeCore vc); 31 void OnVolumeMounted(std::string volumeId, int32_t fsType, std::string fsUuid, 32 std::string path, std::string description); 33 void OnVolumeStateChanged(std::string volumeId, VolumeState state); 34 std::vector<VolumeExternal> GetAllVolumes(); 35 std::shared_ptr<VolumeExternal> GetVolumeByUuid(std::string volumeUuid); 36 int32_t GetVolumeByUuid(std::string fsUuid, VolumeExternal &vc); 37 int32_t GetVolumeById(std::string volumeId, VolumeExternal &vc); 38 int32_t SetVolumeDescription(std::string fsUuid, std::string description); 39 int32_t Format(std::string volumeId, std::string fsType); 40 void NotifyMtpMounted(const std::string &id, const std::string &path, const std::string &desc, 41 const std::string &uuid); 42 void NotifyMtpUnmounted(const std::string &id, const std::string &path, const bool isBadRemove); 43 44 private: 45 StorageService::StorageRlMap<std::string, std::shared_ptr<VolumeExternal>> volumeMap_; 46 void VolumeStateNotify(VolumeState state, std::shared_ptr<VolumeExternal> volume); 47 int32_t Check(std::string volumeId); 48 }; 49 } // StorageManager 50 } // OHOS 51 52 #endif // OHOS_STORAGE_MANAGER_VOLUME_MANAGER_SERVICE_H 53