• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 #include "set_wall_paper_plugin.h"
17 
18 #include <unistd.h>
19 #include <fcntl.h>
20 
21 #include "edm_data_ability_utils.h"
22 #include "edm_ipc_interface_code.h"
23 #include "iplugin_manager.h"
24 #include "wall_paper_param_serializer.h"
25 
26 namespace OHOS {
27 namespace EDM {
28 
29 const bool REGISTER_RESULT = IPluginManager::GetInstance()->AddPlugin(SetWallPaperPlugin::GetPlugin());
30 
InitPlugin(std::shared_ptr<IPluginTemplate<SetWallPaperPlugin,WallPaperParam>> ptr)31 void SetWallPaperPlugin::InitPlugin(std::shared_ptr<IPluginTemplate<SetWallPaperPlugin, WallPaperParam>> ptr)
32 {
33     ptr->InitAttribute(EdmInterfaceCode::SET_WALL_PAPER, PolicyName::POLICY_SET_WALL_PAPER,
34         EdmPermission::PERMISSION_ENTERPRISE_SET_WALLPAPER, IPlugin::PermissionType::SUPER_DEVICE_ADMIN, false);
35     ptr->SetSerializer(WallPaperParamSerializer::GetInstance());
36     ptr->SetOnHandlePolicyListener(&SetWallPaperPlugin::OnSetPolicy, FuncOperateType::SET);
37 }
38 
OnSetPolicy(WallPaperParam & data)39 ErrCode SetWallPaperPlugin::OnSetPolicy(WallPaperParam &data)
40 {
41     EDMLOGD("SetWallPaperPlugin start set wall paper.");
42     if (data.fd >= 0 && fcntl(data.fd, F_GETFL) != -1) {
43         close(data.fd);
44         data.fd = -1;
45     }
46     return EdmReturnErrCode::INTERFACE_UNSUPPORTED;
47 }
48 } // namespace EDM
49 } // namespace OHOS
50