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 #include "enterprise_admin_proxy.h"
17 #include "edm_log.h"
18
19 namespace OHOS {
20 namespace EDM {
OnAdminEnabled()21 void EnterpriseAdminProxy::OnAdminEnabled()
22 {
23 MessageParcel data;
24 if (!data.WriteInterfaceToken(GetDescriptor())) {
25 EDMLOGE("EnterpriseAdminProxy::%{public}s write descriptor failed!", __func__);
26 return;
27 }
28 EDMLOGI("EnterpriseAdminProxy proxy OnAdminEnabled");
29 SendRequest(COMMAND_ON_ADMIN_ENABLED, data);
30 }
31
OnAdminDisabled()32 void EnterpriseAdminProxy::OnAdminDisabled()
33 {
34 MessageParcel data;
35 if (!data.WriteInterfaceToken(GetDescriptor())) {
36 EDMLOGE("EnterpriseAdminProxy::%{public}s write descriptor failed!", __func__);
37 return;
38 }
39 EDMLOGI("EnterpriseAdminProxy proxy OnAdminDisabled");
40 SendRequest(COMMAND_ON_ADMIN_DISABLED, data);
41 }
42
OnBundleAdded(const std::string & bundleName)43 void EnterpriseAdminProxy::OnBundleAdded(const std::string &bundleName)
44 {
45 MessageParcel data;
46 if (!data.WriteInterfaceToken(GetDescriptor())) {
47 EDMLOGE("EnterpriseAdminProxy::%{public}s write descriptor failed!", __func__);
48 return;
49 }
50 data.WriteString(bundleName);
51 EDMLOGI("EnterpriseAdminProxy proxy OnBundleAdded");
52 SendRequest(COMMAND_ON_BUNDLE_ADDED, data);
53 }
54
OnBundleRemoved(const std::string & bundleName)55 void EnterpriseAdminProxy::OnBundleRemoved(const std::string &bundleName)
56 {
57 MessageParcel data;
58 if (!data.WriteInterfaceToken(GetDescriptor())) {
59 EDMLOGE("EnterpriseAdminProxy::%{public}s write descriptor failed!", __func__);
60 return;
61 }
62 data.WriteString(bundleName);
63 EDMLOGI("EnterpriseAdminProxy proxy OnBundleRemoved");
64 SendRequest(COMMAND_ON_BUNDLE_REMOVED, data);
65 }
66
SendRequest(uint32_t code,MessageParcel & data)67 void EnterpriseAdminProxy::SendRequest(uint32_t code, MessageParcel &data)
68 {
69 MessageParcel reply;
70 MessageOption option(MessageOption::TF_SYNC);
71 Remote()->SendRequest(code, data, reply, option);
72 }
73 } // namespace EDM
74 } // namespace OHOS
75