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 int fileLen; 40 }; 41 42 struct FdInfo { 43 int fd = -1; 44 int 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 GetPixelMap(int32_t wallpaperType, FdInfo &fdInfo) = 0; 55 /** 56 * Obtains the WallpaperColorsCollection instance for the wallpaper of the specified type. 57 * @param wallpaperType Wallpaper type, values for WALLPAPER_SYSTEM or WALLPAPER_LOCKSCREEN 58 * @return number type of array callback function 59 */ 60 virtual ErrorCode GetColors(int wallpaperType, std::vector<uint64_t> &colors) = 0; 61 62 virtual ErrorCode GetFile(int32_t wallpaperType, int32_t &wallpaperFd) = 0; 63 64 /** 65 * Obtains the ID of the wallpaper of the specified type. 66 * @param wallpaperType Wallpaper type, values for WALLPAPER_SYSTEM or WALLPAPER_LOCKSCREEN 67 * @return number type of callback function 68 */ 69 virtual int GetWallpaperId(int32_t wallpaperType) = 0; 70 71 /** 72 * Checks whether to allow the application to change the wallpaper for the current user. 73 * @return boolean type of callback function 74 */ 75 virtual bool IsChangePermitted() = 0; 76 77 /** 78 * Checks whether a user is allowed to set wallpapers. 79 * @return boolean type of callback function 80 */ 81 virtual bool IsOperationAllowed() = 0; 82 83 /** 84 * Removes a wallpaper of the specified type and restores the default one. 85 * @param wallpaperType Wallpaper type, values for WALLPAPER_SYSTEM or WALLPAPER_LOCKSCREEN 86 * @permission ohos.permission.SET_WALLPAPER 87 */ 88 virtual ErrorCode ResetWallpaper(int32_t wallpaperType) = 0; 89 90 /** 91 * Registers a listener for wallpaper event changes to receive notifications about the changes. 92 * @param type event type 93 * @param listener event observer. 94 * @return error code 95 */ 96 virtual ErrorCode On(const std::string &type, sptr<IWallpaperEventListener> listener) = 0; 97 98 /** 99 * Unregisters a listener for wallpaper event changes. 100 * @param type event type 101 * @param listener event observer. 102 * @return error code 103 */ 104 virtual ErrorCode Off(const std::string &type, sptr<IWallpaperEventListener> listener) = 0; 105 106 virtual bool RegisterWallpaperCallback(const sptr<IWallpaperCallback> callback) = 0; 107 108 virtual ErrorCode SetWallpaperV9(int32_t fd, int32_t wallpaperType, int32_t length) = 0; 109 virtual ErrorCode GetPixelMapV9(int32_t wallpaperType, FdInfo &fdInfo) = 0; 110 virtual ErrorCode GetColorsV9(int32_t wallpaperType, std::vector<uint64_t> &colors) = 0; 111 virtual ErrorCode ResetWallpaperV9(int32_t wallpaperType) = 0; 112 113 /** 114 * @brief Sets live wallpaper of the specified type based on the uri path 115 * of the MP4 file. 116 * 117 * Need @permission ohos.permission.SET_WALLPAPER 118 * 119 * @param fd Indicates the handle of the MP4 file. 120 * @param wallpaperType Wallpaper type, values for WALLPAPER_SYSTEM 121 * or WALLPAPER_LOCKSCREEN 122 * @param length file size of the MP4 file. 123 * @return ErrorCode 124 */ 125 virtual ErrorCode SetVideo(int32_t fd, int32_t wallpaperType, int32_t length) = 0; 126 127 /** 128 * Sets the custom wallpaper. 129 */ 130 virtual ErrorCode SetCustomWallpaper(const std::string &uri, int32_t wallpaperType) = 0; 131 132 /** 133 * @brief The application sends the event to the wallpaper service. 134 * 135 * Need @permission ohos.permission.SET_WALLPAPER 136 * 137 * @param eventType Event type, values for SHOW_SYSTEMSCREEN or SHOW_LOCKSCREEN 138 * @return ErrorCode 139 */ 140 virtual ErrorCode SendEvent(const std::string &eventType) = 0; 141 }; 142 } // namespace WallpaperMgrService 143 } // namespace OHOS 144 #endif // SERVICES_INCLUDE_WALLPAPER_SERVICE_INTERFACE_H