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 OHOS_ABILITY_RUNTIME_URI_PERMISSION_EVENT_H 17 #define OHOS_ABILITY_RUNTIME_URI_PERMISSION_EVENT_H 18 19 #include "bundle_mgr_helper.h" 20 #include "event_report.h" 21 #include "uri.h" 22 23 namespace OHOS { 24 namespace AAFwk { 25 26 class UPMSUtils { 27 public: 28 static bool SendShareUnPrivilegeUriEvent(uint32_t callTokenId, uint32_t targetTokenId); 29 static bool SendSystemAppGrantUriPermissionEvent(uint32_t callerTokenId, uint32_t targetTokenId, 30 const std::vector<std::string> &uriVec, const std::vector<int32_t> &resVec); 31 static int32_t GetCurrentAccountId(); 32 static bool IsFoundationCall(); 33 static bool IsSAOrSystemAppCall(); 34 static bool IsSystemAppCall(uint32_t tokenId); 35 static bool CheckIsSystemAppByTokenId(uint32_t tokenId); 36 static bool GetDirByBundleNameAndAppIndex(const std::string &bundleName, int32_t appIndex, std::string &dirName); 37 static bool GetBundleNameByTokenId(uint32_t tokenId, std::string &bundleName); 38 static bool GetAlterableBundleNameByTokenId(uint32_t tokenId, std::string &bundleName); 39 static int32_t GetAppIdByBundleName(const std::string &bundleName, std::string &appId); 40 static int32_t GetTokenIdByBundleName(const std::string &bundleName, int32_t appIndex, uint32_t &tokenId); 41 static bool CheckUriTypeIsValid(Uri &uri); 42 static bool GetBundleApiTargetVersion(const std::string &bundleName, int32_t &targetApiVersion); 43 static bool IsDocsCloudUri(Uri &uri); 44 45 private: 46 static std::shared_ptr<AppExecFwk::BundleMgrHelper> ConnectManagerHelper(); 47 static bool CheckAndCreateEventInfo(uint32_t callerTokenId, uint32_t targetTokenId, EventInfo &eventInfo); 48 static bool CheckIsSystemAppByBundleName(std::string &bundleName); 49 50 private: 51 static std::shared_ptr<AppExecFwk::BundleMgrHelper> bundleMgrHelper_; 52 }; 53 } // OHOS 54 } // AAFwk 55 #endif // OHOS_ABILITY_RUNTIME_URI_PERMISSION_EVENT_H