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 "message_parcel.h"
17 #include "wallpaper_event_listener_stub.h"
18
19 namespace OHOS {
20 namespace WallpaperMgrService {
21 using namespace std::chrono;
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)22 int32_t WallpaperEventListenerStub::OnRemoteRequest(
23 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
24 {
25 HILOG_DEBUG("WallpaperEventListenerStub::OnRemoteRequest Start");
26 std::u16string descriptor = WallpaperEventListenerStub::GetDescriptor();
27 std::u16string remoteDescriptor = data.ReadInterfaceToken();
28 if (descriptor != remoteDescriptor) {
29 HILOG_ERROR("local descriptor is not equal to remote.");
30 return -1;
31 }
32 switch (code) {
33 case ON_COLORS_CHANGE: {
34 std::vector<uint64_t> color;
35 if (!data.ReadUInt64Vector(&color)) {
36 HILOG_ERROR("ON_COLORS_CHANGE ReadUInt64Vector error!");
37 return -1;
38 }
39 int32_t wallpaperType = data.ReadInt32();
40 OnColorsChange(color, wallpaperType);
41 HILOG_DEBUG("WallpaperEventListenerStub::OnRemoteRequest End.");
42 return 0;
43 }
44 case ON_WALLPAPER_CHANGE: {
45 int32_t wallpaperType = data.ReadInt32();
46 int32_t resouceType = data.ReadInt32();
47 std::string uri = data.ReadString();
48 OnWallpaperChange(
49 static_cast<WallpaperType>(wallpaperType), static_cast<WallpaperResourceType>(resouceType), uri);
50 HILOG_DEBUG("WallpaperEventListenerStub::OnRemoteRequest End.");
51 return 0;
52 }
53 default: {
54 HILOG_ERROR("code error, WallpaperEventListenerStub::OnRemoteRequest End.");
55 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
56 }
57 }
58 }
59 } // namespace WallpaperMgrService
60 } // namespace OHOS
61