1 /*
2 * Copyright (c) 2024 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 "render_state_observer_stub.h"
17
18 #include "appexecfwk_errors.h"
19 #include "hilog_tag_wrapper.h"
20 #include "ipc_types.h"
21 #include "iremote_object.h"
22
23 namespace OHOS {
24 namespace AppExecFwk {
RenderStateObserverStub()25 RenderStateObserverStub::RenderStateObserverStub() {}
26
~RenderStateObserverStub()27 RenderStateObserverStub::~RenderStateObserverStub() {}
28
OnRenderStateChangedInner(MessageParcel & data,MessageParcel & reply)29 int32_t RenderStateObserverStub::OnRenderStateChangedInner(MessageParcel &data, MessageParcel &reply)
30 {
31 std::unique_ptr<RenderStateData> renderStateData(data.ReadParcelable<RenderStateData>());
32 if (renderStateData == nullptr) {
33 TAG_LOGE(AAFwkTag::APPMGR, "renderStateData is null");
34 return ERR_APPEXECFWK_PARCEL_ERROR;
35 }
36
37 OnRenderStateChanged(*renderStateData);
38 return NO_ERROR;
39 }
40
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)41 int RenderStateObserverStub::OnRemoteRequest(
42 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
43 {
44 std::u16string descriptor = RenderStateObserverStub::GetDescriptor();
45 std::u16string remoteDescriptor = data.ReadInterfaceToken();
46 if (descriptor != remoteDescriptor) {
47 TAG_LOGE(AAFwkTag::APPMGR, "Local descriptor is not equal to remote");
48 return ERR_INVALID_STATE;
49 }
50
51 if (code == IRenderStateObserver::ON_RENDER_STATE_CHANGED) {
52 return OnRenderStateChangedInner(data, reply);
53 }
54
55 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
56 }
57 } // namespace AppExecFwk
58 } // namespace OHOS