• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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_connection_wrapper_proxy.h"
17 
18 #include "dtbschedmgr_log.h"
19 #include "ipc_object_proxy.h"
20 #include "ipc_types.h"
21 #include "parcel_helper.h"
22 
23 namespace OHOS {
24 namespace DistributedSchedule {
25 namespace {
26 const std::u16string CONNECTION_CALLBACK_INTERFACE_TOKEN = u"ohos.abilityshell.DistributedConnection";
27 const std::string TAG = "AbilityConnectionWrapperProxy";
28 }
29 
OnAbilityConnectDone(const AppExecFwk::ElementName & element,const sptr<IRemoteObject> & remoteObject,int32_t resultCode)30 void AbilityConnectionWrapperProxy::OnAbilityConnectDone(const AppExecFwk::ElementName& element,
31     const sptr<IRemoteObject>& remoteObject, int32_t resultCode)
32 {
33     HILOGD("AbilityConnectionWrapperProxy::OnAbilityConnectDone called");
34     MessageParcel data;
35     if (!data.WriteInterfaceToken(CONNECTION_CALLBACK_INTERFACE_TOKEN)) {
36         return;
37     }
38 
39     MessageParcel reply;
40     MessageOption option;
41     PARCEL_WRITE_HELPER_NORET(data, Parcelable, &element);
42     PARCEL_WRITE_HELPER_NORET(data, RemoteObject, remoteObject);
43     PARCEL_WRITE_HELPER_NORET(data, Int32, resultCode);
44     int32_t errCode = Remote()->SendRequest(IAbilityConnection::ON_ABILITY_CONNECT_DONE, data, reply, option);
45     HILOGD("AbilityConnectionWrapperProxy::OnAbilityConnectDone result %{public}d", errCode);
46 }
47 
OnAbilityDisconnectDone(const AppExecFwk::ElementName & element,int32_t resultCode)48 void AbilityConnectionWrapperProxy::OnAbilityDisconnectDone(const AppExecFwk::ElementName& element, int32_t resultCode)
49 {
50     HILOGD("AbilityConnectionWrapperProxy::OnAbilityDisconnectDone called");
51     MessageParcel data;
52     if (!data.WriteInterfaceToken(CONNECTION_CALLBACK_INTERFACE_TOKEN)) {
53         return;
54     }
55 
56     MessageParcel reply;
57     MessageOption option;
58     PARCEL_WRITE_HELPER_NORET(data, Parcelable, &element);
59     PARCEL_WRITE_HELPER_NORET(data, Int32, resultCode);
60     int32_t errCode = Remote()->SendRequest(IAbilityConnection::ON_ABILITY_DISCONNECT_DONE, data, reply, option);
61     HILOGD("AbilityConnectionWrapperProxy::OnAbilityDisconnectDone result %{public}d", errCode);
62 }
63 } // namespace DistributedSchedule
64 } // namespace OHOS