• 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 #include "cj_inputmethod_extension_context.h"
17 #include "global.h"
18 
19 namespace OHOS {
20 namespace AbilityRuntime {
21 static const ErrCode ERROR_INVALIDE_CONTEXT = 16000011;
22 
CjInputMethodExtensionContext(const std::shared_ptr<InputMethodExtensionContext> & context)23 CjInputMethodExtensionContext::CjInputMethodExtensionContext(
24     const std::shared_ptr<InputMethodExtensionContext> &context)
25     : CJExtensionContext(context, context->GetAbilityInfo()), context_(context)
26 {
27 }
28 
GetContext()29 std::shared_ptr<InputMethodExtensionContext> CjInputMethodExtensionContext::GetContext()
30 {
31     return context_.lock();
32 }
33 
StartAbility(const AAFwk::Want & want)34 ErrCode CjInputMethodExtensionContext::StartAbility(const AAFwk::Want &want)
35 {
36     auto context = GetContext();
37     if (context == nullptr) {
38         IMSA_HILOGE("context is nullptr!");
39         return ERROR_INVALIDE_CONTEXT;
40     }
41     return context->StartAbility(want);
42 }
43 
TerminateAbility()44 ErrCode CjInputMethodExtensionContext::TerminateAbility()
45 {
46     auto context = GetContext();
47     if (context == nullptr) {
48         IMSA_HILOGE("context is nullptr!");
49         return ERROR_INVALIDE_CONTEXT;
50     }
51     return context->TerminateAbility();
52 }
53 } // namespace AbilityRuntime
54 } // namespace OHOS
55