• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
16 #ifndef SERVICES_INCLUDE_WALLPAPER_SERVICE_PROXY_H
17 #define SERVICES_INCLUDE_WALLPAPER_SERVICE_PROXY_H
18 
19 #include <mutex>
20 
21 #include "i_wallpaper_service.h"
22 #include "iremote_proxy.h"
23 #include "wallpaper_service_ipc_interface_code.h"
24 
25 namespace OHOS {
26 namespace WallpaperMgrService {
27 class WallpaperServiceProxy : public IRemoteProxy<IWallpaperService> {
28 public:
WallpaperServiceProxy(const sptr<IRemoteObject> & object)29     explicit WallpaperServiceProxy(const sptr<IRemoteObject> &object) : IRemoteProxy<IWallpaperService>(object)
30     {
31     }
~WallpaperServiceProxy()32     ~WallpaperServiceProxy()
33     {
34     }
35     DISALLOW_COPY_AND_MOVE(WallpaperServiceProxy);
36     ErrorCode SetWallpaper(int32_t fd, int32_t wallpaperType, int32_t length) override;
37     ErrorCode GetPixelMap(int32_t wallpaperType, IWallpaperService::FdInfo &fdInfo) override;
38     ErrorCode GetColors(int32_t wallpaperType, std::vector<uint64_t> &colors) override;
39     ErrorCode GetFile(int32_t wallpaperType, int32_t &wallpaperFd) override;
40     int32_t GetWallpaperId(int32_t wallpaperType) override;
41     bool IsChangePermitted() override;
42     bool IsOperationAllowed() override;
43     ErrorCode ResetWallpaper(int wallpaperType) override;
44     ErrorCode On(const std::string &type, sptr<IWallpaperEventListener> listener) override;
45     ErrorCode Off(const std::string &type, sptr<IWallpaperEventListener> listener) override;
46     bool RegisterWallpaperCallback(const sptr<IWallpaperCallback> callback) override;
47     ErrorCode SetVideo(int32_t fd, int32_t wallpaperType, int32_t length) override;
48     ErrorCode SetCustomWallpaper(const std::string &uri, int32_t wallpaperType) override;
49     ErrorCode SendEvent(const std::string &eventType) override;
50     ErrorCode ConvertIntToErrorCode(int32_t errorCode);
51 
52     ErrorCode SetWallpaperV9(int32_t fd, int32_t wallpaperType, int32_t length) override;
53     ErrorCode GetPixelMapV9(int32_t wallpaperType, IWallpaperService::FdInfo &fdInfo) override;
54     ErrorCode GetColorsV9(int32_t wallpaperType, std::vector<uint64_t> &colors) override;
55     ErrorCode ResetWallpaperV9(int wallpaperType) override;
56 
57 private:
58     ErrorCode SetWallpaperInner(
59         int32_t fd, int32_t wallpaperType, int32_t length, WallpaperServiceIpcInterfaceCode code);
60     ErrorCode GetPixelMapInner(
61         int32_t wallpaperType, WallpaperServiceIpcInterfaceCode code, IWallpaperService::FdInfo &fdInfo);
62     ErrorCode GetColorsInner(
63         int32_t wallpaperType, WallpaperServiceIpcInterfaceCode code, std::vector<uint64_t> &colors);
64     ErrorCode ResetWallpaperInner(int wallpaperType, WallpaperServiceIpcInterfaceCode code);
65     bool StartSocket(std::string uri, std::string name);
66     static inline BrokerDelegator<WallpaperServiceProxy> delegator_;
67     sptr<OHOS::Media::PixelMap> pixelMapData_;
68     std::string serviceReadUri = "";
69     int32_t mapSize = 0;
70 };
71 } // namespace WallpaperMgrService
72 } // namespace OHOS
73 #endif // SERVICES_INCLUDE_WALLPAPER_SERVICE_PROXY_H