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_WALLPAPER_MIN_HEIGHT, 43 GET_WALLPAPER_MIN_WIDTH, 44 RESET_WALLPAPER, 45 SCREEN_SHOT_LIVE_WALLPAPER, 46 ON, 47 OFF, 48 IS_CHANGE_PERMITTED, 49 IS_OPERATION_ALLOWED, 50 REGISTER_CALLBACK 51 }; 52 struct getPixelMap { 53 std::string result; 54 int fileLen; 55 }; 56 57 struct mapFD { 58 int fd; 59 int size; 60 }; 61 62 /** 63 * Wallpaper set. 64 * @param uriOrPixelMap Wallpaper picture; wallpaperType Wallpaper type, values for WALLPAPER_SYSTEM or 65 * WALLPAPER_LOCKSCREEN 66 * @return true or false 67 */ 68 virtual bool SetWallpaperByFD(int fd, int wallpaperType, int length) = 0; 69 virtual bool SetWallpaperByMap(int fd, int wallpaperType, int length) = 0; 70 virtual mapFD GetPixelMap(int wallpaperType) = 0; 71 /** 72 * Obtains the WallpaperColorsCollection instance for the wallpaper of the specified type. 73 * @param wallpaperType Wallpaper type, values for WALLPAPER_SYSTEM or WALLPAPER_LOCKSCREEN 74 * @return RgbaColor type of array callback function 75 */ 76 virtual std::vector<RgbaColor> GetColors(int wallpaperType)=0; 77 78 /** 79 * Obtains the ID of the wallpaper of the specified type. 80 * @param wallpaperType Wallpaper type, values for WALLPAPER_SYSTEM or WALLPAPER_LOCKSCREEN 81 * @return number type of callback function 82 */ 83 virtual int GetWallpaperId(int wallpaperType)=0; 84 85 /** 86 * Obtains the minimum height of the wallpaper. 87 * @return number type of callback function 88 */ 89 virtual int GetWallpaperMinHeight()=0; 90 91 /** 92 * Obtains the minimum width of the wallpaper. 93 * @return number type of callback function 94 */ 95 virtual int GetWallpaperMinWidth()=0; 96 97 /** 98 * Checks whether to allow the application to change the wallpaper for the current user. 99 * @return boolean type of callback function 100 */ 101 virtual bool IsChangePermitted()=0; 102 103 /** 104 * Checks whether a user is allowed to set wallpapers. 105 * @return boolean type of callback function 106 */ 107 virtual bool IsOperationAllowed()=0; 108 109 /** 110 * Removes a wallpaper of the specified type and restores the default one. 111 * @param wallpaperType Wallpaper type, values for WALLPAPER_SYSTEM or WALLPAPER_LOCKSCREEN 112 * @permission ohos.permission.SET_WALLPAPER 113 */ 114 virtual bool ResetWallpaper(int wallpaperType)=0; 115 116 /** 117 * Screen shot live wallpaper 118 * @param scale 119 * @param pixelFormat 120 * @return image.PixelMap png type The bitmap file of wallpaper 121 * @permission ohos.permission.CAPTURE_SCREEN 122 * @systemapi Hide this for inner system use. 123 * @return true or false 124 */ 125 virtual bool ScreenshotLiveWallpaper(int sacleNumber, OHOS::Media::PixelMap pixelMap) = 0; 126 127 /** 128 * Registers a listener for wallpaper color changes to receive notifications about the changes. 129 * @param type The incoming colorChange table open receiver pick a color change wallpaper wallpaper color changes 130 * @param callback Provides dominant colors of the wallpaper. 131 * @return true or false 132 */ 133 virtual bool On(sptr<IWallpaperColorChangeListener> listener) = 0; 134 135 /** 136 * Registers a listener for wallpaper color changes to receive notifications about the changes. 137 * @param type Incoming 'colorChange' table delete receiver to pick up a color change wallpaper wallpaper color 138 * changes 139 * @param callback Provides dominant colors of the wallpaper. 140 */ 141 virtual bool Off(sptr<IWallpaperColorChangeListener> listener) = 0; 142 143 virtual bool RegisterWallpaperCallback(const sptr<IWallpaperCallback> callback) = 0; 144 }; 145 } 146 } // namespace OHOS 147 #endif // SERVICES_INCLUDE_WALLPAPER_SERVICE_INTERFACE_H