1 /*
2 * Copyright (C) 2024 Huawei Device Co., Ltd. 2023. All rightsreserved
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 "bluetooth_ability_connection.h"
17
18 #include <algorithm>
19 #include <string>
20
21 #include "foundation/multimedia/image_framework/mock/native/include/log/hitrace_meter.h"
22 #include "log.h"
23
24 constexpr int32_t PARAM_NUM = 3;
25
26 namespace OHOS {
27 namespace bluetooth {
OnAbilityConnectDone(const AppExecFwk::ElementName & element,const sptr<IRemoteObject> & remoteObject,int32_t resultCode)28 void ::OHOS::bluetooth::BluetoothAbilityConnection::OnAbilityConnectDone(
29 const AppExecFwk::ElementName& element, const sptr<IRemoteObject>& remoteObject, int32_t resultCode)
30 {
31 HILOGI("on BT_TRACE_TAG ability connected");
32 MessageParcel data;
33 MessageParcel reply;
34 MessageOption option;
35 data.WriteInt32(PARAM_NUM);
36 data.WriteString16(u"bundleName");
37 data.WriteString16(Str8ToStr16(bundleName_));
38 data.WriteString16(u"abilityName");
39 data.WriteString16(Str8ToStr16(abilityName_));
40 data.WriteString16(u"parameters");
41 data.WriteString16(Str8ToStr16(commandStr_));
42
43 if (!data.WriteParcelable(&element)) {
44 HILOGE("Connect done element error.");
45 return;
46 }
47
48 if (!data.WriteRemoteObject(remoteObject)) {
49 HILOGE("Connect done remote object error.");
50 return;
51 }
52
53 if (!data.WriteInt32(resultCode)) {
54 HILOGE("Connect done result code error.");
55 return;
56 }
57
58 int32_t errCode =
59 remoteObject->SendRequest(AAFwk::IAbilityConnection::ON_ABILITY_CONNECT_DONE, data, reply, option);
60 HILOGI("AbilityConnectionWrapperProxy::OnConnectConnectDone result %{public}d", errCode);
61 }
62
OnAbilityDisconnectDone(const AppExecFwk::ElementName & element,int32_t resultCode)63 void ::OHOS::bluetooth::BluetoothAbilityConnection::OnAbilityDisconnectDone(
64 const AppExecFwk::ElementName& element, int32_t resultCode)
65 {
66 HILOGI("on ability disconnected");
67 }
68
69 } // namespace bluetooth
70 } // namespace OHOS