1 /*
2 * Copyright (c) 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 #include "wallpaper_service_cb_stub.h"
16
17 #include "hilog_wrapper.h"
18 #include "wallpaper_manager.h"
19
20 namespace OHOS {
21 namespace WallpaperMgrService {
WallpaperServiceCbStub()22 WallpaperServiceCbStub::WallpaperServiceCbStub()
23 {
24 memberFuncMap_[ONCALL] = &WallpaperServiceCbStub::HandleOnCall;
25 }
26
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)27 int32_t WallpaperServiceCbStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
28 MessageOption &option)
29 {
30 HILOG_INFO(" WallpaperServiceCbStub::OnRemoteRequest");
31 HILOG_INFO(" start##ret = %{public}u", code);
32 std::u16string myDescriptor = WallpaperServiceCbStub::GetDescriptor();
33 std::u16string remoteDescriptor = data.ReadInterfaceToken();
34 if (myDescriptor != remoteDescriptor) {
35 HILOG_ERROR(" end##descriptor checked fail");
36 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
37 }
38 auto itFunc = memberFuncMap_.find(code);
39 if (itFunc != memberFuncMap_.end()) {
40 auto memberFunc = itFunc->second;
41 if (memberFunc != nullptr) {
42 return (this->*memberFunc)(data, reply);
43 }
44 }
45 int32_t ret = IPCObjectStub::OnRemoteRequest(code, data, reply, option);
46 HILOG_INFO(" end##ret = %{public}d", ret);
47 return ret;
48 }
49
HandleOnCall(MessageParcel & data,MessageParcel & reply)50 int32_t WallpaperServiceCbStub::HandleOnCall(MessageParcel &data, MessageParcel &reply)
51 {
52 HILOG_INFO(" WallpaperServiceCbStub::HandleOnCall");
53 int32_t wallpaperType = data.ReadInt32();
54 OnCall(wallpaperType);
55 HILOG_INFO("wallpaperType = %{public}d", wallpaperType);
56 return 0;
57 }
58
OnCall(const int32_t num)59 int32_t WallpaperServiceCbStub::OnCall(const int32_t num)
60 {
61 HILOG_INFO(" WallpaperServiceCbStub::OnCall");
62 WallpaperMgrService::WallpaperManagerkits::GetInstance().GetCallback()(num);
63 return 0;
64 }
65
66 } // namespace WallpaperMgrService
67 } // namespace OHOS