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 "ability_manager_access_loader.h"
16 
17 #include "ability_manager_client.h"
18 
19 namespace OHOS {
20 namespace Security {
21 namespace AccessToken {
StartAbility(const AAFwk::Want & want,const sptr<IRemoteObject> & callerToken,int32_t requestCode,int32_t userId)22 int32_t AbilityManagerAccessLoader::StartAbility(
23     const AAFwk::Want &want, const sptr<IRemoteObject> &callerToken, int32_t requestCode, int32_t userId)
24 {
25 #ifdef ABILITY_RUNTIME_ENABLE
26     return AAFwk::AbilityManagerClient::GetInstance()->StartAbility(want, callerToken, requestCode, userId);
27 #else
28     return 0;
29 #endif
30 }
31 
32 extern "C" {
Create()33 void* Create()
34 {
35     return reinterpret_cast<void*>(new AbilityManagerAccessLoader);
36 }
37 
Destroy(void * loaderPtr)38 void Destroy(void* loaderPtr)
39 {
40     AbilityManagerAccessLoaderInterface* loader = reinterpret_cast<AbilityManagerAccessLoaderInterface*>(loaderPtr);
41     if (loader != nullptr) {
42         delete loader;
43     }
44 }
45 }
46 } // namespace AccessToken
47 } // namespace Security
48 } // namespace OHOS
49