• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "mock_permission_mgr.h"
16 #include "permission_manager.h"
17 #include <utility>
18 namespace OHOS::AppDomainVerify {
19 static std::shared_ptr<MocIPermissionManager> g_mocPermissionManager = nullptr;
DoMocPermissionManager(std::shared_ptr<MocIPermissionManager> moc)20 void DoMocPermissionManager(std::shared_ptr<MocIPermissionManager> moc)
21 {
22     g_mocPermissionManager = std::move(moc);
23 }
CheckPermission(const std::string & permission)24 bool PermissionManager::CheckPermission(const std::string& permission)
25 {
26     if (g_mocPermissionManager) {
27         return g_mocPermissionManager->CheckPermission(permission);
28     }
29     return true;
30 }
IsSystemAppCall()31 bool PermissionManager::IsSystemAppCall()
32 {
33     if (g_mocPermissionManager) {
34         return g_mocPermissionManager->IsSystemAppCall();
35     }
36     return true;
37 }
IsSACall()38 bool PermissionManager::IsSACall()
39 {
40     if (g_mocPermissionManager) {
41         return g_mocPermissionManager->IsSACall();
42     }
43     return true;
44 }
45 }