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_MEDIALIBRARY_DEVICE_OPERATIONS_H 17 #define OHOS_MEDIALIBRARY_DEVICE_OPERATIONS_H 18 19 #include <string> 20 #include <variant> 21 #include <grp.h> 22 #include <securec.h> 23 #include <stdlib.h> 24 #include <unistd.h> 25 26 #include "album_asset.h" 27 #ifdef DISTRIBUTED 28 #include "device_manager.h" 29 #endif 30 #include "dm_device_info.h" 31 #include "medialibrary_data_manager_utils.h" 32 #include "medialibrary_db_const.h" 33 #include "medialibrary_device_db.h" 34 #include "medialibrary_device_info.h" 35 #include "rdb_store.h" 36 #include "values_bucket.h" 37 38 namespace OHOS { 39 namespace Media { 40 class MediaLibraryDeviceOperations { 41 public: 42 MediaLibraryDeviceOperations() = delete; 43 ~MediaLibraryDeviceOperations() = delete; 44 45 static bool InsertDeviceInfo(const std::shared_ptr<NativeRdb::RdbStore> &rdbStore, 46 const OHOS::Media::MediaLibraryDeviceInfo &deviceInfo, const std::string &bundleName); 47 static bool UpdateDeviceInfo(const shared_ptr<MediaLibraryRdbStore> rdbStore, 48 const OHOS::Media::MediaLibraryDeviceInfo &deviceInfo, const std::string &bundleName); 49 static bool DeleteDeviceInfo(const std::shared_ptr<NativeRdb::RdbStore> &rdbStore, const std::string &udid); 50 static bool UpdateSyncStatus(const std::shared_ptr<NativeRdb::RdbStore> &rdbStore, const std::string &udid, 51 const std::string &tableName, int32_t syncStatus); 52 static bool GetSyncStatusById(const std::shared_ptr<NativeRdb::RdbStore> &rdbStore, const std::string &udid, 53 const std::string &tableName, int32_t &syncStatus); 54 static bool QueryDeviceTable(const std::shared_ptr<NativeRdb::RdbStore> &rdbStore, 55 std::map<std::string, std::set<int>> &excludeMap); 56 static bool GetAllDeviceData(const std::shared_ptr<NativeRdb::RdbStore> &rdbStore, 57 std::vector<MediaLibraryDeviceInfo> &outDeviceList); 58 static bool GetAgingDeviceData(const std::shared_ptr<RdbStore> &rdbStore, 59 std::vector<MediaLibraryDeviceInfo> &outDeviceList); 60 static bool GetAllDeviceUdid(const std::shared_ptr<RdbStore> &rdbStore, 61 std::vector<string> &deviceUdids); 62 }; 63 } // namespace Media 64 } // namespace OHOS 65 #endif // OHOS_MEDIALIBRARY_DEVICE_OPERATIONS_H 66