• 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 
16 #include "libraryloader.h"
17 #include <string>
18 #include "access_token_error.h"
19 #include "ability_manager_access_loader.h"
20 
21 namespace OHOS {
22 namespace Security {
23 namespace AccessToken {
24 namespace {
25 static constexpr uint32_t INVALID_INDEX = 0;
26 }
27 
28 class AbilityManagerAccessLoaderMock final: public AbilityManagerAccessLoaderInterface {
29     int32_t StartAbility(const InnerWant &innerWant, const sptr<IRemoteObject> &callerToken) override;
30     int32_t KillProcessForPermissionUpdate(uint32_t accessTokenId) override;
31 };
32 
StartAbility(const InnerWant & innerWant,const sptr<IRemoteObject> & callerToken)33 int32_t AbilityManagerAccessLoaderMock::StartAbility(const InnerWant &innerWant,
34     const sptr<IRemoteObject> &callerToken)
35 {
36     if (innerWant.hapAppIndex.value_or(INVALID_INDEX) == INVALID_INDEX) {
37         return AccessTokenError::ERR_SERVICE_ABNORMAL;
38     }
39     return ERR_OK;
40 }
41 
KillProcessForPermissionUpdate(uint32_t accessTokenId)42 int32_t AbilityManagerAccessLoaderMock::KillProcessForPermissionUpdate(uint32_t accessTokenId)
43 {
44     return ERR_OK;
45 }
46 
LibraryLoader(const std::string & path)47 LibraryLoader::LibraryLoader(const std::string& path)
48 {
49     instance_ = new (std::nothrow) AbilityManagerAccessLoaderMock();
50     handle_ = nullptr;
51 }
52 
~LibraryLoader()53 LibraryLoader::~LibraryLoader()
54 {}
55 
PrintErrorLog(const std::string & targetName)56 void LibraryLoader::PrintErrorLog(const std::string& targetName)
57 {}
58 
Create()59 void LibraryLoader::Create()
60 {}
61 
Destroy()62 void LibraryLoader::Destroy()
63 {}
64 } // AccessToken
65 } // Security
66 } // OHOS