• 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 <vector>
20 #include <string>
21 #include "iremote_broker.h"
22 #include "pixel_map.h"
23 #include "pixel_map_parcel.h"
24 #include "wallpaper_manager_common_info.h"
25 #include "wallpaper_color_change_listener.h"
26 #include "iwallpaper_color_change_listener.h"
27 #include "wallpaper_color_change_listener_client.h"
28 #include "i_wallpaper_callback.h"
29 
30 namespace OHOS {
31 namespace WallpaperMgrService {
32 class IWallpaperService : public IRemoteBroker {
33 public:
34     DECLARE_INTERFACE_DESCRIPTOR(u"ohos.Wallpaper.IWallpaperService");
35     enum {
36         SET_WALLPAPER_URI_FD,
37         SET_WALLPAPER_MAP,
38         GET_PIXELMAP,
39         GET_PIXELMAPFILE,
40         GET_COLORS,
41         GET_WALLPAPER_ID,
42         GET_FILE,
43         GET_WALLPAPER_MIN_HEIGHT,
44         GET_WALLPAPER_MIN_WIDTH,
45         RESET_WALLPAPER,
46         ON,
47         OFF,
48         IS_CHANGE_PERMITTED,
49         IS_OPERATION_ALLOWED,
50         REGISTER_CALLBACK,
51         SET_WALLPAPER_URI_FD_V9,
52         SET_WALLPAPER_MAP_V9,
53         GET_PIXELMAP_V9,
54         GET_COLORS_V9,
55         GET_WALLPAPER_MIN_HEIGHT_V9,
56         GET_WALLPAPER_MIN_WIDTH_V9,
57         RESET_WALLPAPER_V9,
58     };
59     struct getPixelMap {
60         std::string result;
61         int fileLen;
62     };
63 
64     struct FdInfo {
65         int fd = -1;
66         int size = 0;
67     };
68 
69     /**
70     * Wallpaper set.
71     * @param  uriOrPixelMap Wallpaper picture; wallpaperType Wallpaper type, values for WALLPAPER_SYSTEM or
72     * WALLPAPER_LOCKSCREEN
73     * @return  true or false
74     */
75     virtual int32_t SetWallpaperByFD(int fd, int wallpaperType, int length) = 0;
76     virtual int32_t SetWallpaperByMap(int fd, int wallpaperType, int length) = 0;
77     virtual int32_t GetPixelMap(int wallpaperType, FdInfo &fdInfo) = 0;
78     /**
79      * Obtains the WallpaperColorsCollection instance for the wallpaper of the specified type.
80      * @param wallpaperType Wallpaper type, values for WALLPAPER_SYSTEM or WALLPAPER_LOCKSCREEN
81      * @return number type of array callback function
82      */
83     virtual int32_t GetColors(int wallpaperType, std::vector<uint64_t> &colors) = 0;
84 
85     virtual int32_t GetFile(int wallpaperType, int32_t &wallpaperFd) = 0;
86 
87     /**
88      * Obtains the ID of the wallpaper of the specified type.
89      * @param wallpaperType Wallpaper type, values for WALLPAPER_SYSTEM or WALLPAPER_LOCKSCREEN
90      * @return number type of callback function
91      */
92     virtual int GetWallpaperId(int wallpaperType) = 0;
93 
94     /**
95      * Obtains the minimum height of the wallpaper.
96      * @return number type of callback function
97      */
98     virtual int32_t GetWallpaperMinHeight(int32_t &minHeight) = 0;
99 
100     /**
101      * Obtains the minimum width of the wallpaper.
102      * @return number type of callback function
103      */
104     virtual int32_t GetWallpaperMinWidth(int32_t &minWidth) = 0;
105 
106     /**
107      * Checks whether to allow the application to change the wallpaper for the current user.
108      * @return boolean type of callback function
109      */
110     virtual bool IsChangePermitted() = 0;
111 
112     /**
113      * Checks whether a user is allowed to set wallpapers.
114      * @return boolean type of callback function
115      */
116     virtual bool IsOperationAllowed() = 0;
117 
118     /**
119      * Removes a wallpaper of the specified type and restores the default one.
120      * @param wallpaperType  Wallpaper type, values for WALLPAPER_SYSTEM or WALLPAPER_LOCKSCREEN
121      * @permission ohos.permission.SET_WALLPAPER
122      */
123     virtual int32_t ResetWallpaper(int wallpaperType) = 0;
124 
125     /**
126      * Registers a listener for wallpaper color changes to receive notifications about the changes.
127      * @param type The incoming colorChange table open receiver pick a color change wallpaper wallpaper color changes
128      * @param callback Provides dominant colors of the wallpaper.
129      * @return  true or false
130      */
131     virtual bool On(sptr<IWallpaperColorChangeListener> listener) = 0;
132 
133     /**
134      * Registers a listener for wallpaper color changes to receive notifications about the changes.
135      * @param type Incoming 'colorChange' table delete receiver to pick up a color change wallpaper wallpaper color
136      * changes
137      * @param callback Provides dominant colors of the wallpaper.
138      */
139     virtual bool Off(sptr<IWallpaperColorChangeListener> listener) = 0;
140 
141     virtual bool RegisterWallpaperCallback(const sptr<IWallpaperCallback> callback) = 0;
142 
143     virtual int32_t SetWallpaperByFDV9(int32_t fd, int32_t wallpaperType, int32_t length) = 0;
144     virtual int32_t SetWallpaperByMapV9(int32_t fd, int32_t wallpaperType, int32_t length) = 0;
145     virtual int32_t GetPixelMapV9(int32_t wallpaperType, FdInfo &fdInfo) = 0;
146     virtual int32_t GetColorsV9(int wallpaperType, std::vector<uint64_t> &colors) = 0;
147     virtual int32_t GetWallpaperMinHeightV9(int32_t &minHeight) = 0;
148     virtual int32_t GetWallpaperMinWidthV9(int32_t &minWidth) = 0;
149     virtual int32_t ResetWallpaperV9(int32_t wallpaperType) = 0;
150 };
151 }
152 } // namespace OHOS
153 #endif // SERVICES_INCLUDE_WALLPAPER_SERVICE_INTERFACE_H