From 0aab7d29d0e2cd93e318d42daadd6d03e2d39cc4 Mon Sep 17 00:00:00 2001 From: zhangzezhong Date: Tue, 27 May 2025 13:51:38 +0800 Subject: [PATCH] add startOptions Signed-off-by: zhangzezhong --- .../include/ani_common_start_options.h | 29 +++++++++++++ .../src/ani_common_start_options.cpp | 43 +++++++++++++++++++ .../ets/@ohos.app.ability.StartOptions.ets | 30 +++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 frameworks/ets/ani/ani_common/include/ani_common_start_options.h create mode 100644 frameworks/ets/ani/ani_common/src/ani_common_start_options.cpp create mode 100644 frameworks/ets/ets/@ohos.app.ability.StartOptions.ets diff --git a/frameworks/ets/ani/ani_common/include/ani_common_start_options.h b/frameworks/ets/ani/ani_common/include/ani_common_start_options.h new file mode 100644 index 00000000000..f7cc875d166 --- /dev/null +++ b/frameworks/ets/ani/ani_common/include/ani_common_start_options.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ABILITY_RUNTIME_ANI_COMMON_START_OPTIONS_H +#define OHOS_ABILITY_RUNTIME_ANI_COMMON_START_OPTIONS_H + +#include "start_options.h" +#include "ani_common_util.h" +namespace OHOS { +namespace AppExecFwk { + +bool UnwrapStartOptionsWithProcessOption(ani_env *env, ani_object param, AAFwk::StartOptions &startOptions); +bool UnwrapStartOptions(ani_env *env, ani_object param, AAFwk::StartOptions &startOptions); + +} // namespace AppExecFwk +} // namespace OHOS +#endif // OHOS_ABILITY_RUNTIME_NAPI_COMMON_START_OPTIONS_H \ No newline at end of file diff --git a/frameworks/ets/ani/ani_common/src/ani_common_start_options.cpp b/frameworks/ets/ani/ani_common/src/ani_common_start_options.cpp new file mode 100644 index 00000000000..b6399b528f7 --- /dev/null +++ b/frameworks/ets/ani/ani_common/src/ani_common_start_options.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ani_common_start_options.h" + +#include "hilog_tag_wrapper.h" + +namespace OHOS { +namespace AppExecFwk { + +bool UnwrapStartOptionsWithProcessOption(ani_env* env, ani_object param, AAFwk::StartOptions &startOptions) +{ + UnwrapStartOptions(env, param, startOptions); + return true; +} + +bool UnwrapStartOptions(ani_env *env, ani_object param, AAFwk::StartOptions &startOptions) +{ + TAG_LOGI(AAFwkTag::ETSNAPI, "called"); + if (env == nullptr) { + TAG_LOGE(AAFwkTag::ETSNAPI, "null env"); + return false; + } + ani_double displayId = 0.0; + if (GetDoubleOrUndefined(env, param, "displayId", displayId)) { + startOptions.SetDisplayID(static_cast(displayId)); + } + return true; +} +} // namespace AppExecFwk +} // namespace OHOS \ No newline at end of file diff --git a/frameworks/ets/ets/@ohos.app.ability.StartOptions.ets b/frameworks/ets/ets/@ohos.app.ability.StartOptions.ets new file mode 100644 index 00000000000..9eb705c6162 --- /dev/null +++ b/frameworks/ets/ets/@ohos.app.ability.StartOptions.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default class StartOptions { + // windowMode?: int; + displayId?: number; + // withAnimation?: boolean; + // windowLeft?: int; + // windowTop?: int; + // windowWidth?: int; + // windowHeight?: int; + // windowFocused?: boolean; + // processMode?: contextConstant.ProcessMode; + // startupVisibility?: contextConstant.StartupVisibility; + // startWindowIcon?: image.PixelMap; + // startWindowBackgroundColor?: string; + // supportWindowModes?: Array; +} \ No newline at end of file -- Gitee