• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_extension.h"
17 
18 #include "ability_loader.h"
19 #include "enterprise_admin_extension_context.h"
20 #include "hilog_wrapper.h"
21 #include "js_enterprise_admin_extension.h"
22 #include "runtime.h"
23 
24 namespace OHOS {
25 namespace EDM {
26 using namespace OHOS::AppExecFwk;
Create(const std::unique_ptr<AbilityRuntime::Runtime> & runtime)27 EnterpriseAdminExtension* EnterpriseAdminExtension::Create(const std::unique_ptr<AbilityRuntime::Runtime>& runtime)
28 {
29     if (!runtime) {
30         return new EnterpriseAdminExtension();
31     }
32     HILOG_INFO("EnterpriseAdminExtension::Create runtime");
33     switch (runtime->GetLanguage()) {
34         case AbilityRuntime::Runtime::Language::JS:
35             return JsEnterpriseAdminExtension::Create(runtime);
36         default:
37             return new EnterpriseAdminExtension();
38     }
39 }
40 
Init(const std::shared_ptr<AppExecFwk::AbilityLocalRecord> & record,const std::shared_ptr<AppExecFwk::OHOSApplication> & application,std::shared_ptr<AppExecFwk::AbilityHandler> & handler,const sptr<IRemoteObject> & token)41 void EnterpriseAdminExtension::Init(const std::shared_ptr<AppExecFwk::AbilityLocalRecord>& record,
42     const std::shared_ptr<AppExecFwk::OHOSApplication>& application,
43     std::shared_ptr<AppExecFwk::AbilityHandler>& handler,
44     const sptr<IRemoteObject>& token)
45 {
46     HILOG_INFO("EnterpriseAdminExtension begin init");
47     ExtensionBase<EnterpriseAdminExtensionContext>::Init(record, application, handler, token);
48 }
49 
CreateAndInitContext(const std::shared_ptr<AppExecFwk::AbilityLocalRecord> & record,const std::shared_ptr<AppExecFwk::OHOSApplication> & application,std::shared_ptr<AppExecFwk::AbilityHandler> & handler,const sptr<IRemoteObject> & token)50 std::shared_ptr<EnterpriseAdminExtensionContext> EnterpriseAdminExtension::CreateAndInitContext(
51     const std::shared_ptr<AppExecFwk::AbilityLocalRecord>& record,
52     const std::shared_ptr<AppExecFwk::OHOSApplication>& application,
53     std::shared_ptr<AppExecFwk::AbilityHandler>& handler,
54     const sptr<IRemoteObject>& token)
55 {
56     std::shared_ptr<EnterpriseAdminExtensionContext> context =
57         ExtensionBase<EnterpriseAdminExtensionContext>::CreateAndInitContext(record, application, handler, token);
58     if (record == nullptr) {
59         HILOG_ERROR("EnterpriseAdminExtension::CreateAndInitContext record is nullptr");
60         return context;
61     }
62     return context;
63 }
64 } // namespace EDM
65 } // namespace OHOS