diff --git a/frameworks/kits/ability/ability_runtime/include/ability_context.h b/frameworks/kits/ability/ability_runtime/include/ability_context.h index 45a54360f7113cddfa1ebd5aa4856946056bdfff..762a30c605fa5d66182fc19b3edcf244d9ac8c6f 100644 --- a/frameworks/kits/ability/ability_runtime/include/ability_context.h +++ b/frameworks/kits/ability/ability_runtime/include/ability_context.h @@ -64,9 +64,6 @@ public: virtual ErrCode StartAbilityForResult(const AAFwk::Want &Want, int requestCode, RuntimeTask &&task) = 0; - virtual ErrCode StartAbilityForResult(const AAFwk::Want &Want, const AAFwk::StartOptions &startOptions, - int requestCode, RuntimeTask &&task) = 0; - virtual ErrCode TerminateAbilityWithResult(const AAFwk::Want &want, int resultCode) = 0; virtual ErrCode RestoreWindowStage(void* contentStorage) = 0; diff --git a/frameworks/kits/ability/ability_runtime/include/ability_context_impl.h b/frameworks/kits/ability/ability_runtime/include/ability_context_impl.h index e1a8b273084c22c0c895a719e511d38e8ecf55e0..2d2515cdf2ca960aa24d835531dd5aeb03fa09b8 100644 --- a/frameworks/kits/ability/ability_runtime/include/ability_context_impl.h +++ b/frameworks/kits/ability/ability_runtime/include/ability_context_impl.h @@ -43,8 +43,6 @@ public: ErrCode StartAbility(const AAFwk::Want &want, int requestCode) override; ErrCode StartAbility(const AAFwk::Want &want, const AAFwk::StartOptions &startOptions, int requestCode) override; ErrCode StartAbilityForResult(const AAFwk::Want &want, int requestCode, RuntimeTask &&task) override; - ErrCode StartAbilityForResult(const AAFwk::Want &want, const AAFwk::StartOptions &startOptions, - int requestCode, RuntimeTask &&task) override; ErrCode TerminateAbilityWithResult(const AAFwk::Want &want, int resultCode) override; void OnAbilityResult(int requestCode, int resultCode, const AAFwk::Want &resultData) override; bool ConnectAbility(const AAFwk::Want &want, diff --git a/frameworks/kits/ability/ability_runtime/src/ability_context_impl.cpp b/frameworks/kits/ability/ability_runtime/src/ability_context_impl.cpp index 544403720a5de3b111027b8c117f0d65453c4e71..0ba7d64147a0081f8420d8f68c91ebc8af36a064 100644 --- a/frameworks/kits/ability/ability_runtime/src/ability_context_impl.cpp +++ b/frameworks/kits/ability/ability_runtime/src/ability_context_impl.cpp @@ -86,15 +86,6 @@ ErrCode AbilityContextImpl::StartAbilityForResult(const AAFwk::Want &want, int r return err; } -ErrCode AbilityContextImpl::StartAbilityForResult(const AAFwk::Want &want, const AAFwk::StartOptions &startOptions, - int requestCode, RuntimeTask &&task) -{ - HILOG_DEBUG("%{public}s. Start calling StartAbilityForResult.", __func__); - resultCallbacks_.insert(make_pair(requestCode, std::move(task))); - ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->StartAbility(want, startOptions, token_, requestCode); - HILOG_INFO("%{public}s. End calling StartAbilityForResult. ret=%{public}d", __func__, err); - return err; -} ErrCode AbilityContextImpl::TerminateAbilityWithResult(const AAFwk::Want &want, int resultCode) { diff --git a/frameworks/kits/ability/native/BUILD.gn b/frameworks/kits/ability/native/BUILD.gn index 86aba42b525a1f58de1eb2fc1ddd409f8416f07b..1f2bbb6e553414a077483c45bd86e9f1024c8c59 100644 --- a/frameworks/kits/ability/native/BUILD.gn +++ b/frameworks/kits/ability/native/BUILD.gn @@ -81,44 +81,15 @@ config("ability_public_config") { "//foundation/aafwk/standard/frameworks/kits/ability/native/include/continuation/kits", "//foundation/appexecfwk/standard/interfaces/innerkits/fmskit/native/include", "//foundation/windowmanager/interfaces/innerkits/wm", - "//foundation/windowmanager/interfaces/kits/napi/window_runtime/window_napi", ] } -ohos_shared_library("static_subscriber_ipc") { - include_dirs = [ - "${SUBSYSTEM_DIR}/include", - "//base/notification/ces_standard/interfaces/innerkits/native/include", - "//foundation/aafwk/standard/interfaces/innerkits/want/include/ohos/aafwk/content/", - "//foundation/distributedschedule/dmsfwk/services/dtbschedmgr/include", - ] - - sources = [ - "${SUBSYSTEM_DIR}/src/static_subscriber_proxy.cpp", - "${SUBSYSTEM_DIR}/src/static_subscriber_stub.cpp", - ] - - deps = [ - "//foundation/distributedschedule/dmsfwk/services/dtbschedmgr:distributedschedsvr", - "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy", - "//utils/native/base:utils", - ] - - external_deps = [ - "aafwk_standard:want", - "ces_standard:cesfwk_innerkits", - "ipc:ipc_core", - ] - - subsystem_name = "aafwk" - part_name = "aafwk_standard" -} - ohos_shared_library("abilitykit_native") { include_dirs = [ "//foundation/distributeddatamgr/appdatamgr/frameworks/jskitsimpl/native_rdb", "//foundation/distributeddatamgr/appdatamgr/frameworks/jskitsimpl/common", "//foundation/distributeddatamgr/appdatamgr/frameworks/jskitsimpl/native_dataability", + "${SUBSYSTEM_DIR}/src/ability_runtime/window", "//base/global/i18n_standard/frameworks/intl/include", ] @@ -147,26 +118,22 @@ ohos_shared_library("abilitykit_native") { "${SUBSYSTEM_DIR}/src/extension_base.cpp", "${SUBSYSTEM_DIR}/src/extension_impl.cpp", "${SUBSYSTEM_DIR}/src/form_extension.cpp", + "${SUBSYSTEM_DIR}/src/form_runtime/form_extension_provider_client.cpp", + "${SUBSYSTEM_DIR}/src/form_runtime/js_form_extension.cpp", + "${SUBSYSTEM_DIR}/src/form_runtime/js_form_extension_context.cpp", + "${SUBSYSTEM_DIR}/src/js_service_extension.cpp", + "${SUBSYSTEM_DIR}/src/js_service_extension_context.cpp", + "${SUBSYSTEM_DIR}/src/service_extension.cpp", #"${SUBSYSTEM_DIR}/src/dummy_data_ability_predicates.cpp", #"${SUBSYSTEM_DIR}/src/dummy_result_set.cpp", #"${SUBSYSTEM_DIR}/src/dummy_values_bucket.cpp", "${SUBSYSTEM_DIR}/src/form_js_event_handler.cpp", "${SUBSYSTEM_DIR}/src/form_provider_client.cpp", - "${SUBSYSTEM_DIR}/src/form_runtime/form_extension_provider_client.cpp", - "${SUBSYSTEM_DIR}/src/form_runtime/js_form_extension.cpp", - "${SUBSYSTEM_DIR}/src/form_runtime/js_form_extension_context.cpp", - "${SUBSYSTEM_DIR}/src/js_service_extension.cpp", - "${SUBSYSTEM_DIR}/src/js_service_extension_context.cpp", - "${SUBSYSTEM_DIR}/src/js_static_subscriber_extension.cpp", - "${SUBSYSTEM_DIR}/src/js_static_subscriber_extension_context.cpp", "${SUBSYSTEM_DIR}/src/mission_information.cpp", "${SUBSYSTEM_DIR}/src/new_ability_impl.cpp", "${SUBSYSTEM_DIR}/src/page_ability_impl.cpp", "${SUBSYSTEM_DIR}/src/service_ability_impl.cpp", - "${SUBSYSTEM_DIR}/src/service_extension.cpp", - "${SUBSYSTEM_DIR}/src/static_subscriber_extension.cpp", - "${SUBSYSTEM_DIR}/src/static_subscriber_stub_imp.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/ability_start_setting.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/launch_param.cpp", @@ -199,7 +166,6 @@ ohos_shared_library("abilitykit_native") { "//foundation/appexecfwk/standard/kits/appkit/native/ability_runtime/extension_context.cpp", "//foundation/appexecfwk/standard/kits/appkit/native/ability_runtime/form_extension_context.cpp", "//foundation/appexecfwk/standard/kits/appkit/native/ability_runtime/service_extension_context.cpp", - "//foundation/appexecfwk/standard/kits/appkit/native/ability_runtime/static_subscriber_extension_context.cpp", "//foundation/appexecfwk/standard/kits/appkit/native/app/src/application_context.cpp", "//foundation/appexecfwk/standard/kits/appkit/native/app/src/context_container.cpp", "//foundation/appexecfwk/standard/kits/appkit/native/app/src/context_deal.cpp", @@ -210,6 +176,9 @@ ohos_shared_library("abilitykit_native") { "${SUBSYSTEM_DIR}/src/ability_runtime/js_ability.cpp", "${SUBSYSTEM_DIR}/src/ability_runtime/js_ability_context.cpp", "${SUBSYSTEM_DIR}/src/ability_runtime/js_window_stage.cpp", + "${SUBSYSTEM_DIR}/src/ability_runtime/window/js_window.cpp", + "${SUBSYSTEM_DIR}/src/ability_runtime/window/js_window_manager.cpp", + "${SUBSYSTEM_DIR}/src/ability_runtime/window/js_window_utils.cpp", "//foundation/distributeddatamgr/appdatamgr/frameworks/jskitsimpl/native_dataability/napi_data_ability_predicates.cpp", "//foundation/distributeddatamgr/appdatamgr/frameworks/jskitsimpl/native_rdb/napi_result_set.cpp", ] @@ -220,7 +189,6 @@ ohos_shared_library("abilitykit_native") { ] deps = [ - ":static_subscriber_ipc", "${INNERKITS_PATH}/base:base", "${INNERKITS_PATH}/want:want", "//base/security/permission/interfaces/innerkits/permission_standard/permissionsdk:libpermissionsdk_standard", @@ -245,7 +213,6 @@ ohos_shared_library("abilitykit_native") { "aafwk_standard:runtime", "appexecfwk_standard:fmskit_native", "bytrace_standard:bytrace_core", - "ces_standard:cesfwk_innerkits", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "ipc_js:rpc", @@ -261,7 +228,6 @@ ohos_shared_library("abilitykit_native") { "//base/global/resmgr_standard/frameworks/resmgr:global_resmgr", "//foundation/distributedschedule/dmsfwk/services/dtbschedmgr:distributedschedsvr", "//foundation/graphic/standard:libwmclient", - "//foundation/windowmanager/interfaces/kits/napi/window_runtime:window_native_kit", "//foundation/windowmanager/wm:libwm", ] diff --git a/frameworks/kits/ability/native/include/ability.h b/frameworks/kits/ability/native/include/ability.h index 3cdcb7dfadd114945adc9b6eb8ab4f240d38ccca..c144badf7278076809408ed2c304a73bc37f2dd0 100755 --- a/frameworks/kits/ability/native/include/ability.h +++ b/frameworks/kits/ability/native/include/ability.h @@ -107,7 +107,7 @@ public: int TerminateAbility(Want &want); /** - * @brief By binding an action, you can set different action parameters in want to present different initial + * @brief By binding an action, you can set different action parameters in Intent to present different initial * pages. You must register actions in the profile file. * * @param action Indicates the action to bind. @@ -199,8 +199,8 @@ public: * Starts a new ability with specific start settings. * A Page or Service ability uses this method to start a specific ability. * The system locates the target ability from installed abilities based on - * the value of the want parameter and then starts it. You can specify the - * ability to start using the want parameter. + * the value of the intent parameter and then starts it. You can specify the + * ability to start using the intent parameter. * * @param want Indicates the ability to start. * @param abilityStartSetting Indicates the setting ability used to start. @@ -387,7 +387,7 @@ public: * * @param windowOption Indicates the window option defined by the user. */ - virtual void InitWindow(Rosen::WindowType winType, int32_t displayId, sptr option); + virtual void InitWindow(Rosen::WindowType winType, int32_t displayId); /** * @brief Get the window belong to the ability. @@ -850,10 +850,10 @@ public: /** * @brief A Page or Service ability uses this method to start a specific ability. The system locates the target - * ability from installed abilities based on the value of the want parameter and then starts it. You can specify - * the ability to start using the want parameter. + * ability from installed abilities based on the value of the intent parameter and then starts it. You can specify + * the ability to start using the intent parameter. * - * @param want Indicates the ability to start. + * @param intent Indicates the ability to start. * * @return errCode ERR_OK on success, others on failure. */ @@ -1492,10 +1492,10 @@ private: // Keep consistent with DMS defines. Used to callback to DMS. static const std::string DMS_SESSION_ID; - // The originating deviceId passed by DMS using want param. + // The originating deviceId passed by DMS using intent param. static const std::string DMS_ORIGIN_DEVICE_ID; - // If session id cannot get from want, assign it as default. + // If session id cannot get from intent, assign it as default. static const int DEFAULT_DMS_SESSION_ID; std::vector lostedByReconnectTempForms_; diff --git a/frameworks/kits/ability/native/include/ability_local_record.h b/frameworks/kits/ability/native/include/ability_local_record.h index aedd0e9222ff6ee0384eb50fdd2fe869d9edb4ee..5352b51e43460b9512893976fca72931c92fd496 100644 --- a/frameworks/kits/ability/native/include/ability_local_record.h +++ b/frameworks/kits/ability/native/include/ability_local_record.h @@ -123,6 +123,7 @@ public: * @return None. */ void SetCompatibleVersion(int compatibleVersion); + private: std::shared_ptr abilityInfo_ = nullptr; sptr token_; diff --git a/frameworks/kits/ability/native/include/ability_window.h b/frameworks/kits/ability/native/include/ability_window.h index 69b5005901dfde25e5486ec41c169991c16cc28b..8d92173d517caa2d0098fa5c04ff10128bdc36f6 100644 --- a/frameworks/kits/ability/native/include/ability_window.h +++ b/frameworks/kits/ability/native/include/ability_window.h @@ -51,7 +51,7 @@ public: */ bool InitWindow(Rosen::WindowType winType, std::shared_ptr &abilityContext, - sptr &listener, int32_t displayId, sptr option); + sptr &listener, int32_t displayId); /** * @brief Called when this ability is started. diff --git a/frameworks/kits/ability/native/include/istatic_subscriber.h b/frameworks/kits/ability/native/include/istatic_subscriber.h deleted file mode 100644 index 8ff87119b0f08f7e116749c697425cc961bdab62..0000000000000000000000000000000000000000 --- a/frameworks/kits/ability/native/include/istatic_subscriber.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2022 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_APPEXECFWK_I_STATIC_SUBSCRIBER_H -#define OHOS_APPEXECFWK_I_STATIC_SUBSCRIBER_H - -#include -#include -#include "common_event_data.h" - -namespace OHOS { -namespace AppExecFwk { -using EventFwk::CommonEventData; - -class IStaticSubscriber : public IRemoteBroker { -public: - DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.AppExecFwk.IStaticSubscriber"); - - /** - * @brief Called when subscriber received common event. - * - * @param data Indicates the common event data.. - */ - virtual ErrCode OnCommonEventTriggered(CommonEventData* data) = 0; -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif // OHOS_APPEXECFWK_I_STATIC_SUBSCRIBER_H - diff --git a/frameworks/kits/ability/native/include/js_static_subscriber_extension.h b/frameworks/kits/ability/native/include/js_static_subscriber_extension.h deleted file mode 100644 index cabcb0bc0d74b578bb001c61941a00ba953e1383..0000000000000000000000000000000000000000 --- a/frameworks/kits/ability/native/include/js_static_subscriber_extension.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2022 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 FOUNDATION_ABILITYRUNTIME_OHOS_JS_STATIC_SUBSCRIBER_EXTENSION_H -#define FOUNDATION_ABILITYRUNTIME_OHOS_JS_STATIC_SUBSCRIBER_EXTENSION_H - -#include "common_event_data.h" -#include "static_subscriber_extension.h" - -class NativeReference; -class NativeValue; - -namespace OHOS { -namespace AbilityRuntime { -class JsRuntime; -/** - * @brief js-level static subscriber extension. - */ -class JsStaticSubscriberExtension : public StaticSubscriberExtension { -public: - JsStaticSubscriberExtension(JsRuntime& jsRuntime); - virtual ~JsStaticSubscriberExtension() override; - - /** - * @brief Create JsStaticSubscriberExtension. - * - * @param runtime The runtime. - * @return The JsStaticSubscriberExtension instance. - */ - static JsStaticSubscriberExtension* Create(const std::unique_ptr& runtime); - - void Init(const std::shared_ptr& record, - const std::shared_ptr& application, - std::shared_ptr& handler, - const sptr& token) override; - - void OnStart(const AAFwk::Want& want) override; - - sptr OnConnect(const AAFwk::Want& want) override; - - void OnDisconnect(const AAFwk::Want& want) override; - - void OnStop() override; - - void OnCommonEventTriggered(EventFwk::CommonEventData* data) override; -private: - JsRuntime& jsRuntime_; - std::unique_ptr jsObj_; -}; -} // namespace AbilityRuntime -} // namespace OHOS -#endif // FOUNDATION_ABILITYRUNTIME_OHOS_JS_STATIC_SUBSCRIBER_EXTENSION_H \ No newline at end of file diff --git a/frameworks/kits/ability/native/include/js_static_subscriber_extension_context.h b/frameworks/kits/ability/native/include/js_static_subscriber_extension_context.h deleted file mode 100644 index a1212a61ab73f49046a5e51cfa60f1b94d2b0881..0000000000000000000000000000000000000000 --- a/frameworks/kits/ability/native/include/js_static_subscriber_extension_context.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2022 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 ABILITY_RUNTIME_JS_STATIC_SUBSCRIBER_EXTENSION_CONTEXT_H -#define ABILITY_RUNTIME_JS_STATIC_SUBSCRIBER_EXTENSION_CONTEXT_H - -#include - -#include "static_subscriber_extension_context.h" - -class NativeEngine; -class NativeValue; - -namespace OHOS { -namespace AbilityRuntime { -NativeValue* CreateJsStaticSubscriberExtensionContext(NativeEngine& engine, - std::shared_ptr context); -} // namespace AbilityRuntime -} // namespace OHOS -#endif // ABILITY_RUNTIME_JS_STATIC_SUBSCRIBER_EXTENSION_CONTEXT_H \ No newline at end of file diff --git a/frameworks/kits/ability/native/include/static_subscriber_extension.h b/frameworks/kits/ability/native/include/static_subscriber_extension.h deleted file mode 100644 index 8555ae6fee4ca97bebce6d88a39e1756147e1da5..0000000000000000000000000000000000000000 --- a/frameworks/kits/ability/native/include/static_subscriber_extension.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2022 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 FOUNDATION_ABILITYRUNTIME_OHOS_STATIC_SUBSCRIBER_EXTENSION_H -#define FOUNDATION_ABILITYRUNTIME_OHOS_STATIC_SUBSCRIBER_EXTENSION_H - -#include "common_event_data.h" -#include "extension_base.h" - -namespace OHOS { -namespace AbilityRuntime { -class StaticSubscriberExtensionContext; -class Runtime; - -class StaticSubscriberExtension : public ExtensionBase { -public: - StaticSubscriberExtension() = default; - virtual ~StaticSubscriberExtension() = default; - - std::shared_ptr CreateAndInitContext( - const std::shared_ptr& record, - const std::shared_ptr& application, - std::shared_ptr& handler, - const sptr& token) override; - - void Init(const std::shared_ptr& record, - const std::shared_ptr& application, - std::shared_ptr& handler, - const sptr& token) override; - - static StaticSubscriberExtension* Create(const std::unique_ptr& runtime); - - virtual void OnCommonEventTriggered(EventFwk::CommonEventData* data); -}; -} // namespace AbilityRuntime -} // namespace OHOS -#endif // FOUNDATION_ABILITYRUNTIME_OHOS_STATIC_SUBSCRIBER_EXTENSION_H \ No newline at end of file diff --git a/frameworks/kits/ability/native/include/static_subscriber_proxy.h b/frameworks/kits/ability/native/include/static_subscriber_proxy.h deleted file mode 100644 index e4a9eda0639013764a39da07fcc5b74ac6cca3c3..0000000000000000000000000000000000000000 --- a/frameworks/kits/ability/native/include/static_subscriber_proxy.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2022 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_APPEXECFWK_STATIC_SUBSCRIBER_PROXY_H -#define OHOS_APPEXECFWK_STATIC_SUBSCRIBER_PROXY_H - -#include -#include "istatic_subscriber.h" - -namespace OHOS { -namespace AppExecFwk { -class StaticSubscriberProxy : public IRemoteProxy { -public: - explicit StaticSubscriberProxy(const sptr& remote) - : IRemoteProxy(remote) {} - - virtual ~StaticSubscriberProxy() {} - - ErrCode OnCommonEventTriggered(CommonEventData* data) override; - -private: - static constexpr int COMMAND_ON_COMMON_EVENT_TRIGGERED = MIN_TRANSACTION_ID; - - static inline BrokerDelegator delegator_; -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif // OHOS_APPEXECFWK_STATIC_SUBSCRIBER_PROXY_H - diff --git a/frameworks/kits/ability/native/include/static_subscriber_stub.h b/frameworks/kits/ability/native/include/static_subscriber_stub.h deleted file mode 100644 index a1689dbe0d6b61d9f1435cbef7e11fc5b4f6d557..0000000000000000000000000000000000000000 --- a/frameworks/kits/ability/native/include/static_subscriber_stub.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2022 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_APPEXECFWK_STATIC_SUBSCRIBER_STUB_H -#define OHOS_APPEXECFWK_STATIC_SUBSCRIBER_STUB_H - -#include -#include "istatic_subscriber.h" -#include "static_subscriber_extension.h" - -namespace OHOS { -namespace AppExecFwk { -class StaticSubscriberStub : public IRemoteStub { -public: - StaticSubscriberStub() {} - - virtual ~StaticSubscriberStub() {} - - int OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; -private: - static constexpr int COMMAND_ON_COMMON_EVENT_TRIGGERED = MIN_TRANSACTION_ID; -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif // OHOS_APPEXECFWK_STATIC_SUBSCRIBER_STUB_H - diff --git a/frameworks/kits/ability/native/include/static_subscriber_stub_imp.h b/frameworks/kits/ability/native/include/static_subscriber_stub_imp.h deleted file mode 100644 index 4c607ce10a75bf145db1dc8f5460a4b2325ccf6a..0000000000000000000000000000000000000000 --- a/frameworks/kits/ability/native/include/static_subscriber_stub_imp.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2022 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_APPEXECFWK_STATIC_SUBSCRIBER_STUB_IMP_H -#define OHOS_APPEXECFWK_STATIC_SUBSCRIBER_STUB_IMP_H - -#include -#include "js_static_subscriber_extension.h" -#include "static_subscriber_stub.h" - -namespace OHOS { -namespace AppExecFwk { -using AbilityRuntime::JsStaticSubscriberExtension; -class StaticSubscriberStubImp : public StaticSubscriberStub { -public: - explicit StaticSubscriberStubImp(const std::shared_ptr& extension) - : extension_(extension) {} - - virtual ~StaticSubscriberStubImp() {} - - ErrCode OnCommonEventTriggered(CommonEventData* data) override; -private: - std::weak_ptr extension_; -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif // OHOS_APPEXECFWK_STATIC_SUBSCRIBER_STUB_IMP_H - diff --git a/frameworks/kits/ability/native/src/ability.cpp b/frameworks/kits/ability/native/src/ability.cpp index 88337ec48340121277eafc3165d06792297ee5c9..c8fa668e6a91ac0d913f539c67b5d560d2643fa0 100755 --- a/frameworks/kits/ability/native/src/ability.cpp +++ b/frameworks/kits/ability/native/src/ability.cpp @@ -202,8 +202,8 @@ void Ability::OnStart(const Want &want) abilityInfo_->name.c_str(), winType, displayId); - auto option = GetWindowOption(want); - InitWindow(winType, displayId, option); + + InitWindow(winType, displayId); if (abilityWindow_ != nullptr) { APP_LOGI("%{public}s begin abilityWindow_->OnPostAbilityStart.", __func__); @@ -677,7 +677,7 @@ void Ability::SetUIContent(int layoutRes, std::shared_ptr &context, int * * @param windowOption Indicates the window option defined by the user. */ -void Ability::InitWindow(Rosen::WindowType winType, int32_t displayId, sptr option) +void Ability::InitWindow(Rosen::WindowType winType, int32_t displayId) { if (abilityWindow_ == nullptr) { APP_LOGE("Ability::InitWindow abilityWindow_ is nullptr"); @@ -686,11 +686,11 @@ void Ability::InitWindow(Rosen::WindowType winType, int32_t displayId, sptrInitWindow.", __func__); if (useNewMission) { - abilityWindow_->InitWindow(winType, abilityContext_, sceneListener_, displayId, option); + abilityWindow_->InitWindow(winType, abilityContext_, sceneListener_, displayId); } else { std::shared_ptr context = nullptr; sptr listener = nullptr; - abilityWindow_->InitWindow(winType, context, listener, displayId, option); + abilityWindow_->InitWindow(winType, context, listener, displayId); } APP_LOGI("%{public}s end abilityWindow_->InitWindow.", __func__); } @@ -3247,7 +3247,7 @@ sptr Ability::GetWindowOption(const Want &want) APP_LOGE("Ability::GetWindowOption option is null."); return nullptr; } - auto windowMode = want.GetIntParam(Want::PARAM_RESV_WINDOW_MODE, + auto windowMode = want.GetIntParam(StartOptions::STRING_WINDOW_MODE, AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_UNDEFINED); APP_LOGI("Ability::GetWindowOption window mode is %{public}d.", windowMode); option->SetWindowMode(static_cast(windowMode)); diff --git a/frameworks/kits/ability/native/src/ability_runtime/js_ability.cpp b/frameworks/kits/ability/native/src/ability_runtime/js_ability.cpp index c844ef0089be68a459586da65643e5486b26309e..4c9134f4741c2262f787f3a91b56d3e067b21500 100755 --- a/frameworks/kits/ability/native/src/ability_runtime/js_ability.cpp +++ b/frameworks/kits/ability/native/src/ability_runtime/js_ability.cpp @@ -319,7 +319,7 @@ void JsAbility::DoOnForeground(const Want& want) } } auto option = GetWindowOption(want); - Rosen::WMError ret = scene_->Init(displayId, abilityContext_, sceneListener_, option); + Rosen::WMError ret = scene_->Init(displayId, abilityContext_, sceneListener_); if (ret != Rosen::WMError::WM_OK) { HILOG_ERROR("%{public}s error. failed to init window scene!", __func__); return; @@ -333,7 +333,7 @@ void JsAbility::DoOnForeground(const Want& want) AAFwk::IString::Query(want.GetParams().GetParam(PAGE_STACK_PROPERTY_NAME))); HandleScope handleScope(jsRuntime_); auto& engine = jsRuntime_.GetNativeEngine(); - scene_->GetMainWindow()->SetUIContent(pageStack, &engine, + scene_->GetMainWindow()->SetUIContent(abilityContext_, pageStack, &engine, static_cast(abilityContext_->GetContentStorage())); OnSceneRestored(); NotityContinuationResult(want, true); diff --git a/frameworks/kits/ability/native/src/ability_runtime/js_ability_context.cpp b/frameworks/kits/ability/native/src/ability_runtime/js_ability_context.cpp index dde6a512da66174a0266d0575f7c5076458e5f6c..52a8a8bc64ec7b0a5d1600b84796e6ef79023841 100644 --- a/frameworks/kits/ability/native/src/ability_runtime/js_ability_context.cpp +++ b/frameworks/kits/ability/native/src/ability_runtime/js_ability_context.cpp @@ -152,16 +152,8 @@ NativeValue* JsAbilityContext::OnStartAbilityForResult(NativeEngine& engine, Nat HILOG_ERROR("%s Failed to parse want!", __func__); return engine.CreateUndefined(); } - decltype(info.argc) unwrapArgc = 1; - AAFwk::StartOptions startOptions; - if (info.argc > ARGC_ONE && info.argv[1]->TypeOf() == NATIVE_OBJECT) { - HILOG_INFO("OnStartAbilityForResult start options is used."); - AppExecFwk::UnwrapStartOptions(reinterpret_cast(&engine), - reinterpret_cast(info.argv[1]), startOptions); - unwrapArgc++; - } - NativeValue* lastParam = info.argc == unwrapArgc ? nullptr : info.argv[unwrapArgc]; + NativeValue* lastParam = info.argc == 1 ? nullptr : info.argv[1]; NativeValue* result = nullptr; std::unique_ptr uasyncTask = CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, nullptr, &result); @@ -183,8 +175,7 @@ NativeValue* JsAbilityContext::OnStartAbilityForResult(NativeEngine& engine, Nat asyncTask->Reject(engine, CreateJsError(engine, 1, "context is released!")); } else { curRequestCode_ = (curRequestCode_ == INT_MAX) ? 0 : (curRequestCode_ + 1); - (unwrapArgc == 1) ? context->StartAbilityForResult(want, curRequestCode_, std::move(task)) : - context->StartAbilityForResult(want, startOptions, curRequestCode_, std::move(task)); + context->StartAbilityForResult(want, curRequestCode_, std::move(task)); } HILOG_INFO("OnStartAbilityForResult is called end"); return result; diff --git a/frameworks/kits/ability/native/src/ability_runtime/js_window_stage.cpp b/frameworks/kits/ability/native/src/ability_runtime/js_window_stage.cpp index eb189da6dcc4f3c8702e51d6ac1cc8f8fdcb4b9c..1cb04491332663b1cae198d7e54a86aceeb5f05f 100644 --- a/frameworks/kits/ability/native/src/ability_runtime/js_window_stage.cpp +++ b/frameworks/kits/ability/native/src/ability_runtime/js_window_stage.cpp @@ -129,8 +129,7 @@ NativeValue* JsWindowStage::OnSetUIContent(NativeEngine& engine, NativeCallbackI } HILOG_INFO("JsWindowStage::OnSetUIContent Get url: %{public}s", contextUrl.c_str()); - windowScene_->GetMainWindow()->SetUIContent(contextUrl, &engine, - static_cast(abilityContext->GetContentStorage())); + windowScene_->GetMainWindow()->SetUIContent(abilityContext, contextUrl, &engine, nullptr); return engine.CreateUndefined(); } @@ -146,7 +145,7 @@ NativeValue* JsWindowStage::OnGetMainWindow(NativeEngine& engine, NativeCallback [this](NativeEngine& engine, AsyncTask& task, int32_t status) { auto window = windowScene_->GetMainWindow(); if (window != nullptr) { - task.Resolve(engine, OHOS::Rosen::CreateJsWindowObject(engine, window)); + task.Resolve(engine, CreateJsWindowObject(engine, window)); HILOG_INFO("JsWindowStage::OnGetMainWindow success"); } else { task.Reject(engine, CreateJsError(engine, diff --git a/frameworks/kits/ability/native/src/ability_runtime/window/js_window.cpp b/frameworks/kits/ability/native/src/ability_runtime/window/js_window.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a369266342fa7640b38d8d6307ba0b9bcf19dc75 --- /dev/null +++ b/frameworks/kits/ability/native/src/ability_runtime/window/js_window.cpp @@ -0,0 +1,351 @@ +/* + * Copyright (c) 2021 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 "js_window.h" +#include "window.h" +#include "window_manager_hilog.h" +#include "window_option.h" + +using namespace OHOS::Rosen; + +namespace OHOS { +namespace AbilityRuntime { +using namespace AbilityRuntime; +namespace { + constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, 0, "JsWindow"}; +} + +void JsWindow::Finalizer(NativeEngine* engine, void* data, void* hint) +{ + WLOGFI("JsWindow::Finalizer is called"); + std::unique_ptr(static_cast(data)); +} + +NativeValue* JsWindow::Show(NativeEngine* engine, NativeCallbackInfo* info) +{ + WLOGFI("JsWindow::Show is called"); + JsWindow* me = CheckParamsAndGetThis(engine, info); + return (me != nullptr) ? me->OnShow(*engine, *info) : nullptr; +} + +NativeValue* JsWindow::Destroy(NativeEngine* engine, NativeCallbackInfo* info) +{ + WLOGFI("JsWindow::Destroy is called"); + JsWindow* me = CheckParamsAndGetThis(engine, info); + return (me != nullptr) ? me->OnDestroy(*engine, *info) : nullptr; +} + +NativeValue* JsWindow::Hide(NativeEngine* engine, NativeCallbackInfo* info) +{ + WLOGFI("JsWindow::Hide is called"); + JsWindow* me = CheckParamsAndGetThis(engine, info); + return (me != nullptr) ? me->OnHide(*engine, *info) : nullptr; +} + +NativeValue* JsWindow::MoveTo(NativeEngine* engine, NativeCallbackInfo* info) +{ + WLOGFI("JsWindow::MoveTo is called"); + JsWindow* me = CheckParamsAndGetThis(engine, info); + return (me != nullptr) ? me->OnMoveTo(*engine, *info) : nullptr; +} + +NativeValue* JsWindow::Resize(NativeEngine* engine, NativeCallbackInfo* info) +{ + WLOGFI("JsWindow::Resize is called"); + JsWindow* me = CheckParamsAndGetThis(engine, info); + return (me != nullptr) ? me->OnResize(*engine, *info) : nullptr; +} + +NativeValue* JsWindow::SetWindowType(NativeEngine* engine, NativeCallbackInfo* info) +{ + WLOGFI("JsWindow::SetWindowType is called"); + JsWindow* me = CheckParamsAndGetThis(engine, info); + return (me != nullptr) ? me->OnSetWindowType(*engine, *info) : nullptr; +} + +NativeValue* JsWindow::SetWindowMode(NativeEngine* engine, NativeCallbackInfo* info) +{ + WLOGFI("JsWindow::SetWindowMode is called"); + JsWindow* me = CheckParamsAndGetThis(engine, info); + return (me != nullptr) ? me->OnSetWindowMode(*engine, *info) : nullptr; +} + +NativeValue* JsWindow::GetProperties(NativeEngine* engine, NativeCallbackInfo* info) +{ + WLOGFI("JsWindow::GetProperties is called"); + JsWindow* me = CheckParamsAndGetThis(engine, info); + return (me != nullptr) ? me->OnGetProperties(*engine, *info) : nullptr; +} + +NativeValue* JsWindow::OnShow(NativeEngine& engine, NativeCallbackInfo& info) +{ + WLOGFI("JsWindow::OnShow is called"); + if (windowToken_ == nullptr) { + WLOGFE("JsWindow windowToken_ is nullptr"); + return engine.CreateUndefined(); + } + AsyncTask::CompleteCallback complete = + [this](NativeEngine& engine, AsyncTask& task, int32_t status) { + auto ret = windowToken_->Show(); + if (ret == OHOS::Rosen::WMError::WM_OK) { + task.Resolve(engine, engine.CreateUndefined()); + WLOGFI("JsWindow::OnShow success"); + } else { + task.Reject(engine, CreateJsError(engine, static_cast(ret), "ShowWindow failed.")); + } + }; + + NativeValue* lastParam = (info.argc == 0) ? nullptr : info.argv[0]; + NativeValue* result = nullptr; + AsyncTask::Schedule( + engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result)); + return engine.CreateUndefined(); +} + +NativeValue* JsWindow::OnDestroy(NativeEngine& engine, NativeCallbackInfo& info) +{ + WLOGFI("JsWindow::OnDestroy is called"); + if (windowToken_ == nullptr) { + WLOGFE("JsWindow windowToken_ is nullptr"); + return engine.CreateUndefined(); + } + AsyncTask::CompleteCallback complete = + [this](NativeEngine& engine, AsyncTask& task, int32_t status) { + auto ret = windowToken_->Destroy(); + windowToken_ = nullptr; + if (ret == OHOS::Rosen::WMError::WM_OK) { + task.Resolve(engine, engine.CreateUndefined()); + WLOGFI("JsWindow::OnDestroy success"); + } else { + task.Reject(engine, CreateJsError(engine, static_cast(ret), "JsWindow::OnDestroy failed.")); + } + }; + + NativeValue* lastParam = (info.argc == 0) ? nullptr : info.argv[0]; + NativeValue* result = nullptr; + AsyncTask::Schedule( + engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result)); + return engine.CreateUndefined(); +} + +NativeValue* JsWindow::OnHide(NativeEngine& engine, NativeCallbackInfo& info) +{ + WLOGFI("JsWindow::OnHide is called"); + if (windowToken_ == nullptr) { + WLOGFE("JsWindow windowToken_ is nullptr"); + return engine.CreateUndefined(); + } + AsyncTask::CompleteCallback complete = + [this](NativeEngine& engine, AsyncTask& task, int32_t status) { + auto ret = windowToken_->Hide(); + if (ret == OHOS::Rosen::WMError::WM_OK) { + task.Resolve(engine, engine.CreateUndefined()); + WLOGFI("JsWindow::OnHide success"); + } else { + task.Reject(engine, CreateJsError(engine, static_cast(ret), "JsWindow::OnHide failed.")); + } + }; + + NativeValue* lastParam = (info.argc == 0) ? nullptr : info.argv[0]; + NativeValue* result = nullptr; + AsyncTask::Schedule( + engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result)); + return engine.CreateUndefined(); +} + +NativeValue* JsWindow::OnMoveTo(NativeEngine& engine, NativeCallbackInfo& info) +{ + WLOGFI("JsWindow::OnMoveTo is called"); + if (windowToken_ == nullptr) { + WLOGFE("JsWindow windowToken_ is nullptr"); + return engine.CreateUndefined(); + } + int32_t x; + if (!ConvertFromJsValue(engine, info.argv[0], x)) { + WLOGFE("Failed to convert parameter to x"); + return engine.CreateUndefined(); + } + + int32_t y; + if (!ConvertFromJsValue(engine, info.argv[1], y)) { + WLOGFE("Failed to convert parameter to y"); + return engine.CreateUndefined(); + } + AsyncTask::CompleteCallback complete = + [this, x, y](NativeEngine& engine, AsyncTask& task, int32_t status) { + auto ret = windowToken_->MoveTo(x, y); + if (ret == OHOS::Rosen::WMError::WM_OK) { + task.Resolve(engine, engine.CreateUndefined()); + WLOGFI("JsWindow::OnMoveTo success"); + } else { + task.Reject(engine, CreateJsError(engine, static_cast(ret), "JsWindow::OnMoveTo failed.")); + } + }; + + NativeValue* lastParam = (info.argc == ARGC_TWO) ? nullptr : info.argv[INDEX_TWO]; + NativeValue* result = nullptr; + AsyncTask::Schedule( + engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result)); + return engine.CreateUndefined(); +} + +NativeValue* JsWindow::OnResize(NativeEngine& engine, NativeCallbackInfo& info) +{ + WLOGFI("JsWindow::OnResize is called"); + if (windowToken_ == nullptr) { + WLOGFE("JsWindow windowToken_ is nullptr"); + return engine.CreateUndefined(); + } + uint32_t width; + if (!ConvertFromJsValue(engine, info.argv[0], width)) { + WLOGFE("Failed to convert parameter to width"); + return engine.CreateUndefined(); + } + + uint32_t height; + if (!ConvertFromJsValue(engine, info.argv[1], height)) { + WLOGFE("Failed to convert parameter to height"); + return engine.CreateUndefined(); + } + AsyncTask::CompleteCallback complete = + [this, width, height](NativeEngine& engine, AsyncTask& task, int32_t status) { + auto ret = windowToken_->Resize(width, height); + if (ret == OHOS::Rosen::WMError::WM_OK) { + task.Resolve(engine, engine.CreateUndefined()); + WLOGFI("JsWindow::OnResize success"); + } else { + task.Reject(engine, CreateJsError(engine, static_cast(ret), "JsWindow::OnResize failed.")); + } + }; + + NativeValue* lastParam = (info.argc == ARGC_TWO) ? nullptr : info.argv[INDEX_TWO]; + NativeValue* result = nullptr; + AsyncTask::Schedule( + engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result)); + return engine.CreateUndefined(); +} + +NativeValue* JsWindow::OnSetWindowType(NativeEngine& engine, NativeCallbackInfo& info) +{ + WLOGFI("JsWindow::OnSetWindowType is called"); + if (windowToken_ == nullptr) { + WLOGFE("JsWindow windowToken_ is nullptr"); + return engine.CreateUndefined(); + } + NativeNumber* nativeType = ConvertNativeValueTo(info.argv[0]); + if (nativeType == nullptr) { + WLOGFE("Failed to convert parameter to windowType"); + return engine.CreateUndefined(); + } + WindowType winType = static_cast(static_cast(*nativeType)); + AsyncTask::CompleteCallback complete = + [this, winType](NativeEngine& engine, AsyncTask& task, int32_t status) { + auto ret = windowToken_->SetWindowType(winType); + if (ret == OHOS::Rosen::WMError::WM_OK) { + task.Resolve(engine, engine.CreateUndefined()); + WLOGFI("JsWindow::OnSetWindowType success"); + } else { + task.Reject(engine, CreateJsError(engine, + static_cast(ret), "JsWindow::OnSetWindowType failed.")); + } + }; + + NativeValue* lastParam = (info.argc == ARGC_ONE) ? nullptr : info.argv[INDEX_ONE]; + NativeValue* result = nullptr; + AsyncTask::Schedule( + engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result)); + return engine.CreateUndefined(); +} + +NativeValue* JsWindow::OnSetWindowMode(NativeEngine& engine, NativeCallbackInfo& info) +{ + WLOGFI("JsWindow::OnSetWindowMode is called"); + if (windowToken_ == nullptr) { + WLOGFE("JsWindow windowToken_ is nullptr"); + return engine.CreateUndefined(); + } + NativeNumber* nativeMode = ConvertNativeValueTo(info.argv[0]); + if (nativeMode == nullptr) { + WLOGFE("Failed to convert parameter to windowMode"); + return engine.CreateUndefined(); + } + WindowMode winMode = static_cast(static_cast(*nativeMode)); + AsyncTask::CompleteCallback complete = + [this, winMode](NativeEngine& engine, AsyncTask& task, int32_t status) { + auto ret = windowToken_->SetWindowMode(winMode); + if (ret == OHOS::Rosen::WMError::WM_OK) { + task.Resolve(engine, engine.CreateUndefined()); + WLOGFI("JsWindow::OnSetWindowMode success"); + } else { + task.Reject(engine, + CreateJsError(engine, static_cast(ret), "JsWindow::OnSetWindowMode failed.")); + } + }; + + NativeValue* lastParam = (info.argc == ARGC_ONE) ? nullptr : info.argv[INDEX_ONE]; + NativeValue* result = nullptr; + AsyncTask::Schedule( + engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result)); + return engine.CreateUndefined(); +} + +NativeValue* JsWindow::OnGetProperties(NativeEngine& engine, NativeCallbackInfo& info) +{ + WLOGFI("JsWindow::OnGetProperties is called"); + if (windowToken_ == nullptr) { + WLOGFE("JsWindow windowToken_ is nullptr"); + return engine.CreateUndefined(); + } + AsyncTask::CompleteCallback complete = + [this](NativeEngine& engine, AsyncTask& task, int32_t status) { + auto objValue = CreateJsWindowPropertiesObject(engine, windowToken_); + WLOGFI("JsWindow::OnGetProperties objValue %{public}p", objValue); + if (objValue != nullptr) { + task.Resolve(engine, objValue); + WLOGFI("JsWindow::OnGetProperties success"); + } else { + task.Reject(engine, CreateJsError(engine, + static_cast(OHOS::Rosen::WMError::WM_ERROR_NULLPTR), "JsWindow::OnGetProperties failed.")); + } + }; + + NativeValue* lastParam = (info.argc == 0) ? nullptr : info.argv[0]; + NativeValue* result = nullptr; + AsyncTask::Schedule( + engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result)); + return result; +} + +NativeValue* CreateJsWindowObject(NativeEngine& engine, sptr& window) +{ + WLOGFI("JsWindow::CreateJsWindow is called"); + NativeValue* objValue = engine.CreateObject(); + NativeObject* object = ConvertNativeValueTo(objValue); + + std::unique_ptr jsWindow = std::make_unique(window); + object->SetNativePointer(jsWindow.release(), JsWindow::Finalizer, nullptr); + + BindNativeFunction(engine, *object, "show", JsWindow::Show); + BindNativeFunction(engine, *object, "destroy", JsWindow::Destroy); + BindNativeFunction(engine, *object, "hide", JsWindow::Hide); + BindNativeFunction(engine, *object, "moveTo", JsWindow::MoveTo); + BindNativeFunction(engine, *object, "resetSize", JsWindow::Resize); + BindNativeFunction(engine, *object, "setWindowType", JsWindow::SetWindowType); + BindNativeFunction(engine, *object, "setWindowMode", JsWindow::SetWindowMode); + BindNativeFunction(engine, *object, "getProperties", JsWindow::GetProperties); + return objValue; +} +} // namespace AbilityRuntime +} // namespace OHOS diff --git a/frameworks/kits/ability/native/src/js_static_subscriber_extension_context.cpp b/frameworks/kits/ability/native/src/ability_runtime/window/js_window.h similarity index 30% rename from frameworks/kits/ability/native/src/js_static_subscriber_extension_context.cpp rename to frameworks/kits/ability/native/src/ability_runtime/window/js_window.h index e350c9ee335f11ae3cf3e955ab0ac320daf533d3..29b5065160a4eb56fba33550b33ac27545298ee1 100644 --- a/frameworks/kits/ability/native/src/js_static_subscriber_extension_context.cpp +++ b/frameworks/kits/ability/native/src/ability_runtime/window/js_window.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2021 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 @@ -13,47 +13,43 @@ * limitations under the License. */ -#include "js_static_subscriber_extension_context.h" - -#include "hilog_wrapper.h" - -#include "js_extension_context.h" -#include "js_runtime.h" +#ifndef OHOS_JS_WINDOW_H +#define OHOS_JS_WINDOW_H #include "js_runtime_utils.h" -#include "napi/native_api.h" -#include "napi_common_want.h" - +#include "js_window_utils.h" +#include "native_engine/native_engine.h" +#include "native_engine/native_value.h" +#include "window.h" namespace OHOS { namespace AbilityRuntime { -namespace { -class JsStaticSubscriberExtensionContext final { +NativeValue* CreateJsWindowObject(NativeEngine& engine, sptr& window); + +class JsWindow final { public: - explicit JsStaticSubscriberExtensionContext(const std::shared_ptr& context) - : context_(context) {} - ~JsStaticSubscriberExtensionContext() = default; + explicit JsWindow(const sptr& window) : windowToken_(window) {} + ~JsWindow() = default; + static void Finalizer(NativeEngine* engine, void* data, void* hint); + static NativeValue* Show(NativeEngine* engine, NativeCallbackInfo* info); + static NativeValue* Destroy(NativeEngine* engine, NativeCallbackInfo* info); + static NativeValue* Hide(NativeEngine* engine, NativeCallbackInfo* info); + static NativeValue* MoveTo(NativeEngine* engine, NativeCallbackInfo* info); + static NativeValue* Resize(NativeEngine* engine, NativeCallbackInfo* info); + static NativeValue* SetWindowType(NativeEngine* engine, NativeCallbackInfo* info); + static NativeValue* SetWindowMode(NativeEngine* engine, NativeCallbackInfo* info); + static NativeValue* GetProperties(NativeEngine* engine, NativeCallbackInfo* info); - static void Finalizer(NativeEngine* engine, void* data, void* hint) - { - HILOG_INFO("JsStaticSubscriberExtensionContext::Finalizer is called"); - std::unique_ptr( - static_cast(data)); - } private: - std::weak_ptr context_; -}; -} // namespace - -NativeValue* CreateJsStaticSubscriberExtensionContext(NativeEngine& engine, - std::shared_ptr context) -{ - HILOG_INFO("CreateJsStaticSubscriberExtensionContext begin"); - NativeValue *objValue = CreateJsExtensionContext(engine, context); - NativeObject *object = ConvertNativeValueTo(objValue); + NativeValue* OnShow(NativeEngine& engine, NativeCallbackInfo& info); + NativeValue* OnDestroy(NativeEngine& engine, NativeCallbackInfo& info); + NativeValue* OnHide(NativeEngine& engine, NativeCallbackInfo& info); + NativeValue* OnMoveTo(NativeEngine& engine, NativeCallbackInfo& info); + NativeValue* OnResize(NativeEngine& engine, NativeCallbackInfo& info); + NativeValue* OnSetWindowType(NativeEngine& engine, NativeCallbackInfo& info); + NativeValue* OnSetWindowMode(NativeEngine& engine, NativeCallbackInfo& info); + NativeValue* OnGetProperties(NativeEngine& engine, NativeCallbackInfo& info); - std::unique_ptr jsContext = - std::make_unique(context); - object->SetNativePointer(jsContext.release(), JsStaticSubscriberExtensionContext::Finalizer, nullptr); - return objValue; -} + sptr windowToken_ = nullptr; +}; } // namespace AbilityRuntime } // namespace OHOS +#endif \ No newline at end of file diff --git a/frameworks/kits/ability/native/src/ability_runtime/window/js_window_manager.cpp b/frameworks/kits/ability/native/src/ability_runtime/window/js_window_manager.cpp new file mode 100644 index 0000000000000000000000000000000000000000..24156ae1dd140f3164987927339d80ed4dd90ed4 --- /dev/null +++ b/frameworks/kits/ability/native/src/ability_runtime/window/js_window_manager.cpp @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2021 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 "js_window_manager.h" +#include "js_runtime_utils.h" +#include "js_window.h" +#include "js_window_utils.h" +#include "native_engine/native_reference.h" +#include "window_manager_hilog.h" +#include "window_option.h" + +using namespace OHOS::Rosen; + +namespace OHOS { +namespace AbilityRuntime { +using namespace AbilityRuntime; +namespace { + constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, 0, "JsWindowManager"}; +} + +class JsWindowManager { +public: + JsWindowManager() = default; + ~JsWindowManager() = default; + + static void Finalizer(NativeEngine* engine, void* data, void* hint) + { + WLOGFI("JsWindowManager::Finalizer is called"); + std::unique_ptr(static_cast(data)); + } + + static NativeValue* CreateWindow(NativeEngine* engine, NativeCallbackInfo* info) + { + JsWindowManager* me = CheckParamsAndGetThis(engine, info); + return (me != nullptr) ? me->OnCreateWindow(*engine, *info) : nullptr; + } + + static NativeValue* FindWindow(NativeEngine* engine, NativeCallbackInfo* info) + { + JsWindowManager* me = CheckParamsAndGetThis(engine, info); + return (me != nullptr) ? me->OnFindWindow(*engine, *info) : nullptr; + } + +private: + + NativeValue* OnCreateWindow(NativeEngine& engine, NativeCallbackInfo& info) + { + WLOGFI("JsOnCreateWindow is called"); + + if (info.argc < ARGC_TWO) { + WLOGFE("OnCreateWindow MUST set windowname"); + return engine.CreateUndefined(); + } + + std::string windowName; + if (!ConvertFromJsValue(engine, info.argv[0], windowName)) { + WLOGFE("Failed to convert parameter to windowName"); + return engine.CreateUndefined(); + } + + NativeNumber* nativeType = ConvertNativeValueTo(info.argv[1]); + if (nativeType == nullptr) { + WLOGFE("Failed to convert parameter to windowType"); + return engine.CreateUndefined(); + } + WindowType winType = static_cast(static_cast(*nativeType)); + sptr windowOption = new WindowOption(); + windowOption->SetWindowType(winType); + AsyncTask::CompleteCallback complete = + [windowName, &windowOption](NativeEngine& engine, AsyncTask& task, int32_t status) { + sptr window = Window::Create(windowName, windowOption); + if (window != nullptr) { + task.Resolve(engine, CreateJsWindowObject(engine, window)); + WLOGFI("JsWindowManager::OnCreateWindow success"); + } else { + task.Reject(engine, CreateJsError(engine, + static_cast(WMError::WM_ERROR_NULLPTR), "JsWindowManager::OnCreateWindow failed.")); + } + }; + + NativeValue* lastParam = (info.argc == ARGC_TWO) ? nullptr : info.argv[INDEX_TWO]; + NativeValue* result = nullptr; + AsyncTask::Schedule( + engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result)); + return result; + } + + NativeValue* OnFindWindow(NativeEngine& engine, NativeCallbackInfo& info) + { + std::string windowName; + if (!ConvertFromJsValue(engine, info.argv[0], windowName)) { + WLOGFE("Failed to convert parameter to windowName"); + return engine.CreateUndefined(); + } + + AsyncTask::CompleteCallback complete = + [windowName](NativeEngine& engine, AsyncTask& task, int32_t status) { + sptr window = Window::Find(windowName); + if (window != nullptr) { + task.Resolve(engine, CreateJsWindowObject(engine, window)); + WLOGFI("JsWindowManager::OnFindWindow success"); + } else { + task.Reject(engine, CreateJsError(engine, + static_cast(WMError::WM_ERROR_NULLPTR), "JsWindow::OnFindWindow failed.")); + } + }; + + NativeValue* lastParam = (info.argc == ARGC_ONE) ? nullptr : info.argv[INDEX_ONE]; + if (lastParam == nullptr) { + WLOGFI("JsWindowManager::OnFindWindow lastParam is nullptr"); + } + NativeValue* result = nullptr; + AsyncTask::Schedule( + engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result)); + return result; + } +}; + +NativeValue* JsWindowManagerInit(NativeEngine* engine, NativeValue* exportObj) +{ + WLOGFI("JsWindowManagerInit is called"); + + if (engine == nullptr || exportObj == nullptr) { + WLOGFE("JsWindowManagerInit engine or exportObj is nullptr"); + return nullptr; + } + + NativeObject* object = ConvertNativeValueTo(exportObj); + if (object == nullptr) { + WLOGFE("JsWindowManagerInit object is nullptr"); + return nullptr; + } + + std::unique_ptr jsWinManager = std::make_unique(); + object->SetNativePointer(jsWinManager.release(), JsWindowManager::Finalizer, nullptr); + + BindNativeFunction(*engine, *object, "create", JsWindowManager::CreateWindow); + BindNativeFunction(*engine, *object, "find", JsWindowManager::FindWindow); + + return engine->CreateUndefined(); +} +} // namespace AbilityRuntime +} // namespace OHOS \ No newline at end of file diff --git a/interfaces/kits/napi/aafwk/static_subscriber_extension_context/static_subscriber_extension_context.js b/frameworks/kits/ability/native/src/ability_runtime/window/js_window_manager.h similarity index 64% rename from interfaces/kits/napi/aafwk/static_subscriber_extension_context/static_subscriber_extension_context.js rename to frameworks/kits/ability/native/src/ability_runtime/window/js_window_manager.h index 7df95b9b7d33cce541291f8ff6e917005c083e1e..d6f32d1641d0b83a34968da2ab23b856896c0d6f 100644 --- a/interfaces/kits/napi/aafwk/static_subscriber_extension_context/static_subscriber_extension_context.js +++ b/frameworks/kits/ability/native/src/ability_runtime/window/js_window_manager.h @@ -13,12 +13,14 @@ * limitations under the License. */ -var ExtensionContext = requireNapi("application.ExtensionContext") +#include "native_engine/native_engine.h" +#include "native_engine/native_value.h" +#ifndef OHOS_JS_WINDOW_MANAGER_H +#define OHOS_JS_WINDOW_MANAGER_H +namespace OHOS { +namespace AbilityRuntime { +NativeValue* JsWindowManagerInit(NativeEngine* engine, NativeValue* exportObj); +} // namespace AbilityRuntime +} // namespace OHOS -class StaticSubscriberExtensionContext extends ExtensionContext { - constructor(obj) { - super(obj); - } -} - -export default StaticSubscriberExtensionContext \ No newline at end of file +#endif diff --git a/frameworks/kits/ability/native/src/ability_runtime/window/js_window_utils.cpp b/frameworks/kits/ability/native/src/ability_runtime/window/js_window_utils.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1506959eb0ac879435716b2e7b048689f1b154d4 --- /dev/null +++ b/frameworks/kits/ability/native/src/ability_runtime/window/js_window_utils.cpp @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2021 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 "js_window_utils.h" +#include "js_runtime_utils.h" +#include "window_manager_hilog.h" + +using namespace OHOS::Rosen; + +namespace OHOS { +namespace AbilityRuntime { +using namespace AbilityRuntime; +namespace { + constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, 0, "JsWindowUtils"}; +} + +static NativeValue* GetRectAndConvertToJsValue(NativeEngine& engine, const OHOS::Rosen::Rect& rect) +{ + NativeValue* objValue = engine.CreateObject(); + NativeObject* object = ConvertNativeValueTo(objValue); + if (object == nullptr) { + WLOGFE("Failed to convert rect to jsObject"); + return engine.CreateUndefined(); + } + WLOGFI("JsWindow::CreateJsWindowPropertiesObject x:%{public}d, y:%{public}d,", rect.posX_, rect.posY_); + object->SetProperty("left", CreateJsValue(engine, rect.posX_)); + object->SetProperty("top", CreateJsValue(engine, rect.posY_)); + object->SetProperty("width", CreateJsValue(engine, rect.width_)); + object->SetProperty("height", CreateJsValue(engine, rect.height_)); + return objValue; +} + +NativeValue* CreateJsWindowPropertiesObject(NativeEngine& engine, sptr& window) +{ + WLOGFI("JsWindow::CreateJsWindowPropertiesObject is called"); + NativeValue* objValue = engine.CreateObject(); + NativeObject* object = ConvertNativeValueTo(objValue); + if (object == nullptr) { + WLOGFE("Failed to convert windowProperties to jsObject"); + return nullptr; + } + + OHOS::Rosen::Rect rect = window->GetRect(); + NativeValue* rectObj = GetRectAndConvertToJsValue(engine, rect); + if (rectObj == nullptr) { + WLOGFE("GetRect failed!"); + } + object->SetProperty("windowRect", rectObj); + object->SetProperty("type", CreateJsValue(engine, window->GetType())); + return objValue; +} +} // namespace AbilityRuntime +} // namespace OHOS \ No newline at end of file diff --git a/interfaces/kits/napi/aafwk/static_subscriber_extension/static_subscriber_extension.js b/frameworks/kits/ability/native/src/ability_runtime/window/js_window_utils.h similarity index 53% rename from interfaces/kits/napi/aafwk/static_subscriber_extension/static_subscriber_extension.js rename to frameworks/kits/ability/native/src/ability_runtime/window/js_window_utils.h index 4e31c2ff63721acebcb1c9df1e26cee46f2470fe..1e265dbe4f56c74e401406eb16951a0a17344360 100644 --- a/interfaces/kits/napi/aafwk/static_subscriber_extension/static_subscriber_extension.js +++ b/frameworks/kits/ability/native/src/ability_runtime/window/js_window_utils.h @@ -13,10 +13,24 @@ * limitations under the License. */ -class StaticSubscriberExtension { - onCommonEventTriggered(event) { - console.log('onCommonEventTriggered, event:' + event.code); - } +#ifndef OHOS_JS_WINDOW_UTILS_H +#define OHOS_JS_WINDOW_UTILS_H +#include "native_engine/native_engine.h" +#include "native_engine/native_value.h" +#include "window.h" +#include "window_option.h" +#include "wm_common.h" + +namespace OHOS { +namespace AbilityRuntime { +namespace { + constexpr size_t ARGC_ONE = 1; + constexpr size_t ARGC_TWO = 2; + constexpr int32_t INDEX_ONE = 1; + constexpr int32_t INDEX_TWO = 2; } -export default StaticSubscriberExtension \ No newline at end of file + NativeValue* CreateJsWindowPropertiesObject(NativeEngine& engine, sptr& window); +} +} +#endif \ No newline at end of file diff --git a/frameworks/kits/ability/native/src/ability_thread.cpp b/frameworks/kits/ability/native/src/ability_thread.cpp index 6b697f11ef25ff40466c41490b26e53aec09a74c..cee7f5e6f31afb6fe0111db5ec035a21b57c82fa 100644 --- a/frameworks/kits/ability/native/src/ability_thread.cpp +++ b/frameworks/kits/ability/native/src/ability_thread.cpp @@ -43,7 +43,6 @@ constexpr static char ACE_DATA_ABILITY_NAME[] = "AceDataAbility"; constexpr static char ACE_FORM_ABILITY_NAME[] = "AceFormAbility"; constexpr static char BASE_SERVICE_EXTENSION[] = "ServiceExtension"; constexpr static char FORM_EXTENSION[] = "FormExtension"; -// constexpr static char STATIC_SUBSCRIBER_EXTENSION[] = "StaticSubscriberExtension"; constexpr int TARGET_VERSION_THRESHOLDS = 8; /** @@ -100,9 +99,6 @@ std::string AbilityThread::CreateAbilityName(const std::shared_ptrtype == AbilityType::DATA) { abilityName = ACE_DATA_ABILITY_NAME; } else if (abilityInfo->type == AbilityType::EXTENSION) { - /* if (abilityInfo->extensionAbilityType == ExtensionAbilityType::STATICSUBSCRIBER) { - abilittName = STATIC_SUBSCRIBER_EXTENSION; - } */ abilityName = BASE_SERVICE_EXTENSION; if (abilityInfo->formEnabled == true) { abilityName = FORM_EXTENSION; diff --git a/frameworks/kits/ability/native/src/ability_window.cpp b/frameworks/kits/ability/native/src/ability_window.cpp index c595e1b722747ebdb523f1bc04c3970f7198bdb4..611beeb80a7d836afbc378bfcebe859c97c696df 100644 --- a/frameworks/kits/ability/native/src/ability_window.cpp +++ b/frameworks/kits/ability/native/src/ability_window.cpp @@ -50,10 +50,10 @@ void AbilityWindow::Init(std::shared_ptr& handler, std::shared_p */ bool AbilityWindow::InitWindow(Rosen::WindowType winType, std::shared_ptr &abilityContext, - sptr &listener, int32_t displayId, sptr option) + sptr &listener, int32_t displayId) { APP_LOGI("%{public}s begin.", __func__); - auto ret = windowScene_->Init(displayId, abilityContext, listener, option); + auto ret = windowScene_->Init(displayId, abilityContext, listener); if (ret != OHOS::Rosen::WMError::WM_OK) { APP_LOGE("%{public}s error. failed to init window scene!", __func__); return false; diff --git a/frameworks/kits/ability/native/src/js_static_subscriber_extension.cpp b/frameworks/kits/ability/native/src/js_static_subscriber_extension.cpp deleted file mode 100644 index d3b16557d98e468153300e54f89821a8c64dff35..0000000000000000000000000000000000000000 --- a/frameworks/kits/ability/native/src/js_static_subscriber_extension.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright (c) 2022 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 "js_static_subscriber_extension.h" - -#include "ability_info.h" -#include "hilog_wrapper.h" -#include "js_runtime.h" -#include "js_runtime_utils.h" -#include "js_static_subscriber_extension_context.h" -#include "napi_common_want.h" -#include "napi/native_api.h" -#include "napi/native_node_api.h" -#include "napi_remote_object.h" -#include "static_subscriber_stub_imp.h" - -namespace OHOS { -namespace AbilityRuntime { -namespace { -constexpr size_t ARGC_ONE = 1; -} - -using namespace OHOS::AppExecFwk; -JsStaticSubscriberExtension* JsStaticSubscriberExtension::Create(const std::unique_ptr& runtime) -{ - return new JsStaticSubscriberExtension(static_cast(*runtime)); -} - -JsStaticSubscriberExtension::JsStaticSubscriberExtension(JsRuntime& jsRuntime) : jsRuntime_(jsRuntime) {} -JsStaticSubscriberExtension::~JsStaticSubscriberExtension() = default; - -void JsStaticSubscriberExtension::Init(const std::shared_ptr& record, - const std::shared_ptr& application, - std::shared_ptr& handler, - const sptr& token) -{ - StaticSubscriberExtension::Init(record, application, handler, token); - std::string srcPath(Extension::abilityInfo_->package); - srcPath.append("/assets/js/"); - if (!Extension::abilityInfo_->srcPath.empty()) { - srcPath.append(Extension::abilityInfo_->srcPath); - } - srcPath.append("/").append(Extension::abilityInfo_->name).append(".abc"); - - std::string moduleName(Extension::abilityInfo_->moduleName); - moduleName.append("::").append(abilityInfo_->name); - HILOG_INFO("JsStaticSubscriberExtension::Init moduleName:%{public}s,srcPath:%{public}s.", - moduleName.c_str(), srcPath.c_str()); - HandleScope handleScope(jsRuntime_); - auto& engine = jsRuntime_.GetNativeEngine(); - - jsObj_ = jsRuntime_.LoadModule(moduleName, srcPath); - if (jsObj_ == nullptr) { - HILOG_ERROR("Failed to get jsObj_"); - return; - } - HILOG_INFO("JsStaticSubscriberExtension::Init ConvertNativeValueTo."); - NativeObject* obj = ConvertNativeValueTo(jsObj_->Get()); - if (obj == nullptr) { - HILOG_ERROR("Failed to get JsStaticSubscriberExtension object"); - return; - } - - auto context = GetContext(); - if (context == nullptr) { - HILOG_ERROR("Failed to get context"); - return; - } - HILOG_INFO("JsStaticSubscriberExtension::Init CreateJsStaticSubscriberExtensionContext."); - NativeValue* contextObj = CreateJsStaticSubscriberExtensionContext(engine, context); - auto shellContextRef = jsRuntime_.LoadSystemModule("application.StaticSubscriberExtensionContext", - &contextObj, ARGC_ONE); - contextObj = shellContextRef->Get(); - HILOG_INFO("JsStaticSubscriberExtension::Init Bind."); - context->Bind(jsRuntime_, shellContextRef.release()); - HILOG_INFO("JsStaticSubscriberExtension::SetProperty."); - obj->SetProperty("context", contextObj); - HILOG_INFO("JsStaticSubscriberExtension::Init end."); -} - -void JsStaticSubscriberExtension::OnStart(const AAFwk::Want& want) -{ - Extension::OnStart(want); - HILOG_INFO("%{public}s begin.", __func__); - HILOG_INFO("%{public}s end.", __func__); -} - -void JsStaticSubscriberExtension::OnStop() -{ - Extension::OnStop(); - HILOG_INFO("%{public}s end.", __func__); -} - -sptr JsStaticSubscriberExtension::OnConnect(const AAFwk::Want& want) -{ - Extension::OnConnect(want); - HILOG_INFO("%{public}s begin.", __func__); - sptr remoteObject = new (std::nothrow) StaticSubscriberStubImp( - std::static_pointer_cast(shared_from_this())); - HILOG_INFO("%{public}s end. ", __func__); - return remoteObject->AsObject(); -} - -void JsStaticSubscriberExtension::OnDisconnect(const AAFwk::Want& want) -{ - Extension::OnDisconnect(want); - HILOG_INFO("%{public}s begin.", __func__); - HILOG_INFO("%{public}s end.", __func__); -} - -void JsStaticSubscriberExtension::OnCommonEventTriggered(EventFwk::CommonEventData* data) -{ - StaticSubscriberExtension::OnCommonEventTriggered(data); - HILOG_INFO("%{public}s begin.", __func__); - if (data == nullptr) { - HILOG_ERROR("%{public}s common event data == nullptr", __func__); - return; - } - - HandleScope handleScope(jsRuntime_); - NativeEngine& nativeEngine = jsRuntime_.GetNativeEngine(); - - NativeValue* jCommonEventData = nativeEngine.CreateObject(); - NativeObject* commonEventData = ConvertNativeValueTo(jCommonEventData); - Want want = data->GetWant(); - commonEventData->SetProperty("event", nativeEngine.CreateString(want.GetAction().c_str(), want.GetAction().size())); - commonEventData->SetProperty("bundleName", nativeEngine.CreateString(want.GetBundle().c_str(), - want.GetBundle().size())); - commonEventData->SetProperty("code", nativeEngine.CreateNumber(data->GetCode())); - commonEventData->SetProperty("data", nativeEngine.CreateString(data->GetData().c_str(), data->GetData().size())); - napi_value napiParams = AppExecFwk::WrapWantParams(reinterpret_cast(&nativeEngine), want.GetParams()); - NativeValue* nativeParams = reinterpret_cast(napiParams); - commonEventData->SetProperty("parameters", nativeParams); - - NativeValue* argv[] = {jCommonEventData}; - if (!jsObj_) { - HILOG_WARN("Not found StaticSubscriberExtension.js"); - return; - } - - NativeValue* value = jsObj_->Get(); - NativeObject* obj = ConvertNativeValueTo(value); - if (obj == nullptr) { - HILOG_ERROR("Failed to get StaticSubscriberExtension object"); - return; - } - - NativeValue* method = obj->GetProperty("onCommonEventTriggered"); - if (method == nullptr) { - HILOG_ERROR("Failed to get onCommonEventTriggered from StaticSubscriberExtension object"); - return; - } - nativeEngine.CallFunction(value, method, argv, ARGC_ONE); - HILOG_INFO("%{public}s end.", __func__); -} -} // namespace AbilityRuntime -} // namespace OHOS \ No newline at end of file diff --git a/frameworks/kits/ability/native/src/static_subscriber_extension.cpp b/frameworks/kits/ability/native/src/static_subscriber_extension.cpp deleted file mode 100644 index 2bf23e4f8d0497a8c2daee524fade0b1f49430ce..0000000000000000000000000000000000000000 --- a/frameworks/kits/ability/native/src/static_subscriber_extension.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2021 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 "static_subscriber_extension.h" - -#include "ability_loader.h" -#include "extension_base.cpp" -#include "hilog_wrapper.h" -#include "js_static_subscriber_extension.h" -#include "runtime.h" -#include "static_subscriber_extension_context.h" - -namespace OHOS { -namespace AbilityRuntime { -using namespace OHOS::AppExecFwk; -StaticSubscriberExtension* StaticSubscriberExtension::Create(const std::unique_ptr& runtime) -{ - if (!runtime) { - return new StaticSubscriberExtension(); - } - HILOG_INFO("StaticSubscriberExtension::Create runtime"); - switch (runtime->GetLanguage()) { - case Runtime::Language::JS: - return JsStaticSubscriberExtension::Create(runtime); - - default: - return new StaticSubscriberExtension(); - } -} - -void StaticSubscriberExtension::Init(const std::shared_ptr& record, - const std::shared_ptr& application, - std::shared_ptr& handler, - const sptr& token) -{ - HILOG_INFO("StaticSubscriberExtension begin init"); - ExtensionBase::Init(record, application, handler, token); -} - -std::shared_ptr StaticSubscriberExtension::CreateAndInitContext( - const std::shared_ptr& record, - const std::shared_ptr& application, - std::shared_ptr& handler, - const sptr& token) -{ - std::shared_ptr context = - ExtensionBase::CreateAndInitContext(record, application, handler, token); - if (record == nullptr) { - HILOG_ERROR("StaticSubscriberExtension::CreateAndInitContext record is nullptr"); - return context; - } - return context; -} - -void StaticSubscriberExtension::OnCommonEventTriggered(EventFwk::CommonEventData* data) -{ - HILOG_INFO("%{public}s begin.", __func__); - HILOG_INFO("%{public}s end.", __func__); -} -} // namespace AbilityRuntime -} // namespace OHOS \ No newline at end of file diff --git a/frameworks/kits/ability/native/src/static_subscriber_proxy.cpp b/frameworks/kits/ability/native/src/static_subscriber_proxy.cpp deleted file mode 100644 index 7d25387d32e93a14f1366da9fb78cd225602f513..0000000000000000000000000000000000000000 --- a/frameworks/kits/ability/native/src/static_subscriber_proxy.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2022 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 "static_subscriber_proxy.h" - -namespace OHOS { -namespace AppExecFwk { -ErrCode StaticSubscriberProxy::OnCommonEventTriggered(CommonEventData* inData) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - - data.WriteParcelable(inData); - - int32_t st = Remote()->SendRequest(COMMAND_ON_COMMON_EVENT_TRIGGERED, data, reply, option); - if (st != ERR_NONE) { - return st; - } - - ErrCode ec = reply.ReadInt32(); - if (FAILED(ec)) { - return ec; - } - - return ERR_OK; -} -} // namespace AppExecFwk -} // namespace OHOS diff --git a/frameworks/kits/ability/native/src/static_subscriber_stub.cpp b/frameworks/kits/ability/native/src/static_subscriber_stub.cpp deleted file mode 100644 index 16c617ed2f20ab29dee2d465810f1217ddcc46e1..0000000000000000000000000000000000000000 --- a/frameworks/kits/ability/native/src/static_subscriber_stub.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2022 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 "static_subscriber_stub.h" - -namespace OHOS { -namespace AppExecFwk { -int StaticSubscriberStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, - MessageOption& option) -{ - switch (code) { - case COMMAND_ON_COMMON_EVENT_TRIGGERED: { - CommonEventData* inData = data.ReadParcelable(); - ErrCode ec = OnCommonEventTriggered(inData); - reply.WriteInt32(ec); - return ERR_NONE; - } - default: - return IPCObjectStub::OnRemoteRequest(code, data, reply, option); - } - - return ERR_TRANSACTION_FAILED; -} -} // namespace AppExecFwk -} // namespace OHOS diff --git a/frameworks/kits/ability/native/src/static_subscriber_stub_imp.cpp b/frameworks/kits/ability/native/src/static_subscriber_stub_imp.cpp deleted file mode 100644 index 98c2bd561c710df5abf89dd9b616067e1d2661c1..0000000000000000000000000000000000000000 --- a/frameworks/kits/ability/native/src/static_subscriber_stub_imp.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2022 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 "static_subscriber_stub_imp.h" - -#include "hilog_wrapper.h" - -namespace OHOS { -namespace AppExecFwk { -ErrCode StaticSubscriberStubImp::OnCommonEventTriggered(CommonEventData* data) -{ - HILOG_INFO("%{public}s begin.", __func__); - auto extension = extension_.lock(); - if (extension != nullptr) { - extension->OnCommonEventTriggered(data); - HILOG_INFO("%{public}s end successfully.", __func__); - return 0; - } - HILOG_INFO("%{public}s end failed.", __func__); - return -1; -} -} // namespace AppExecFwk -} // namespace OHOS diff --git a/frameworks/kits/content/cpp/src/ohos/aafwk/content/want.cpp b/frameworks/kits/content/cpp/src/ohos/aafwk/content/want.cpp index fee16ccbf447f803c870d81d28b547401f3743eb..ffe84090a3ac8739e5fa5f45d0171bdd6fa8a488 100644 --- a/frameworks/kits/content/cpp/src/ohos/aafwk/content/want.cpp +++ b/frameworks/kits/content/cpp/src/ohos/aafwk/content/want.cpp @@ -66,8 +66,6 @@ const std::string Want::OCT_SEMICOLON("073"); // ';' const std::string Want::MIME_TYPE("mime-type"); const std::string Want::WANT_HEADER("#Intent;"); -const std::string Want::PARAM_RESV_WINDOW_MODE("ohos.aafwk.param.windowMode"); - /** * @description:Default construcotr of Want class, which is used to initialzie flags and URI. * @param None diff --git a/frameworks/kits/runtime/native/js_data_struct_converter.cpp b/frameworks/kits/runtime/native/js_data_struct_converter.cpp index b4a9583fba2f798800523bee9b4243f74e33cd85..bb26794ba1b53011487d6d9efd2eaf0917f41dac 100644 --- a/frameworks/kits/runtime/native/js_data_struct_converter.cpp +++ b/frameworks/kits/runtime/native/js_data_struct_converter.cpp @@ -78,11 +78,33 @@ NativeValue* CreateJsAbilityInfo(NativeEngine& engine, const AppExecFwk::Ability object->SetProperty("minFormWidth", CreateJsValue(engine, abilityInfo.minFormWidth)); object->SetProperty("defaultFormWidth", CreateJsValue(engine, abilityInfo.defaultFormWidth)); object->SetProperty("uri", CreateJsValue(engine, abilityInfo.uri)); - // customizeData: Map>; + object->SetProperty("metaData", CreateJsCustomizeDataArray(engine, abilityInfo.metaData.customizeData)); return objValue; } +NativeValue* CreateJsCustomizeData(NativeEngine& engine, const AppExecFwk::CustomizeData &Info) +{ + NativeValue *objValue = engine.CreateObject(); + NativeObject *object = ConvertNativeValueTo(objValue); + + object->SetProperty("name", CreateJsValue(engine, Info.name)); + object->SetProperty("value", CreateJsValue(engine, Info.value)); + object->SetProperty("extra", CreateJsValue(engine, Info.extra)); + return objValue; +} + +NativeValue* CreateJsCustomizeDataArray(NativeEngine& engine, const std::vector &info) +{ + NativeValue* arrayValue = engine.CreateArray(info.size()); + NativeArray* array = ConvertNativeValueTo(arrayValue); + uint32_t index = 0; + for (const auto& item : info) { + array->SetElement(index++, CreateJsCustomizeData(engine, item)); + } + return arrayValue; +} + NativeValue* CreateJsModuleInfo(NativeEngine& engine, const AppExecFwk::ModuleInfo &moduleInfo) { NativeValue *objValue = engine.CreateObject(); @@ -126,6 +148,10 @@ NativeValue* CreateJsApplicationInfo(NativeEngine& engine, const AppExecFwk::App } } object->SetProperty("moduleInfo", arrayValue); + // metaData: Map>; + for (auto &item : applicationInfo.metaData) { + object->SetProperty(item.first.c_str(), CreateJsCustomizeDataArray(engine, item.second)); + } return objValue; } diff --git a/interfaces/innerkits/ability_manager/include/start_options.h b/interfaces/innerkits/ability_manager/include/start_options.h index 82fe7cd47f70d11565949bff267bab297c8fa8a7..8410fab1056e7f00a0b1583bbd6a25a5de09d10d 100644 --- a/interfaces/innerkits/ability_manager/include/start_options.h +++ b/interfaces/innerkits/ability_manager/include/start_options.h @@ -24,6 +24,7 @@ namespace OHOS { namespace AAFwk { class StartOptions : public Parcelable { public: + static const std::string STRING_WINDOW_MODE; static const std::string STRING_DISPLAY_ID; const int32_t DEFAULT_DISPLAY_ID {0}; diff --git a/interfaces/innerkits/runtime/include/js_data_struct_converter.h b/interfaces/innerkits/runtime/include/js_data_struct_converter.h index 739234ffd28951c31cdc3adb093c3d124dab91b3..67b41a09c7f6514047d10450ef06952411cea9cc 100644 --- a/interfaces/innerkits/runtime/include/js_data_struct_converter.h +++ b/interfaces/innerkits/runtime/include/js_data_struct_converter.h @@ -32,6 +32,8 @@ NativeValue* CreateJsAbilityInfo(NativeEngine& engine, const AppExecFwk::Ability NativeValue* CreateJsModuleInfo(NativeEngine& engine, const AppExecFwk::ModuleInfo &moduleInfo); NativeValue* CreateJsApplicationInfo(NativeEngine& engine, const AppExecFwk::ApplicationInfo &applicationInfo); NativeValue* CreateJsLaunchParam(NativeEngine& engine, const AAFwk::LaunchParam& launchParam); +NativeValue* CreateJsCustomizeData(NativeEngine& engine, const AppExecFwk::CustomizeData &Info); +NativeValue* CreateJsCustomizeDataArray(NativeEngine& engine, const std::vector &info); } // namespace AbilityRuntime } // namespace OHOS #endif // ABILITY_RUNTIME_JS_DATA_STRUCT_CONVERTER_H \ No newline at end of file diff --git a/interfaces/innerkits/want/include/ohos/aafwk/content/want.h b/interfaces/innerkits/want/include/ohos/aafwk/content/want.h index 315916ac39c3f7f0afa07ef12c0573107b5cd7e4..0127fedd27838ad0535f84011dfd7888aa17f401 100644 --- a/interfaces/innerkits/want/include/ohos/aafwk/content/want.h +++ b/interfaces/innerkits/want/include/ohos/aafwk/content/want.h @@ -787,9 +787,6 @@ public: static constexpr int HEX_STRING_BUF_LEN = 36; static constexpr int HEX_STRING_LEN = 10; - // reserved param definition - static const std::string PARAM_RESV_WINDOW_MODE; - private: WantParams parameters_; Operation operation_; diff --git a/interfaces/kits/napi/BUILD.gn b/interfaces/kits/napi/BUILD.gn index 5c89216ac9dcc3eaac36b74d3fb26dfabf1bd515..ebe5c1800964205ae79537daf02f07c77c235c2e 100644 --- a/interfaces/kits/napi/BUILD.gn +++ b/interfaces/kits/napi/BUILD.gn @@ -26,13 +26,11 @@ group("napi_packages") { "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/form_extension:formextension_napi", "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/form_extension_context:formextensioncontext_napi", "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/inner/napi_common:napi_common", - "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/mission_manager:distributedmissionmanager", "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/mission_manager:missionmanager_napi", + "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/mission_manager:missionregistration_napi", "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/particleAbility:particleability", "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/service_extension_context:serviceextensioncontext_napi", "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/serviceextension:serviceextension_napi", - "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/static_subscriber_extension:staticsubscriberextension_napi", - "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/static_subscriber_extension_context:staticsubscriberextensioncontext_napi", "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/wantConstant:wantconstant", ] } diff --git a/interfaces/kits/napi/aafwk/formManager/BUILD.gn b/interfaces/kits/napi/aafwk/formManager/BUILD.gn index c03ccf4f1cadfa3ebd84bbce1f33d435668f7d33..b8e50a0567c5ff96f55e7fdff6dbd1dd2c1d888d 100644 --- a/interfaces/kits/napi/aafwk/formManager/BUILD.gn +++ b/interfaces/kits/napi/aafwk/formManager/BUILD.gn @@ -36,7 +36,6 @@ ohos_shared_library("formmanager") { external_deps = [ "aafwk_standard:ability_manager", - "aafwk_standard:runtime", "aafwk_standard:want", "hiviewdfx_hilog_native:libhilog", ] diff --git a/interfaces/kits/napi/aafwk/formManager/napi_form_manager.cpp b/interfaces/kits/napi/aafwk/formManager/napi_form_manager.cpp index 8d621a674affba11d00dd626ad89dc7f718c8989..edd1f274150355c4f9b7faed362b719eb1e85ff9 100644 --- a/interfaces/kits/napi/aafwk/formManager/napi_form_manager.cpp +++ b/interfaces/kits/napi/aafwk/formManager/napi_form_manager.cpp @@ -22,7 +22,6 @@ #include "napi/native_api.h" #include "napi/native_node_api.h" -#include "runtime.h" using namespace OHOS; using namespace OHOS::AAFwk; @@ -39,7 +38,6 @@ namespace { constexpr int DECIMAL_VALUE = 10; constexpr int BASE_NUMBER = 9; constexpr int REF_COUNT = 1; - OHOS::AppExecFwk::Ability* g_ability = nullptr; } /** @@ -68,7 +66,7 @@ OHOS::AppExecFwk::Ability* GetGlobalAbility(napi_env env) // get global value napi_value global = nullptr; napi_get_global(env, &global); - + // get ability napi_value abilityObj = nullptr; napi_get_named_property(env, global, "ability", &abilityObj); @@ -77,14 +75,7 @@ OHOS::AppExecFwk::Ability* GetGlobalAbility(napi_env env) OHOS::AppExecFwk::Ability* ability = nullptr; napi_get_value_external(env, abilityObj, (void**)&ability); HILOG_INFO("%{public}s, ability = [%{public}p]", __func__, ability); - if (ability == nullptr) { - if (g_ability == nullptr) { - std::unique_ptr runtime; - g_ability = OHOS::AppExecFwk::Ability::Create(runtime); - } - ability = g_ability; - HILOG_INFO("%{public}s, Use Local tmp Ability for Stage Module", __func__); - } + return ability; } diff --git a/interfaces/kits/napi/aafwk/inner/napi_common/napi_common_want.cpp b/interfaces/kits/napi/aafwk/inner/napi_common/napi_common_want.cpp index 9dff21cbd37d74ba198927c30e7e09cfda5094cb..5829d942c022f8cd1afa881cfe350ee6132e8470 100644 --- a/interfaces/kits/napi/aafwk/inner/napi_common/napi_common_want.cpp +++ b/interfaces/kits/napi/aafwk/inner/napi_common/napi_common_want.cpp @@ -708,10 +708,6 @@ bool UnwrapWantParams(napi_env env, napi_value param, AAFwk::WantParams &wantPar NAPI_CALL_BASE(env, napi_get_element(env, jsProNameList, index, &jsProName), false); std::string strProName = UnwrapStringFromJS(env, jsProName); - /* skip reserved param */ - if (strProName == Want::PARAM_RESV_WINDOW_MODE) { - continue; - } HILOG_INFO("%{public}s called. Property name=%{public}s.", __func__, strProName.c_str()); NAPI_CALL_BASE(env, napi_get_named_property(env, param, strProName.c_str(), &jsProValue), false); NAPI_CALL_BASE(env, napi_typeof(env, jsProValue, &jsValueType), false); diff --git a/interfaces/kits/napi/aafwk/mission_manager/BUILD.gn b/interfaces/kits/napi/aafwk/mission_manager/BUILD.gn index 7b26afe1bcb503dfff9dc905c98a0c4f3f15d733..f0acd3349d46a65a576a965fe4856357306da6be 100644 --- a/interfaces/kits/napi/aafwk/mission_manager/BUILD.gn +++ b/interfaces/kits/napi/aafwk/mission_manager/BUILD.gn @@ -55,7 +55,7 @@ ohos_shared_library("missionmanager_napi") { part_name = "aafwk_standard" } -ohos_shared_library("distributedmissionmanager") { +ohos_shared_library("missionregistration_napi") { include_dirs = [ "//third_party/libuv/include", "//third_party/node/src", diff --git a/interfaces/kits/napi/aafwk/mission_manager/napi_mission_registration.cpp b/interfaces/kits/napi/aafwk/mission_manager/napi_mission_registration.cpp index a4f22de58646c13089ace7fd5404e757efb2ddf6..c4e1e70c117635e61a7600a3b3a2448d8b3da843 100644 --- a/interfaces/kits/napi/aafwk/mission_manager/napi_mission_registration.cpp +++ b/interfaces/kits/napi/aafwk/mission_manager/napi_mission_registration.cpp @@ -1395,7 +1395,7 @@ static napi_module missionModule = { .nm_flags = 0, .nm_filename = nullptr, .nm_register_func = DistributedMissionManagerExport, - .nm_modname = "distributedMissionManager", + .nm_modname = "missionRegistration", .nm_priv = ((void*)0), .reserved = {0} }; diff --git a/interfaces/kits/napi/aafwk/static_subscriber_extension/BUILD.gn b/interfaces/kits/napi/aafwk/static_subscriber_extension/BUILD.gn deleted file mode 100644 index 19f75fa65cbdf71458671970aa232de028535515..0000000000000000000000000000000000000000 --- a/interfaces/kits/napi/aafwk/static_subscriber_extension/BUILD.gn +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright (c) 2021 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. - -import("//ark/ts2abc/ts2panda/ts2abc_config.gni") -import("//build/ohos.gni") - -ts2abc_gen_abc("gen_static_subscriber_extension_abc") { - src_js = rebase_path("static_subscriber_extension.js") - dst_file = rebase_path(target_out_dir + "/static_subscriber_extension.abc") - in_puts = [ "static_subscriber_extension.js" ] - out_puts = [ target_out_dir + "/static_subscriber_extension.abc" ] - extra_args = [ "--module" ] -} - -gen_js_obj("static_subscriber_extension_js") { - input = "static_subscriber_extension.js" - output = target_out_dir + "/static_subscriber_extension.o" -} - -gen_js_obj("static_subscriber_extension_abc") { - input = get_label_info(":gen_static_subscriber_extension_abc", - "target_out_dir") + "/static_subscriber_extension.abc" - output = target_out_dir + "/static_subscriber_extension_abc.o" - dep = ":gen_static_subscriber_extension_abc" -} - -ohos_shared_library("staticsubscriberextension_napi") { - sources = [ "static_subscriber_extension_module.cpp" ] - - deps = [ - ":static_subscriber_extension_abc", - ":static_subscriber_extension_js", - ] - - external_deps = [ "napi:ace_napi" ] - - relative_install_dir = "module/application" - subsystem_name = "aafwk" - part_name = "aafwk_standard" -} diff --git a/interfaces/kits/napi/aafwk/static_subscriber_extension/static_subscriber_extension_module.cpp b/interfaces/kits/napi/aafwk/static_subscriber_extension/static_subscriber_extension_module.cpp deleted file mode 100644 index 4a0bd21ded14662b8a4b8a2dd3fb005da7ee66b2..0000000000000000000000000000000000000000 --- a/interfaces/kits/napi/aafwk/static_subscriber_extension/static_subscriber_extension_module.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2021 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 "native_engine/native_engine.h" - -extern const char _binary_static_subscriber_extension_js_start[]; -extern const char _binary_static_subscriber_extension_js_end[]; -extern const char _binary_static_subscriber_extension_abc_start[]; -extern const char _binary_static_subscriber_extension_abc_end[]; - -extern "C" __attribute__((constructor)) -void NAPI_application_StaticSubscriberExtension_AutoRegister() -{ - auto moduleManager = NativeModuleManager::GetInstance(); - NativeModule newModuleInfo = { - .name = "application.StaticSubscriberExtension", - .fileName = "application/libstaticsubscriberextension_napi.so/StaticSubscriberExtension.js", - }; - - moduleManager->Register(&newModuleInfo); -} - -extern "C" __attribute__((visibility("default"))) -void NAPI_application_StaticSubscriberExtension_GetJSCode(const char **buf, int *bufLen) -{ - if (buf != nullptr) { - *buf = _binary_static_subscriber_extension_js_start; - } - - if (bufLen != nullptr) { - *bufLen = _binary_static_subscriber_extension_js_end - - _binary_static_subscriber_extension_js_start; - } -} - -// StaticSubscriberExtension JS register -extern "C" __attribute__((visibility("default"))) -void NAPI_application_StaticSubscriberExtension_GetABCCode(const char **buf, int *buflen) -{ - if (buf != nullptr) { - *buf = _binary_static_subscriber_extension_abc_start; - } - if (buflen != nullptr) { - *buflen = _binary_static_subscriber_extension_abc_end - - _binary_static_subscriber_extension_abc_start; - } -} \ No newline at end of file diff --git a/interfaces/kits/napi/aafwk/static_subscriber_extension_context/BUILD.gn b/interfaces/kits/napi/aafwk/static_subscriber_extension_context/BUILD.gn deleted file mode 100644 index e6837c238c35e9f212be1eda74db861ed0f339f0..0000000000000000000000000000000000000000 --- a/interfaces/kits/napi/aafwk/static_subscriber_extension_context/BUILD.gn +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright (c) 2021 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. - -import("//ark/ts2abc/ts2panda/ts2abc_config.gni") -import("//build/ohos.gni") - -ts2abc_gen_abc("gen_static_subscriber_extension_context_abc") { - src_js = rebase_path("static_subscriber_extension_context.js") - dst_file = - rebase_path(target_out_dir + "/static_subscriber_extension_context.abc") - in_puts = [ "static_subscriber_extension_context.js" ] - out_puts = [ target_out_dir + "/static_subscriber_extension_context.abc" ] - extra_args = [ "--module" ] -} - -gen_js_obj("static_subscriber_extension_context_js") { - input = "static_subscriber_extension_context.js" - output = target_out_dir + "/static_subscriber_extension_context.o" -} - -gen_js_obj("static_subscriber_extension_context_abc") { - input = get_label_info(":gen_static_subscriber_extension_context_abc", - "target_out_dir") + - "/static_subscriber_extension_context.abc" - output = target_out_dir + "/static_subscriber_extension_context_abc.o" - dep = ":gen_static_subscriber_extension_context_abc" -} - -ohos_shared_library("staticsubscriberextensioncontext_napi") { - sources = [ "static_subscriber_extension_context_module.cpp" ] - - deps = [ - ":static_subscriber_extension_context_abc", - ":static_subscriber_extension_context_js", - ] - - external_deps = [ "napi:ace_napi" ] - - relative_install_dir = "module/application" - subsystem_name = "aafwk" - part_name = "aafwk_standard" -} diff --git a/interfaces/kits/napi/aafwk/static_subscriber_extension_context/static_subscriber_extension_context_module.cpp b/interfaces/kits/napi/aafwk/static_subscriber_extension_context/static_subscriber_extension_context_module.cpp deleted file mode 100644 index 3731cfe899604a01887634581cab6659f59ca6d8..0000000000000000000000000000000000000000 --- a/interfaces/kits/napi/aafwk/static_subscriber_extension_context/static_subscriber_extension_context_module.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2021 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 "native_engine/native_engine.h" - -extern const char _binary_static_subscriber_extension_context_js_start[]; -extern const char _binary_static_subscriber_extension_context_js_end[]; -extern const char _binary_static_subscriber_extension_context_abc_start[]; -extern const char _binary_static_subscriber_extension_context_abc_end[]; - -extern "C" __attribute__((constructor)) -void NAPI_application_StaticSubscriberExtensionContext_AutoRegister() -{ - auto moduleManager = NativeModuleManager::GetInstance(); - NativeModule newModuleInfo = { - .name = "application.StaticSubscriberExtensionContext", - .fileName = "application/libstaticsubscriberextensioncontext_napi.so/StaticSubscriberExtensionContext.js", - }; - - moduleManager->Register(&newModuleInfo); -} - -extern "C" __attribute__((visibility("default"))) -void NAPI_application_StaticSubscriberExtensionContext_GetJSCode(const char **buf, int *bufLen) -{ - if (buf != nullptr) { - *buf = _binary_static_subscriber_extension_context_js_start; - } - - if (bufLen != nullptr) { - *bufLen = _binary_static_subscriber_extension_context_js_end - - _binary_static_subscriber_extension_context_js_start; - } -} - -// StaticSubscriberExtensionContext JS register -extern "C" __attribute__((visibility("default"))) -void NAPI_application_StaticSubscriberExtensionContext_GetABCCode(const char **buf, int *buflen) -{ - if (buf != nullptr) { - *buf = _binary_static_subscriber_extension_context_abc_start; - } - if (buflen != nullptr) { - *buflen = _binary_static_subscriber_extension_context_abc_end - - _binary_static_subscriber_extension_context_abc_start; - } -} diff --git a/ohos.build b/ohos.build index 4173475df065a33a064838e795ced253afa51ff2..cf7185cccbed613ae1b6395d0663dca8678643d1 100755 --- a/ohos.build +++ b/ohos.build @@ -6,7 +6,6 @@ "//foundation/aafwk/standard/tools:tools_target", "//foundation/aafwk/standard/interfaces/innerkits:innerkits_target", "//foundation/aafwk/standard/frameworks/kits/ability/native:abilitykit_native", - "//foundation/aafwk/standard/frameworks/kits/ability/native:static_subscriber_ipc", "//foundation/aafwk/standard/sa_profile:aafwk_sa_profile", "//foundation/aafwk/standard/interfaces/kits/napi:napi_packages", "//foundation/aafwk/standard/frameworks/kits/ability/ability_runtime:ability_context_native", diff --git a/services/abilitymgr/include/ability_manager_service.h b/services/abilitymgr/include/ability_manager_service.h index f6c2176e8201055b639d0a01c21375befc90eb39..d6a5f7ad7506b7f10d9c241a607a9f897e16477c 100644 --- a/services/abilitymgr/include/ability_manager_service.h +++ b/services/abilitymgr/include/ability_manager_service.h @@ -873,8 +873,6 @@ private: std::vector &missionInfos); int GetRemoteMissionInfo(const std::string& deviceId, int32_t missionId, MissionInfo &missionInfo); - int32_t GetRemoteMissionSnapshotInfo(const std::string& deviceId, int32_t missionId, - MissionSnapshot& missionSnapshot); void DumpInner(const std::string &args, std::vector &info); void DumpStackListInner(const std::string &args, std::vector &info); diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index b4837a790348f793d37f1e298d88e099486f5efe..5d2552076a1dc3ba9b420ddc56de1358129852f8 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -393,8 +393,9 @@ int AbilityManagerService::StartAbility(const Want &want, const StartOptions &st } } + abilityRequest.want.SetParam(StartOptions::STRING_WINDOW_MODE, startOptions.GetWindowMode()); abilityRequest.want.SetParam(StartOptions::STRING_DISPLAY_ID, startOptions.GetDisplayID()); - abilityRequest.want.SetParam(Want::PARAM_RESV_WINDOW_MODE, startOptions.GetWindowMode()); + if (useNewMission_) { return currentMissionListManager_->StartAbility(abilityRequest); } else { @@ -630,7 +631,7 @@ int AbilityManagerService::MinimizeAbility(const sptr &token) if (!IsAbilityControllerResuming(abilityRecord->GetAbilityInfo().bundleName)) { return ERR_WOULD_BLOCK; } - + if (useNewMission_) { return currentMissionListManager_->MinimizeAbility(token); } else { @@ -2590,7 +2591,7 @@ void AbilityManagerService::StartSystemApplication() HILOG_INFO("start mms"); StartingMmsAbility(); } - + // Location may change DelayedSingleton::GetInstance()->StartupResidentProcess(); } @@ -2818,12 +2819,6 @@ int AbilityManagerService::RegisterSnapshotHandler(const sptr& int32_t AbilityManagerService::GetMissionSnapshot(const std::string& deviceId, int32_t missionId, MissionSnapshot& missionSnapshot) { - if (CheckIsRemote(deviceId)) { - HILOG_INFO("get remote mission snapshot."); - return GetRemoteMissionSnapshotInfo(deviceId, missionId, missionSnapshot); - } - - HILOG_INFO("get local mission snapshot."); if (!snapshotHandler_) { return 0; } @@ -2833,25 +2828,6 @@ int32_t AbilityManagerService::GetMissionSnapshot(const std::string& deviceId, i return result; } -int32_t AbilityManagerService::GetRemoteMissionSnapshotInfo(const std::string& deviceId, int32_t missionId, - MissionSnapshot& missionSnapshot) -{ - HILOG_INFO("GetRemoteMissionSnapshotInfo begin"); - sptr dmsProxy = GetDmsProxy(); - if (dmsProxy == nullptr) { - HILOG_ERROR("GetRemoteMissionSnapshotInfo failed to get dms."); - return ERR_INVALID_VALUE; - } - std::unique_ptr missionSnapshotPtr = std::make_unique(); - int result = dmsProxy->GetRemoteMissionSnapshotInfo(deviceId, missionId, missionSnapshotPtr); - if (result != ERR_OK) { - HILOG_ERROR("GetRemoteMissionSnapshotInfo failed, result = %{public}d", result); - return result; - } - missionSnapshot = *missionSnapshotPtr; - return ERR_OK; -} - void AbilityManagerService::StartFreezingScreen() { HILOG_DEBUG("%{public}s", __func__); diff --git a/services/abilitymgr/src/start_options.cpp b/services/abilitymgr/src/start_options.cpp index 20eb4bfd33af410f4bf68d5d27c14aa979080452..c0e0046700656800fa8c849511de4a4f66422736 100644 --- a/services/abilitymgr/src/start_options.cpp +++ b/services/abilitymgr/src/start_options.cpp @@ -18,6 +18,7 @@ namespace OHOS { namespace AAFwk { +const std::string StartOptions::STRING_WINDOW_MODE = "ohos.aafwk.windowMode"; const std::string StartOptions::STRING_DISPLAY_ID = "ohos.aafwk.displayId"; bool StartOptions::ReadFromParcel(Parcel &parcel) diff --git a/tools/test/systemtest/aa/BUILD.gn b/tools/test/systemtest/aa/BUILD.gn index 955b13924221522e03b37a9e43658741e27019d1..1da41815e85567095136959f8a16d4d2c961c71d 100644 --- a/tools/test/systemtest/aa/BUILD.gn +++ b/tools/test/systemtest/aa/BUILD.gn @@ -16,17 +16,6 @@ import("//foundation/aafwk/standard/aafwk.gni") module_output_path = "aafwk_standard/tools" -config("tools_aa_test_config") { - include_dirs = [ - "${appexecfwk_path}/interfaces/innerkits/appexecfwk_base/include", - "${appexecfwk_path}/interfaces/innerkits/appexecfwk_core/include/bundlemgr", - "${appexecfwk_path}/tools/bm/include", - "//utils/system/safwk/native/include", - "//base/security/permission/interfaces/innerkits/permission_standard/permissionsdk/main/cpp/include", - "//base/security/appverify/interfaces/innerkits/appverify/include", - ] -} - ohos_systemtest("aa_command_start_system_test") { module_out_path = module_output_path @@ -37,7 +26,7 @@ ohos_systemtest("aa_command_start_system_test") { "tool_system_test.cpp", ] - configs = [ ":tools_aa_test_config" ] + configs = [ "${appexecfwk_path}/tools/bm:tools_bm_config" ] cflags = [] if (target_cpu == "arm") { @@ -65,7 +54,7 @@ ohos_systemtest("aa_command_stop_service_system_test") { "tool_system_test.cpp", ] - configs = [ ":tools_aa_test_config" ] + configs = [ "${appexecfwk_path}/tools/bm:tools_bm_config" ] cflags = [] if (target_cpu == "arm") { @@ -95,7 +84,7 @@ ohos_systemtest("aa_command_dump_system_test") { "tool_system_test.cpp", ] - configs = [ ":tools_aa_test_config" ] + configs = [ "${appexecfwk_path}/tools/bm:tools_bm_config" ] cflags = [] if (target_cpu == "arm") {