1 /*
2  * Copyright (c) 2021-2022 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 "hcamera_scene_session_manager_proxy.h"
17 #include "camera_log.h"
18 
19 namespace OHOS {
20 namespace CameraStandard {
RegisterWindowManagerAgent(WindowManagerAgentType type,const sptr<IWindowManagerAgent> & windowManagerAgent)21 int32_t CameraSceneSessionManagerProxy::RegisterWindowManagerAgent(WindowManagerAgentType type,
22     const sptr<IWindowManagerAgent>& windowManagerAgent)
23 {
24     MessageOption option;
25     MessageParcel reply;
26     MessageParcel data;
27 
28     data.WriteInterfaceToken(GetDescriptor());
29     data.WriteUint32(static_cast<uint32_t>(type));
30     data.WriteRemoteObject(windowManagerAgent->AsObject());
31 
32     int32_t error = Remote()->SendRequest(static_cast<uint32_t>(
33         SceneSessionManagerMessage::TRANS_ID_REGISTER_WINDOW_MANAGER_AGENT),
34         data, reply, option);
35     CHECK_ERROR_PRINT_LOG(error != ERR_NONE, "RegisterWindowManagerAgent failed, error: %{public}d", error);
36 
37     return reply.ReadInt32();
38 }
39 
UnregisterWindowManagerAgent(WindowManagerAgentType type,const sptr<IWindowManagerAgent> & windowManagerAgent)40 int32_t CameraSceneSessionManagerProxy::UnregisterWindowManagerAgent(WindowManagerAgentType type,
41     const sptr<IWindowManagerAgent>& windowManagerAgent)
42 {
43     MessageParcel reply;
44     MessageOption option;
45     MessageParcel data;
46     data.WriteInterfaceToken(GetDescriptor());
47     data.WriteUint32(static_cast<uint32_t>(type));
48     data.WriteRemoteObject(windowManagerAgent->AsObject());
49 
50     int32_t error = Remote()->SendRequest(static_cast<uint32_t>(
51         SceneSessionManagerMessage::TRANS_ID_UNREGISTER_WINDOW_MANAGER_AGENT),
52         data, reply, option);
53     CHECK_ERROR_PRINT_LOG(error != ERR_NONE, "UnregisterWindowManagerAgent failed, error: %{public}d", error);
54 
55     return reply.ReadInt32();
56 }
57 
GetFocusWindowInfo(OHOS::Rosen::FocusChangeInfo & focusInfo)58 void CameraSceneSessionManagerProxy::GetFocusWindowInfo(OHOS::Rosen::FocusChangeInfo& focusInfo)
59 {
60     MessageParcel data;
61     MessageParcel reply;
62     MessageOption option;
63 
64     data.WriteInterfaceToken(GetDescriptor());
65 
66     int32_t error = Remote()->SendRequest(
67         static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_FOCUS_SESSION_INFO),
68         data, reply, option);
69     CHECK_ERROR_RETURN_LOG(error != ERR_NONE, "HCameraDeviceProxy DisableResult failed, error: %{public}d", error);
70     sptr<OHOS::Rosen::FocusChangeInfo> info = reply.ReadParcelable<OHOS::Rosen::FocusChangeInfo>();
71     if (info) {
72         focusInfo = *info;
73     } else {
74         MEDIA_ERR_LOG("GetFocusWindowInfo Focus info is null");
75     }
76 }
77 } // namespace CameraStandard
78 } // namespace OHOS