• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 
17 #include "cj_calendar_env.h"
18 #include "calendar_log.h"
19 #include "calendar_env.h"
20 #include "ability.h"
21 #include "ability_context.h"
22 #include "context.h"
23 #include "napi_base_context.h"
24 #include "data_share_helper_manager.h"
25 #include "datashare_helper.h"
26 #include "datashare_predicates.h"
27 #include "accesstoken_kit.h"
28 
29 #include "ipc_skeleton.h"
30 
31 namespace OHOS::CalendarApi {
32 
Init(std::shared_ptr<OHOS::AbilityRuntime::Context> context)33 void CJCalendarEnv::Init(std::shared_ptr<OHOS::AbilityRuntime::Context> context)
34 {
35     if (hasInited) {
36         return;
37     }
38     LOG_INFO("CJCalendarEnv Init.");
39     m_context = context;
40     if (m_context == nullptr) {
41         LOG_ERROR("CJCalendarEnv::Init error");
42         return;
43     }
44     std::string bundleName = m_context->GetBundleName();
45     uint64_t tokenId = IPCSkeleton::GetSelfTokenID();
46     CalendarEnv::GetInstance().Init(bundleName, tokenId);
47     hasInited = true;
48 }
49 
getContext()50 std::shared_ptr<OHOS::AbilityRuntime::Context> CJCalendarEnv::getContext()
51 {
52     return m_context;
53 }
54 };
55