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 "hilog_wrapper.h"
16 #include "wallpaper_manager.h"
17 #include "wallpaper_service_cb_stub.h"
18
19 namespace OHOS {
20 namespace WallpaperMgrService {
21
WallpaperServiceCbStub()22 WallpaperServiceCbStub::WallpaperServiceCbStub()
23 {
24 }
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)25 int32_t WallpaperServiceCbStub::OnRemoteRequest(
26 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
27 {
28 HILOG_INFO("WallpaperServiceCbStub::OnRemoteRequest start##ret = %{public}u", code);
29 std::u16string myDescriptor = WallpaperServiceCbStub::GetDescriptor();
30 std::u16string remoteDescriptor = data.ReadInterfaceToken();
31 if (myDescriptor != remoteDescriptor) {
32 HILOG_ERROR("end##descriptor checked fail!");
33 return E_CHECK_DESCRIPTOR_ERROR;
34 }
35 switch (code) {
36 case static_cast<uint32_t>(ONCALL):
37 return HandleOnCall(data, reply);
38 default:
39 HILOG_ERROR("remote request unhandled: %{public}d.", code);
40 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
41 }
42 return E_OK;
43 }
44
HandleOnCall(MessageParcel & data,MessageParcel & reply)45 int32_t WallpaperServiceCbStub::HandleOnCall(MessageParcel &data, MessageParcel &reply)
46 {
47 HILOG_INFO("WallpaperServiceCbStub::HandleOnCall.");
48 int32_t wallpaperType = data.ReadInt32();
49 OnCall(wallpaperType);
50 HILOG_INFO("wallpaperType = %{public}d", wallpaperType);
51 return 0;
52 }
53
OnCall(const int32_t num)54 int32_t WallpaperServiceCbStub::OnCall(const int32_t num)
55 {
56 HILOG_INFO("WallpaperServiceCbStub::OnCall.");
57 WallpaperMgrService::WallpaperManager::GetInstance().GetCallback()(num);
58 return 0;
59 }
60
61 } // namespace WallpaperMgrService
62 } // namespace OHOS