diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000000000000000000000000000000000000..bbf6eb595e789eebd94d5ddc3b5ad4f9b36a3757 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1,15 @@ +# Copyright (c) 2023 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. + +# any change to xxx_ipc_interface_code.h needs to be reviewed by @leochan5 +interfaces/inner_api/include/distributed_bundle_ipc_interface_code.h @leonchan5 \ No newline at end of file diff --git a/interfaces/inner_api/include/distributed_bms_interface.h b/interfaces/inner_api/include/distributed_bms_interface.h index b93397fc9e6985ebd1f4e15116c571b470ece28d..d51a1fba0e45c6910578efbb1f548f08b502f3bf 100644 --- a/interfaces/inner_api/include/distributed_bms_interface.h +++ b/interfaces/inner_api/include/distributed_bms_interface.h @@ -149,19 +149,6 @@ public: { return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; } - - enum class Message { - GET_REMOTE_ABILITY_INFO = 0, - GET_REMOTE_ABILITY_INFOS, - GET_ABILITY_INFO, - GET_ABILITY_INFOS, - GET_REMOTE_ABILITY_INFO_WITH_LOCALE, - GET_REMOTE_ABILITY_INFOS_WITH_LOCALE, - GET_ABILITY_INFO_WITH_LOCALE, - GET_ABILITY_INFOS_WITH_LOCALE, - GET_DISTRIBUTED_BUNDLE_INFO, - GET_DISTRIBUTED_BUNDLE_NAME, - }; }; } // namespace AppExecFwk } // namespace OHOS diff --git a/interfaces/inner_api/include/distributed_bms_proxy.h b/interfaces/inner_api/include/distributed_bms_proxy.h index ee43ec03a4f59c684dd0e95925063720e5651376..edf8882b3dba04960f751e35dfba5a4f248dace1 100644 --- a/interfaces/inner_api/include/distributed_bms_proxy.h +++ b/interfaces/inner_api/include/distributed_bms_proxy.h @@ -19,6 +19,7 @@ #include #include "distributed_bms_interface.h" +#include "distributed_bundle_ipc_interface_code.h" #include "iremote_proxy.h" namespace OHOS { @@ -117,13 +118,13 @@ public: int32_t GetDistributedBundleName(const std::string &networkId, uint32_t accessTokenId, std::string &bundleName) override; private: - int32_t SendRequest(IDistributedBms::Message code, MessageParcel &data, MessageParcel &reply); + int32_t SendRequest(DistributedInterfaceCode code, MessageParcel &data, MessageParcel &reply); template bool WriteParcelableVector(const std::vector &parcelableVector, Parcel &data); template - int32_t GetParcelableInfo(IDistributedBms::Message code, MessageParcel &data, T &parcelableInfo); + int32_t GetParcelableInfo(DistributedInterfaceCode code, MessageParcel &data, T &parcelableInfo); template - int32_t GetParcelableInfos(IDistributedBms::Message code, MessageParcel &data, std::vector &parcelableInfos); + int32_t GetParcelableInfos(DistributedInterfaceCode code, MessageParcel &data, std::vector &parcelableInfos); int32_t CheckElementName(const ElementName &elementName); static inline BrokerDelegator delegator_; }; diff --git a/interfaces/inner_api/include/distributed_bundle_ipc_interface_code.h b/interfaces/inner_api/include/distributed_bundle_ipc_interface_code.h new file mode 100644 index 0000000000000000000000000000000000000000..0f430a01ec6bd3ef5da76d619a503eb3ea7a0628 --- /dev/null +++ b/interfaces/inner_api/include/distributed_bundle_ipc_interface_code.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_DISTRIBUTED_BUNDLE_IPC_INTERFACE_CODE_H +#define OHOS_DISTRIBUTED_BUNDLE_IPC_INTERFACE_CODE_H + +/* SAID: 402 */ +namespace OHOS { +namespace AppExecFwk { +enum class DistributedInterfaceCode : uint32_t { + GET_REMOTE_ABILITY_INFO = 0, + GET_REMOTE_ABILITY_INFOS, + GET_ABILITY_INFO, + GET_ABILITY_INFOS, + GET_REMOTE_ABILITY_INFO_WITH_LOCALE, + GET_REMOTE_ABILITY_INFOS_WITH_LOCALE, + GET_ABILITY_INFO_WITH_LOCALE, + GET_ABILITY_INFOS_WITH_LOCALE, + GET_DISTRIBUTED_BUNDLE_INFO, + GET_DISTRIBUTED_BUNDLE_NAME, +}; +} // namespace AppExecFwk +} // namespace OHOS +#endif // OHOS_DISTRIBUTED_BUNDLE_IPC_INTERFACE_CODE_H \ No newline at end of file diff --git a/interfaces/inner_api/src/distributed_bms_proxy.cpp b/interfaces/inner_api/src/distributed_bms_proxy.cpp index f9dc61b42764dc250f30d6ead494dc1b56ecafac..132e585d3d54cf8f6d894ef12be9b1bbccac5625 100644 --- a/interfaces/inner_api/src/distributed_bms_proxy.cpp +++ b/interfaces/inner_api/src/distributed_bms_proxy.cpp @@ -64,7 +64,7 @@ int32_t DistributedBmsProxy::GetRemoteAbilityInfo(const OHOS::AppExecFwk::Elemen } int32_t result = GetParcelableInfo( - IDistributedBms::Message::GET_REMOTE_ABILITY_INFO_WITH_LOCALE, data, remoteAbilityInfo); + DistributedInterfaceCode::GET_REMOTE_ABILITY_INFO_WITH_LOCALE, data, remoteAbilityInfo); if (result != OHOS::NO_ERROR) { APP_LOGE("fail to query ability info mutiparam from server, result:%{public}d", result); } @@ -106,7 +106,7 @@ int32_t DistributedBmsProxy::GetRemoteAbilityInfos(const std::vector( - IDistributedBms::Message::GET_REMOTE_ABILITY_INFOS_WITH_LOCALE, data, remoteAbilityInfos); + DistributedInterfaceCode::GET_REMOTE_ABILITY_INFOS_WITH_LOCALE, data, remoteAbilityInfos); if (result != OHOS::NO_ERROR) { APP_LOGE("fail to query remote ability infos mutiparam from server"); } @@ -140,10 +140,10 @@ int32_t DistributedBmsProxy::GetAbilityInfo(const OHOS::AppExecFwk::ElementName return ERR_APPEXECFWK_PARCEL_ERROR; } int32_t result = GetParcelableInfo( - IDistributedBms::Message::GET_ABILITY_INFO_WITH_LOCALE, data, remoteAbilityInfo); + DistributedInterfaceCode::GET_ABILITY_INFO_WITH_LOCALE, data, remoteAbilityInfo); if (result == OHOS::IPC_STUB_UNKNOW_TRANS_ERR) { return GetParcelableInfo( - IDistributedBms::Message::GET_ABILITY_INFO, data, remoteAbilityInfo); + DistributedInterfaceCode::GET_ABILITY_INFO, data, remoteAbilityInfo); } return result; } @@ -175,10 +175,10 @@ int32_t DistributedBmsProxy::GetAbilityInfos(const std::vector &ele return ERR_APPEXECFWK_PARCEL_ERROR; } int32_t result = GetParcelableInfos( - IDistributedBms::Message::GET_ABILITY_INFOS_WITH_LOCALE, data, remoteAbilityInfos); + DistributedInterfaceCode::GET_ABILITY_INFOS_WITH_LOCALE, data, remoteAbilityInfos); if (result == OHOS::IPC_STUB_UNKNOW_TRANS_ERR) { return GetParcelableInfos( - IDistributedBms::Message::GET_ABILITY_INFOS, data, remoteAbilityInfos); + DistributedInterfaceCode::GET_ABILITY_INFOS, data, remoteAbilityInfos); } return result; } @@ -201,7 +201,7 @@ bool DistributedBmsProxy::GetDistributedBundleInfo(const std::string &networkId, return false; } int32_t result = GetParcelableInfo( - IDistributedBms::Message::GET_DISTRIBUTED_BUNDLE_INFO, data, distributedBundleInfo); + DistributedInterfaceCode::GET_DISTRIBUTED_BUNDLE_INFO, data, distributedBundleInfo); if (result == OHOS::NO_ERROR) { return true; } @@ -225,7 +225,7 @@ int32_t DistributedBmsProxy::GetDistributedBundleName(const std::string &network return ERR_APPEXECFWK_PARCEL_ERROR; } MessageParcel reply; - int32_t result = SendRequest(IDistributedBms::Message::GET_DISTRIBUTED_BUNDLE_NAME, data, reply); + int32_t result = SendRequest(DistributedInterfaceCode::GET_DISTRIBUTED_BUNDLE_NAME, data, reply); if (result == OHOS::NO_ERROR) { bundleName = reply.ReadString(); } @@ -250,7 +250,7 @@ bool DistributedBmsProxy::WriteParcelableVector(const std::vector &parcelable } template -int32_t DistributedBmsProxy::GetParcelableInfo(IDistributedBms::Message code, MessageParcel &data, T &parcelableInfo) +int32_t DistributedBmsProxy::GetParcelableInfo(DistributedInterfaceCode code, MessageParcel &data, T &parcelableInfo) { MessageParcel reply; int32_t result = SendRequest(code, data, reply); @@ -276,7 +276,7 @@ int32_t DistributedBmsProxy::GetParcelableInfo(IDistributedBms::Message code, Me template int32_t DistributedBmsProxy::GetParcelableInfos( - IDistributedBms::Message code, MessageParcel &data, std::vector &parcelableInfos) + DistributedInterfaceCode code, MessageParcel &data, std::vector &parcelableInfos) { MessageParcel reply; int32_t result = SendRequest(code, data, reply); @@ -304,7 +304,7 @@ int32_t DistributedBmsProxy::GetParcelableInfos( return OHOS::NO_ERROR; } -int32_t DistributedBmsProxy::SendRequest(IDistributedBms::Message code, MessageParcel &data, MessageParcel &reply) +int32_t DistributedBmsProxy::SendRequest(DistributedInterfaceCode code, MessageParcel &data, MessageParcel &reply) { APP_LOGD("DistributedBmsProxy SendRequest"); sptr remote = Remote(); diff --git a/services/dbms/src/distributed_bms_host.cpp b/services/dbms/src/distributed_bms_host.cpp index 3349c030f709bbb90dd66c48c26de97919eb4ca6..fd0a28a4faae09560f64677741b06796a50b51e2 100644 --- a/services/dbms/src/distributed_bms_host.cpp +++ b/services/dbms/src/distributed_bms_host.cpp @@ -19,6 +19,7 @@ #include "appexecfwk_errors.h" #include "bundle_constants.h" #include "bundle_memory_guard.h" +#include "distributed_bundle_ipc_interface_code.h" #include "remote_ability_info.h" namespace OHOS { @@ -49,21 +50,21 @@ int DistributedBmsHost::OnRemoteRequest(uint32_t code, MessageParcel &data, Mess return ERR_INVALID_STATE; } switch (code) { - case static_cast(IDistributedBms::Message::GET_REMOTE_ABILITY_INFO): - case static_cast(IDistributedBms::Message::GET_REMOTE_ABILITY_INFO_WITH_LOCALE): + case static_cast(DistributedInterfaceCode::GET_REMOTE_ABILITY_INFO): + case static_cast(DistributedInterfaceCode::GET_REMOTE_ABILITY_INFO_WITH_LOCALE): return HandleGetRemoteAbilityInfo(data, reply); - case static_cast(IDistributedBms::Message::GET_REMOTE_ABILITY_INFOS): - case static_cast(IDistributedBms::Message::GET_REMOTE_ABILITY_INFOS_WITH_LOCALE): + case static_cast(DistributedInterfaceCode::GET_REMOTE_ABILITY_INFOS): + case static_cast(DistributedInterfaceCode::GET_REMOTE_ABILITY_INFOS_WITH_LOCALE): return HandleGetRemoteAbilityInfos(data, reply); - case static_cast(IDistributedBms::Message::GET_ABILITY_INFO): - case static_cast(IDistributedBms::Message::GET_ABILITY_INFO_WITH_LOCALE): + case static_cast(DistributedInterfaceCode::GET_ABILITY_INFO): + case static_cast(DistributedInterfaceCode::GET_ABILITY_INFO_WITH_LOCALE): return HandleGetAbilityInfo(data, reply); - case static_cast(IDistributedBms::Message::GET_ABILITY_INFOS): - case static_cast(IDistributedBms::Message::GET_ABILITY_INFOS_WITH_LOCALE): + case static_cast(DistributedInterfaceCode::GET_ABILITY_INFOS): + case static_cast(DistributedInterfaceCode::GET_ABILITY_INFOS_WITH_LOCALE): return HandleGetAbilityInfos(data, reply); - case static_cast(IDistributedBms::Message::GET_DISTRIBUTED_BUNDLE_INFO): + case static_cast(DistributedInterfaceCode::GET_DISTRIBUTED_BUNDLE_INFO): return HandleGetDistributedBundleInfo(data, reply); - case static_cast(IDistributedBms::Message::GET_DISTRIBUTED_BUNDLE_NAME): + case static_cast(DistributedInterfaceCode::GET_DISTRIBUTED_BUNDLE_NAME): return HandleGetDistributedBundleName(data, reply); default: APP_LOGW("DistributedBmsHost receives unknown code, code = %{public}d", code); diff --git a/services/dbms/test/unittest/distributed_bms_host_test/distributed_bms_host_test.cpp b/services/dbms/test/unittest/distributed_bms_host_test/distributed_bms_host_test.cpp index 301a7b2fdc1539902c6fd839565ad764e8efa6c7..07a97070a8851750961a981b2e95cc1740b41694 100644 --- a/services/dbms/test/unittest/distributed_bms_host_test/distributed_bms_host_test.cpp +++ b/services/dbms/test/unittest/distributed_bms_host_test/distributed_bms_host_test.cpp @@ -19,6 +19,7 @@ #include "appexecfwk_errors.h" #include "distributed_bms_proxy.h" +#include "distributed_bundle_ipc_interface_code.h" #undef private #include "mock_distributed_bms_interface.h" @@ -59,7 +60,7 @@ HWTEST_F(DistributedBmsHostTest, OnRemoteRequest_0100, Function | MediumTest | L MockDistributedBmsHost host; int res = host.OnRemoteRequest(static_cast - (IDistributedBms::Message::GET_REMOTE_ABILITY_INFO), data, reply, option); + (DistributedInterfaceCode::GET_REMOTE_ABILITY_INFO), data, reply, option); EXPECT_EQ(res, ERR_INVALID_STATE); } @@ -78,7 +79,7 @@ HWTEST_F(DistributedBmsHostTest, OnRemoteRequest_0200, Function | MediumTest | L AppExecFwk::ElementName elementName; data.WriteParcelable(&elementName); MockDistributedBmsHost host; - int res = host.OnRemoteRequest(static_cast(IDistributedBms::Message::GET_REMOTE_ABILITY_INFO), + int res = host.OnRemoteRequest(static_cast(DistributedInterfaceCode::GET_REMOTE_ABILITY_INFO), data, reply, option); EXPECT_EQ(res, NO_ERROR); } @@ -98,7 +99,7 @@ HWTEST_F(DistributedBmsHostTest, OnRemoteRequest_0300, Function | MediumTest | L AppExecFwk::ElementName elementName; data.WriteParcelable(&elementName); MockDistributedBmsHost host; - int res = host.OnRemoteRequest(static_cast(IDistributedBms::Message::GET_REMOTE_ABILITY_INFO_WITH_LOCALE), + int res = host.OnRemoteRequest(static_cast(DistributedInterfaceCode::GET_REMOTE_ABILITY_INFO_WITH_LOCALE), data, reply, option); EXPECT_EQ(res, NO_ERROR); } @@ -122,7 +123,7 @@ HWTEST_F(DistributedBmsHostTest, OnRemoteRequest_0400, Function | MediumTest | L data.WriteString(localeInfo); MockDistributedBmsHost host; int res = host.OnRemoteRequest(static_cast - (IDistributedBms::Message::GET_REMOTE_ABILITY_INFOS), data, reply, option); + (DistributedInterfaceCode::GET_REMOTE_ABILITY_INFOS), data, reply, option); EXPECT_EQ(res, NO_ERROR); } @@ -145,7 +146,7 @@ HWTEST_F(DistributedBmsHostTest, OnRemoteRequest_0500, Function | MediumTest | L data.WriteString(localeInfo); MockDistributedBmsHost host; int res = host.OnRemoteRequest(static_cast - (IDistributedBms::Message::GET_REMOTE_ABILITY_INFOS_WITH_LOCALE), data, reply, option); + (DistributedInterfaceCode::GET_REMOTE_ABILITY_INFOS_WITH_LOCALE), data, reply, option); EXPECT_EQ(res, NO_ERROR); } @@ -168,7 +169,7 @@ HWTEST_F(DistributedBmsHostTest, OnRemoteRequest_0600, Function | MediumTest | L data.WriteString(localeInfo); MockDistributedBmsHost host; int res = host.OnRemoteRequest(static_cast - (IDistributedBms::Message::GET_REMOTE_ABILITY_INFOS_WITH_LOCALE), data, reply, option); + (DistributedInterfaceCode::GET_REMOTE_ABILITY_INFOS_WITH_LOCALE), data, reply, option); EXPECT_EQ(res, NO_ERROR); } @@ -190,7 +191,7 @@ HWTEST_F(DistributedBmsHostTest, OnRemoteRequest_0700, Function | MediumTest | L data.WriteString(localeInfo); MockDistributedBmsHost host; int res = host.OnRemoteRequest(static_cast - (IDistributedBms::Message::GET_ABILITY_INFO), data, reply, option); + (DistributedInterfaceCode::GET_ABILITY_INFO), data, reply, option); EXPECT_EQ(res, NO_ERROR); } @@ -213,7 +214,7 @@ HWTEST_F(DistributedBmsHostTest, OnRemoteRequest_0800, Function | MediumTest | L MockDistributedBmsHost host; int res = host.OnRemoteRequest(static_cast - (IDistributedBms::Message::GET_ABILITY_INFO_WITH_LOCALE), data, reply, option); + (DistributedInterfaceCode::GET_ABILITY_INFO_WITH_LOCALE), data, reply, option); EXPECT_EQ(res, NO_ERROR); } @@ -237,7 +238,7 @@ HWTEST_F(DistributedBmsHostTest, OnRemoteRequest_0900, Function | MediumTest | L MockDistributedBmsHost host; int res = host.OnRemoteRequest(static_cast - (IDistributedBms::Message::GET_ABILITY_INFOS), data, reply, option); + (DistributedInterfaceCode::GET_ABILITY_INFOS), data, reply, option); EXPECT_EQ(res, NO_ERROR); } @@ -261,7 +262,7 @@ HWTEST_F(DistributedBmsHostTest, OnRemoteRequest_1000, Function | MediumTest | L MockDistributedBmsHost host; int res = host.OnRemoteRequest(static_cast - (IDistributedBms::Message::GET_ABILITY_INFOS_WITH_LOCALE), data, reply, option); + (DistributedInterfaceCode::GET_ABILITY_INFOS_WITH_LOCALE), data, reply, option); EXPECT_EQ(res, NO_ERROR); } @@ -285,7 +286,7 @@ HWTEST_F(DistributedBmsHostTest, OnRemoteRequest_1100, Function | MediumTest | L MockDistributedBmsHost host; int res = host.OnRemoteRequest(static_cast - (IDistributedBms::Message::GET_DISTRIBUTED_BUNDLE_INFO), data, reply, option); + (DistributedInterfaceCode::GET_DISTRIBUTED_BUNDLE_INFO), data, reply, option); EXPECT_EQ(res, NO_ERROR); }