1 /* 2 * Copyright (C) 2021-2022 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_MTP_STORAGE_MANAGER 17 #define OHOS_MTP_STORAGE_MANAGER 18 19 #include <string> 20 #include <iostream> 21 #include <memory> 22 #include <vector> 23 24 #include "mtp_constants.h" 25 #include "storage_manager_proxy.h" 26 #include "storage.h" 27 28 namespace OHOS { 29 namespace Media { 30 class MtpStorageManager { 31 public: 32 ~MtpStorageManager(); 33 static std::shared_ptr<MtpStorageManager> GetInstance(); 34 int64_t GetTotalSize(); 35 int64_t GetFreeSize(); 36 static std::mutex mutex_; 37 static std::shared_ptr<MtpStorageManager> instance_; 38 void AddStorage(std::shared_ptr<Storage> &storage); 39 void RemoveStorage(std::shared_ptr<Storage> &storage); 40 std::shared_ptr<Storage> GetStorage(uint32_t id); 41 bool HasStorage(uint32_t id = MTP_STORAGE_ID_ALL2); 42 std::vector<std::shared_ptr<Storage>> GetStorages(); 43 private: 44 MtpStorageManager(); 45 sptr<StorageManager::IStorageManager> proxy_; 46 std::vector<std::shared_ptr<Storage>> storages; 47 }; 48 } // namespace Media 49 } // namespace OHOS 50 #endif // OHOS_MTP_STORAGE_MANAGER 51