1 /*
2 * Copyright (c) 2024-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 #include "uri_permission_utils.h"
17
18 #include "ability_manager_errors.h"
19 #include "mock_my_flag.h"
20
21 namespace OHOS {
22 namespace AAFwk {
23 using MyFlag = OHOS::AAFwk::MyFlag;
24
SendShareUnPrivilegeUriEvent(uint32_t callerTokenId,uint32_t targetTokenId)25 bool UPMSUtils::SendShareUnPrivilegeUriEvent(uint32_t callerTokenId, uint32_t targetTokenId)
26 {
27 return true;
28 }
29
SendSystemAppGrantUriPermissionEvent(uint32_t callerTokenId,uint32_t targetTokenId,const std::vector<std::string> & uriVec,const std::vector<bool> & resVec)30 bool UPMSUtils::SendSystemAppGrantUriPermissionEvent(uint32_t callerTokenId, uint32_t targetTokenId,
31 const std::vector<std::string> &uriVec, const std::vector<bool> &resVec)
32 {
33 return true;
34 }
35
GetCurrentAccountId()36 int32_t UPMSUtils::GetCurrentAccountId()
37 {
38 return 1;
39 }
40
IsFoundationCall()41 bool UPMSUtils::IsFoundationCall()
42 {
43 return MyFlag::upmsUtilsIsFoundationCallRet_;
44 }
45
IsSAOrSystemAppCall()46 bool UPMSUtils::IsSAOrSystemAppCall()
47 {
48 return MyFlag::isSAOrSystemAppCall_ || (MyFlag::IS_SA_CALL & MyFlag::flag_) != 0;
49 }
50
IsSystemAppCall()51 bool UPMSUtils::IsSystemAppCall()
52 {
53 return MyFlag::isSystemAppCall_;
54 }
55
GetBundleApiTargetVersion(const std::string & bundleName,int32_t & targetApiVersion)56 bool UPMSUtils::GetBundleApiTargetVersion(const std::string &bundleName, int32_t &targetApiVersion)
57 {
58 return true;
59 }
60
CheckIsSystemAppByTokenId(uint32_t tokenId)61 bool UPMSUtils::CheckIsSystemAppByTokenId(uint32_t tokenId)
62 {
63 return MyFlag::upmsUtilsCheckIsSystemAppByTokenIdRet_;
64 }
65
GetDirByBundleNameAndAppIndex(const std::string & bundleName,int32_t appIndex,std::string & dirName)66 bool UPMSUtils::GetDirByBundleNameAndAppIndex(const std::string &bundleName, int32_t appIndex, std::string &dirName)
67 {
68 dirName = MyFlag::upmsUtilsAlterBundleName_;
69 return MyFlag::upmsUtilsGetDirByBundleNameAndAppIndexRet_;
70 }
71
GetAlterableBundleNameByTokenId(uint32_t tokenId,std::string & bundleName)72 bool UPMSUtils::GetAlterableBundleNameByTokenId(uint32_t tokenId, std::string &bundleName)
73 {
74 bundleName = MyFlag::upmsUtilsAlterBundleName_;
75 return MyFlag::upmsUtilsGetAlterBundleNameByTokenIdRet_;
76 }
77
GetBundleNameByTokenId(uint32_t tokenId,std::string & bundleName)78 bool UPMSUtils::GetBundleNameByTokenId(uint32_t tokenId, std::string &bundleName)
79 {
80 bundleName = MyFlag::upmsUtilsBundleName_;
81 return MyFlag::upmsUtilsGetBundleNameByTokenIdRet_;
82 }
83
GetAppIdByBundleName(const std::string & bundleName,std::string & appId)84 int32_t UPMSUtils::GetAppIdByBundleName(const std::string &bundleName, std::string &appId)
85 {
86 appId = MyFlag::upmsUtilsAppId_;
87 return MyFlag::upmsUtilsGetAppIdByBundleNameRet_;
88 }
89
GetTokenIdByBundleName(const std::string & bundleName,int32_t appIndex,uint32_t & tokenId)90 int32_t UPMSUtils::GetTokenIdByBundleName(const std::string &bundleName, int32_t appIndex, uint32_t &tokenId)
91 {
92 tokenId = MyFlag::upmsUtilsTokenId_;
93 return MyFlag::getTokenIdByBundleNameStatus_;
94 }
95
CheckUriTypeIsValid(Uri & uri)96 bool UPMSUtils::CheckUriTypeIsValid(Uri &uri)
97 {
98 return MyFlag::isUriTypeValid_;
99 }
100
IsDocsCloudUri(Uri & uri)101 bool UPMSUtils::IsDocsCloudUri(Uri &uri)
102 {
103 return MyFlag::isDocsCloudUri_;
104 }
105 } // namespace AAFwk
106 } // namespace OHOS
107