1 /*
2 * Copyright (c) 2022-2023 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_bundle_connection.h"
17
18 #include "edm_log.h"
19 #include "enterprise_conn_manager.h"
20 #include "managed_event.h"
21
22 namespace OHOS {
23 namespace EDM {
~EnterpriseBundleConnection()24 EnterpriseBundleConnection::~EnterpriseBundleConnection() {}
25
OnAbilityConnectDone(const AppExecFwk::ElementName & element,const sptr<IRemoteObject> & remoteObject,int32_t resultCode)26 void EnterpriseBundleConnection::OnAbilityConnectDone(
27 const AppExecFwk::ElementName& element, const sptr<IRemoteObject>& remoteObject, int32_t resultCode)
28 {
29 EDMLOGI("EnterpriseBundleConnection OnAbilityConnectDone");
30 proxy_ = (new (std::nothrow) EnterpriseAdminProxy(remoteObject));
31 if (proxy_ == nullptr) {
32 EDMLOGI("EnterpriseBundleConnection get enterpriseAdminProxy failed.");
33 return;
34 }
35 switch (code_) {
36 case static_cast<uint32_t>(ManagedEvent::BUNDLE_ADDED):
37 proxy_->OnBundleAdded(bundleName_, accountId_);
38 break;
39 case static_cast<uint32_t>(ManagedEvent::BUNDLE_REMOVED):
40 proxy_->OnBundleRemoved(bundleName_, accountId_);
41 break;
42 case static_cast<uint32_t>(ManagedEvent::APP_START):
43 proxy_->OnAppStart(bundleName_);
44 break;
45 case static_cast<uint32_t>(ManagedEvent::APP_STOP):
46 proxy_->OnAppStop(bundleName_);
47 break;
48 default:
49 return;
50 }
51 EDMLOGI("EnterpriseBundleConnection OnAbilityConnectDone over");
52 }
53
OnAbilityDisconnectDone(const AppExecFwk::ElementName & element,int32_t resultCode)54 void EnterpriseBundleConnection::OnAbilityDisconnectDone(const AppExecFwk::ElementName& element, int32_t resultCode)
55 {
56 EDMLOGI("EnterpriseBundleConnection OnAbilityDisconnectDone");
57 }
58 } // namespace EDM
59 } // namespace OHOS
60