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 "window_extension_context.h" 17 18 #include "ability_info.h" 19 #include "native_engine/native_reference.h" 20 #include "window_manager_hilog.h" 21 22 namespace OHOS { 23 namespace Rosen { 24 25 namespace { 26 constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowExtensionContext"}; 27 } 28 29 const size_t WindowExtensionContext::CONTEXT_TYPE_ID(std::hash<const char*> {} ("WindowExtensionContext")); 30 int WindowExtensionContext::ILLEGAL_REQUEST_CODE(-1); 31 StartAbility(const AAFwk::Want & want,const AAFwk::StartOptions & startOptions) const32 WMError WindowExtensionContext::StartAbility(const AAFwk::Want &want, const AAFwk::StartOptions &startOptions) const 33 { 34 WLOGFD("Start ability begin, ability:%{public}s.", want.GetElement().GetAbilityName().c_str()); 35 ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->StartAbility(want, startOptions, token_, 36 ILLEGAL_REQUEST_CODE); 37 if (err != ERR_OK) { 38 WLOGFE("WindowContext::StartAbility is failed %{public}d", err); 39 return WMError::WM_ERROR_START_ABILITY_FAILED; 40 } 41 return WMError::WM_OK; 42 } 43 } // namespace Rosen 44 } // namespace OHOS 45