1 /*
2 * Copyright (C) 2025 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 "camera_dialog_connection.h"
17 #include <nlohmann/json.hpp>
18 #include "extension_manager_client.h"
19 #include "camera_dialog_manager.h"
20
21 constexpr int32_t PARAM_NUM = 3;
22
23 namespace OHOS {
24 namespace CameraStandard {
25
OnAbilityConnectDone(const AppExecFwk::ElementName & element,const sptr<IRemoteObject> & remoteObject,int32_t resultCode)26 void NoFrontCameraAbilityConnection::OnAbilityConnectDone(const AppExecFwk::ElementName &element,
27 const sptr<IRemoteObject> &remoteObject, int32_t resultCode)
28 {
29 MEDIA_INFO_LOG("OnAbilityConnectDone, resultCode = %{public}d", resultCode);
30 CHECK_RETURN_ELOG(remoteObject == nullptr, "remote object is nullptr");
31 MessageParcel data;
32 MessageParcel reply;
33 MessageOption option;
34 data.WriteInt32(PARAM_NUM);
35 data.WriteString16(u"bundleName");
36 data.WriteString16(Str8ToStr16(bundleName_));
37 data.WriteString16(u"abilityName");
38 data.WriteString16(Str8ToStr16(abilityName_));
39 data.WriteString16(u"parameters");
40 nlohmann::json param;
41 param["ability.want.params.uiExtensionType"] = "sysDialog/common";
42 std::string paramStr = param.dump();
43 data.WriteString16(Str8ToStr16(paramStr));
44 int32_t sendRequestRet = remoteObject->SendRequest(IAbilityConnection::ON_ABILITY_CONNECT_DONE,
45 data, reply, option);
46 MEDIA_INFO_LOG("OnAbilityConnectDone, sendRequestRet = %{public}d", sendRequestRet);
47 NoFrontCameraDialog::GetInstance()->DisconnectAbilityForDialog();
48 }
49
OnAbilityDisconnectDone(const AppExecFwk::ElementName & element,int32_t resultCode)50 void NoFrontCameraAbilityConnection::OnAbilityDisconnectDone(const AppExecFwk::ElementName &element,
51 int32_t resultCode)
52 {
53 MEDIA_INFO_LOG("OnAbilityDisconnectDone, resultCode = %{public}d", resultCode);
54 }
55 } // namespace CameraStandard
56 } // namespace OHOS