From fb97e0bb358a852217c10eefb88da1336dd0ec41 Mon Sep 17 00:00:00 2001 From: litao Date: Wed, 26 Mar 2025 15:29:15 +0800 Subject: [PATCH] Revert "add GetLocalAbilityManagerProxy" This reverts commit 862246aada3dbc28aafb22a3828bb5a13f8487ac. Signed-off-by: litao --- .../source/system_ability_manager_proxy.cpp | 31 +----------- .../include/if_local_ability_manager.h | 2 - .../include/local_ability_manager_proxy.h | 1 - .../include/safwk_ipc_interface_code.h | 3 +- .../include/samgr_ipc_interface_code.h | 1 - .../src/local_ability_manager_proxy.cpp | 42 ----------------- .../native/include/system_ability_manager.h | 7 +-- .../include/system_ability_manager_stub.h | 6 --- .../source/system_ability_manager_stub.cpp | 33 +------------ .../src/local_ability_manager_proxy_test.cpp | 38 --------------- .../src/system_ability_mgr_proxy_test.cpp | 36 -------------- .../src/system_ability_mgr_stub_test.cpp | 47 ------------------- .../unittest/src/system_ability_mgr_test.cpp | 43 ----------------- 13 files changed, 4 insertions(+), 286 deletions(-) diff --git a/frameworks/native/source/system_ability_manager_proxy.cpp b/frameworks/native/source/system_ability_manager_proxy.cpp index 62269167..3a7186e5 100644 --- a/frameworks/native/source/system_ability_manager_proxy.cpp +++ b/frameworks/native/source/system_ability_manager_proxy.cpp @@ -1565,35 +1565,6 @@ int32_t SystemAbilityManagerProxy::GetCommonEventExtraDataIdlist(int32_t saId, s sptr SystemAbilityManagerProxy::GetLocalAbilityManagerProxy(int32_t systemAbilityId) { - if (!CheckInputSysAbilityId(systemAbilityId)) { - HILOGW("GetLocalAbilityManagerProxy SA invalid:%{public}d!", systemAbilityId); - return nullptr; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(SAMANAGER_INTERFACE_TOKEN)) { - HILOGE("GetLocalAbilityManagerProxy write token failed!"); - return nullptr; - } - if (!data.WriteInt32(systemAbilityId)) { - HILOGE("GetLocalAbilityManagerProxy write said failed!"); - return nullptr; - } - - auto remote = Remote(); - if (remote == nullptr) { - HILOGI("GetLocalAbilityManagerProxy remote is nullptr"); - return nullptr; - } - - MessageParcel reply; - MessageOption option; - int32_t err = remote->SendRequest( - static_cast(SamgrInterfaceCode::GET_LOCAL_ABILITY_MANAGER_PROXY_TRANSCATION), data, reply, option); - if (err != ERR_NONE) { - HILOGE("GetLocalAbilityManagerProxy SendRequest error: %{public}d!", err); - return nullptr; - } - return reply.ReadRemoteObject(); + return nullptr; } } // namespace OHOS diff --git a/interfaces/innerkits/samgr_proxy/include/if_local_ability_manager.h b/interfaces/innerkits/samgr_proxy/include/if_local_ability_manager.h index bfd0749b..1a4f5332 100755 --- a/interfaces/innerkits/samgr_proxy/include/if_local_ability_manager.h +++ b/interfaces/innerkits/samgr_proxy/include/if_local_ability_manager.h @@ -77,8 +77,6 @@ public: virtual bool FfrtDumperProc(std::string& result) = 0; virtual int32_t SystemAbilityExtProc(const std::string& extension, int32_t said, SystemAbilityExtensionPara* callback, bool isAsync = false) = 0; - virtual int32_t ServiceControlCmd(int32_t fd, int32_t systemAbilityId, - const std::vector& args) = 0; DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.ILocalAbilityManager"); protected: static inline const std::u16string LOCAL_ABILITY_MANAGER_INTERFACE_TOKEN = u"ohos.localabilitymanager.accessToken"; diff --git a/interfaces/innerkits/samgr_proxy/include/local_ability_manager_proxy.h b/interfaces/innerkits/samgr_proxy/include/local_ability_manager_proxy.h index 127a50bb..f4f9d6b9 100755 --- a/interfaces/innerkits/samgr_proxy/include/local_ability_manager_proxy.h +++ b/interfaces/innerkits/samgr_proxy/include/local_ability_manager_proxy.h @@ -42,7 +42,6 @@ public: bool FfrtDumperProc(std::string& ffrtDumperInfo); int32_t SystemAbilityExtProc(const std::string& extension, int32_t said, SystemAbilityExtensionPara* callback, bool isAsync = false); - int32_t ServiceControlCmd(int32_t fd, int32_t systemAbilityId, const std::vector& args); private: static inline BrokerDelegator delegator_; bool PrepareData(MessageParcel& data, int32_t said, const std::string& extension); diff --git a/interfaces/innerkits/samgr_proxy/include/safwk_ipc_interface_code.h b/interfaces/innerkits/samgr_proxy/include/safwk_ipc_interface_code.h index db0bbe25..8d3dff42 100755 --- a/interfaces/innerkits/samgr_proxy/include/safwk_ipc_interface_code.h +++ b/interfaces/innerkits/samgr_proxy/include/safwk_ipc_interface_code.h @@ -27,8 +27,7 @@ enum SafwkInterfaceCode : uint32_t { IPC_STAT_CMD_TRANSACTION = 6, FFRT_DUMPER_TRANSACTION = 7, SYSTEM_ABILITY_EXT_TRANSACTION = 8, - SERVICE_CONTROL_CMD_TRANSACTION = 9, - FFRT_STAT_CMD_TRANSACTION = 10, + FFRT_STAT_CMD_TRANSACTION = 9, }; } #endif // !defined(SAFWK_IPC_INTERFACE_CODE_H) \ No newline at end of file diff --git a/interfaces/innerkits/samgr_proxy/include/samgr_ipc_interface_code.h b/interfaces/innerkits/samgr_proxy/include/samgr_ipc_interface_code.h index a37feca4..5ca883b6 100644 --- a/interfaces/innerkits/samgr_proxy/include/samgr_ipc_interface_code.h +++ b/interfaces/innerkits/samgr_proxy/include/samgr_ipc_interface_code.h @@ -50,7 +50,6 @@ enum class SamgrInterfaceCode : uint32_t { GET_EXTERNSION_SA_LIST_TRANSCATION = 34, GET_SA_EXTENSION_INFO_TRANSCATION = 35, GET_COMMON_EVENT_EXTRA_ID_LIST_TRANSCATION = 36, - GET_LOCAL_ABILITY_MANAGER_PROXY_TRANSCATION = 37, }; } // namespace OHOS #endif // !defined(INTERFACES_INNERKITS_SAMGR_INCLUDE_SAMGR_INTERFACE_CODE_H) \ No newline at end of file diff --git a/services/lsamgr/src/local_ability_manager_proxy.cpp b/services/lsamgr/src/local_ability_manager_proxy.cpp index 3d15d71e..efc62102 100644 --- a/services/lsamgr/src/local_ability_manager_proxy.cpp +++ b/services/lsamgr/src/local_ability_manager_proxy.cpp @@ -443,46 +443,4 @@ bool LocalAbilityManagerProxy::PrepareData(MessageParcel& data, int32_t said, co } return true; } - -int32_t LocalAbilityManagerProxy::ServiceControlCmd(int32_t fd, int32_t systemAbilityId, - const std::vector& args) -{ - if (systemAbilityId <= 0) { - HILOG_WARN(LOG_CORE, "ServiceControlCmd systemAbilityId invalid."); - return INVALID_DATA; - } - - sptr iro = Remote(); - if (iro == nullptr) { - HILOG_ERROR(LOG_CORE, "ServiceControlCmd remote return null"); - return OBJECT_NULL; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(LOCAL_ABILITY_MANAGER_INTERFACE_TOKEN)) { - HILOG_WARN(LOG_CORE, "ServiceControlCmd interface token check failed"); - return INVALID_DATA; - } - if (!data.WriteInt32(systemAbilityId)) { - HILOG_WARN(LOG_CORE, "ServiceControlCmd write systemAbilityId failed"); - return INVALID_DATA; - } - if (!data.WriteFileDescriptor(fd)) { - HILOG_WARN(LOG_CORE, "ServiceControlCmd write fd failed"); - return INVALID_DATA; - } - if (!data.WriteString16Vector(args)) { - HILOG_WARN(LOG_CORE, "ServiceControlCmd write args failed"); - return INVALID_DATA; - } - - MessageParcel reply; - MessageOption option; - int32_t status = iro->SendRequest( - static_cast(SafwkInterfaceCode::SERVICE_CONTROL_CMD_TRANSACTION), data, reply, option); - if (status != NO_ERROR) { - HILOG_ERROR(LOG_CORE, "ServiceControlCmd SendRequest failed, return value : %{public}d", status); - } - return status; -} } diff --git a/services/samgr/native/include/system_ability_manager.h b/services/samgr/native/include/system_ability_manager.h index f4c672d4..e1818ee5 100644 --- a/services/samgr/native/include/system_ability_manager.h +++ b/services/samgr/native/include/system_ability_manager.h @@ -231,12 +231,7 @@ public: sptr GetSystemProcess(const std::u16string& procName); sptr GetLocalAbilityManagerProxy(int32_t systemAbilityId) override { - CommonSaProfile saProfile; - if (!GetSaProfile(systemAbilityId, saProfile)) { - HILOGD("SA:%{public}d no profile!", systemAbilityId); - return nullptr; - } - return GetSystemProcess(saProfile.process); + return nullptr; } bool IsModuleUpdate(int32_t systemAbilityId) { diff --git a/services/samgr/native/include/system_ability_manager_stub.h b/services/samgr/native/include/system_ability_manager_stub.h index 837284a5..0d16d3b1 100644 --- a/services/samgr/native/include/system_ability_manager_stub.h +++ b/services/samgr/native/include/system_ability_manager_stub.h @@ -179,11 +179,6 @@ private: { return stub->GetCommonEventExtraDataIdlistInner(data, reply); } - static int32_t LocalGetLocalAbilityManagerProxy(SystemAbilityManagerStub* stub, - MessageParcel& data, MessageParcel& reply) - { - return stub->GetLocalAbilityManagerProxyInner(data, reply); - } int32_t ListSystemAbilityInner(MessageParcel& data, MessageParcel& reply); int32_t SubsSystemAbilityInner(MessageParcel& data, MessageParcel& reply); int32_t UnSubsSystemAbilityInner(MessageParcel& data, MessageParcel& reply); @@ -214,7 +209,6 @@ private: int32_t GetExtensionRunningSaListInner(MessageParcel& data, MessageParcel& reply); int32_t GetRunningSaExtensionInfoListInner(MessageParcel& data, MessageParcel& reply); int32_t GetCommonEventExtraDataIdlistInner(MessageParcel& data, MessageParcel& reply); - int32_t GetLocalAbilityManagerProxyInner(MessageParcel& data, MessageParcel& reply); static int32_t GetHapIdMultiuser(int32_t uid); void SetAbilityFuncMap(); void SetProcessFuncMap(); diff --git a/services/samgr/native/source/system_ability_manager_stub.cpp b/services/samgr/native/source/system_ability_manager_stub.cpp index b5aadc86..0a4dd921 100644 --- a/services/samgr/native/source/system_ability_manager_stub.cpp +++ b/services/samgr/native/source/system_ability_manager_stub.cpp @@ -105,8 +105,7 @@ namespace { using namespace OHOS::Security; namespace OHOS { namespace { -const std::string EXT_TRANSACTION_PERMISSION = "ohos.permission.ACCESS_EXT_SYSTEM_ABILITY"; -const std::string PERMISSION_SVC = "ohos.permission.CONTROL_SVC_CMD"; +constexpr const char *EXT_TRANSACTION_PERMISSION = "ohos.permission.ACCESS_EXT_SYSTEM_ABILITY"; } void SystemAbilityManagerStub::SetAbilityFuncMap() @@ -179,8 +178,6 @@ SystemAbilityManagerStub::SystemAbilityManagerStub() SystemAbilityManagerStub::LocalGetRunningSaExtensionInfoList; memberFuncMap_[static_cast(SamgrInterfaceCode::GET_COMMON_EVENT_EXTRA_ID_LIST_TRANSCATION)] = SystemAbilityManagerStub::LocalGetCommonEventExtraDataIdlist; - memberFuncMap_[static_cast(SamgrInterfaceCode::GET_LOCAL_ABILITY_MANAGER_PROXY_TRANSCATION)] = - SystemAbilityManagerStub::LocalGetLocalAbilityManagerProxy; } int32_t SystemAbilityManagerStub::OnRemoteRequest(uint32_t code, @@ -1244,32 +1241,4 @@ int32_t SystemAbilityManagerStub::GetCommonEventExtraDataIdlistInner(MessageParc } return ERR_NONE; } - -int32_t SystemAbilityManagerStub::GetLocalAbilityManagerProxyInner(MessageParcel& data, MessageParcel& reply) -{ - if (!CheckPermission(PERMISSION_SVC)) { - HILOGE("GetLocalSystemAbilityProxyInner permission denied! CallSid:%{public}s", - OHOS::IPCSkeleton::GetCallingSid().c_str()); - return ERR_PERMISSION_DENIED; - } - - int32_t systemAbilityId = -1; - bool ret = data.ReadInt32(systemAbilityId); - if (!ret || !CheckInputSysAbilityId(systemAbilityId)) { - HILOGE("GetLocalSystemAbilityProxyInner get SAId failed."); - return ERR_NULL_OBJECT; - } - - sptr remoteObject = GetLocalAbilityManagerProxy(systemAbilityId); - if (remoteObject == nullptr) { - HILOGE("GetLocalSystemAbilityProxyInner SA:%{public}d GetLocalSystemAbilityProxy failed.", systemAbilityId); - return ERR_NULL_OBJECT; - } - ret = reply.WriteRemoteObject(remoteObject); - if (!ret) { - HILOGE("GetLocalSystemAbilityProxyInner SA:%{public}d write reply failed.", systemAbilityId); - return ERR_FLATTEN_OBJECT; - } - return ERR_NONE; -} } // namespace OHOS diff --git a/services/samgr/native/test/unittest/src/local_ability_manager_proxy_test.cpp b/services/samgr/native/test/unittest/src/local_ability_manager_proxy_test.cpp index 35196e4d..af8b0b48 100644 --- a/services/samgr/native/test/unittest/src/local_ability_manager_proxy_test.cpp +++ b/services/samgr/native/test/unittest/src/local_ability_manager_proxy_test.cpp @@ -476,42 +476,4 @@ HWTEST_F(LocalAbilityManagerProxyTest, SystemAbilityExtProc004, TestSize.Level3) int32_t result = localAbility->SystemAbilityExtProc("OnBackup", TEST_SAID_INVAILD, &callback, true); EXPECT_EQ(result, INVALID_DATA); } - -/** - * @tc.name: ServiceControlCmd001 - * @tc.desc: test ServiceControlCmd001 - * @tc.type: FUNC - * @tc.require: I9IE98 - */ -HWTEST_F(LocalAbilityManagerProxyTest, ServiceControlCmd001, TestSize.Level3) -{ - sptr testAbility(new MockIroSendrequesteStub()); - sptr localAbility(new LocalAbilityManagerProxy(testAbility)); - - int32_t fd = 1; - int32_t systemAbilityId = -1; - std::vector args (1, Str8ToStr16(std::string("help"))); - - int32_t result = localAbility->ServiceControlCmd(fd, systemAbilityId, args); - EXPECT_EQ(result, INVALID_DATA); -} - -/** - * @tc.name: ServiceControlCmd002 - * @tc.desc: test ServiceControlCmd002 - * @tc.type: FUNC - * @tc.require: I9IE98 - */ -HWTEST_F(LocalAbilityManagerProxyTest, ServiceControlCmd002, TestSize.Level3) -{ - sptr testAbility(new MockIroSendrequesteStub()); - sptr localAbility(new LocalAbilityManagerProxy(testAbility)); - - int32_t fd = 1; - int32_t systemAbilityId = 1; - std::vector args (1, Str8ToStr16(std::string("help"))); - - int32_t result = localAbility->ServiceControlCmd(fd, systemAbilityId, args); - EXPECT_EQ(result, NO_ERROR); -} } \ No newline at end of file diff --git a/services/samgr/native/test/unittest/src/system_ability_mgr_proxy_test.cpp b/services/samgr/native/test/unittest/src/system_ability_mgr_proxy_test.cpp index 1d9c6f59..edd34499 100644 --- a/services/samgr/native/test/unittest/src/system_ability_mgr_proxy_test.cpp +++ b/services/samgr/native/test/unittest/src/system_ability_mgr_proxy_test.cpp @@ -1260,40 +1260,4 @@ HWTEST_F(SystemAbilityMgrProxyTest, OnLoadSystemAbilityFail005, TestSize.Level3) callback->OnLoadSystemAbilityFail(-1); EXPECT_EQ(nullptr, callback->loadproxy_); } - -/** - * @tc.name: GetLocalAbilityManagerProxy001 - * @tc.desc: test GetLocalAbilityManagerProxy - * @tc.type: FUNC - */ -HWTEST_F(SystemAbilityMgrProxyTest, GetLocalAbilityManagerProxy001, TestSize.Level3) -{ - sptr samgrProxy = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); - - auto ret = samgrProxy->GetLocalAbilityManagerProxy(TEST_ID_NORANGE_SAID); - EXPECT_TRUE(ret == nullptr); -} - -/** - * @tc.name: GetLocalAbilityManagerProxy002 - * @tc.desc: test GetLocalAbilityManagerProxy - * @tc.type: FUNC - */ -HWTEST_F(SystemAbilityMgrProxyTest, GetLocalAbilityManagerProxy002, TestSize.Level3) -{ - sptr samgrProxy = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); - - auto ret = samgrProxy->GetLocalAbilityManagerProxy(TEST_SAID_INVALID); - EXPECT_TRUE(ret == nullptr); -} - -HWTEST_F(SystemAbilityMgrProxyTest, GetLocalAbilityManagerProxy003, TestSize.Level3) -{ - DTEST_LOG << " GetLocalAbilityManagerProxy003 begin " << std::endl; - sptr samgrMock = new ISystemAbilityManagerMock; - EXPECT_TRUE(samgrMock != nullptr); - auto ret = samgrMock->GetLocalAbilityManagerProxy(TEST_SAID_INVALID); - EXPECT_TRUE(ret == nullptr); - DTEST_LOG << " GetLocalAbilityManagerProxy003 end " << std::endl; -} } \ No newline at end of file diff --git a/services/samgr/native/test/unittest/src/system_ability_mgr_stub_test.cpp b/services/samgr/native/test/unittest/src/system_ability_mgr_stub_test.cpp index 4ffbfae4..c1b00a6e 100644 --- a/services/samgr/native/test/unittest/src/system_ability_mgr_stub_test.cpp +++ b/services/samgr/native/test/unittest/src/system_ability_mgr_stub_test.cpp @@ -808,51 +808,4 @@ HWTEST_F(SystemAbilityMgrStubTest, SendStrategyInner001, TestSize.Level3) int32_t result = saMgr->SendStrategyInner(data, reply); EXPECT_EQ(result, ERR_FLATTEN_OBJECT); } - -/** - * @tc.name: GetLocalAbilityManagerProxyInner001 - * @tc.desc: test GetLocalAbilityManagerProxyInner - * @tc.type: FUNC - * @tc.require: I6XB42 - */ -HWTEST_F(SystemAbilityMgrStubTest, GetLocalAbilityManagerProxyInner001, TestSize.Level3) -{ - sptr saMgr = SystemAbilityManager::GetInstance(); - MessageParcel data; - MessageParcel reply; - int32_t ret = saMgr->GetLocalAbilityManagerProxyInner(data, reply); - EXPECT_EQ(ret, ERR_NULL_OBJECT); -} - -/** - * @tc.name: GetLocalAbilityManagerProxyInner002 - * @tc.desc: test GetLocalAbilityManagerProxyInner - * @tc.type: FUNC - * @tc.require: I6XB42 - */ -HWTEST_F(SystemAbilityMgrStubTest, GetLocalAbilityManagerProxyInner002, TestSize.Level3) -{ - sptr saMgr = SystemAbilityManager::GetInstance(); - MessageParcel data; - MessageParcel reply; - EXPECT_TRUE(data.WriteInt32(INVALID_SAID)); - int32_t ret = saMgr->GetLocalAbilityManagerProxyInner(data, reply); - EXPECT_EQ(ret, ERR_NULL_OBJECT); -} - -/** - * @tc.name: GetLocalAbilityManagerProxyInner003 - * @tc.desc: test GetLocalAbilityManagerProxyInner - * @tc.type: FUNC - * @tc.require: I6XB42 - */ -HWTEST_F(SystemAbilityMgrStubTest, GetLocalAbilityManagerProxyInner003, TestSize.Level3) -{ - sptr saMgr = SystemAbilityManager::GetInstance(); - MessageParcel data; - MessageParcel reply; - EXPECT_TRUE(data.WriteInt32(SAID)); - int32_t ret = saMgr->GetLocalAbilityManagerProxyInner(data, reply); - EXPECT_EQ(ret, ERR_NULL_OBJECT); -} } \ No newline at end of file diff --git a/services/samgr/native/test/unittest/src/system_ability_mgr_test.cpp b/services/samgr/native/test/unittest/src/system_ability_mgr_test.cpp index f8fa4909..69743254 100644 --- a/services/samgr/native/test/unittest/src/system_ability_mgr_test.cpp +++ b/services/samgr/native/test/unittest/src/system_ability_mgr_test.cpp @@ -1623,47 +1623,4 @@ HWTEST_F(SystemAbilityMgrTest, OnRemoteDied002, TestSize.Level3) saMgr->remoteCallbackDeath_->OnRemoteDied(nullptr); DTEST_LOG<<"OnRemoteDied002 END"; } - -/** - * @tc.name: Test GetLocalAbilityManagerProxy001 - * @tc.desc: GetLocalAbilityManagerProxy001 - * @tc.type: FUNC - * @tc.require: I7VQQG - */ -HWTEST_F(SystemAbilityMgrTest, GetLocalAbilityManagerProxy001, TestSize.Level3) -{ - DTEST_LOG << "GetLocalAbilityManagerProxy001 BEGIN" << std::endl; - - sptr saMgr = new SystemAbilityManager; - saMgr->saProfileMap_.clear(); - auto ret = saMgr->GetLocalAbilityManagerProxy(SAID); - EXPECT_TRUE(ret == nullptr); - DTEST_LOG << "GetLocalAbilityManagerProxy001 END" << std::endl; -} - -/** - * @tc.name: Test GetLocalAbilityManagerProxy002 - * @tc.desc: GetLocalAbilityManagerProxy001 - * @tc.type: FUNC - * @tc.require: I7VQQG - */ -HWTEST_F(SystemAbilityMgrTest, GetLocalAbilityManagerProxy002, TestSize.Level3) -{ - DTEST_LOG << "GetLocalAbilityManagerProxy002 BEGIN" << std::endl; - - sptr saMgr = new SystemAbilityManager; - CommonSaProfile saProfile; - saProfile.process = u"test"; - saProfile.saId = SAID; - saMgr->saProfileMap_[SAID] = saProfile; - - sptr testAbility = new TestTransactionService(); - EXPECT_FALSE(testAbility == nullptr); - saMgr->systemProcessMap_[u"test"] = testAbility; - - auto ret = saMgr->GetLocalAbilityManagerProxy(SAID); - EXPECT_FALSE(ret == nullptr); - - DTEST_LOG << "GetLocalAbilityManagerProxy002 END" << std::endl; -} } // namespace OHOS \ No newline at end of file -- Gitee