From 01c27d6766324a64d29882bcb1496c8c5614aab5 Mon Sep 17 00:00:00 2001 From: fangyun Date: Mon, 27 Nov 2023 14:48:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=87=E6=8D=A2=E7=94=A8?= =?UTF-8?q?=E6=88=B7=EF=BC=8Cextension=E6=A6=82=E7=8E=87=E6=80=A7=E6=8B=89?= =?UTF-8?q?=E8=B5=B7=E5=A4=B1=E8=B4=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fangyun --- services/edm/BUILD.gn | 1 - .../include/ability_manager_death_recipient.h | 41 ----------------- .../connection/enterprise_admin_connection.h | 3 -- .../connection/enterprise_conn_manager.h | 1 - .../src/ability_manager_death_recipient.cpp | 46 ------------------- .../enterprise_admin_connection.cpp | 17 +++---- .../edm_plugin/src/lock_screen_plugin.cpp | 3 +- test/unittest/BUILD.gn | 1 - 8 files changed, 7 insertions(+), 106 deletions(-) delete mode 100644 services/edm/include/ability_manager_death_recipient.h delete mode 100644 services/edm/src/ability_manager_death_recipient.cpp diff --git a/services/edm/BUILD.gn b/services/edm/BUILD.gn index 999fc4ca6..aeca8b0c0 100644 --- a/services/edm/BUILD.gn +++ b/services/edm/BUILD.gn @@ -25,7 +25,6 @@ config("edm_config") { ohos_shared_library("edmservice") { sources = [ - "./src/ability_manager_death_recipient.cpp", "./src/admin.cpp", "./src/admin_manager.cpp", "./src/admin_policies_storage_rdb.cpp", diff --git a/services/edm/include/ability_manager_death_recipient.h b/services/edm/include/ability_manager_death_recipient.h deleted file mode 100644 index 5348b7a74..000000000 --- a/services/edm/include/ability_manager_death_recipient.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef SERVICES_EDM_INCLUDE_ABILITY_MANAGER_DEATH_RECIPIENT_H -#define SERVICES_EDM_INCLUDE_ABILITY_MANAGER_DEATH_RECIPIENT_H - -#include "iremote_object.h" - -namespace OHOS { -namespace EDM { -class EnterpriseAdminConnection; -class AbilityManagerDeathRecipient : public IRemoteObject::DeathRecipient { -public: - explicit AbilityManagerDeathRecipient(const sptr& extensionConnection) - : extensionConnection_(extensionConnection) {} - /** - * Called back when the remote object is died. - * - * @param wptrDeath Indicates the died object. - */ - void OnRemoteDied(const wptr& wptrDeath) override; - -private: - sptr extensionConnection_; -}; -} // namespace EDM -} // namespace OHOS - -#endif // SERVICES_EDM_INCLUDE_ABILITY_MANAGER_DEATH_RECIPIENT_H \ No newline at end of file diff --git a/services/edm/include/connection/enterprise_admin_connection.h b/services/edm/include/connection/enterprise_admin_connection.h index 688036d3e..f0f0b5261 100644 --- a/services/edm/include/connection/enterprise_admin_connection.h +++ b/services/edm/include/connection/enterprise_admin_connection.h @@ -16,7 +16,6 @@ #ifndef SERVICES_EDM_INCLUDE_CONNECTION_ENTERPRISE_ADMIN_CONNECTION_H #define SERVICES_EDM_INCLUDE_CONNECTION_ENTERPRISE_ADMIN_CONNECTION_H -#include "ability_manager_death_recipient.h" #include "ienterprise_connection.h" namespace OHOS { @@ -50,8 +49,6 @@ public: private: bool isOnAdminEnabled_; - sptr extensionRemoteObject_; - sptr deathRecipient_{nullptr}; }; } // namespace EDM } // namespace OHOS diff --git a/services/edm/include/connection/enterprise_conn_manager.h b/services/edm/include/connection/enterprise_conn_manager.h index 2edb5fa78..5c4f2feff 100644 --- a/services/edm/include/connection/enterprise_conn_manager.h +++ b/services/edm/include/connection/enterprise_conn_manager.h @@ -20,7 +20,6 @@ #include #include -#include "ability_manager_death_recipient.h" #include "ability_manager_interface.h" #include "enterprise_admin_connection.h" #include "enterprise_bundle_connection.h" diff --git a/services/edm/src/ability_manager_death_recipient.cpp b/services/edm/src/ability_manager_death_recipient.cpp deleted file mode 100644 index 5509b61b1..000000000 --- a/services/edm/src/ability_manager_death_recipient.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ability_manager_death_recipient.h" -#include "admin_manager.h" -#include "edm_log.h" -#include "enterprise_conn_manager.h" -#include "singleton.h" - -namespace OHOS { -namespace EDM { -void AbilityManagerDeathRecipient::OnRemoteDied(const wptr& wptrDeath) -{ - EDMLOGI("ability manager service died, remove the proxy object"); - - if (wptrDeath == nullptr) { - EDMLOGE("wptrDeath is null"); - return; - } - - sptr object = wptrDeath.promote(); - if (object == nullptr) { - EDMLOGE("object is null"); - return; - } - - if (AdminManager::GetInstance()->IsSuperAdmin(extensionConnection_->GetWant().GetElement().GetBundleName())) { - std::shared_ptr manager = DelayedSingleton::GetInstance(); - extensionConnection_->SetIsOnAdminEnabled(false); - manager->ConnectAbility(extensionConnection_); - } -} -} // namespace EDM -} // namespace OHOS \ No newline at end of file diff --git a/services/edm/src/connection/enterprise_admin_connection.cpp b/services/edm/src/connection/enterprise_admin_connection.cpp index bd35723e7..944b4512c 100644 --- a/services/edm/src/connection/enterprise_admin_connection.cpp +++ b/services/edm/src/connection/enterprise_admin_connection.cpp @@ -42,20 +42,9 @@ void EnterpriseAdminConnection::OnAbilityConnectDone( if (isOnAdminEnabled_) { proxy_->OnAdminEnabled(); } - if (AdminManager::GetInstance()->IsSuperAdmin(want_.GetElement().GetBundleName())) { - if (!deathRecipient_) { - deathRecipient_ = (new (std::nothrow) AbilityManagerDeathRecipient(this)); - } - if (!deathRecipient_) { - EDMLOGE("EnterpriseAdminConnection get enterpriseAdminProxy failed."); - return; - } - proxy_->AddDeathRecipient(deathRecipient_); - } break; case IEnterpriseAdmin::COMMAND_ON_ADMIN_DISABLED: proxy_->OnAdminDisabled(); - proxy_->RemoveDeathRecipient(deathRecipient_); break; default: return; @@ -66,6 +55,12 @@ void EnterpriseAdminConnection::OnAbilityConnectDone( void EnterpriseAdminConnection::OnAbilityDisconnectDone(const AppExecFwk::ElementName& element, int32_t resultCode) { EDMLOGI("EnterpriseAdminConnection OnAbilityDisconnectDone"); + if (AdminManager::GetInstance()->IsSuperAdmin(want_.GetElement().GetBundleName())) { + std::shared_ptr manager = DelayedSingleton::GetInstance(); + sptr connection = + manager->CreateAdminConnection(want_, IEnterpriseAdmin::COMMAND_ON_ADMIN_ENABLED, DEFAULT_USER_ID, false); + manager->ConnectAbility(connection); + } } } // namespace EDM } // namespace OHOS diff --git a/services/edm_plugin/src/lock_screen_plugin.cpp b/services/edm_plugin/src/lock_screen_plugin.cpp index 6943032fd..51724a50e 100644 --- a/services/edm_plugin/src/lock_screen_plugin.cpp +++ b/services/edm_plugin/src/lock_screen_plugin.cpp @@ -35,8 +35,7 @@ void LockScreenPlugin::InitPlugin(std::shared_ptrLock(userId); + int32_t ret = ScreenLock::ScreenLockManager::GetInstance()->Lock(userId); if (ret != ScreenLock::E_SCREENLOCK_OK) { EDMLOGE("LockScreenPlugin:OnSetPolicy send request fail. %{public}d", ret); return EdmReturnErrCode::SYSTEM_ABNORMALLY; diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index f1304205f..37761adee 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -33,7 +33,6 @@ config("edm_config") { ohos_static_library("edmservice_static") { testonly = true sources = [ - "../../services/edm/src/ability_manager_death_recipient.cpp", "../../services/edm/src/admin.cpp", "../../services/edm/src/admin_manager.cpp", "../../services/edm/src/admin_policies_storage_rdb.cpp", -- Gitee