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