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 SERVICES_SAMGR_NATIVE_INCLUDE_SYSTEM_ABILITY_MANAGER_UTIL_H 17 #define SERVICES_SAMGR_NATIVE_INCLUDE_SYSTEM_ABILITY_MANAGER_UTIL_H 18 19 #include <string> 20 #include <list> 21 22 #include "sa_profiles.h" 23 #include "system_ability_on_demand_event.h" 24 #include "ffrt_handler.h" 25 26 namespace OHOS { 27 class SamgrUtil { 28 public: 29 ~SamgrUtil(); 30 static bool IsNameInValid(const std::u16string& name); 31 static void ParseRemoteSaName(const std::u16string& name, std::string& deviceId, std::u16string& saName); 32 static bool CheckDistributedPermission(); 33 static bool IsSameEvent(const OnDemandEvent& event, std::list<OnDemandEvent>& enableOnceList); 34 static std::string EventToStr(const OnDemandEvent& event); 35 static std::string TransformDeviceId(const std::string& deviceId, int32_t type, bool isPrivate); 36 static bool CheckCallerProcess(const SaProfile& saProfile); 37 static bool CheckCallerProcess(const std::string& callProcess); 38 static bool CheckAllowUpdate(OnDemandPolicyType type, const SaProfile& saProfile); 39 static void ConvertToOnDemandEvent(const SystemAbilityOnDemandEvent& from, OnDemandEvent& to); 40 static void ConvertToSystemAbilityOnDemandEvent(const OnDemandEvent& from, SystemAbilityOnDemandEvent& to); 41 static uint64_t GenerateFreKey(int32_t uid, int32_t saId); 42 static std::list<int32_t> GetCacheCommonEventSa(const OnDemandEvent& event, 43 const std::list<SaControlInfo>& saControlList); 44 static void SetModuleUpdateParam(const std::string& key, const std::string& value); 45 static void SendUpdateSaState(int32_t systemAbilityId, const std::string& updateSaState); 46 static void InvalidateSACache(); 47 private: 48 static std::shared_ptr<FFRTHandler> setParmHandler_; 49 }; 50 } // namespace OHOS 51 52 #endif // !defined(SERVICES_SAMGR_NATIVE_INCLUDE_SYSTEM_ABILITY_MANAGER_UTIL_H) 53