diff --git a/services/edm/BUILD.gn b/services/edm/BUILD.gn index 999fc4ca6778900b3b0728410aab634daffcb200..aeca8b0c0d8469e62ff840e35437be8695b9e1b3 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 5348b7a74c061e8e16751690cb64330c69ebaa8b..0000000000000000000000000000000000000000 --- 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 688036d3e390c30b415631fb42dc9350113295ca..f0f0b5261ece361c84e7d5affae73b3f425c6b2d 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 2edb5fa78b77656dfd568eaa699557e322541dd9..5c4f2feff4f72dae00973565d2bac7dc0c6b7984 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 5509b61b1c39bad8096db7033ef1d3e0e5e7bb2c..0000000000000000000000000000000000000000 --- 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 bd35723e70f636fca802ea61b583f3eea42b251b..944b4512ca1c0ef9ede37b1935d5a1b7ac3bfd76 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 6943032fd4035b7a9fd60e2c6e4f296448df74c0..51724a50eab7022182578cacf1773d2add8aa52d 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 f1304205f1cfffbfbf570b8cb08e3defc5a9e2c0..37761adee2d82b81b689bfaef1c2959e9b4aaf5c 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",