diff --git a/interfaces/innerkits/appexecfwk_base/include/install_param.h b/interfaces/innerkits/appexecfwk_base/include/install_param.h index b22cd2cdd71aa2f134cb959a2d0855952a6e006e..1af45cbe5db812a62d3bb86733fcb92be00201e6 100644 --- a/interfaces/innerkits/appexecfwk_base/include/install_param.h +++ b/interfaces/innerkits/appexecfwk_base/include/install_param.h @@ -18,7 +18,6 @@ #include -#include "bundle_constants.h" #include "parcel.h" namespace OHOS { namespace AppExecFwk { @@ -40,7 +39,7 @@ enum class InstallLocation { struct InstallParam : public Parcelable { InstallFlag installFlag = InstallFlag::NORMAL; InstallLocation installLocation = InstallLocation::INTERNAL_ONLY; - int userId = Constants::UNSPECIFIED_USERID; + int userId = 0; // is keep user data while uninstall. bool isKeepData = false; bool noCheckSignature = false; diff --git a/interfaces/innerkits/appexecfwk_base/src/application_info.cpp b/interfaces/innerkits/appexecfwk_base/src/application_info.cpp index cfe0b4527b004735949bad431d522fe347a51acc..38ac956f21a83d1603f613d0374ffbde2c6307be 100644 --- a/interfaces/innerkits/appexecfwk_base/src/application_info.cpp +++ b/interfaces/innerkits/appexecfwk_base/src/application_info.cpp @@ -202,17 +202,6 @@ bool ApplicationInfo::ReadFromParcel(Parcel &parcel) } metadata.emplace_back(*meta); } - - vendor = Str16ToStr8(parcel.ReadString16()); - versionCode = parcel.ReadInt32(); - versionName = Str16ToStr8(parcel.ReadString16()); - minCompatibleVersionCode = parcel.ReadInt32(); - apiCompatibleVersion = parcel.ReadInt32(); - apiTargetVersion = parcel.ReadInt32(); - apiReleaseType = Str16ToStr8(parcel.ReadString16()); - distributedNotificationEnabled = parcel.ReadBool(); - keepAlive = parcel.ReadBool(); - clearUserData = parcel.ReadBool(); return true; } @@ -306,17 +295,6 @@ bool ApplicationInfo::Marshalling(Parcel &parcel) const for (const auto &meta : metadata) { WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &meta); } - - WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(vendor)); - WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, versionCode); - WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(versionName)); - WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, minCompatibleVersionCode); - WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, apiCompatibleVersion); - WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, apiTargetVersion); - WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(apiReleaseType)); - WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, distributedNotificationEnabled); - WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, keepAlive); - WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, clearUserData); return true; } diff --git a/interfaces/innerkits/appexecfwk_base/src/bundle_info.cpp b/interfaces/innerkits/appexecfwk_base/src/bundle_info.cpp index 7a43496e278eaefa69a6452b062d72ea43e8baeb..cf455a3fc8d909d08fb494174eba63547fa8dff0 100644 --- a/interfaces/innerkits/appexecfwk_base/src/bundle_info.cpp +++ b/interfaces/innerkits/appexecfwk_base/src/bundle_info.cpp @@ -166,21 +166,6 @@ bool BundleInfo::ReadFromParcel(Parcel &parcel) } hapModuleInfos.emplace_back(*hapModuleInfo); } - - int32_t extensionInfoSize = parcel.ReadInt32(); - for (int32_t i = 0; i < extensionInfoSize; ++i) { - std::unique_ptr info(parcel.ReadParcelable()); - if (!info) { - APP_LOGE("ReadParcelable failed"); - return false; - } - extensionInfos.emplace_back(*info); - } - - int32_t reqPermissionStatesSize = parcel.ReadInt32(); - for (int32_t i = 0; i < reqPermissionStatesSize; ++i) { - reqPermissionStates.emplace_back(parcel.ReadInt32()); - } return true; } @@ -266,16 +251,6 @@ bool BundleInfo::Marshalling(Parcel &parcel) const for (auto &hapModuleInfo : hapModuleInfos) { WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &hapModuleInfo); } - - WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, extensionInfos.size()); - for (auto &info : extensionInfos) { - WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &info); - } - - WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, reqPermissionStates.size()); - for (auto &states : reqPermissionStates) { - WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, states); - } return true; } diff --git a/interfaces/innerkits/appexecfwk_base/src/hap_module_info.cpp b/interfaces/innerkits/appexecfwk_base/src/hap_module_info.cpp index b86c09208f3894398c9d07937c27c1e50606e1c9..3a9a0ebee14553f3a36b5ebf125f4f1c28c7e7c8 100644 --- a/interfaces/innerkits/appexecfwk_base/src/hap_module_info.cpp +++ b/interfaces/innerkits/appexecfwk_base/src/hap_module_info.cpp @@ -42,36 +42,23 @@ const std::string HAP_MODULE_INFO_COLOR_MODE = "colorMode"; bool HapModuleInfo::ReadFromParcel(Parcel &parcel) { name = Str16ToStr8(parcel.ReadString16()); + APP_LOGE("Read name is %{public}s", name.c_str()); moduleName = Str16ToStr8(parcel.ReadString16()); + APP_LOGE("Read moduleName is %{public}s", moduleName.c_str()); description = Str16ToStr8(parcel.ReadString16()); + APP_LOGE("Read description is %{public}s", description.c_str()); iconPath = Str16ToStr8(parcel.ReadString16()); + APP_LOGE("Read iconPath is %{public}s", iconPath.c_str()); label = Str16ToStr8(parcel.ReadString16()); + APP_LOGE("Read label is %{public}s", label.c_str()); backgroundImg = Str16ToStr8(parcel.ReadString16()); + APP_LOGE("Read backgroundImg is %{public}s", backgroundImg.c_str()); mainAbility = Str16ToStr8(parcel.ReadString16()); + APP_LOGE("Read mainAbility is %{public}s", mainAbility.c_str()); srcPath = Str16ToStr8(parcel.ReadString16()); + APP_LOGE("Read srcPath is %{public}s", srcPath.c_str()); supportedModes = parcel.ReadInt32(); - mainElementName = Str16ToStr8(parcel.ReadString16()); - int32_t extensionAbilityInfoSize = parcel.ReadInt32(); - for (int32_t i = 0; i < extensionAbilityInfoSize; ++i) { - std::unique_ptr extensionAbilityInfo(parcel.ReadParcelable()); - if (!extensionAbilityInfo) { - APP_LOGE("ReadParcelable failed"); - return false; - } - extensionInfos.emplace_back(*extensionAbilityInfo); - } - int32_t metadataSize = parcel.ReadInt32(); - APP_LOGE("Read metadataSize is %{public}d", metadataSize); - for (int32_t i = 0; i < metadataSize; ++i) { - std::unique_ptr meta(parcel.ReadParcelable()); - if (!meta) { - APP_LOGE("ReadParcelable failed"); - return false; - } - metadata.emplace_back(*meta); - } - resourcePath = Str16ToStr8(parcel.ReadString16()); - isStageBasedModel = parcel.ReadBool(); + APP_LOGE("Read supportedModes is %{public}d", supportedModes); int32_t reqCapabilitiesSize; READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, reqCapabilitiesSize); @@ -123,17 +110,6 @@ bool HapModuleInfo::Marshalling(Parcel &parcel) const WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(mainAbility)); WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(srcPath)); WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, supportedModes); - WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(mainElementName)); - WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, extensionInfos.size()); - for (auto &extensionInfo : extensionInfos) { - WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &extensionInfo); - } - WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, metadata.size()); - for (const auto &meta : metadata) { - WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &meta); - } - WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(resourcePath)); - WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isStageBasedModel); WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, reqCapabilities.size()); for (auto &reqCapability : reqCapabilities) { diff --git a/interfaces/innerkits/appexecfwk_core/BUILD.gn b/interfaces/innerkits/appexecfwk_core/BUILD.gn index aee26dba0c208391c07cd3dd9a0bc6f72d27ee71..b8f7ea9ca44fa1f36862a29bbda5ad90e42a71d6 100644 --- a/interfaces/innerkits/appexecfwk_core/BUILD.gn +++ b/interfaces/innerkits/appexecfwk_core/BUILD.gn @@ -47,8 +47,6 @@ ohos_shared_library("appexecfwk_core") { ] sources = [ - "src/appmgr/ability_controller_proxy.cpp", - "src/appmgr/ability_controller_stub.cpp", "src/appmgr/ability_state_data.cpp", "src/appmgr/ams_mgr_proxy.cpp", "src/appmgr/ams_mgr_stub.cpp", diff --git a/interfaces/innerkits/appexecfwk_core/include/appmgr/ability_controller_proxy.h b/interfaces/innerkits/appexecfwk_core/include/appmgr/ability_controller_proxy.h deleted file mode 100644 index 67a52721a2d0b7d489fdfef6990ab74f56ca87ee..0000000000000000000000000000000000000000 --- a/interfaces/innerkits/appexecfwk_core/include/appmgr/ability_controller_proxy.h +++ /dev/null @@ -1,53 +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. - */ - -#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_ABILITY_CONTROLLER_PROXY_H -#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_ABILITY_CONTROLLER_PROXY_H - -#include "iremote_proxy.h" -#include "iability_controller.h" - -namespace OHOS { -namespace AppExecFwk { -/** - * @brief Testing interface to monitor what is happening in ability manager while tests are running. - */ -class AbilityControllerProxy : public IRemoteProxy { -public: - explicit AbilityControllerProxy(const sptr &impl); - virtual ~AbilityControllerProxy() = default; - - /** - * The system is trying to start an ability. Return true to allow, or false to reject. - * - * @param want The want of ability to start. - * @param bundleName The bundleName of ability to start. - */ - virtual bool AbilityStarting(const Want &want, const std::string &bundleName) override; - - /** - * The system is trying to return to an ability. Return true to allow, or false to reject. - * - * @param bundleName The bundleName of ability to return. - */ - virtual bool AbilityResuming(const std::string &bundleName) override; - -private: - bool WriteInterfaceToken(MessageParcel &data); - static inline BrokerDelegator delegator_; -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif diff --git a/interfaces/innerkits/appexecfwk_core/include/appmgr/ability_controller_stub.h b/interfaces/innerkits/appexecfwk_core/include/appmgr/ability_controller_stub.h deleted file mode 100644 index 7c6b81c22ee94c4b8691d3fc653d4fc8a839cc2c..0000000000000000000000000000000000000000 --- a/interfaces/innerkits/appexecfwk_core/include/appmgr/ability_controller_stub.h +++ /dev/null @@ -1,67 +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. - */ - -#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_ABILITY_CONTROLLER_STUB_H -#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_ABILITY_CONTROLLER_STUB_H - -#include - -#include "iremote_stub.h" -#include "iability_controller.h" -#include "nocopyable.h" -#include "string_ex.h" - -namespace OHOS { -namespace AppExecFwk { -/** - * @brief Testing interface to monitor what is happening in ability manager while tests are running. - */ -class AbilityControllerStub : public IRemoteStub { -public: - AbilityControllerStub(); - virtual ~AbilityControllerStub(); - - virtual int OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; - - /** - * The system is trying to start an ability. Return true to allow, or false to reject. - * - * @param want The want of ability to start. - * @param bundleName The bundleName of ability to start. - */ - virtual bool AbilityStarting(const Want &want, const std::string &bundleName) override; - - /** - * The system is trying to return to an ability. Return true to allow, or false to reject. - * - * @param bundleName The bundleName of ability to return. - */ - virtual bool AbilityResuming(const std::string &bundleName) override; - -private: - int32_t HandleAbilityStarting(MessageParcel &data, MessageParcel &reply); - - int32_t HandleAbilityResuming(MessageParcel &data, MessageParcel &reply); - - using AbilityControllerFunc = int32_t (AbilityControllerStub::*)(MessageParcel &data, - MessageParcel &reply); - std::map memberFuncMap_; - - DISALLOW_COPY_AND_MOVE(AbilityControllerStub); -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_ABILITY_CONTROLLER_STUB_H diff --git a/interfaces/innerkits/appexecfwk_core/include/appmgr/app_scheduler_host.h b/interfaces/innerkits/appexecfwk_core/include/appmgr/app_scheduler_host.h index 35020fd89561e73b0784995fe87771088a490567..7f94c6237bfa347425790a99ec2274dcdec0dcb0 100644 --- a/interfaces/innerkits/appexecfwk_core/include/appmgr/app_scheduler_host.h +++ b/interfaces/innerkits/appexecfwk_core/include/appmgr/app_scheduler_host.h @@ -43,7 +43,7 @@ private: int32_t HandleScheduleLaunchAbility(MessageParcel &data, MessageParcel &reply); int32_t HandleScheduleCleanAbility(MessageParcel &data, MessageParcel &reply); int32_t HandleScheduleLaunchApplication(MessageParcel &data, MessageParcel &reply); - int32_t HandleScheduleAbilityStageInfo(MessageParcel &data, MessageParcel &reply); + int32_t HandleScheduleAbilityStage(MessageParcel &data, MessageParcel &reply); int32_t HandleScheduleProfileChanged(MessageParcel &data, MessageParcel &reply); int32_t HandleScheduleConfigurationUpdated(MessageParcel &data, MessageParcel &reply); int32_t HandleScheduleProcessSecurityExit(MessageParcel &data, MessageParcel &reply); diff --git a/interfaces/innerkits/appexecfwk_core/include/appmgr/app_scheduler_interface.h b/interfaces/innerkits/appexecfwk_core/include/appmgr/app_scheduler_interface.h index bc9b9702616aa804025e44dc615c7c511bed7731..b7d6cfe7483fc0d08cfb8062a320a80f3b688200 100644 --- a/interfaces/innerkits/appexecfwk_core/include/appmgr/app_scheduler_interface.h +++ b/interfaces/innerkits/appexecfwk_core/include/appmgr/app_scheduler_interface.h @@ -88,7 +88,7 @@ public: * * @return */ - virtual void ScheduleAbilityStageInfo(const HapModuleInfo &) = 0; + virtual void ScheduleAbilityStage(const HapModuleInfo &) = 0; /** * ScheduleLaunchAbility, call ScheduleLaunchAbility() through proxy project, diff --git a/interfaces/innerkits/appexecfwk_core/include/appmgr/app_scheduler_proxy.h b/interfaces/innerkits/appexecfwk_core/include/appmgr/app_scheduler_proxy.h index a6762b225d128a51fdc12a2ba590cbfe297d6181..e63e449fffaaaad2786ed25f3b45e7fe96c8c9d7 100644 --- a/interfaces/innerkits/appexecfwk_core/include/appmgr/app_scheduler_proxy.h +++ b/interfaces/innerkits/appexecfwk_core/include/appmgr/app_scheduler_proxy.h @@ -83,7 +83,7 @@ public: * * @param The resident process data value. */ - virtual void ScheduleAbilityStageInfo(const HapModuleInfo &abilityStage) override; + virtual void ScheduleAbilityStage(const HapModuleInfo &abilityStage) override; /** * ScheduleLaunchAbility, call ScheduleLaunchAbility() through proxy project, diff --git a/interfaces/innerkits/appexecfwk_core/include/appmgr/iability_controller.h b/interfaces/innerkits/appexecfwk_core/include/appmgr/iability_controller.h deleted file mode 100644 index 55ff856a234d3ed2a64a7e98bd550612d21bda0a..0000000000000000000000000000000000000000 --- a/interfaces/innerkits/appexecfwk_core/include/appmgr/iability_controller.h +++ /dev/null @@ -1,55 +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. - */ - -#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_IABILITY_CONTROLLER_H -#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_IABILITY_CONTROLLER_H - -#include "iremote_broker.h" -#include "iremote_object.h" -#include "want.h" - -namespace OHOS { -namespace AppExecFwk { -using OHOS::AAFwk::Want; -/** - * @brief Testing interface to monitor what is happening in ability manager while tests are running. - */ -class IAbilityController : public IRemoteBroker { -public: - DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.IAbilityController"); - - /** - * The system is trying to start an ability. Return true to allow, or false to reject. - * - * @param want The want of ability to start. - * @param bundleName The bundleName of ability to start. - */ - virtual bool AbilityStarting(const Want &want, const std::string &bundleName) = 0; - - /** - * The system is trying to return to an ability. Return true to allow, or false to reject. - * - * @param bundleName The bundleName of ability to return. - */ - virtual bool AbilityResuming(const std::string &bundleName) = 0; - - enum class Message { - TRANSACT_ON_ABILITY_STARTING = 0, - TRANSACT_ON_ABILITY_RESUMING, - }; -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APPMGR_IABILITY_CONTROLLER_H diff --git a/interfaces/innerkits/appexecfwk_core/include/bundlemgr/bundle_mgr_interface.h b/interfaces/innerkits/appexecfwk_core/include/bundlemgr/bundle_mgr_interface.h index 1ec89cd5febdb82ca0fb087120c96afc1cb6f3e9..6d97fa7d5e1b130a7a59be40b526ba4b2ecfd30d 100644 --- a/interfaces/innerkits/appexecfwk_core/include/bundlemgr/bundle_mgr_interface.h +++ b/interfaces/innerkits/appexecfwk_core/include/bundlemgr/bundle_mgr_interface.h @@ -647,8 +647,8 @@ public: * @param extensionInfos Indicates the obtained extensions. * @return Returns true if this function is successfully called; returns false otherwise. */ - virtual bool QueryExtensionAbilityInfos(const Want &want, const ExtensionAbilityType &extensionType, - const int32_t &flag, const int32_t &userId, std::vector &extensionInfos) + virtual bool QueryExtensionAbilityInfos(const Want &want, const int32_t &extensionType, const int32_t &flag, + const int32_t &userId, std::vector &extensionInfos) { return true; } diff --git a/interfaces/innerkits/appexecfwk_core/include/bundlemgr/bundle_mgr_proxy.h b/interfaces/innerkits/appexecfwk_core/include/bundlemgr/bundle_mgr_proxy.h index a0ed96fa5286582f8f4725019d6e09027e7b4353..f97054fc26ee021a8e3500faf20e206c893d53b9 100644 --- a/interfaces/innerkits/appexecfwk_core/include/bundlemgr/bundle_mgr_proxy.h +++ b/interfaces/innerkits/appexecfwk_core/include/bundlemgr/bundle_mgr_proxy.h @@ -604,8 +604,8 @@ public: * @param extensionInfos Indicates the obtained extensions. * @return Returns true if this function is successfully called; returns false otherwise. */ - virtual bool QueryExtensionAbilityInfos(const Want &want, const ExtensionAbilityType &extensionType, - const int32_t &flag, const int32_t &userId, std::vector &extensionInfos) override; + virtual bool QueryExtensionAbilityInfos(const Want &want, const int32_t &extensionType, const int32_t &flag, + const int32_t &userId, std::vector &extensionInfos) override; private: /** diff --git a/interfaces/innerkits/appexecfwk_core/src/appmgr/ability_controller_proxy.cpp b/interfaces/innerkits/appexecfwk_core/src/appmgr/ability_controller_proxy.cpp deleted file mode 100644 index 1d6adbaf835af5d8ddc56036fa90689b8850d255..0000000000000000000000000000000000000000 --- a/interfaces/innerkits/appexecfwk_core/src/appmgr/ability_controller_proxy.cpp +++ /dev/null @@ -1,85 +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 "ability_controller_proxy.h" - -#include "ipc_types.h" -#include "app_log_wrapper.h" - -namespace OHOS { -namespace AppExecFwk { -AbilityControllerProxy::AbilityControllerProxy( - const sptr &impl) : IRemoteProxy(impl) -{} - -bool AbilityControllerProxy::WriteInterfaceToken(MessageParcel &data) -{ - if (!data.WriteInterfaceToken(AbilityControllerProxy::GetDescriptor())) { - APP_LOGE("write interface token failed"); - return false; - } - return true; -} - -bool AbilityControllerProxy::AbilityStarting(const Want &want, const std::string &bundleName) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - if (!WriteInterfaceToken(data)) { - return true; - } - data.WriteParcelable(&want); - data.WriteString(bundleName); - sptr remote = Remote(); - if (remote == nullptr) { - APP_LOGE("Remote() is NULL"); - return true; - } - int32_t ret = remote->SendRequest( - static_cast(IAbilityController::Message::TRANSACT_ON_ABILITY_STARTING), - data, reply, option); - if (ret != NO_ERROR) { - APP_LOGW("SendRequest is failed, error code: %{public}d", ret); - return true; - } - return reply.ReadBool(); -} - -bool AbilityControllerProxy::AbilityResuming(const std::string &bundleName) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - if (!WriteInterfaceToken(data)) { - return true; - } - data.WriteString(bundleName); - sptr remote = Remote(); - if (remote == nullptr) { - APP_LOGE("Remote() is NULL"); - return true; - } - int32_t ret = remote->SendRequest( - static_cast(IAbilityController::Message::TRANSACT_ON_ABILITY_RESUMING), - data, reply, option); - if (ret != NO_ERROR) { - APP_LOGW("SendRequest is failed, error code: %{public}d", ret); - return true; - } - return reply.ReadBool(); -} -} // namespace AppExecFwk -} // namespace OHOS diff --git a/interfaces/innerkits/appexecfwk_core/src/appmgr/ability_controller_stub.cpp b/interfaces/innerkits/appexecfwk_core/src/appmgr/ability_controller_stub.cpp deleted file mode 100644 index b48e981a5a743bf2fbf5986246f13a02c900a619..0000000000000000000000000000000000000000 --- a/interfaces/innerkits/appexecfwk_core/src/appmgr/ability_controller_stub.cpp +++ /dev/null @@ -1,93 +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 "ability_controller_stub.h" -#include "appexecfwk_errors.h" -#include "app_log_wrapper.h" -#include "ipc_types.h" -#include "iremote_object.h" - -namespace OHOS { -namespace AppExecFwk { -AbilityControllerStub::AbilityControllerStub() -{ - memberFuncMap_[static_cast( - IAbilityController::Message::TRANSACT_ON_ABILITY_STARTING)] = - &AbilityControllerStub::HandleAbilityStarting; - memberFuncMap_[static_cast( - IAbilityController::Message::TRANSACT_ON_ABILITY_RESUMING)] = - &AbilityControllerStub::HandleAbilityResuming; -} - -AbilityControllerStub::~AbilityControllerStub() -{ - memberFuncMap_.clear(); -} - -int AbilityControllerStub::OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) -{ - APP_LOGI("AbilityControllerStub::OnReceived, code = %{public}d, flags= %{public}d.", code, option.GetFlags()); - std::u16string descriptor = AbilityControllerStub::GetDescriptor(); - std::u16string remoteDescriptor = data.ReadInterfaceToken(); - if (descriptor != remoteDescriptor) { - APP_LOGE("local descriptor is not equal to remote"); - return ERR_INVALID_STATE; - } - - auto itFunc = memberFuncMap_.find(code); - if (itFunc != memberFuncMap_.end()) { - auto memberFunc = itFunc->second; - if (memberFunc != nullptr) { - return (this->*memberFunc)(data, reply); - } - } - return IPCObjectStub::OnRemoteRequest(code, data, reply, option); -} - -bool AbilityControllerStub::AbilityStarting(const Want &want, const std::string &bundleName) -{ - return true; -} - -bool AbilityControllerStub::AbilityResuming(const std::string &bundleName) -{ - return true; -} - -int32_t AbilityControllerStub::HandleAbilityStarting(MessageParcel &data, MessageParcel &reply) -{ - APP_LOGI("HandleAbilityStarting"); - std::unique_ptr want(data.ReadParcelable()); - if (!want) { - APP_LOGE("ReadParcelable failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - std::string pkg = data.ReadString(); - bool ret = AbilityStarting(*want, pkg); - reply.WriteBool(ret); - return NO_ERROR; -} - -int32_t AbilityControllerStub::HandleAbilityResuming(MessageParcel &data, MessageParcel &reply) -{ - APP_LOGI("HandleAbilityResuming"); - std::string pkg = data.ReadString(); - bool ret = AbilityResuming(pkg); - reply.WriteBool(ret); - return NO_ERROR; -} -} // namespace AppExecFwk -} // namespace OHOS diff --git a/interfaces/innerkits/appexecfwk_core/src/appmgr/app_scheduler_host.cpp b/interfaces/innerkits/appexecfwk_core/src/appmgr/app_scheduler_host.cpp index 5c0e2d1ed02b5aea7796ccb344f6e6e668cab5db..ceb7c4d4d9164d3bd9f87317a208af20170a9ff1 100644 --- a/interfaces/innerkits/appexecfwk_core/src/appmgr/app_scheduler_host.cpp +++ b/interfaces/innerkits/appexecfwk_core/src/appmgr/app_scheduler_host.cpp @@ -47,7 +47,7 @@ AppSchedulerHost::AppSchedulerHost() memberFuncMap_[static_cast(IAppScheduler::Message::SCHEDULE_PROCESS_SECURITY_EXIT_TRANSACTION)] = &AppSchedulerHost::HandleScheduleProcessSecurityExit; memberFuncMap_[static_cast(IAppScheduler::Message::SCHEDULE_ABILITY_STAGE_INFO)] = - &AppSchedulerHost::HandleScheduleAbilityStageInfo; + &AppSchedulerHost::HandleScheduleAbilityStage; } AppSchedulerHost::~AppSchedulerHost() @@ -146,7 +146,7 @@ int32_t AppSchedulerHost::HandleScheduleLaunchApplication(MessageParcel &data, M return NO_ERROR; } -int32_t AppSchedulerHost::HandleScheduleAbilityStageInfo(MessageParcel &data, MessageParcel &reply) +int32_t AppSchedulerHost::HandleScheduleAbilityStage(MessageParcel &data, MessageParcel &reply) { BYTRACE(BYTRACE_TAG_APP); std::unique_ptr abilityStage(data.ReadParcelable()); @@ -155,7 +155,7 @@ int32_t AppSchedulerHost::HandleScheduleAbilityStageInfo(MessageParcel &data, Me return ERR_APPEXECFWK_PARCEL_ERROR; } - ScheduleAbilityStageInfo(*abilityStage); + ScheduleAbilityStage(*abilityStage); return NO_ERROR; } diff --git a/interfaces/innerkits/appexecfwk_core/src/appmgr/app_scheduler_proxy.cpp b/interfaces/innerkits/appexecfwk_core/src/appmgr/app_scheduler_proxy.cpp index b35b47272d00f6ad5014e5b6ffe6bc810d99e51f..4b980856fe6ecadc5bec4c19b84cb44c2f359900 100644 --- a/interfaces/innerkits/appexecfwk_core/src/appmgr/app_scheduler_proxy.cpp +++ b/interfaces/innerkits/appexecfwk_core/src/appmgr/app_scheduler_proxy.cpp @@ -214,9 +214,9 @@ void AppSchedulerProxy::ScheduleLaunchApplication(const AppLaunchData &launchDat APP_LOGI("AppSchedulerProxy ScheduleLaunchApplication end"); } -void AppSchedulerProxy::ScheduleAbilityStageInfo(const HapModuleInfo &abilityStage) +void AppSchedulerProxy::ScheduleAbilityStage(const HapModuleInfo &abilityStage) { - APP_LOGI("AppSchedulerProxy ScheduleAbilityStageInfo start"); + APP_LOGI("AppSchedulerProxy ScheduleAbilityStage start"); MessageParcel data; MessageParcel reply; MessageOption option(MessageOption::TF_SYNC); @@ -238,7 +238,7 @@ void AppSchedulerProxy::ScheduleAbilityStageInfo(const HapModuleInfo &abilitySta if (ret != NO_ERROR) { APP_LOGW("SendRequest is failed, error code: %{public}d", ret); } - APP_LOGI("AppSchedulerProxy ScheduleAbilityStageInfo end"); + APP_LOGI("AppSchedulerProxy ScheduleAbilityStage end"); } void AppSchedulerProxy::ScheduleProfileChanged(const Profile &profile) diff --git a/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_mgr_client.cpp b/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_mgr_client.cpp index 3930428f2e2f305ae8a7dfb42ddc732c869bd1a4..d7bf2e4cb6f64fcbd56088af1c2f533ed8364f7e 100644 --- a/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_mgr_client.cpp +++ b/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_mgr_client.cpp @@ -14,7 +14,6 @@ */ #include "bundle_mgr_client.h" -#include #include #include @@ -253,10 +252,9 @@ bool BundleMgrClient::TransformFileToJsonString(const std::string &resPath, std: APP_LOGE("the file is not existed"); return false; } - std::fstream in; - in.open(resPath, std::ios_base::in | std::ios_base::binary); + std::fstream in(resPath); if (!in.is_open()) { - APP_LOGE("the file cannot be open due to %{public}s", strerror(errno)); + APP_LOGE("the file is not opened %{private}s", resPath.c_str()); return false; } in.seekg(0, std::ios::end); @@ -270,11 +268,9 @@ bool BundleMgrClient::TransformFileToJsonString(const std::string &resPath, std: nlohmann::json profileJson = nlohmann::json::parse(in, nullptr, false); if (profileJson.is_discarded()) { APP_LOGE("bad profile file"); - in.close(); return false; } profile = profileJson.dump(Constants::DUMP_INDENT); - in.close(); return true; } diff --git a/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_mgr_host.cpp b/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_mgr_host.cpp index 80667b1c73c1c4b1b909be4510cd37d2d0990231..c9b711ef9c65d1c7c706e8e256f01196f1b5a511 100644 --- a/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_mgr_host.cpp +++ b/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_mgr_host.cpp @@ -1649,7 +1649,7 @@ ErrCode BundleMgrHost::HandleQueryExtAbilityInfos(Parcel &data, Parcel &reply) return ERR_APPEXECFWK_PARCEL_ERROR; } - ExtensionAbilityType type = static_cast(data.ReadInt32()); + int32_t type = data.ReadInt32(); int32_t flag = data.ReadInt32(); int32_t userId = data.ReadInt32(); std::vector infos; diff --git a/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_mgr_proxy.cpp b/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_mgr_proxy.cpp index 309be35067e60c5289019b540785797f0460860e..2d018a4061edbcb3deaaabcd68a2c71acbbab5aa 100644 --- a/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_mgr_proxy.cpp +++ b/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_mgr_proxy.cpp @@ -2037,8 +2037,8 @@ bool BundleMgrProxy::QueryExtensionAbilityInfos(const Want &want, const int32_t return true; } -bool BundleMgrProxy::QueryExtensionAbilityInfos(const Want &want, const ExtensionAbilityType &extensionType, - const int32_t &flag, const int32_t &userId, std::vector &extensionInfos) +bool BundleMgrProxy::QueryExtensionAbilityInfos(const Want &want, const int32_t &extensionType, const int32_t &flag, + const int32_t &userId, std::vector &extensionInfos) { MessageParcel data; if (!data.WriteInterfaceToken(GetDescriptor())) { @@ -2049,7 +2049,7 @@ bool BundleMgrProxy::QueryExtensionAbilityInfos(const Want &want, const Extensio APP_LOGE("fail to QueryExtensionAbilityInfos due to write want fail"); return false; } - if (!data.WriteInt32(static_cast(extensionType))) { + if (!data.WriteInt32(extensionType)) { APP_LOGE("fail to QueryExtensionAbilityInfos due to write type fail"); return false; } diff --git a/kits/appkit/napi/app_manager/js_app_manager.cpp b/kits/appkit/napi/app_manager/js_app_manager.cpp index 844c9f077b5150045f260b4bbde29544a0f93135..3b4e12831b3a0b814b6d670e1b724726a7eca88c 100644 --- a/kits/appkit/napi/app_manager/js_app_manager.cpp +++ b/kits/appkit/napi/app_manager/js_app_manager.cpp @@ -17,7 +17,6 @@ #include -#include "ability_manager_interface.h" #include "app_mgr_interface.h" #include "hilog_wrapper.h" #include "js_runtime.h" @@ -41,9 +40,7 @@ constexpr size_t ARGC_TWO = 2; class JsAppManager final { public: - JsAppManager(sptr appManager, - sptr abilityManager) : appManager_(appManager), - abilityManager_(abilityManager) {} + JsAppManager(sptr appManager) : appManager_(appManager) {} ~JsAppManager() = default; static void Finalizer(NativeEngine* engine, void* data, void* hint) @@ -70,19 +67,12 @@ public: return (me != nullptr) ? me->OnGetForegroundApplications(*engine, *info) : nullptr; } - static NativeValue* IsUserAStabilityTest(NativeEngine* engine, NativeCallbackInfo* info) - { - JsAppManager* me = CheckParamsAndGetThis(engine, info); - return (me != nullptr) ? me->OnIsUserAStabilityTest(*engine, *info) : nullptr; - } - private: sptr appManager_ = nullptr; - sptr abilityManager_ = nullptr; NativeValue* OnRegisterApplicationStateObserver(NativeEngine& engine, NativeCallbackInfo& info) { - HILOG_INFO("OnRegisterApplicationStateObserver is called"); + HILOG_INFO("OnRegisterApplicationStateObserver is called"); // only support one or two params if (info.argc != ARGC_ONE) { HILOG_ERROR("Not enough params"); @@ -104,11 +94,6 @@ private: AsyncTask::CompleteCallback complete = [appManager = appManager_, observer](NativeEngine& engine, AsyncTask& task, int32_t status) { HILOG_INFO("RegisterApplicationStateObserver callback begin"); - if (appManager == nullptr) { - HILOG_ERROR("appManager nullptr"); - task.Reject(engine, CreateJsError(engine, ERROR_CODE_ONE, "appManager nullptr")); - return; - } int32_t err = appManager->RegisterApplicationStateObserver(observer); if (err == 0) { HILOG_INFO("RegisterApplicationStateObserver success err 0"); @@ -151,9 +136,9 @@ private: [appManager = appManager_, observer, observerId]( NativeEngine& engine, AsyncTask& task, int32_t status) { HILOG_INFO("OnUnregisterApplicationStateObserver begin"); - if (observer == nullptr || appManager == nullptr) { - HILOG_ERROR("observer or appManager nullptr"); - task.Reject(engine, CreateJsError(engine, ERROR_CODE_ONE, "observer or appManager nullptr")); + if (observer == nullptr) { + HILOG_WARN("observer nullptr"); + task.Reject(engine, CreateJsError(engine, ERROR_CODE_ONE, "not found observer")); return; } HILOG_INFO("observer->UnregisterApplicationStateObserver"); @@ -187,11 +172,6 @@ private: [appManager = appManager_]( NativeEngine& engine, AsyncTask& task, int32_t status) { HILOG_INFO("OnGetForegroundApplications begin"); - if (appManager == nullptr) { - HILOG_ERROR("appManager nullptr"); - task.Reject(engine, CreateJsError(engine, ERROR_CODE_ONE, "appManager nullptr")); - return; - } std::vector list; int32_t err = appManager->GetForegroundApplications(list); if (err == 0) { @@ -209,33 +189,6 @@ private: engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result)); return result; } - - NativeValue* OnIsUserAStabilityTest(NativeEngine& engine, NativeCallbackInfo& info) - { - // only support 0 or 1 params - if (info.argc != ARGC_ONE && info.argc != ARGC_ZERO) { - HILOG_ERROR("Not enough params"); - return engine.CreateUndefined(); - } - AsyncTask::CompleteCallback complete = - [abilityManager = abilityManager_](NativeEngine& engine, AsyncTask& task, int32_t status) { - if (abilityManager == nullptr) { - HILOG_WARN("abilityManager nullptr"); - task.Reject(engine, CreateJsError(engine, ERROR_CODE_ONE, "abilityManager nullptr")); - return; - } - HILOG_INFO("IsUserAStabilityTest begin"); - bool ret = abilityManager->IsUserAStabilityTest(); - HILOG_INFO("IsUserAStabilityTest result:%{public}d", ret); - task.Resolve(engine, CreateJsValue(engine, ret)); - }; - - NativeValue* lastParam = (info.argc == ARGC_ZERO) ? nullptr : info.argv[INDEX_ZERO]; - NativeValue* result = nullptr; - AsyncTask::Schedule( - engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result)); - return result; - } }; } // namespace @@ -247,15 +200,6 @@ OHOS::sptr GetAppManagerInstance() return OHOS::iface_cast(appObject); } -OHOS::sptr GetAbilityManagerInstance() -{ - OHOS::sptr systemAbilityManager = - OHOS::SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); - OHOS::sptr abilityObject = - systemAbilityManager->GetSystemAbility(OHOS::ABILITY_MGR_SERVICE_ID); - return OHOS::iface_cast(abilityObject); -} - NativeValue* JsAppManagerInit(NativeEngine* engine, NativeValue* exportObj) { HILOG_INFO("JsAppManagerInit is called"); @@ -272,7 +216,7 @@ NativeValue* JsAppManagerInit(NativeEngine* engine, NativeValue* exportObj) } std::unique_ptr jsAppManager = - std::make_unique(GetAppManagerInstance(), GetAbilityManagerInstance()); + std::make_unique(GetAppManagerInstance()); object->SetNativePointer(jsAppManager.release(), JsAppManager::Finalizer, nullptr); //make handler @@ -285,8 +229,6 @@ NativeValue* JsAppManagerInit(NativeEngine* engine, NativeValue* exportObj) JsAppManager::UnregisterApplicationStateObserver); BindNativeFunction(*engine, *object, "getForegroundApplications", JsAppManager::GetForegroundApplications); - BindNativeFunction(*engine, *object, "isUserAStabilityTest", - JsAppManager::IsUserAStabilityTest); HILOG_INFO("JsAppManagerInit end"); return engine->CreateUndefined(); } diff --git a/kits/appkit/napi/bundlemgr/bundle_mgr.cpp b/kits/appkit/napi/bundlemgr/bundle_mgr.cpp index c794ef919cc3a9c1ecfb212cdd03dd27234300e2..4794dc9808d3b4bfb9a61752767fa0f4a81da38d 100755 --- a/kits/appkit/napi/bundlemgr/bundle_mgr.cpp +++ b/kits/appkit/napi/bundlemgr/bundle_mgr.cpp @@ -853,15 +853,9 @@ static void ConvertBundleInfo(napi_env env, napi_value objBundleInfo, const Bund env, napi_set_named_property(env, objBundleInfo, "minCompatibleVersionCode", nMinCompatibleVersionCode)); napi_value nEntryInstallationFree; - NAPI_CALL_RETURN_VOID(env, napi_get_boolean(env, bundleInfo.entryInstallationFree, &nEntryInstallationFree)); + NAPI_CALL_RETURN_VOID(env, napi_get_boolean(env, false, &nEntryInstallationFree)); NAPI_CALL_RETURN_VOID( env, napi_set_named_property(env, objBundleInfo, "entryInstallationFree", nEntryInstallationFree)); - - napi_value nExtensionAbilityInfos; - napi_create_array_with_length(env, bundleInfo.extensionInfos.size(), &nExtensionAbilityInfos); - ConvertExtensionInfos(env, nExtensionAbilityInfos, bundleInfo.extensionInfos); - NAPI_CALL_RETURN_VOID(env, - napi_set_named_property(env, objBundleInfo, "extensionAbilityInfo", nExtensionAbilityInfos)); } static void ConvertDistributedAbilityInfo(napi_env env, napi_value objDistributedAbilityInfo, @@ -2646,72 +2640,54 @@ static bool ParseInstallParam(napi_env env, InstallParam &installParam, napi_val HILOG_ERROR("args type incorrect!"); return false; } - napi_value property = nullptr; - bool hasKey = false; - napi_has_named_property(env, args, "userId", &hasKey); - if (hasKey) { - status = napi_get_named_property(env, args, "userId", &property); - if (status != napi_ok) { - HILOG_ERROR("napi get named property error!"); - return false; - } - - napi_typeof(env, property, &valueType); - if (valueType != napi_number) { - HILOG_ERROR("param(userId) type incorrect!"); - return false; - } - - int userId = Constants::UNSPECIFIED_USERID; - NAPI_CALL(env, napi_get_value_int32(env, property, &userId)); - installParam.userId = userId; + status = napi_get_named_property(env, args, "userId", &property); + if (status != napi_ok) { + HILOG_ERROR("cannot find property userId"); + return false; } + napi_typeof(env, property, &valueType); + if (valueType != napi_number) { + HILOG_ERROR("param type incorrect!"); + return false; + } + int userId = 0; + NAPI_CALL(env, napi_get_value_int32(env, property, &userId)); + installParam.userId = userId; HILOG_INFO("ParseInstallParam userId=%{public}d.", installParam.userId); property = nullptr; - hasKey = false; - napi_has_named_property(env, args, "installFlag", &hasKey); - if (hasKey) { - status = napi_get_named_property(env, args, "installFlag", &property); - if (status != napi_ok) { - HILOG_ERROR("napi get named property error!"); - return false; - } - - napi_typeof(env, property, &valueType); - if (valueType != napi_number) { - HILOG_ERROR("param(installFlag) type incorrect!"); - return false; - } - - int installFlag = 0; - NAPI_CALL(env, napi_get_value_int32(env, property, &installFlag)); - installParam.installFlag = static_cast(installFlag); + status = napi_get_named_property(env, args, "installFlag", &property); + if (status != napi_ok) { + HILOG_ERROR("cannot find property installFlag"); + return false; + } + napi_typeof(env, property, &valueType); + if (valueType != napi_number) { + HILOG_ERROR("param type incorrect!"); + return false; } + int installFlag = 0; + NAPI_CALL(env, napi_get_value_int32(env, property, &installFlag)); + installParam.installFlag = static_cast(installFlag); HILOG_INFO("ParseInstallParam installFlag=%{public}d.", installParam.installFlag); property = nullptr; - hasKey = false; - napi_has_named_property(env, args, "isKeepData", &hasKey); - if (hasKey) { - status = napi_get_named_property(env, args, "isKeepData", &property); - if (status != napi_ok) { - HILOG_ERROR("napi get named property error!"); - return false; - } - - napi_typeof(env, property, &valueType); - if (valueType != napi_boolean) { - HILOG_ERROR("param(isKeepData) type incorrect!"); - return false; - } - - bool isKeepData = false; - NAPI_CALL(env, napi_get_value_bool(env, property, &isKeepData)); - installParam.isKeepData = isKeepData; + status = napi_get_named_property(env, args, "isKeepData", &property); + if (status != napi_ok) { + HILOG_ERROR("cannot find property isKeepData"); + return false; + } + napi_typeof(env, property, &valueType); + if (valueType != napi_boolean) { + HILOG_ERROR("param type incorrect!"); + return false; } + bool isKeepData = false; + NAPI_CALL(env, napi_get_value_bool(env, property, &isKeepData)); + installParam.isKeepData = isKeepData; HILOG_INFO("ParseInstallParam isKeepData=%{public}d.", installParam.isKeepData); + return true; } @@ -2870,7 +2846,6 @@ napi_value Install(napi_env env, napi_callback_info info) retFirst = ParseStringArray(env, bundleFilePaths, argv[PARAM0]); retSecond = ParseInstallParam(env, installParam, argv[PARAM1]); if (retFirst == nullptr || !retSecond) { - HILOG_ERROR("Install installParam error."); asyncCallbackInfo->errCode = PARAM_TYPE_ERROR; } asyncCallbackInfo->hapFiles = bundleFilePaths; @@ -2894,9 +2869,7 @@ napi_value Install(napi_env env, napi_callback_info info) [](napi_env env, void *data) { AsyncInstallCallbackInfo *asyncCallbackInfo = (AsyncInstallCallbackInfo *)data; if (!asyncCallbackInfo->errCode) { - InnerInstall(env, - asyncCallbackInfo->hapFiles, - asyncCallbackInfo->installParam, + InnerInstall(env, asyncCallbackInfo->hapFiles, asyncCallbackInfo->installParam, asyncCallbackInfo->installResult); } }, @@ -3008,28 +2981,22 @@ napi_value Recover(napi_env env, napi_callback_info info) HILOG_DEBUG("Recover by bundleName called"); size_t argc = ARGS_SIZE_THREE; napi_value argv[ARGS_SIZE_THREE] = {nullptr}; + NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, NULL, NULL)); + HILOG_DEBUG("argc = [%{public}zu]", argc); + std::string bundleName; + ParseString(env, bundleName, argv[PARAM0]); + InstallParam installParam; + ParseInstallParam(env, installParam, argv[PARAM1]); AsyncInstallCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncInstallCallbackInfo { .env = env, .asyncWork = nullptr, .deferred = nullptr, - .errCode = 0, + .bundleName = bundleName, + .installParam = installParam, }; if (asyncCallbackInfo == nullptr) { return nullptr; } - - NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, NULL, NULL)); - HILOG_DEBUG("argc = [%{public}zu]", argc); - std::string bundleName; - ParseString(env, bundleName, argv[PARAM0]); - InstallParam installParam; - if (!ParseInstallParam(env, installParam, argv[PARAM1])) { - HILOG_ERROR("Recover installParam error."); - asyncCallbackInfo->errCode = PARAM_TYPE_ERROR; - } - - asyncCallbackInfo->installParam = installParam; - asyncCallbackInfo->bundleName = bundleName; if (argc > (ARGS_SIZE_THREE - CALLBACK_SIZE)) { HILOG_DEBUG("Recover by bundleName asyncCallback."); napi_valuetype valuetype = napi_undefined; @@ -3045,12 +3012,10 @@ napi_value Recover(napi_env env, napi_callback_info info) resourceName, [](napi_env env, void *data) { AsyncInstallCallbackInfo *asyncCallbackInfo = (AsyncInstallCallbackInfo *)data; - if (!asyncCallbackInfo->errCode) { - InnerRecover(env, - asyncCallbackInfo->bundleName, - asyncCallbackInfo->installParam, - asyncCallbackInfo->installResult); - } + InnerRecover(env, + asyncCallbackInfo->bundleName, + asyncCallbackInfo->installParam, + asyncCallbackInfo->installResult); }, [](napi_env env, napi_status status, void *data) { AsyncInstallCallbackInfo *asyncCallbackInfo = (AsyncInstallCallbackInfo *)data; @@ -3058,25 +3023,17 @@ napi_value Recover(napi_env env, napi_callback_info info) napi_value callback = 0; napi_value undefined = 0; napi_value callResult = 0; - if (!asyncCallbackInfo->errCode) { - napi_create_object(env, &result[PARAM1]); - ConvertInstallResult(asyncCallbackInfo->installResult); - napi_value nResultMsg; - napi_create_string_utf8( - env, asyncCallbackInfo->installResult.resultMsg.c_str(), NAPI_AUTO_LENGTH, &nResultMsg); - napi_set_named_property(env, result[PARAM1], "statusMessage", nResultMsg); - napi_value nResultCode; - napi_create_int32(env, asyncCallbackInfo->installResult.resultCode, &nResultCode); - napi_set_named_property(env, result[PARAM1], "status", nResultCode); - result[PARAM0] = GetCallbackErrorValue( - env, (asyncCallbackInfo->installResult.resultCode == 0) ? CODE_SUCCESS : CODE_FAILED); - } else { - napi_value nResultMsg; - std::string msg = "error param type."; - napi_create_string_utf8(env, msg.c_str(), NAPI_AUTO_LENGTH, &nResultMsg); - result[PARAM0] = GetCallbackErrorValue(env, CODE_FAILED); - napi_set_named_property(env, result[PARAM0], "Message", nResultMsg); - } + napi_create_object(env, &result[PARAM1]); + ConvertInstallResult(asyncCallbackInfo->installResult); + napi_value nResultMsg; + napi_create_string_utf8( + env, asyncCallbackInfo->installResult.resultMsg.c_str(), NAPI_AUTO_LENGTH, &nResultMsg); + napi_set_named_property(env, result[PARAM1], "statusMessage", nResultMsg); + napi_value nResultCode; + napi_create_int32(env, asyncCallbackInfo->installResult.resultCode, &nResultCode); + napi_set_named_property(env, result[PARAM1], "status", nResultCode); + result[PARAM0] = GetCallbackErrorValue( + env, (asyncCallbackInfo->installResult.resultCode == 0) ? CODE_SUCCESS : CODE_FAILED); napi_get_undefined(env, &undefined); napi_get_reference_value(env, asyncCallbackInfo->callback, &callback); napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, &result[PARAM0], &callResult); @@ -3190,28 +3147,22 @@ napi_value Uninstall(napi_env env, napi_callback_info info) HILOG_INFO("Uninstall called"); size_t argc = ARGS_SIZE_THREE; napi_value argv[ARGS_SIZE_THREE] = {nullptr}; + NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, NULL, NULL)); + HILOG_INFO("argc = [%{public}zu]", argc); + std::string bundleName; + ParseString(env, bundleName, argv[PARAM0]); + InstallParam installParam; + ParseInstallParam(env, installParam, argv[PARAM1]); AsyncInstallCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncInstallCallbackInfo { .env = env, .asyncWork = nullptr, .deferred = nullptr, - .errCode = 0, + .param = bundleName, + .installParam = installParam, }; if (asyncCallbackInfo == nullptr) { return nullptr; } - - NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, NULL, NULL)); - HILOG_INFO("argc = [%{public}zu]", argc); - std::string bundleName; - ParseString(env, bundleName, argv[PARAM0]); - InstallParam installParam; - if (!ParseInstallParam(env, installParam, argv[PARAM1])) { - HILOG_ERROR("Uninstall installParam error."); - asyncCallbackInfo->errCode = PARAM_TYPE_ERROR; - } - - asyncCallbackInfo->installParam = installParam; - asyncCallbackInfo->bundleName = bundleName; if (argc > (ARGS_SIZE_THREE - CALLBACK_SIZE)) { HILOG_INFO("Uninstall asyncCallback."); napi_valuetype valuetype = napi_undefined; @@ -3227,12 +3178,8 @@ napi_value Uninstall(napi_env env, napi_callback_info info) resourceName, [](napi_env env, void *data) { AsyncInstallCallbackInfo *asyncCallbackInfo = (AsyncInstallCallbackInfo *)data; - if (!asyncCallbackInfo->errCode) { - InnerUninstall(env, - asyncCallbackInfo->bundleName, - asyncCallbackInfo->installParam, - asyncCallbackInfo->installResult); - } + InnerUninstall( + env, asyncCallbackInfo->param, asyncCallbackInfo->installParam, asyncCallbackInfo->installResult); }, [](napi_env env, napi_status status, void *data) { AsyncInstallCallbackInfo *asyncCallbackInfo = (AsyncInstallCallbackInfo *)data; @@ -3240,25 +3187,17 @@ napi_value Uninstall(napi_env env, napi_callback_info info) napi_value callback = 0; napi_value undefined = 0; napi_value callResult = 0; - if (!asyncCallbackInfo->errCode) { - napi_create_object(env, &result[PARAM1]); - ConvertInstallResult(asyncCallbackInfo->installResult); - napi_value nResultMsg; - napi_create_string_utf8( - env, asyncCallbackInfo->installResult.resultMsg.c_str(), NAPI_AUTO_LENGTH, &nResultMsg); - napi_set_named_property(env, result[PARAM1], "statusMessage", nResultMsg); - napi_value nResultCode; - napi_create_int32(env, asyncCallbackInfo->installResult.resultCode, &nResultCode); - napi_set_named_property(env, result[PARAM1], "status", nResultCode); - result[PARAM0] = GetCallbackErrorValue( - env, (asyncCallbackInfo->installResult.resultCode == 0) ? CODE_SUCCESS : CODE_FAILED); - } else { - napi_value nResultMsg; - std::string msg = "error param type."; - napi_create_string_utf8(env, msg.c_str(), NAPI_AUTO_LENGTH, &nResultMsg); - result[PARAM0] = GetCallbackErrorValue(env, CODE_FAILED); - napi_set_named_property(env, result[PARAM0], "Message", nResultMsg); - } + napi_create_object(env, &result[PARAM1]); + ConvertInstallResult(asyncCallbackInfo->installResult); + napi_value nResultMsg; + napi_create_string_utf8( + env, asyncCallbackInfo->installResult.resultMsg.c_str(), NAPI_AUTO_LENGTH, &nResultMsg); + napi_set_named_property(env, result[PARAM1], "statusMessage", nResultMsg); + napi_value nResultCode; + napi_create_int32(env, asyncCallbackInfo->installResult.resultCode, &nResultCode); + napi_set_named_property(env, result[PARAM1], "status", nResultCode); + result[PARAM0] = GetCallbackErrorValue( + env, (asyncCallbackInfo->installResult.resultCode == 0) ? CODE_SUCCESS : CODE_FAILED); napi_get_undefined(env, &undefined); napi_get_reference_value(env, asyncCallbackInfo->callback, &callback); napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, &result[PARAM0], &callResult); @@ -5314,9 +5253,10 @@ static bool ParseWant(napi_env env, AsyncExtensionInfoCallbackInfo *info, napi_v HILOG_ERROR("args not object type"); return false; } + napi_status status; napi_value prop = nullptr; - napi_get_named_property(env, args, "extensionAbilityName", &prop); - if (prop == nullptr) { + status = napi_get_named_property(env, args, "extensionAbilityName", &prop); + if (status != napi_ok) { HILOG_WARN("cannot find the property of extensionAbilityName"); } else { napi_typeof(env, prop, &valueType); @@ -5328,11 +5268,11 @@ static bool ParseWant(napi_env env, AsyncExtensionInfoCallbackInfo *info, napi_v } prop = nullptr; - napi_get_named_property(env, args, "extensionAbilityType", &prop); - if (prop == nullptr) { + status = napi_get_named_property(env, args, "extensionAbilityType", &prop); + if (status != napi_ok) { HILOG_WARN("cannot find the property of extensionAbilityType"); } else { - napi_typeof(env, prop, &valueType); + napi_typeof(env, prop, &valueType); if (valueType != napi_number) { HILOG_ERROR("extensionAbilityName is not type of number"); return false; @@ -5357,12 +5297,13 @@ static bool InnerQueryExtensionInfo(napi_env env, AsyncExtensionInfoCallbackInfo HILOG_ERROR("can not get iBundleMgr"); return false; } - + if (info->userId < 0) { + info->userId = IPCSkeleton::GetCallingUid(); + } if (info->extensionAbilityType < 0) { return iBundleMgr->QueryExtensionAbilityInfos(info->want, info->flags, info->userId, info->extensionInfos); } else { - auto type = static_cast(info->extensionAbilityType); - return iBundleMgr->QueryExtensionAbilityInfos(info->want, type, info->flags, info->userId, + return iBundleMgr->QueryExtensionAbilityInfos(info->want, info->extensionAbilityType, info->flags, info->userId, info->extensionInfos); } } diff --git a/kits/appkit/napi/bundlemgr/bundle_mgr.h b/kits/appkit/napi/bundlemgr/bundle_mgr.h index 08d1bd03cf6194d858413c9e6ffacc326fbe7c77..34772118aafb617894d19bedf2be9e7f9c8b4f6a 100644 --- a/kits/appkit/napi/bundlemgr/bundle_mgr.h +++ b/kits/appkit/napi/bundlemgr/bundle_mgr.h @@ -223,7 +223,7 @@ struct AsyncExtensionInfoCallbackInfo { std::string extensionAbilityName; int32_t extensionAbilityType = -1; int32_t flags = 0; - int32_t userId = Constants::UNSPECIFIED_USERID; + int32_t userId = -1; std::vector extensionInfos; bool ret = false; int32_t err = 0; diff --git a/kits/appkit/native/ability_runtime/context/context_impl.cpp b/kits/appkit/native/ability_runtime/context/context_impl.cpp index eb65f8691dbf1234989d0c7ec29c44b9eae47796..92a2057121c8b0f448ee8fcf1742b142cbdd8c5f 100644 --- a/kits/appkit/native/ability_runtime/context/context_impl.cpp +++ b/kits/appkit/native/ability_runtime/context/context_impl.cpp @@ -293,6 +293,11 @@ void ContextImpl::InitHapModuleInfo(const std::shared_ptr(hapModuleInfo); +} + std::shared_ptr ContextImpl::GetHapModuleInfo() const { return hapModuleInfo_; diff --git a/kits/appkit/native/ability_runtime/context/context_impl.h b/kits/appkit/native/ability_runtime/context/context_impl.h index 1d4a5e485e13c9788fe682c3ec360ea739d38bca..db19e2c8348737c5d9d0c9e24cce630b7fb42197 100644 --- a/kits/appkit/native/ability_runtime/context/context_impl.h +++ b/kits/appkit/native/ability_runtime/context/context_impl.h @@ -163,6 +163,13 @@ public: */ void InitHapModuleInfo(const std::shared_ptr &abilityInfo); + /** + * @brief Set HapModuleInfo + * + * @param hapModuleInfo HapModuleInfo instance. + */ + void InitHapModuleInfo(const AppExecFwk::HapModuleInfo &hapModuleInfo); + /** * @brief Set application context */ diff --git a/kits/appkit/native/app/include/main_thread.h b/kits/appkit/native/app/include/main_thread.h index ec68a46df1fae96a5bc72ec8e48e6dfef44351c0..a761934500d80e9aaa863f27347f4f27b20db55e 100644 --- a/kits/appkit/native/app/include/main_thread.h +++ b/kits/appkit/native/app/include/main_thread.h @@ -159,7 +159,7 @@ public: * * @param The resident process data value. */ - void ScheduleAbilityStageInfo(const HapModuleInfo &abilityStage) override; + void ScheduleAbilityStage(const HapModuleInfo &abilityStage) override; /** * @@ -252,7 +252,7 @@ private: * @param appLaunchData The launchdata of the application witch launced. * */ - void HandleAbilityStageInfo(const HapModuleInfo &abilityStage); + void HandleAbilityStage(const HapModuleInfo &abilityStage); /** * diff --git a/kits/appkit/native/app/include/ohos_application.h b/kits/appkit/native/app/include/ohos_application.h index 25d711c2b268dc138328d308cb0eb707ecedfe35..dd134dd06f3dd249fa7ff348b986bd3c90c88cd6 100644 --- a/kits/appkit/native/app/include/ohos_application.h +++ b/kits/appkit/native/app/include/ohos_application.h @@ -224,6 +224,14 @@ public: std::shared_ptr AddAbilityStage( const std::shared_ptr &abilityRecord); + /** + * @brief add the ability stage when a hap first load + * + * @param hapModuleInfo + * @return Returns true on success, false on failure + */ + bool AddAbilityStage(const AppExecFwk::HapModuleInfo &hapModuleInfo); + /** * @brief remove the ability stage when all of the abilities in the hap have been removed * diff --git a/kits/appkit/native/app/src/main_thread.cpp b/kits/appkit/native/app/src/main_thread.cpp index d282ead31724c02dc9f2c586bc99ac36edbfc686..4bd4f4f374b44f8ad74e51bc19e44162a16be274 100644 --- a/kits/appkit/native/app/src/main_thread.cpp +++ b/kits/appkit/native/app/src/main_thread.cpp @@ -357,10 +357,10 @@ void MainThread::ScheduleLaunchApplication(const AppLaunchData &data) APP_LOGI("MainThread::scheduleLaunchApplication end."); } -void MainThread::ScheduleAbilityStageInfo(const HapModuleInfo &abilityStage) +void MainThread::ScheduleAbilityStage(const HapModuleInfo &abilityStage) { APP_LOGI("MainThread::ScheduleAbilityStageInfo start"); - auto task = [appThread = this, abilityStage]() { appThread->HandleAbilityStageInfo(abilityStage);}; + auto task = [appThread = this, abilityStage]() { appThread->HandleAbilityStage(abilityStage);}; if (!mainHandler_->PostTask(task)) { APP_LOGE("MainThread::ScheduleAbilityStageInfo PostTask task failed"); } @@ -804,8 +804,25 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData) APP_LOGI("MainThread::handleLaunchApplication called end."); } -void MainThread::HandleAbilityStageInfo(const HapModuleInfo &abilityStage) -{} +void MainThread::HandleAbilityStage(const HapModuleInfo &abilityStage) +{ + APP_LOGI("MainThread::HandleAbilityStageInfo"); + if (!application_) { + APP_LOGE("application_ is nullptr"); + return; + } + auto ref = application_->AddAbilityStage(abilityStage); + if (!ref) { + APP_LOGE("AddAbilityStage Failed "); + return; + } + + if (!appMgr_ || !applicationImpl_) { + APP_LOGE("appMgr_ is nullptr"); + return; + } + appMgr_->AddAbilityStageDone(applicationImpl_->GetRecordId()); +} /** * diff --git a/kits/appkit/native/app/src/ohos_application.cpp b/kits/appkit/native/app/src/ohos_application.cpp index efca9a81dea6b321d9da16bdbf945fd1fa594bd4..432c9d2ea23c39ed6828b6b4b7e76aa8dfd61e1c 100644 --- a/kits/appkit/native/app/src/ohos_application.cpp +++ b/kits/appkit/native/app/src/ohos_application.cpp @@ -467,6 +467,40 @@ std::shared_ptr OHOSApplication::AddAbilityStage( return abilityStage->GetContext(); } +bool OHOSApplication::AddAbilityStage(const AppExecFwk::HapModuleInfo &hapModuleInfo) +{ + APP_LOGI("OHOSApplication::AddAbilityStage"); + if (abilityRuntimeContext_ == nullptr) { + APP_LOGE("OHOSApplication::AddAbilityStage abilityRuntimeContext_ is nullptr."); + return false; + } + + if (runtime_ == nullptr) { + APP_LOGE("OHOSApplication::AddAbilityStage abilityRuntimeContext_ is nullptr."); + return false; + } + + if (abilityStages_.find(hapModuleInfo.moduleName) != abilityStages_.end()) { + APP_LOGE("OHOSApplication::%{public}s: object already exists ", __func__); + return false; + } + + auto stageContext = std::make_shared(); + stageContext->SetParentContext(abilityRuntimeContext_); + stageContext->InitHapModuleInfo(hapModuleInfo); + auto moduleInfo = stageContext->GetHapModuleInfo(); + if (moduleInfo == nullptr) { + APP_LOGE("OHOSApplication::%{public}s: moduleInfo is nullptr", __func__); + return false; + } + auto abilityStage = AbilityRuntime::AbilityStage::Create(runtime_, *moduleInfo); + abilityStage->Init(stageContext); + abilityStage->OnCreate(); + abilityStages_[hapModuleInfo.moduleName] = abilityStage; + APP_LOGE("OHOSApplication::%{public}s: abilityStage insert and initialization", __func__); + return true; +} + void OHOSApplication::CleanAbilityStage(const sptr &token, const std::shared_ptr &abilityInfo) { @@ -500,37 +534,37 @@ const std::unique_ptr& OHOSApplication::GetRuntime() return runtime_; } -bool OHOSApplication::InitAddAbilityStage(const std::shared_ptr &abilityInfo) -{ - if (abilityInfo == nullptr || - abilityRuntimeContext_ == nullptr || - runtime_ == nullptr) { - APP_LOGE("OHOSApplication::%{public}s: %{public}s is nullptr", - __func__, - ((abilityInfo == nullptr) ? - ("abilityInfo") : ((runtime_ == nullptr) ? ("runtime") : ("abilityRuntimeContext_")))); - return false; - } - - if (abilityStages_.find(abilityInfo->moduleName) != abilityStages_.end()) { - APP_LOGE("OHOSApplication::%{public}s: object already exists ", __func__); - return false; - } - - auto stageContext = std::make_shared(); - stageContext->SetParentContext(abilityRuntimeContext_); - stageContext->InitHapModuleInfo(abilityInfo); - auto hapModuleInfo = stageContext->GetHapModuleInfo(); - if (hapModuleInfo == nullptr) { - APP_LOGE("OHOSApplication::%{public}s: hapModuleInfo is nullptr", __func__); - return false; - } - auto abilityStage = AbilityRuntime::AbilityStage::Create(runtime_, *hapModuleInfo); - abilityStage->Init(stageContext); - abilityStage->OnCreate(); - abilityStages_[abilityInfo->moduleName] = abilityStage; - APP_LOGE("OHOSApplication::%{public}s: abilityStage insert and initialization", __func__); - return true; -} +// bool OHOSApplication::InitAddAbilityStage(const std::shared_ptr &abilityInfo) +// { +// if (abilityInfo == nullptr || +// abilityRuntimeContext_ == nullptr || +// runtime_ == nullptr) { +// APP_LOGE("OHOSApplication::%{public}s: %{public}s is nullptr", +// __func__, +// ((abilityInfo == nullptr) ? +// ("abilityInfo") : ((runtime_ == nullptr) ? ("runtime") : ("abilityRuntimeContext_")))); +// return false; +// } + +// if (abilityStages_.find(abilityInfo->moduleName) != abilityStages_.end()) { +// APP_LOGE("OHOSApplication::%{public}s: object already exists ", __func__); +// return false; +// } + +// auto stageContext = std::make_shared(); +// stageContext->SetParentContext(abilityRuntimeContext_); +// stageContext->InitHapModuleInfo(abilityInfo); +// auto hapModuleInfo = stageContext->GetHapModuleInfo(); +// if (hapModuleInfo == nullptr) { +// APP_LOGE("OHOSApplication::%{public}s: hapModuleInfo is nullptr", __func__); +// return false; +// } +// auto abilityStage = AbilityRuntime::AbilityStage::Create(runtime_, *hapModuleInfo); +// abilityStage->Init(stageContext); +// abilityStage->OnCreate(); +// abilityStages_[abilityInfo->moduleName] = abilityStage; +// APP_LOGE("OHOSApplication::%{public}s: abilityStage insert and initialization", __func__); +// return true; +// } } // namespace AppExecFwk } // namespace OHOS diff --git a/kits/appkit/test/Mock/include/mock_ability_mgr_service.h b/kits/appkit/test/Mock/include/mock_ability_mgr_service.h index 73ffbb868dd7eb8fa706a8a92171b4bb73c8e8db..d61f8f6e467a50ec2be7b72eff8a1827adfe22f8 100644 --- a/kits/appkit/test/Mock/include/mock_ability_mgr_service.h +++ b/kits/appkit/test/Mock/include/mock_ability_mgr_service.h @@ -74,17 +74,6 @@ public: MOCK_METHOD0(CleanAllMissions, int()); MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId)); - virtual int SetAbilityController(const sptr &abilityController, - bool imAStabilityTest) override - { - return 0; - } - - virtual bool IsUserAStabilityTest() override - { - return true; - } - void Wait() { sem_.Wait(); diff --git a/services/appmgr/include/app_lifecycle_deal.h b/services/appmgr/include/app_lifecycle_deal.h index 8f35c1a4a233c4fbb89c2a1557b12230fa6a3f11..4a2d0c8654d4802d1027c776710e8d4653e44ef6 100644 --- a/services/appmgr/include/app_lifecycle_deal.h +++ b/services/appmgr/include/app_lifecycle_deal.h @@ -46,7 +46,7 @@ public: * * @return */ - void AddAbilityStageInfo(const HapModuleInfo &abilityStage); + void AddAbilityStage(const HapModuleInfo &abilityStage); /** * LaunchAbility, call ScheduleLaunchAbility() through proxy project, diff --git a/services/appmgr/include/app_running_record.h b/services/appmgr/include/app_running_record.h index 14e82d9683c4950857ee400bbd3b489615bef9ec..2c3c250327eeecef13a8347bec73302fcfd650c8 100644 --- a/services/appmgr/include/app_running_record.h +++ b/services/appmgr/include/app_running_record.h @@ -404,7 +404,7 @@ public: bool IsKeepAliveApp() const; // Please use with caution, it may affect the ability to start. - void SetKeepAliveAppState(); + void SetKeepAliveAppState(bool isKeepAlive, bool isNewMission); std::list> GetAllModuleRecord() const; @@ -474,7 +474,8 @@ private: void RemoveModuleRecord(const std::shared_ptr &record); private: - bool isKeepAliveApp = false; // Only resident processes can be set to true, please choose carefully + bool isKeepAliveApp_ = false; // Only resident processes can be set to true, please choose carefully + bool isNewMission_ = false; ApplicationState curState_ = ApplicationState::APP_STATE_CREATE; // current state of this process std::shared_ptr appInfo_ = nullptr; // the application's info of this process diff --git a/services/appmgr/src/app_lifecycle_deal.cpp b/services/appmgr/src/app_lifecycle_deal.cpp index f230e164a100a7cae7abc529bd6e7def6529243e..2a338806b46d3a479e4b54f23fdbef1dfffffefd 100644 --- a/services/appmgr/src/app_lifecycle_deal.cpp +++ b/services/appmgr/src/app_lifecycle_deal.cpp @@ -34,14 +34,14 @@ void AppLifeCycleDeal::LaunchApplication(const AppLaunchData &launchData_) } } -void AppLifeCycleDeal::AddAbilityStageInfo(const HapModuleInfo &abilityStage) +void AppLifeCycleDeal::AddAbilityStage(const HapModuleInfo &abilityStage) { if (!appThread_) { APP_LOGE("appThread_ is nullptr"); return; } - appThread_->ScheduleAbilityStageInfo(abilityStage); + appThread_->ScheduleAbilityStage(abilityStage); } void AppLifeCycleDeal::LaunchAbility(const std::shared_ptr &ability) diff --git a/services/appmgr/src/app_mgr_service.cpp b/services/appmgr/src/app_mgr_service.cpp index 4c79e2725c7c5f4c48e22a988d784f88e3f9718e..3db49a8e9ebc973f993c52c39b538ee3e27a2c4c 100755 --- a/services/appmgr/src/app_mgr_service.cpp +++ b/services/appmgr/src/app_mgr_service.cpp @@ -241,7 +241,7 @@ void AppMgrService::StartupResidentProcess() if (!IsReady()) { return; } - + APP_LOGD("StartupResidentProcess"); std::function startupResidentProcess = std::bind(&AppMgrServiceInner::LoadResidentProcess, appMgrServiceInner_); handler_->PostTask(startupResidentProcess, TASK_STARTUP_RESIDENT_PROCESS); @@ -283,7 +283,7 @@ int32_t AppMgrService::GetAllRunningProcesses(std::vector &i void AppMgrService::SetAppFreezingTime(int time) { - APP_LOGE("set app freeze time %{public}d ", time); + APP_LOGD("set app freeze time %{public}d ", time); if (!IsReady()) { return; } diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 4c1639b0c3e457f85364ca880fba9bfee741c186..19ad7d9c5a5a46a3a04db2137f11ba69e3d3a1ca 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -40,6 +40,7 @@ namespace AppExecFwk { using namespace OHOS::Security; namespace { +constexpr int TARGET_VERSION_THRESHOLDS = 8; // NANOSECONDS mean 10^9 nano second constexpr int64_t NANOSECONDS = 1000000000; // MICROSECONDS mean 10^6 millias second @@ -1518,6 +1519,25 @@ void AppMgrServiceInner::HandleTerminateApplicationTimeOut(const int64_t eventId void AppMgrServiceInner::HandleAddAbilityStageTimeOut(const int64_t eventId) { APP_LOGI("called add ability stage info time out!"); + if (!appRunningManager_) { + APP_LOGE("appRunningManager_ is nullptr"); + return; + } + auto appRecord = appRunningManager_->GetAppRunningRecord(eventId); + if (!appRecord) { + APP_LOGE("appRecord is nullptr"); + return; + } + + appRecord->SetState(ApplicationState::APP_STATE_TERMINATED); + appRecord->RemoveAppDeathRecipient(); + pid_t pid = appRecord->GetPriorityObject()->GetPid(); + KillProcessByPid(pid); + appRunningManager_->RemoveAppRunningRecordById(appRecord->GetRecordId()); + + OptimizerAppStateChanged(appRecord, ApplicationState::APP_STATE_TERMINATED); + RemoveAppFromRecentListById(appRecord->GetRecordId()); + OnProcessDied(appRecord); } int AppMgrServiceInner::CompelVerifyPermission(const std::string &permission, int pid, int uid, std::string &message) @@ -1643,9 +1663,11 @@ void AppMgrServiceInner::StartEmptyResidentProcess( return; } - appRecord->SetKeepAliveAppState(); + APP_LOGI("StartEmptyResidentProcess current version : [%{public}d], ", info.compatibleVersion); + appRecord->SetKeepAliveAppState(true, info.compatibleVersion >= TARGET_VERSION_THRESHOLDS); if (restartCount > 0) { + APP_LOGI("StartEmptyResidentProcess restartCount : [%{public}d], ", restartCount); appRecord->SetRestartResidentProcCount(restartCount); } diff --git a/services/appmgr/src/app_running_record.cpp b/services/appmgr/src/app_running_record.cpp index 189a75bb2d1dad5cd8983d764aa5b26cb765fe99..9041e1c2768b05eb40a050601b676e512ed21df0 100644 --- a/services/appmgr/src/app_running_record.cpp +++ b/services/appmgr/src/app_running_record.cpp @@ -245,11 +245,16 @@ void AppRunningRecord::LaunchApplication() void AppRunningRecord::AddAbilityStage() { + if (!isNewMission_) { + APP_LOGI("Current version than supports !"); + return; + } HapModuleInfo abilityStage; if (GetTheModuleInfoNeedToUpdated(mainBundleName_, abilityStage)) { SendEvent(AMSEventHandler::ADD_ABILITY_STAGE_INFO_TIMEOUT_MSG, AMSEventHandler::ADD_ABILITY_STAGE_INFO_TIMEOUT); - APP_LOGI("Current Informed module : [%{public}s]", abilityStage.moduleName.c_str()); - appLifeCycleDeal_->AddAbilityStageInfo(abilityStage); + APP_LOGI("Current Informed module : [%{public}s] | bundle : [%{public}s]", + abilityStage.moduleName.c_str(), mainBundleName_.c_str()); + appLifeCycleDeal_->AddAbilityStage(abilityStage); return; } @@ -774,12 +779,13 @@ bool AppRunningRecord::IsTerminating() bool AppRunningRecord::IsKeepAliveApp() const { - return isKeepAliveApp; + return isKeepAliveApp_; } -void AppRunningRecord::SetKeepAliveAppState() +void AppRunningRecord::SetKeepAliveAppState(bool isKeepAlive, bool isNewMission) { - isKeepAliveApp = true; + isKeepAliveApp_ = isKeepAlive; + isNewMission_ = isNewMission; } bool AppRunningRecord::GetTheModuleInfoNeedToUpdated(const std::string bundleName, HapModuleInfo &info) diff --git a/services/bundlemgr/BUILD.gn b/services/bundlemgr/BUILD.gn index 9a054088a48008753cb4a67b5dc12753e2ec4252..70cd046ac3ecfadd4ab462d37400e250e4148cbc 100644 --- a/services/bundlemgr/BUILD.gn +++ b/services/bundlemgr/BUILD.gn @@ -16,10 +16,22 @@ import("//foundation/appexecfwk/standard/appexecfwk.gni") import( "//foundation/appexecfwk/standard/services/bundlemgr/appexecfwk_bundlemgr.gni") +config("bundlemgr_config") { + include_dirs = [ + "include", + "//utils/system/safwk/native/include", + ] +} + config("bundlemgr_common_config") { include_dirs = [ "include", + "${appexecfwk_path}/interfaces/innerkits/appexecfwk_base/include", + "${appexecfwk_path}/interfaces/innerkits/appexecfwk_core/include/bundlemgr", "//utils/system/safwk/native/include", + "//base/security/access_token/interfaces/innerkits/accesstoken/include", + "//base/security/permission/interfaces/innerkits/permission_standard/permissionsdk/main/cpp/include", + "//base/security/appverify/interfaces/innerkits/appverify/include", ] defines = [ @@ -33,6 +45,7 @@ config("bundlemgr_parse_config") { "//third_party/json/include", "//third_party/zlib/contrib/minizip", "//third_party/zlib", + "//utils/native/base/include", ] } @@ -132,6 +145,7 @@ ohos_shared_library("libbms") { defines = [ "APP_LOG_TAG = \"BundleMgrService\"" ] configs = [ + ":bundlemgr_config", ":bundlemgr_common_config", "${libs_path}/libeventhandler:libeventhandler_config", ] @@ -178,7 +192,7 @@ ohos_executable("installs") { defines = [ "APP_LOG_TAG = \"BundleMgrService\"" ] - configs = [ ":bundlemgr_common_config" ] + configs = [ ":bundlemgr_config" ] cflags = [] if (target_cpu == "arm") { cflags += [ "-DBINDER_IPC_32BIT" ] @@ -190,7 +204,6 @@ ohos_executable("installs") { ] external_deps = [ - "bundle_framework:appexecfwk_base", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "samgr_standard:samgr_proxy", diff --git a/services/bundlemgr/appexecfwk_bundlemgr.gni b/services/bundlemgr/appexecfwk_bundlemgr.gni index f5d6204caa0d44fe10b6ab5a84fd6aca2238d833..d2d70ed84293128ce73d1846a655ce0997a668cc 100644 --- a/services/bundlemgr/appexecfwk_bundlemgr.gni +++ b/services/bundlemgr/appexecfwk_bundlemgr.gni @@ -42,6 +42,12 @@ bundle_install_sources = [ ] bundle_install_deps = [ + "${appexecfwk_path}/interfaces/innerkits/appexecfwk_base:appexecfwk_base", "${services_path}/bundlemgr:bundle_parser", "${services_path}/bundlemgr:parser_common", ] + +bundle_install_external_deps = [ + "aafwk_standard:want", + #"communication:ipc_core", +] diff --git a/services/bundlemgr/bundle.json b/services/bundlemgr/bundle.json index 180641ecf0e657352b371115f9327b76ae4ac810..ae272f156e197e79fb179beae235252aa3482602 100644 --- a/services/bundlemgr/bundle.json +++ b/services/bundlemgr/bundle.json @@ -3,9 +3,6 @@ "description": "提供OpenHarmony应用和服务安装包的安装、更新、卸载以及信息查询等能力,包含包管理接口和包管理服务", "version": "3.1", "license": "Apache 2.0", - "segment": { - "destPath": "foundation/appexecfwk/standard/services/bundlemgr" - }, "component": { "name": "bundle_framework", "subsystem": "appexecfwk", diff --git a/services/bundlemgr/include/bundle_mgr_host_impl.h b/services/bundlemgr/include/bundle_mgr_host_impl.h index 81ac784f1f7e28db11d481f86e88d1856627c84e..19b8ad1301eea9e3ba4fac79e390ab644161bf8c 100644 --- a/services/bundlemgr/include/bundle_mgr_host_impl.h +++ b/services/bundlemgr/include/bundle_mgr_host_impl.h @@ -583,8 +583,8 @@ public: * @param extensionInfos Indicates the obtained extensions. * @return Returns true if this function is successfully called; returns false otherwise. */ - virtual bool QueryExtensionAbilityInfos(const Want &want, const ExtensionAbilityType &extensionType, - const int32_t &flag, const int32_t &userId, std::vector &extensionInfos) override; + virtual bool QueryExtensionAbilityInfos(const Want &want, const int32_t &extensionType, const int32_t &flag, + const int32_t &userId, std::vector &extensionInfos) override; private: const std::shared_ptr GetCloneMgrFromService(); diff --git a/services/bundlemgr/src/bundle_data_mgr.cpp b/services/bundlemgr/src/bundle_data_mgr.cpp index a082db6090e0548aa38e6a793d23c35475192ea5..2726a2a391204ad443c5697e68e588f20cb91897 100644 --- a/services/bundlemgr/src/bundle_data_mgr.cpp +++ b/services/bundlemgr/src/bundle_data_mgr.cpp @@ -417,10 +417,6 @@ bool BundleDataMgr::ExplicitQueryAbilityInfo(const std::string &bundleName, cons APP_LOGE("ability not found"); return false; } - if ((static_cast(flags) & GET_ABILITY_INFO_SYSTEMAPP_ONLY) == GET_ABILITY_INFO_SYSTEMAPP_ONLY && - !innerBundleInfo.IsSystemApp()) { - return false; - } if (!(static_cast(flags) & GET_ABILITY_INFO_WITH_DISABLE)) { if (!innerBundleInfo.IsAbilityEnabled((*ability), GetUserId(userId))) { APP_LOGE("ability:%{public}s is disabled", ability->name.c_str()); @@ -442,6 +438,7 @@ bool BundleDataMgr::ExplicitQueryAbilityInfo(const std::string &bundleName, cons return true; } + bool BundleDataMgr::QueryAbilityInfosForClone(const Want &want, std::vector &abilityInfo) { ElementName element = want.GetElement(); @@ -2586,7 +2583,6 @@ bool BundleDataMgr::QueryExtensionAbilityInfos(const Want &want, int32_t flags, APP_LOGE("no matching abilityInfo"); return false; } - APP_LOGD("query extensionAbilityInfo successfully"); return true; } @@ -2608,7 +2604,7 @@ bool BundleDataMgr::ExplicitQueryExtensionInfo(const std::string &bundleName, co } auto extension = innerBundleInfo.FindExtensionInfo(bundleName, extensionName); if (!extension) { - APP_LOGE("extensionAbility not found or disabled"); + APP_LOGE("ability not found or disabled"); return false; } if ((static_cast(flags) & GET_ABILITY_INFO_WITH_PERMISSION) != GET_ABILITY_INFO_WITH_PERMISSION) { diff --git a/services/bundlemgr/src/bundle_mgr_host_impl.cpp b/services/bundlemgr/src/bundle_mgr_host_impl.cpp index 6ad8a43862401461be5e9d72036ae332110c232e..0ffb434fd51c0a5c1cfd19db48f6d21f8ea80721 100644 --- a/services/bundlemgr/src/bundle_mgr_host_impl.cpp +++ b/services/bundlemgr/src/bundle_mgr_host_impl.cpp @@ -1040,8 +1040,8 @@ bool BundleMgrHostImpl::QueryExtensionAbilityInfos(const Want &want, const int32 return true; } -bool BundleMgrHostImpl::QueryExtensionAbilityInfos(const Want &want, const ExtensionAbilityType &extensionType, - const int32_t &flag, const int32_t &userId, std::vector &extensionInfos) +bool BundleMgrHostImpl::QueryExtensionAbilityInfos(const Want &want, const int32_t &extensionType, const int32_t &flag, + const int32_t &userId, std::vector &extensionInfos) { APP_LOGI("QueryExtensionAbilityInfos begin"); auto dataMgr = GetDataMgrFromService(); @@ -1056,7 +1056,7 @@ bool BundleMgrHostImpl::QueryExtensionAbilityInfos(const Want &want, const Exten return false; } for_each(infos.begin(), infos.end(), [&extensionType, &extensionInfos](const auto &info)->decltype(auto) { - if (extensionType == info.type) { + if (extensionType == static_cast(info.type)) { extensionInfos.emplace_back(info); } }); diff --git a/services/bundlemgr/test/BUILD.gn b/services/bundlemgr/test/BUILD.gn index e3931128b74c2676efe5a9e86870c723e9b7a9a7..7d4582a6d709251dc2096d416938f4bee22bfa86 100644 --- a/services/bundlemgr/test/BUILD.gn +++ b/services/bundlemgr/test/BUILD.gn @@ -15,8 +15,6 @@ import("//foundation/appexecfwk/standard/appexecfwk.gni") config("bundlemgr_test_config") { include_dirs = [ - "${appexecfwk_path}/interfaces/innerkits/appexecfwk_base/include", - "${appexecfwk_path}/interfaces/innerkits/appexecfwk_core/include/bundlemgr", "//utils/native/base/include", "//utils/system/safwk/native/include", "mock/include", @@ -27,11 +25,10 @@ config("bundlemgr_test_config") { "//foundation/aafwk/standard/services/abilitymgr/include", "//foundation/aafwk/standard/services/common/include", "//base/notification/ces_standard/interfaces/innerkits/native/include", - "//base/security/permission/interfaces/innerkits/permission_standard/permissionsdk/main/cpp/include", - "//base/security/appverify/interfaces/innerkits/appverify/include", ] configs = [ + "${services_path}/bundlemgr:bundlemgr_config", "${services_path}/bundlemgr:bundlemgr_common_config", "${common_path}:appexecfwk_common_config", ] diff --git a/services/bundlemgr/test/mock/include/mock_ability_mgr_host.h b/services/bundlemgr/test/mock/include/mock_ability_mgr_host.h index 55127652ffca59650bc5ac2bfc821fffdb5dffa6..0e625a34116b4fb0c3c54c9c838b2d17c2026695 100644 --- a/services/bundlemgr/test/mock/include/mock_ability_mgr_host.h +++ b/services/bundlemgr/test/mock/include/mock_ability_mgr_host.h @@ -422,15 +422,6 @@ public: { return 0; } - virtual int SetAbilityController(const sptr &abilityController, - bool imAStabilityTest) override - { - return 0; - } - virtual bool IsUserAStabilityTest() override - { - return true; - } }; } // namespace AppExecFwk } // namespace OHOS diff --git a/services/bundlemgr/test/unittest/bms_bundle_clone_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_clone_test/BUILD.gn index 0234fe71ee178d887c54f41eb65069a5e1f41f3e..0df336cd5674abae24d3384ab50a912493644ae7 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_clone_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_clone_test/BUILD.gn @@ -65,7 +65,6 @@ ohos_unittest("BmsBundleCloneTest") { cflags += [ "-DBINDER_IPC_32BIT" ] } deps = [ - "${appexecfwk_path}/interfaces/innerkits/appexecfwk_base:appexecfwk_base", "${appexecfwk_path}/interfaces/innerkits/appexecfwk_core:appexecfwk_core", "${libs_path}/libeventhandler:libeventhandler_target", "//base/security/appverify/interfaces/innerkits/appverify:libhapverify", diff --git a/services/bundlemgr/test/unittest/bms_bundle_data_storage_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_data_storage_test/BUILD.gn index 00a78c47edf59304fa3dc125c2d44b71086ad9f9..0c1082519ade142f5d89d0215468fcbdb55b347a 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_data_storage_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_data_storage_test/BUILD.gn @@ -98,7 +98,6 @@ ohos_unittest("BmsBundleDataStorageDatabaseTest") { ] external_deps = [ - "access_token:libaccesstoken_sdk", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "resmgr_standard:global_resmgr", diff --git a/services/bundlemgr/test/unittest/bms_bundle_installer_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_installer_test/BUILD.gn index 7701cb64f67dba4f09b46e3f1fbf15e7d137b33e..fe76093e9b63313edcad7c67809daebe39da3117 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_installer_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_installer_test/BUILD.gn @@ -63,7 +63,6 @@ ohos_unittest("BmsBundleInstallerTest") { cflags += [ "-DBINDER_IPC_32BIT" ] } deps = [ - "${appexecfwk_path}/interfaces/innerkits/appexecfwk_base:appexecfwk_base", "${appexecfwk_path}/interfaces/innerkits/appexecfwk_core:appexecfwk_core", "${libs_path}/libeventhandler:libeventhandler_target", "//base/security/appverify/interfaces/innerkits/appverify:libhapverify", @@ -81,7 +80,6 @@ ohos_unittest("BmsBundleInstallerTest") { deps += bundle_install_deps external_deps = [ - "access_token:libaccesstoken_sdk", "ces_standard:cesfwk_innerkits", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", @@ -137,7 +135,6 @@ ohos_unittest("BmsMultipleBundleInstallerTest") { cflags += [ "-DBINDER_IPC_32BIT" ] } deps = [ - "${appexecfwk_path}/interfaces/innerkits/appexecfwk_base:appexecfwk_base", "${appexecfwk_path}/interfaces/innerkits/appexecfwk_core:appexecfwk_core", "${libs_path}/libeventhandler:libeventhandler_target", "//base/security/appverify/interfaces/innerkits/appverify:libhapverify", @@ -155,7 +152,6 @@ ohos_unittest("BmsMultipleBundleInstallerTest") { deps += bundle_install_deps external_deps = [ - "access_token:libaccesstoken_sdk", "ces_standard:cesfwk_innerkits", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/BUILD.gn index 1bda1e89449ca47ac1ddfd9e221e5255bf243560..dd1705740ca137c281e1a0c0a39536033a63957e 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/BUILD.gn @@ -71,7 +71,6 @@ ohos_unittest("BmsBundleKitServiceTest") { cflags += [ "-DBINDER_IPC_32BIT" ] } deps = [ - "${appexecfwk_path}/interfaces/innerkits/appexecfwk_base:appexecfwk_base", "${appexecfwk_path}/interfaces/innerkits/appexecfwk_core:appexecfwk_core", "${libs_path}/libeventhandler:libeventhandler_target", "//base/security/appverify/interfaces/innerkits/appverify:libhapverify", @@ -90,7 +89,6 @@ ohos_unittest("BmsBundleKitServiceTest") { deps += bundle_install_deps external_deps = [ - "access_token:libaccesstoken_sdk", "ces_standard:cesfwk_innerkits", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/services/bundlemgr/test/unittest/bms_bundle_parser_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_parser_test/BUILD.gn index 5abcc6bbbd67c56e841f55a092c283aa48c3d00c..f2dfd3804974fe64a5ee5c23debf9c39a1c14189 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_parser_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_parser_test/BUILD.gn @@ -51,7 +51,6 @@ ohos_unittest("BmsBundleParserTest") { external_deps = [ "aafwk_standard:want", - "access_token:libaccesstoken_sdk", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "resmgr_standard:global_resmgr", diff --git a/services/bundlemgr/test/unittest/bms_bundle_permission_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_permission_test/BUILD.gn index d0f71662c2da2dbe69e7993e2bb33cccf21c6e48..2c8254e59f696e1628e1a9437ee886100acabc8e 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_permission_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_permission_test/BUILD.gn @@ -68,7 +68,6 @@ ohos_unittest("BmsBundlePermissionTest") { cflags += [ "-DBINDER_IPC_32BIT" ] } deps = [ - "${appexecfwk_path}/interfaces/innerkits/appexecfwk_base:appexecfwk_base", "${appexecfwk_path}/interfaces/innerkits/appexecfwk_core:appexecfwk_core", "${libs_path}/libeventhandler:libeventhandler_target", "//base/security/appverify/interfaces/innerkits/appverify:libhapverify", @@ -86,7 +85,6 @@ ohos_unittest("BmsBundlePermissionTest") { deps += bundle_install_deps external_deps = [ - "access_token:libaccesstoken_sdk", "ces_standard:cesfwk_innerkits", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/services/bundlemgr/test/unittest/bms_bundle_uninstaller_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_uninstaller_test/BUILD.gn index 96c3823f113538af92b0480035d825944dc780c5..b05a78a3cc3fc72d1fd868439c1051dc052c7e1a 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_uninstaller_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_uninstaller_test/BUILD.gn @@ -68,7 +68,6 @@ ohos_unittest("BmsBundleUninstallerTest") { cflags += [ "-DBINDER_IPC_32BIT" ] } deps = [ - "${appexecfwk_path}/interfaces/innerkits/appexecfwk_base:appexecfwk_base", "${appexecfwk_path}/interfaces/innerkits/appexecfwk_core:appexecfwk_core", "${libs_path}/libeventhandler:libeventhandler_target", "//base/security/appverify/interfaces/innerkits/appverify:libhapverify", @@ -86,7 +85,6 @@ ohos_unittest("BmsBundleUninstallerTest") { deps += bundle_install_deps external_deps = [ - "access_token:libaccesstoken_sdk", "ces_standard:cesfwk_innerkits", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/services/bundlemgr/test/unittest/bms_bundle_updater_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_updater_test/BUILD.gn index f0e1b7a944df9deef51001125d145fd0307e8094..f43c22d3b30039be3dc9d4d7c7c0d2531df1a8bc 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_updater_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_updater_test/BUILD.gn @@ -72,7 +72,6 @@ ohos_unittest("BmsBundleUpdaterTest") { cflags += [ "-DBINDER_IPC_32BIT" ] } deps = [ - "${appexecfwk_path}/interfaces/innerkits/appexecfwk_base:appexecfwk_base", "${appexecfwk_path}/interfaces/innerkits/appexecfwk_core:appexecfwk_core", "${libs_path}/libeventhandler:libeventhandler_target", "//base/security/appverify/interfaces/innerkits/appverify:libhapverify", @@ -90,7 +89,6 @@ ohos_unittest("BmsBundleUpdaterTest") { deps += bundle_install_deps external_deps = [ - "access_token:libaccesstoken_sdk", "ces_standard:cesfwk_innerkits", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/services/bundlemgr/test/unittest/bms_data_mgr_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_data_mgr_test/BUILD.gn index d76f0011cd2be0466991ba34b9a4d2b54b24722b..707f71675fb45ed3cdaa97dbcf7081e750f35803 100644 --- a/services/bundlemgr/test/unittest/bms_data_mgr_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_data_mgr_test/BUILD.gn @@ -86,7 +86,6 @@ ohos_unittest("BmsDataMgrTest") { deps += bundle_install_deps external_deps = [ - "access_token:libaccesstoken_sdk", "ces_standard:cesfwk_innerkits", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/services/bundlemgr/test/unittest/bms_install_daemon_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_install_daemon_test/BUILD.gn index d2851d2bf03abacf94d7496e078339cd523192a0..94e44b812b40b5a67830b37304609294479087bc 100644 --- a/services/bundlemgr/test/unittest/bms_install_daemon_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_install_daemon_test/BUILD.gn @@ -50,7 +50,6 @@ ohos_unittest("BmsInstallDaemonTest") { ] external_deps = [ - "access_token:libaccesstoken_sdk", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "resmgr_standard:global_resmgr", diff --git a/services/bundlemgr/test/unittest/bms_service_bundle_scan_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_service_bundle_scan_test/BUILD.gn index 28febea6f3d965eb456d03f24a8575901c251879..47c2da0bfa05a93680bf30159ade6d4378161832 100644 --- a/services/bundlemgr/test/unittest/bms_service_bundle_scan_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_service_bundle_scan_test/BUILD.gn @@ -55,7 +55,6 @@ ohos_unittest("BmsServiceBundleScanTest") { cflags += [ "-DBINDER_IPC_32BIT" ] } deps = [ - "${appexecfwk_path}/interfaces/innerkits/appexecfwk_base:appexecfwk_base", "${appexecfwk_path}/interfaces/innerkits/appexecfwk_core:appexecfwk_core", "${libs_path}/libeventhandler:libeventhandler_target", "//base/security/appverify/interfaces/innerkits/appverify:libhapverify", @@ -71,7 +70,6 @@ ohos_unittest("BmsServiceBundleScanTest") { deps += bundle_install_deps external_deps = [ - "access_token:libaccesstoken_sdk", "ces_standard:cesfwk_innerkits", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/services/bundlemgr/test/unittest/bms_service_startup_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_service_startup_test/BUILD.gn index 50adda50ef375032e9baac542f75a4ef9e2c4663..cdb6b00aab34a264654152326a4774289a3d1ba9 100644 --- a/services/bundlemgr/test/unittest/bms_service_startup_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_service_startup_test/BUILD.gn @@ -55,7 +55,6 @@ ohos_unittest("BmsServiceStartupTest") { cflags += [ "-DBINDER_IPC_32BIT" ] } deps = [ - "${appexecfwk_path}/interfaces/innerkits/appexecfwk_base:appexecfwk_base", "${appexecfwk_path}/interfaces/innerkits/appexecfwk_core:appexecfwk_core", "${libs_path}/libeventhandler:libeventhandler_target", "//base/security/appverify/interfaces/innerkits/appverify:libhapverify", @@ -72,7 +71,6 @@ ohos_unittest("BmsServiceStartupTest") { deps += bundle_install_deps external_deps = [ - "access_token:libaccesstoken_sdk", "ces_standard:cesfwk_innerkits", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/services/formmgr/test/mock/include/mock_ability_manager.h b/services/formmgr/test/mock/include/mock_ability_manager.h index 180151f4d8eba6475d44c6503d97bf28a634058d..ac4aef568f9e8ea08ac1e3a2abffdfa6553c2fb4 100644 --- a/services/formmgr/test/mock/include/mock_ability_manager.h +++ b/services/formmgr/test/mock/include/mock_ability_manager.h @@ -719,15 +719,6 @@ public: { return 0; } - virtual int SetAbilityController(const sptr &abilityController, - bool imAStabilityTest) override - { - return 0; - } - virtual bool IsUserAStabilityTest() override - { - return true; - } private: Semaphore sem_; }; diff --git a/services/test/mock/include/mock_ability_mgr_host.h b/services/test/mock/include/mock_ability_mgr_host.h index 59659c7a4500f2e89d7681bdcf0acf58ace8603a..208285131c4c1cc5a76e9b679b597521b4fd6e92 100644 --- a/services/test/mock/include/mock_ability_mgr_host.h +++ b/services/test/mock/include/mock_ability_mgr_host.h @@ -393,15 +393,6 @@ public: { return 0; } - virtual int SetAbilityController(const sptr &abilityController, - bool imAStabilityTest) override - { - return 0; - } - virtual bool IsUserAStabilityTest() override - { - return true; - } }; } // namespace AppExecFwk } // namespace OHOS diff --git a/services/test/moduletest/common/bms/BUILD.gn b/services/test/moduletest/common/bms/BUILD.gn old mode 100644 new mode 100755 index cba0d0811161170cc9edd9e1f19908a4f8cd8089..3e208675a7076242868ad60d2e12011577ce6c10 --- a/services/test/moduletest/common/bms/BUILD.gn +++ b/services/test/moduletest/common/bms/BUILD.gn @@ -26,7 +26,7 @@ config("bms_module_test_config") { configs = [ "${services_path}/test:services_module_test_config", - "${services_path}/bundlemgr:bundlemgr_common_config", + "${services_path}/bundlemgr:bundlemgr_config", ] } diff --git a/services/test/moduletest/common/bms/bundle_installer_test/BUILD.gn b/services/test/moduletest/common/bms/bundle_installer_test/BUILD.gn index 68522a7415dd570f84ceeb2bc62849ed44e72361..406b4280e640dbc944fbc48a87227d3bf93e7ff7 100644 --- a/services/test/moduletest/common/bms/bundle_installer_test/BUILD.gn +++ b/services/test/moduletest/common/bms/bundle_installer_test/BUILD.gn @@ -90,7 +90,6 @@ ohos_moduletest("BmsBundleInstallerModuleTest") { deps += bundle_install_deps external_deps = [ - "access_token:libaccesstoken_sdk", "ces_standard:cesfwk_innerkits", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/services/test/moduletest/common/bms/bundle_uninstall_test/BUILD.gn b/services/test/moduletest/common/bms/bundle_uninstall_test/BUILD.gn index 7daaa512369d7f22df3729d948ce14ce3eeaa623..427a94973628cb78af684359f814f03d3841e2cc 100644 --- a/services/test/moduletest/common/bms/bundle_uninstall_test/BUILD.gn +++ b/services/test/moduletest/common/bms/bundle_uninstall_test/BUILD.gn @@ -85,7 +85,6 @@ ohos_moduletest("BmsBundleUninstallerModuleTest") { ] external_deps = [ - "access_token:libaccesstoken_sdk", "ces_standard:cesfwk_innerkits", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/services/test/moduletest/common/bms/service_start_process_test/BUILD.gn b/services/test/moduletest/common/bms/service_start_process_test/BUILD.gn index ced913cdb60d3aaf08cf24139bf4bfae2a99567e..704408ed724dc2ff0dc0d58dd4a4f515795fbbce 100644 --- a/services/test/moduletest/common/bms/service_start_process_test/BUILD.gn +++ b/services/test/moduletest/common/bms/service_start_process_test/BUILD.gn @@ -76,7 +76,6 @@ ohos_moduletest("BmsServiceStartModuleTest") { deps += bundle_install_deps external_deps = [ - "access_token:libaccesstoken_sdk", "ces_standard:cesfwk_innerkits", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/tools/bm/BUILD.gn b/tools/bm/BUILD.gn index 0192ba0acb08966bab310a346a9f6e61dbffa479..1bae2253cbb3ea58aaba22e1b9cabc056edb0c21 100644 --- a/tools/bm/BUILD.gn +++ b/tools/bm/BUILD.gn @@ -16,13 +16,15 @@ import("//foundation/appexecfwk/standard/appexecfwk.gni") config("tools_bm_config") { include_dirs = [ - "include", "${aafwk_path}/services/common/include", "${aafwk_path}/tools/aa/include", "${common_path}/log/include", "${kits_path}/appkit/napi/bundlemgr", "//utils/system/safwk/native/include", + "include", ] + + configs = [ "${services_path}/bundlemgr:bundlemgr_common_config" ] } ohos_source_set("tools_bm_source_set") { @@ -35,7 +37,10 @@ ohos_source_set("tools_bm_source_set") { "src/status_receiver_impl.cpp", ] - public_configs = [ ":tools_bm_config" ] + public_configs = [ + "${aafwk_path}/tools/aa:ability_command_config", + ":tools_bm_config", + ] cflags = [] if (target_cpu == "arm") { @@ -44,8 +49,8 @@ ohos_source_set("tools_bm_source_set") { external_deps = [ "aafwk_standard:want", - "bundle_framework:appexecfwk_base", - "bundle_framework:appexecfwk_core", + "appexecfwk_standard:appexecfwk_base", + "appexecfwk_standard:appexecfwk_core", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "samgr_standard:samgr_proxy", diff --git a/tools/bm/bundle.json b/tools/bm/bundle.json index 07714e1808de7eb7c74ad21de2bbc7a1f1f7333e..b329b0b35de3f7afefcb48a9088c8537719a0a82 100644 --- a/tools/bm/bundle.json +++ b/tools/bm/bundle.json @@ -3,9 +3,6 @@ "description": "包管理命令行工具:提供命令行中执行hap包的安装、更新、卸载及信息查询的能力", "version": "3.1", "license": "Apache 2.0", - "segment": { - "destPath": "foundation/appexecfwk/standard/tools/bm" - }, "component": { "name": "bundle_tool", "subsystem": "appexecfwk", @@ -19,7 +16,7 @@ "deps": { "components": [ "aafwk_standard", - "bundle_framework", + "appexecfwk_standard", "hiviewdfx_hilog_native", "ipc", "samgr_standard", diff --git a/tools/bm/include/bundle_command.h b/tools/bm/include/bundle_command.h index ce96fda72f12562928c821d8be33346dc03746cd..89be0ac8a88c791bbb291be962dc595c035f4697 100644 --- a/tools/bm/include/bundle_command.h +++ b/tools/bm/include/bundle_command.h @@ -98,8 +98,7 @@ const std::string HELP_MSG_QUERY = " -h, --help list available commands\n" " -n, --bundle-name query bundle by bundle name\n" " -e, --element-name query info by element name\n" - " -m, --metadata-name query metadata by metadata name\n" - " -u, --user-id designate an user id\n"; + " -m, --metadata-name query metadata by metadata name\n"; const std::string HELP_MSG_NO_BUNDLE_PATH_OPTION = "error: you must specify a bundle path with '-p' or '--bundle-path'."; diff --git a/tools/test/unittest/bm/BUILD.gn b/tools/test/unittest/bm/BUILD.gn index b943a03443f781a981a2f33eb7ca0d205e643d68..5f300c07aa2e0709f4719d9d2838e2cb1f76909a 100644 --- a/tools/test/unittest/bm/BUILD.gn +++ b/tools/test/unittest/bm/BUILD.gn @@ -18,15 +18,11 @@ module_output_path = "appexecfwk_standard/tools" config("tools_bm_config_mock") { include_dirs = [ - "${appexecfwk_path}/interfaces/innerkits/appexecfwk_base/include", - "${appexecfwk_path}/interfaces/innerkits/appexecfwk_core/include/bundlemgr", "${aafwk_path}/interfaces/innerkits/want/include", "${aafwk_path}/interfaces/innerkits/want/include/ohos/aafwk/content", "${appexecfwk_path}/interfaces/innerkits/libeventhandler/include", "${appexecfwk_path}/services/bundlemgr/include", "${appexecfwk_path}/tools/test/mock", - "//base/security/permission/interfaces/innerkits/permission_standard/permissionsdk/main/cpp/include", - "//base/security/appverify/interfaces/innerkits/appverify/include", "//foundation/distributedschedule/dmsfwk/services/dtbschedmgr/include", "//third_party/googletest/googlemock/include", "//third_party/json/single_include",