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 #include "fence_extension.h"
17 #include "js_fence_extension.h"
18 #include "location_log.h"
19 #include "runtime.h"
20 
21 namespace OHOS {
22 namespace Location {
23 using namespace OHOS::AppExecFwk;
Create(const std::unique_ptr<OHOS::AbilityRuntime::Runtime> & runtime)24 FenceExtension *FenceExtension::Create(const std::unique_ptr<OHOS::AbilityRuntime::Runtime> &runtime)
25 {
26     if (!runtime) {
27         return new FenceExtension();
28     }
29 
30     LBSLOGI(FENCE_EXTENSION, "FenceExtension:Create");
31     switch (runtime->GetLanguage()) {
32         case OHOS::AbilityRuntime::Runtime::Language::JS:
33             return JsFenceExtension::Create(runtime);
34         default:
35             return new FenceExtension();
36     }
37 }
38 
Init(const std::shared_ptr<AbilityLocalRecord> & record,const std::shared_ptr<OHOSApplication> & application,std::shared_ptr<AbilityHandler> & handler,const sptr<IRemoteObject> & token)39 void FenceExtension::Init(const std::shared_ptr<AbilityLocalRecord> &record,
40     const std::shared_ptr<OHOSApplication> &application, std::shared_ptr<AbilityHandler> &handler,
41     const sptr<IRemoteObject> &token)
42 {
43     ExtensionBase<FenceExtensionContext>::Init(record, application, handler, token);
44     LBSLOGI(FENCE_EXTENSION, "FenceExtension:Init");
45 }
46 
CreateAndInitContext(const std::shared_ptr<AbilityLocalRecord> & record,const std::shared_ptr<OHOSApplication> & application,std::shared_ptr<AbilityHandler> & handler,const sptr<IRemoteObject> & token)47 std::shared_ptr<FenceExtensionContext> FenceExtension::CreateAndInitContext(
48     const std::shared_ptr<AbilityLocalRecord> &record, const std::shared_ptr<OHOSApplication> &application,
49     std::shared_ptr<AbilityHandler> &handler, const sptr<IRemoteObject> &token)
50 {
51     std::shared_ptr<FenceExtensionContext> context =
52         ExtensionBase<FenceExtensionContext>::CreateAndInitContext(record, application, handler, token);
53     if (context == nullptr) {
54         LBSLOGE(FENCE_EXTENSION, "FenceExtension:context is null");
55         return context;
56     }
57     LBSLOGI(FENCE_EXTENSION, "FenceExtension:CreateAndInitContext");
58     return context;
59 }
60 
OnFenceStatusChange(std::map<std::string,std::string> extraData)61 FenceExtensionErrCode FenceExtension::OnFenceStatusChange(std::map<std::string, std::string> extraData)
62 {
63     LBSLOGI(FENCE_EXTENSION, "FenceExtension:OnFenceStatusChange");
64     return FenceExtensionErrCode::EXTENSION_SUCCESS;
65 }
66 
OnDestroy()67 void FenceExtension::OnDestroy()
68 {
69     LBSLOGI(FENCE_EXTENSION, "FenceExtension:OnDestroy");
70 }
71 }  // namespace Location
72 }  // namespace OHOS