1 /*
2  * Copyright (c) 2022-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_INCLUDE_EDM_ENTERPRISE_DEVICE_MGR_STUB_ABILITY_H
17 #define SERVICES_EDM_INCLUDE_EDM_ENTERPRISE_DEVICE_MGR_STUB_ABILITY_H
18 
19 #include <map>
20 
21 #include "edm_log.h"
22 #include "external_manager_factory.h"
23 #include "func_code.h"
24 #include "ienterprise_device_mgr.h"
25 #include "iexternal_manager_factory.h"
26 #include "iremote_stub.h"
27 
28 namespace OHOS {
29 namespace EDM {
30 class EnterpriseDeviceMgrStub : public IRemoteStub<IEnterpriseDeviceMgr> {
31 public:
32     EnterpriseDeviceMgrStub();
33     int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
34 
35 protected:
36     virtual std::shared_ptr<IExternalManagerFactory> GetExternalManagerFactory();
37     std::shared_ptr<IEdmAccessTokenManager> GetAccessTokenMgr();
38 
39 private:
40     std::vector<uint32_t> systemCodeList;
41     void InitSystemCodeList();
42     ErrCode EnableAdminInner(MessageParcel &data, MessageParcel &reply);
43     ErrCode DisableAdminInner(MessageParcel &data, MessageParcel &reply);
44     ErrCode DisableSuperAdminInner(MessageParcel &data, MessageParcel &reply);
45     ErrCode HandleDevicePolicyInner(uint32_t code, MessageParcel &data, MessageParcel &reply, int32_t userId);
46     ErrCode GetDevicePolicyInner(uint32_t code, MessageParcel &data, MessageParcel &reply, int32_t userId);
47     ErrCode GetEnabledAdminInner(MessageParcel &data, MessageParcel &reply);
48     ErrCode GetEnterpriseInfoInner(MessageParcel &data, MessageParcel &reply);
49     ErrCode SetEnterpriseInfoInner(MessageParcel &data, MessageParcel &reply);
50     ErrCode IsSuperAdminInner(MessageParcel &data, MessageParcel &reply);
51     ErrCode IsAdminEnabledInner(MessageParcel &data, MessageParcel &reply);
52     ErrCode SubscribeManagedEventInner(MessageParcel &data, MessageParcel &reply);
53     ErrCode UnsubscribeManagedEventInner(MessageParcel &data, MessageParcel &reply);
54     ErrCode SubscribeManagedEventInner(MessageParcel &data, MessageParcel &reply, bool subscribe);
55     ErrCode AuthorizeAdminInner(MessageParcel &data, MessageParcel &reply);
56     ErrCode GetSuperAdminInner(MessageParcel &data, MessageParcel &reply);
57     ErrCode SetDelegatedPoliciesInner(MessageParcel &data, MessageParcel &reply);
58     ErrCode GetDelegatedPoliciesInner(MessageParcel &data, MessageParcel &reply);
59     ErrCode GetDelegatedBundleNamesInner(MessageParcel &data, MessageParcel &reply);
60     #ifdef EDM_SUPPORT_ALL_ENABLE
61     ErrCode CallFuncByCode(uint32_t code, MessageParcel &data, MessageParcel &reply);
62     #endif
63     std::shared_ptr<IExternalManagerFactory> externalManagerFactory_ = std::make_shared<ExternalManagerFactory>();
64 };
65 } // namespace EDM
66 } // namespace OHOS
67 #endif // SERVICES_EDM_INCLUDE_EDM_ENTERPRISE_DEVICE_MGR_STUB_ABILITY_H
68