1 /* 2 * Copyright (c) 2024 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 ATOMICSERVICE_BASIC_ENGINE_PLUGIN 17 #define ATOMICSERVICE_BASIC_ENGINE_PLUGIN 18 19 #include <string> 20 #include <dlfcn.h> 21 #include <mutex> 22 23 #include "parcel.h" 24 25 namespace OHOS::Ace::NG { 26 #ifdef ATOMIC_SERVICE_ATTRIBUTION_ENABLE 27 class AtomicserviceIconInfo : public virtual Parcelable { 28 public: AtomicserviceIconInfo()29 AtomicserviceIconInfo() {} 30 virtual ~AtomicserviceIconInfo() = default; 31 32 // The following functions are used to get data 33 std::string GetBundleName() const; 34 std::string GetModuleName() const; 35 std::string GetAbilityName() const; 36 std::string GetCircleIcon() const; 37 std::string GetEyelashRingIcon() const; 38 std::string GetAppName() const; 39 40 // The following functions are used to set data 41 void SetBundleName(const std::string& val); 42 void SetModuleName(const std::string& val); 43 void SetAbilityName(const std::string& val); 44 void SetCircleIcon(const std::string& val); 45 void SetEyelashRingIcon(const std::string& val); 46 void SetAppName(const std::string& val); 47 48 // The following functions are used for serialization and deserialization 49 bool Marshalling(Parcel& parcel) const override; 50 static AtomicserviceIconInfo *Unmarshalling(Parcel& parcel); 51 52 private: 53 // Member variable 54 std::string bundleName_; 55 std::string moduleName_; 56 std::string abilityName_; 57 std::string circleIcon_; 58 std::string eyelashRingIcon_; 59 std::string appName_; 60 }; 61 62 class AtomicServiceBasicEnginePlugin { 63 private: 64 AtomicServiceBasicEnginePlugin(); 65 ~AtomicServiceBasicEnginePlugin(); 66 67 typedef int32_t GetAtomicserviceIconInfoPlugin( 68 std::string bundleName, AtomicserviceIconInfo** atomicserviceIconInfo); 69 typedef void FreeData(AtomicserviceIconInfo* data); 70 71 std::mutex mutex_; 72 void* atomicServiceBasicEngine_ = nullptr; 73 AtomicserviceIconInfo* atomicserviceIconInfo_ = nullptr; 74 GetAtomicserviceIconInfoPlugin* getAtomicserviceIconInfoPlugin = nullptr; 75 FreeData* freeData = nullptr; 76 77 public: 78 static AtomicServiceBasicEnginePlugin& GetInstance(); 79 int32_t releaseData(); 80 std::vector<std::string> getParamsFromAtomicServiceBasicEngine(const std::string& bundleName); 81 }; // AtomicServiceBasicEnginePlugin 82 #endif // ATOMIC_SERVICE_ATTRIBUTION_ENABLE 83 } // namespace OHOS::Ace::NG 84 #endif // ATOMICSERVICE_BASIC_ENGINE_PLUGIN 85