1 /* 2 * Copyright (c) 2025 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_INSIGHT_INTENT_DB_CACHE_H 17 #define OHOS_INSIGHT_INTENT_DB_CACHE_H 18 19 #include <gtest/gtest.h> 20 #include <gmock/gmock.h> 21 #include <mutex> 22 #include <set> 23 #include <singleton.h> 24 #include <vector> 25 #include "insight_intent_rdb_storage_mgr.h" 26 27 namespace OHOS { 28 namespace AbilityRuntime { 29 class InsightIntentDbCache : public std::enable_shared_from_this<InsightIntentDbCache> { 30 DECLARE_DELAYED_SINGLETON(InsightIntentDbCache) 31 public: 32 void InitInsightIntentCache(const int32_t userId); 33 void GetAllInsightIntentGenericInfo(std::vector<ExtractInsightIntentGenericInfo> &genericInfos); 34 void GetInsightIntentGenericInfoByName(const std::string &bundleName, 35 std::vector<ExtractInsightIntentGenericInfo> &genericInfos); 36 void GetInsightIntentGenericInfo(const std::string &bundleName, const std::string &moduleName, 37 const std::string &intentName, ExtractInsightIntentGenericInfo &genericInfos); 38 void GetAllInsightIntentInfo(const int32_t userId, std::vector<ExtractInsightIntentInfo> &infos); 39 void GetInsightIntentInfoByName(const std::string &bundleName, const int32_t userId, 40 std::vector<ExtractInsightIntentInfo> &infos); 41 void GetInsightIntentInfo(const std::string &bundleName, const std::string &moduleName, 42 const std::string &intentName, const int32_t userId, ExtractInsightIntentInfo &infos); 43 int32_t SaveInsightIntentTotalInfo(const std::string &bundleName, const std::string &moduleName, 44 const int32_t userId, ExtractInsightIntentProfileInfoVec profileInfos); 45 int32_t DeleteInsightIntentTotalInfo(const std::string &bundleName, 46 const std::string &moduleName, const int32_t userId); 47 int32_t DeleteInsightIntentByUserId(const int32_t userId); 48 private: 49 int32_t userId_ = -1; 50 mutable std::mutex genericInfosMutex_; 51 std::map<std::string, std::vector<ExtractInsightIntentGenericInfo>> intentGenericInfos_; 52 }; 53 } // namespace AbilityRuntime 54 } // namespace OHOS 55 #endif // OHOS_INSIGHT_INTENT_DB_CACHE_H 56