diff --git a/frameworks/native/source/system_ability_manager_proxy.cpp b/frameworks/native/source/system_ability_manager_proxy.cpp index 622691679ab0e859003a8b0d8cbdad2de751a1cb..3a7186e54b9068ee30cb6ce3e18cdb4de5be851b 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 bfd0749b51f86b886ed7fb96b59afd36a49f2d80..1a4f5332e183de35e75d46475018366fb1544244 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 127a50bb890687547e6e618f4f21f58831f7aa87..f4f9d6b9373f6de0c00bdb79296c8fcd2aad914a 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 db0bbe25a48f58b433bfc794c9b61c31a93d2c79..8d3dff429cdf17b237477f1d13159e8fd75eacdd 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 a37feca4f57c06a6846c7ee57b1e0a42eef2a8fc..5ca883b6cb81ce211d99cd6e1e465a97d39d1b56 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 3d15d71e259f985a058350c7a2b477b1ee19478e..efc6210215b6ab784b18943787610a10d1ae6957 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 f4c672d4c3e0c5eb235f93643380f882a602399b..e1818ee5d4004cd947787b7780dff93edcffb744 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 837284a5b38bb12441159673a2cff1e5d4dd389b..0d16d3b19f9a0b853e99bf73efe248c649e244c5 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 b5aadc863c0a0fda4d82d70ba15c6b101c426618..0a4dd921ed8e39ae769d6a38e7d5407c78506838 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 35196e4d758b4154e6742436c04e62bae5fcc696..af8b0b48b0c12dc77e0edd04e72041026ff6dfd3 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 1d9c6f59994e67131e40e67937328e0fc4323ed5..edd34499350199365fd0322c2a88a06defcb43ad 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 4ffbfae42d8f3666b9f21fe7b78a03ddfe9ffbb1..c1b00a6ef571bf25669c250566491da0e5814b0b 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 f8fa49094839f5d71561167cb62cbec8ece7c12e..6974325439c445376116ee88f6151aa8d8bbf3b7 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