1 /*
2 * Copyright (c) 2020 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 "ability_kit.h"
17 #include "ability_service.h"
18
19 namespace OHOS {
RegisterReceiver(const char * bundleName,SuccessCallback success,FailCallback fail,uint32_t successCallbackFunc,uint32_t failCallbackFunc,uint32_t context)20 int32_t AbilityKit::RegisterReceiver(const char *bundleName, SuccessCallback success, FailCallback fail,
21 uint32_t successCallbackFunc, uint32_t failCallbackFunc, uint32_t context)
22 {
23 return AbilityService::GetInstance().RegisterReceiver(bundleName, success, fail, successCallbackFunc,
24 failCallbackFunc, context);
25 }
26
UnregisterReceiver(const char * bundleName)27 int32_t AbilityKit::UnregisterReceiver(const char *bundleName)
28 {
29 return AbilityService::GetInstance().UnregisterReceiver(bundleName);
30 }
31
SendMsgToPeerApp(bool isLocalMsg,const char * callingPkgName,const char * calledPkgName,const uint8_t * msgBody,uint32_t length,uint32_t successCallbackFunc,uint32_t failCallbackFunc,uint32_t context)32 int32_t AbilityKit::SendMsgToPeerApp(bool isLocalMsg, const char *callingPkgName,
33 const char *calledPkgName, const uint8_t *msgBody, uint32_t length,
34 uint32_t successCallbackFunc, uint32_t failCallbackFunc, uint32_t context)
35 {
36 return AbilityService::GetInstance().SendMsgToPeerApp(isLocalMsg, callingPkgName, calledPkgName,
37 msgBody, length, successCallbackFunc, failCallbackFunc, context);
38 }
39
DetectPhoneApp(const char * callingPkgName,const char * calledPkgName,uint32_t successCallbackFunc,uint32_t failCallbackFunc,uint32_t context)40 int32_t AbilityKit::DetectPhoneApp(const char *callingPkgName, const char *calledPkgName, uint32_t successCallbackFunc,
41 uint32_t failCallbackFunc, uint32_t context)
42 {
43 return AbilityService::GetInstance().DetectPhoneApp(callingPkgName, calledPkgName, successCallbackFunc,
44 failCallbackFunc, context);
45 }
46
DetectResourceRelease()47 int32_t AbilityKit::DetectResourceRelease()
48 {
49 return AbilityService::GetInstance().DetectResourceRelease();
50 }
51
SendMsgResourceRelease()52 int32_t AbilityKit::SendMsgResourceRelease()
53 {
54 return AbilityService::GetInstance().SendMsgResourceRelease();
55 }
56 } // namespace OHOS
57
58 #ifdef __LITEOS_M__
59 extern "C" {
RegisterReceiver(const char * bundleName,SuccessCallback success,FailCallback fail)60 int32_t RegisterReceiver(const char *bundleName, SuccessCallback success, FailCallback fail)
61 {
62 return OHOS::AbilityKit::RegisterReceiver(bundleName, success, fail, 0, 0, 0);
63 }
64
UnregisterReceiver(const char * bundleName)65 int32_t UnregisterReceiver(const char *bundleName)
66 {
67 return OHOS::AbilityKit::UnregisterReceiver(bundleName);
68 }
69
SendMsgToPeerApp(bool isLocalMsg,const char * callingPkgName,const char * calledPkgName,const uint8_t * msgBody,uint32_t length)70 int32_t SendMsgToPeerApp(bool isLocalMsg, const char *callingPkgName, const char *calledPkgName,
71 const uint8_t *msgBody, uint32_t length)
72 {
73 return OHOS::AbilityKit::SendMsgToPeerApp(isLocalMsg, callingPkgName, calledPkgName, msgBody, length, 0, 0, 0);
74 }
75 }
76 #endif // __LITEOS_M__
77