• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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_EDM_PLUGIN_INCLUDE_MANAGE_KEEP_ALIVE_APPS_PLUGIN_H
17 #define SERVICES_EDM_PLUGIN_INCLUDE_MANAGE_KEEP_ALIVE_APPS_PLUGIN_H
18 
19 #include "ability_manager_interface.h"
20 #include "bundle_mgr_interface.h"
21 #include "message_parcel.h"
22 #include "iplugin.h"
23 #include "iremote_stub.h"
24 #include "manage_keep_alive_apps_info.h"
25 
26 namespace OHOS {
27 namespace EDM {
28 class ManageKeepAliveAppsPlugin : public IPlugin {
29 public:
30     ManageKeepAliveAppsPlugin();
31     ErrCode OnHandlePolicy(std::uint32_t funcCode, MessageParcel &data, MessageParcel &reply,
32         HandlePolicyData &policyData, int32_t userId) override;
OnHandlePolicyDone(std::uint32_t funcCode,const std::string & adminName,bool isGlobalChanged,int32_t userId)33     void OnHandlePolicyDone(std::uint32_t funcCode, const std::string &adminName, bool isGlobalChanged,
34         int32_t userId) override{};
35     ErrCode OnGetPolicy(std::string &policyData, MessageParcel &data, MessageParcel &reply, int32_t userId) override;
36     ErrCode OnAdminRemove(const std::string &adminName, const std::string &currentJsonData,
37         const std::string &mergeJsonData, int32_t userId) override;
OnAdminRemoveDone(const std::string & adminName,const std::string & currentJsonData,int32_t userId)38     void OnAdminRemoveDone(const std::string &adminName, const std::string &currentJsonData,
39         int32_t userId) override {};
40     ErrCode GetOthersMergePolicyData(const std::string &adminName, int32_t userId,
41         std::string &othersMergePolicyData) override;
42 
43 private:
44     ErrCode RemoveOtherModulePolicy(const std::vector<ManageKeepAliveAppInfo> &data, int32_t userId,
45         std::vector<ManageKeepAliveAppInfo> &failedData);
46     ErrCode AddKeepAliveApps(std::vector<std::string> &keepAliveApps, int32_t userId, bool disallowModify);
47     ErrCode RemoveKeepAliveApps(std::vector<std::string> &keepAliveApps, int32_t userId);
48     ErrCode OnSetPolicy(std::vector<std::string> &data, bool disallowModify,
49         std::vector<ManageKeepAliveAppInfo> &currentData, std::vector<ManageKeepAliveAppInfo> &mergeData,
50         int32_t userId);
51     ErrCode OnRemovePolicy(std::vector<std::string> &data,
52         std::vector<ManageKeepAliveAppInfo> &currentData, std::vector<ManageKeepAliveAppInfo> &mergeData,
53         int32_t userId);
54     ErrCode SetOtherModulePolicy(const std::vector<std::string> &keepAliveApps,
55         int32_t userId, std::vector<ManageKeepAliveAppInfo> &failedData, bool disallowModify);
56     void ParseErrCode(ErrCode &ret);
57     void GetErrorMessage(ErrCode &errCode, std::string &errMessage);
58     sptr<AAFwk::IAbilityManager> GetAbilityManager();
59     sptr<AppExecFwk::IAppControlMgr> GetAppControlProxy();
60     uint32_t maxListSize_ = 0;
61 };
62 } // namespace EDM
63 } // namespace OHOS
64 
65 #endif /* SERVICES_EDM_PLUGIN_INCLUDE_MANAGE_KEEP_ALIVE_APPS_PLUGIN_H */
66