• 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_INTERFACE_H
17 #define SERVICES_INCLUDE_WALLPAPER_SERVICE_INTERFACE_H
18 
19 #include <string>
20 #include <vector>
21 
22 #include "i_wallpaper_callback.h"
23 #include "iremote_broker.h"
24 #include "iwallpaper_event_listener.h"
25 #include "pixel_map.h"
26 #include "pixel_map_parcel.h"
27 #include "wallpaper_common.h"
28 #include "wallpaper_event_listener.h"
29 #include "wallpaper_event_listener_client.h"
30 #include "wallpaper_manager_common_info.h"
31 
32 namespace OHOS {
33 namespace WallpaperMgrService {
34 class IWallpaperService : public IRemoteBroker {
35 public:
36     DECLARE_INTERFACE_DESCRIPTOR(u"ohos.Wallpaper.IWallpaperService");
37     struct getPixelMap {
38         std::string result;
39         int32_t fileLen;
40     };
41 
42     struct FdInfo {
43         int32_t fd = -1;
44         int32_t size = 0;
45     };
46 
47     /**
48     * Wallpaper set.
49     * @param  uriOrPixelMap Wallpaper picture; wallpaperType Wallpaper type, values for WALLPAPER_SYSTEM or
50     * WALLPAPER_LOCKSCREEN
51     * @return  true or false
52     */
53     virtual ErrorCode SetWallpaper(int32_t fd, int32_t wallpaperType, int32_t length) = 0;
54     virtual ErrorCode SetWallpaperByPixelMap(
55         std::shared_ptr<OHOS::Media::PixelMap> pixelMap, int32_t wallpaperType) = 0;
56     virtual ErrorCode GetPixelMap(int32_t wallpaperType, FdInfo &fdInfo) = 0;
57     /**
58      * Obtains the WallpaperColorsCollection instance for the wallpaper of the specified type.
59      * @param wallpaperType Wallpaper type, values for WALLPAPER_SYSTEM or WALLPAPER_LOCKSCREEN
60      * @return number type of array callback function
61      */
62     virtual ErrorCode GetColors(int32_t wallpaperType, std::vector<uint64_t> &colors) = 0;
63 
64     virtual ErrorCode GetFile(int32_t wallpaperType, int32_t &wallpaperFd) = 0;
65 
66     /**
67      * Obtains the ID of the wallpaper of the specified type.
68      * @param wallpaperType Wallpaper type, values for WALLPAPER_SYSTEM or WALLPAPER_LOCKSCREEN
69      * @return number type of callback function
70      */
71     virtual int32_t GetWallpaperId(int32_t wallpaperType) = 0;
72 
73     /**
74      * Checks whether to allow the application to change the wallpaper for the current user.
75      * @return boolean type of callback function
76      */
77     virtual bool IsChangePermitted() = 0;
78 
79     /**
80      * Checks whether a user is allowed to set wallpapers.
81      * @return boolean type of callback function
82      */
83     virtual bool IsOperationAllowed() = 0;
84 
85     /**
86      * Removes a wallpaper of the specified type and restores the default one.
87      * @param wallpaperType  Wallpaper type, values for WALLPAPER_SYSTEM or WALLPAPER_LOCKSCREEN
88      * @permission ohos.permission.SET_WALLPAPER
89      */
90     virtual ErrorCode ResetWallpaper(int32_t wallpaperType) = 0;
91 
92     /**
93      * Registers a listener for wallpaper event changes to receive notifications about the changes.
94      * @param type event type
95      * @param listener event observer.
96      * @return error code
97      */
98     virtual ErrorCode On(const std::string &type, sptr<IWallpaperEventListener> listener) = 0;
99 
100     /**
101      * Unregisters a listener for wallpaper event changes.
102      * @param type event type
103      * @param listener event observer.
104      * @return error code
105      */
106     virtual ErrorCode Off(const std::string &type, sptr<IWallpaperEventListener> listener) = 0;
107 
108     virtual bool RegisterWallpaperCallback(const sptr<IWallpaperCallback> callback) = 0;
109 
110     virtual ErrorCode SetWallpaperV9(int32_t fd, int32_t wallpaperType, int32_t length) = 0;
111     virtual ErrorCode SetWallpaperV9ByPixelMap(
112         std::shared_ptr<OHOS::Media::PixelMap> pixelMap, int32_t wallpaperType) = 0;
113     virtual ErrorCode GetPixelMapV9(int32_t wallpaperType, FdInfo &fdInfo) = 0;
114     virtual ErrorCode GetColorsV9(int32_t wallpaperType, std::vector<uint64_t> &colors) = 0;
115     virtual ErrorCode ResetWallpaperV9(int32_t wallpaperType) = 0;
116 
117     /**
118      * @brief Sets live wallpaper of the specified type based on the uri path
119      *        of the MP4 file.
120      *
121      * Need @permission ohos.permission.SET_WALLPAPER
122      *
123      * @param fd Indicates the handle of the MP4 file.
124      * @param wallpaperType Wallpaper type, values for WALLPAPER_SYSTEM
125      *        or WALLPAPER_LOCKSCREEN
126      * @param length file size of the MP4 file.
127      * @return ErrorCode
128      */
129     virtual ErrorCode SetVideo(int32_t fd, int32_t wallpaperType, int32_t length) = 0;
130 
131     /**
132      * Sets the custom wallpaper.
133      */
134     virtual ErrorCode SetCustomWallpaper(int32_t fd, int32_t wallpaperType, int32_t length) = 0;
135 
136     /**
137      * @brief The application sends the event to the wallpaper service.
138      *
139      * Need @permission ohos.permission.SET_WALLPAPER
140      *
141      * @param eventType Event type, values for SHOW_SYSTEMSCREEN or SHOW_LOCKSCREEN
142      * @return ErrorCode
143      */
144     virtual ErrorCode SendEvent(const std::string &eventType) = 0;
145 };
146 } // namespace WallpaperMgrService
147 } // namespace OHOS
148 #endif // SERVICES_INCLUDE_WALLPAPER_SERVICE_INTERFACE_H