1 /*
2 * Copyright (c) 2023 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 "hgm_config_change_callback_stub.h"
17
18 #include "platform/common/rs_log.h"
19
20 namespace OHOS {
21 namespace Rosen {
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)22 int RSHgmConfigChangeCallbackStub::OnRemoteRequest(
23 uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option)
24 {
25 auto token = data.ReadInterfaceToken();
26 if (token != RSIHgmConfigChangeCallback::GetDescriptor()) {
27 RS_LOGE("RSHgmConfigChangeCallbackStub::OnRemoteRequest read token failed!");
28 return ERR_INVALID_STATE;
29 }
30
31 int ret = ERR_NONE;
32 switch (code) {
33 case static_cast<uint32_t>(RSIHgmConfigChangeCallbackInterfaceCode::ON_HGM_CONFIG_CHANGED): {
34 std::shared_ptr<RSHgmConfigData> configData(data.ReadParcelable<RSHgmConfigData>());
35 OnHgmConfigChanged(configData);
36 break;
37 }
38 case static_cast<uint32_t>(RSIHgmConfigChangeCallbackInterfaceCode::
39 ON_HGM_REFRESH_RATE_MODE_CHANGED): {
40 int32_t refreshRateMode{0};
41 if (!data.ReadInt32(refreshRateMode)) {
42 RS_LOGE("RSHgmConfigChangeCallbackStub::ON_HGM_REFRESH_RATE_MODE_CHANGED read refreshRateMode failed!");
43 ret = ERR_INVALID_DATA;
44 break;
45 }
46 OnHgmRefreshRateModeChanged(refreshRateMode);
47 break;
48 }
49 case static_cast<uint32_t>(RSIHgmConfigChangeCallbackInterfaceCode::ON_HGM_REFRESH_RATE_CHANGED): {
50 int32_t refreshRate{0};
51 if (!data.ReadInt32(refreshRate)) {
52 RS_LOGE("RSHgmConfigChangeCallbackStub::ON_HGM_REFRESH_RATE_CHANGED read refreshRate failed!");
53 ret = ERR_INVALID_DATA;
54 break;
55 }
56 OnHgmRefreshRateUpdate(refreshRate);
57 break;
58 }
59 default: {
60 ret = IPCObjectStub::OnRemoteRequest(code, data, reply, option);
61 break;
62 }
63 }
64
65 return ret;
66 }
67 } // namespace Rosen
68 } // namespace OHOS
69