• 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 SetWallpaperByPixelMap(std::shared_ptr<OHOS::Media::PixelMap> pixelMap, int32_t wallpaperType) override;
38     ErrorCode GetPixelMap(int32_t wallpaperType, IWallpaperService::FdInfo &fdInfo) override;
39     ErrorCode GetColors(int32_t wallpaperType, std::vector<uint64_t> &colors) override;
40     ErrorCode GetFile(int32_t wallpaperType, int32_t &wallpaperFd) override;
41     int32_t GetWallpaperId(int32_t wallpaperType) override;
42     bool IsChangePermitted() override;
43     bool IsOperationAllowed() override;
44     ErrorCode ResetWallpaper(int32_t wallpaperType) override;
45     ErrorCode On(const std::string &type, sptr<IWallpaperEventListener> listener) override;
46     ErrorCode Off(const std::string &type, sptr<IWallpaperEventListener> listener) override;
47     bool RegisterWallpaperCallback(const sptr<IWallpaperCallback> callback) override;
48     ErrorCode SetVideo(int32_t fd, int32_t wallpaperType, int32_t length) override;
49     ErrorCode SetCustomWallpaper(int32_t fd, int32_t wallpaperType, int32_t length) override;
50     ErrorCode SendEvent(const std::string &eventType) override;
51     ErrorCode ConvertIntToErrorCode(int32_t errorCode);
52 
53     ErrorCode SetWallpaperV9(int32_t fd, int32_t wallpaperType, int32_t length) override;
54     ErrorCode SetWallpaperV9ByPixelMap(std::shared_ptr<OHOS::Media::PixelMap> pixelMap, int32_t wallpaperType) override;
55     ErrorCode GetPixelMapV9(int32_t wallpaperType, IWallpaperService::FdInfo &fdInfo) override;
56     ErrorCode GetColorsV9(int32_t wallpaperType, std::vector<uint64_t> &colors) override;
57     ErrorCode ResetWallpaperV9(int32_t wallpaperType) override;
58 
59 private:
60     ErrorCode SetWallpaperInner(
61         int32_t fd, int32_t wallpaperType, int32_t length, WallpaperServiceIpcInterfaceCode code);
62     ErrorCode SetWallpaperInnerByPixelMap(
63         std::shared_ptr<OHOS::Media::PixelMap> pixelMap, int32_t wallpaperType, WallpaperServiceIpcInterfaceCode code);
64     ErrorCode GetPixelMapInner(
65         int32_t wallpaperType, WallpaperServiceIpcInterfaceCode code, IWallpaperService::FdInfo &fdInfo);
66     ErrorCode GetColorsInner(
67         int32_t wallpaperType, WallpaperServiceIpcInterfaceCode code, std::vector<uint64_t> &colors);
68     ErrorCode ResetWallpaperInner(int32_t wallpaperType, WallpaperServiceIpcInterfaceCode code);
69     bool StartSocket(std::string uri, std::string name);
70     std::vector<std::uint8_t> PixelMapToVector(std::shared_ptr<OHOS::Media::PixelMap> pixelMap);
71     static inline BrokerDelegator<WallpaperServiceProxy> delegator_;
72     sptr<OHOS::Media::PixelMap> pixelMapData_;
73     std::string serviceReadUri = "";
74     int32_t mapSize = 0;
75 };
76 } // namespace WallpaperMgrService
77 } // namespace OHOS
78 #endif // SERVICES_INCLUDE_WALLPAPER_SERVICE_PROXY_H