mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-12-04 21:48:49 +00:00
aa start支持唤醒解锁锁屏
Signed-off-by: xlw <xialiangwei1@huawei.com> Change-Id: I966d95d4e9c998ef1053af589a6d90e937af40aa
This commit is contained in:
parent
ece81ac2ef
commit
c59221de60
@ -125,6 +125,11 @@ declare_args() {
|
||||
resource_schedule_service_enable = false
|
||||
}
|
||||
|
||||
if (defined(global_parts_info) &&
|
||||
!defined(global_parts_info.powermgr_power_manager)) {
|
||||
ability_runtime_power = false
|
||||
}
|
||||
|
||||
if (defined(global_parts_info) &&
|
||||
!defined(global_parts_info.resourceschedule_efficiency_manager)) {
|
||||
efficiency_manager = false
|
||||
|
@ -80,11 +80,13 @@
|
||||
"netmanager_base",
|
||||
"node",
|
||||
"os_account",
|
||||
"power_manager",
|
||||
"relational_store",
|
||||
"resource_management",
|
||||
"resource_schedule_service",
|
||||
"safwk",
|
||||
"samgr",
|
||||
"screenlock_mgr",
|
||||
"storage_service",
|
||||
"toolchain",
|
||||
"webview",
|
||||
|
@ -509,6 +509,11 @@ enum {
|
||||
* Result(2097250) for app twin index does not exist.
|
||||
*/
|
||||
ERR_APP_TWIN_INDEX_INVALID,
|
||||
|
||||
/**
|
||||
* Result(2097251) for unlock screen failed in developer mode.
|
||||
*/
|
||||
ERR_UNLOCK_SCREEN_FAILED_IN_DEVELOPER_MODE,
|
||||
};
|
||||
|
||||
enum {
|
||||
|
@ -164,6 +164,7 @@ ohos_shared_library("abilityms") {
|
||||
"ipc:ipc_core",
|
||||
"kv_store:distributeddata_inner",
|
||||
"os_account:os_account_innerkits",
|
||||
"power_manager:powermgr_client",
|
||||
"relational_store:native_appdatafwk",
|
||||
"relational_store:native_dataability",
|
||||
"relational_store:native_rdb",
|
||||
@ -194,7 +195,10 @@ ohos_shared_library("abilityms") {
|
||||
external_deps += [ "dlp_permission_service:libdlp_permission_sdk" ]
|
||||
}
|
||||
|
||||
defines = []
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
defines += [ "SUPPORT_GRAPHICS" ]
|
||||
external_deps += [
|
||||
"ability_base:session_info",
|
||||
"i18n:intl_util",
|
||||
@ -202,6 +206,7 @@ ohos_shared_library("abilityms") {
|
||||
"image_framework:image_native",
|
||||
"input:libmmi-client",
|
||||
"resource_management:global_resmgr",
|
||||
"screenlock_mgr:screenlock_client",
|
||||
"window_manager:libdm",
|
||||
"window_manager:libmodal_system_ui_extension_client",
|
||||
"window_manager:libwm",
|
||||
@ -211,6 +216,11 @@ ohos_shared_library("abilityms") {
|
||||
]
|
||||
}
|
||||
|
||||
if (ability_runtime_power) {
|
||||
defines += [ "SUPPORT_POWER" ]
|
||||
external_deps += [ "power_manager:powermgr_client" ]
|
||||
}
|
||||
|
||||
version_script = "libabilityms.map"
|
||||
subsystem_name = "ability"
|
||||
innerapi_tags = [ "platformsdk_indirect" ]
|
||||
|
@ -80,6 +80,8 @@ abilityms_files = [
|
||||
"src/extension_record_factory.cpp",
|
||||
"src/ui_extension_record.cpp",
|
||||
"src/ui_extension_record_factory.cpp",
|
||||
"src/screen_lock/unlock_screen_callback.cpp",
|
||||
"src/screen_lock/unlock_screen_manager.cpp",
|
||||
"src/start_options.cpp",
|
||||
"src/user_callback_proxy.cpp",
|
||||
"src/call_container.cpp",
|
||||
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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_ABILITY_RUNTIME_UNLOCK_SCREEN_CALLBACK_H
|
||||
#define OHOS_ABILITY_RUNTIME_UNLOCK_SCREEN_CALLBACK_H
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#include "screenlock_callback_stub.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
class UnlockScreenCallback : public ScreenLock::ScreenLockCallbackStub {
|
||||
public:
|
||||
explicit UnlockScreenCallback();
|
||||
~UnlockScreenCallback() override;
|
||||
void OnCallBack(const int32_t screenLockResult) override;
|
||||
};
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
#endif // SUPPORT_GRAPHICS
|
||||
#endif // OHOS_ABILITY_RUNTIME_UNLOCK_SCREEN_MANAGER_H
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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_ABILITY_RUNTIME_UNLOCK_SCREEN_MANAGER_H
|
||||
#define OHOS_ABILITY_RUNTIME_UNLOCK_SCREEN_MANAGER_H
|
||||
|
||||
#include "nocopyable.h"
|
||||
|
||||
#ifdef SUPPORT_POWER
|
||||
#include "power_mgr_client.h"
|
||||
#endif
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#include "screen_lock/unlock_screen_callback.h"
|
||||
#include "screenlock_manager.h"
|
||||
#include "screenlock_common.h"
|
||||
#endif
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
class UnlockScreenManager {
|
||||
public:
|
||||
static UnlockScreenManager &GetInstance();
|
||||
~UnlockScreenManager();
|
||||
bool UnlockScreen();
|
||||
private:
|
||||
UnlockScreenManager();
|
||||
DISALLOW_COPY_AND_MOVE(UnlockScreenManager);
|
||||
};
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ABILITY_RUNTIME_UNLOCK_SCREEN_MANAGER_H
|
@ -87,6 +87,7 @@
|
||||
#include "restart_app_manager.h"
|
||||
#include "sa_mgr_client.h"
|
||||
#include "scene_board_judgement.h"
|
||||
#include "screen_lock/unlock_screen_manager.h"
|
||||
#include "server_constant.h"
|
||||
#include "session_info.h"
|
||||
#include "softbus_bus_center.h"
|
||||
@ -539,6 +540,10 @@ int AbilityManagerService::StartAbility(const Want &want, int32_t userId, int re
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Developer Mode is false.");
|
||||
return ERR_NOT_DEVELOPER_MODE;
|
||||
}
|
||||
if (!UnlockScreenManager::GetInstance().UnlockScreen()) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Screen need passord to unlock");
|
||||
return ERR_UNLOCK_SCREEN_FAILED_IN_DEVELOPER_MODE;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "coldStart:%{public}d", want.GetBoolParam("coldStart", false));
|
||||
bool startWithAccount = want.GetBoolParam(START_ABILITY_TYPE, false);
|
||||
if (startWithAccount || IsCrossUserCall(userId)) {
|
||||
@ -1191,6 +1196,10 @@ int AbilityManagerService::StartAbilityDetails(const Want &want, const AbilitySt
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Developer Mode is false.");
|
||||
return ERR_NOT_DEVELOPER_MODE;
|
||||
}
|
||||
if (!UnlockScreenManager::GetInstance().UnlockScreen()) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Screen need passord to unlock");
|
||||
return ERR_UNLOCK_SCREEN_FAILED_IN_DEVELOPER_MODE;
|
||||
}
|
||||
AbilityUtil::RemoveWantKey(const_cast<Want &>(want));
|
||||
StartAbilityParams startParams(const_cast<Want &>(want));
|
||||
startParams.callerToken = callerToken;
|
||||
|
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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.
|
||||
*/
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#include "screen_lock/unlock_screen_callback.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
UnlockScreenCallback::~UnlockScreenCallback() {}
|
||||
|
||||
UnlockScreenCallback::UnlockScreenCallback() {}
|
||||
|
||||
void UnlockScreenCallback::OnCallBack(const int32_t screenLockResult)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "Unlock Screen result is %{public}d", screenLockResult);
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
#endif // SUPPORT_GRAPHICS
|
||||
|
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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 "screen_lock/unlock_screen_manager.h"
|
||||
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "in_process_call_wrapper.h"
|
||||
#include "parameters.h"
|
||||
#include "permission_verification.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
namespace {
|
||||
constexpr char DEVELOPER_MODE_STATE[] = "const.security.developermode.state";
|
||||
}
|
||||
|
||||
UnlockScreenManager::~UnlockScreenManager() {}
|
||||
|
||||
UnlockScreenManager::UnlockScreenManager() {}
|
||||
|
||||
UnlockScreenManager &UnlockScreenManager::GetInstance()
|
||||
{
|
||||
static UnlockScreenManager instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
bool UnlockScreenManager::UnlockScreen()
|
||||
{
|
||||
bool isShellCall = AAFwk::PermissionVerification::GetInstance()->IsShellCall();
|
||||
bool isDeveloperMode = system::GetBoolParameter(DEVELOPER_MODE_STATE, false);
|
||||
if (!isShellCall) {
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "not aa start call, just start ability");
|
||||
return true;
|
||||
}
|
||||
if (!isDeveloperMode) {
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "not devlop mode, just start ability");
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
bool isScreenLocked = OHOS::ScreenLock::ScreenLockManager::GetInstance()->IsScreenLocked();
|
||||
bool isScreenSecured = OHOS::ScreenLock::ScreenLockManager::GetInstance()->GetSecure();
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "isScreenLocked: %{public}d, isScreenSecured: %{public}d",
|
||||
isScreenLocked, isScreenSecured);
|
||||
if (isScreenLocked && isScreenSecured) {
|
||||
return false;
|
||||
}
|
||||
if (isScreenLocked) {
|
||||
sptr<UnlockScreenCallback> listener = sptr<UnlockScreenCallback>(new (std::nothrow) UnlockScreenCallback());
|
||||
IN_PROCESS_CALL(OHOS::ScreenLock::ScreenLockManager::GetInstance()->Unlock(
|
||||
OHOS::ScreenLock::Action::UNLOCKSCREEN, listener));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SUPPORT_POWER
|
||||
bool isScreenOn = PowerMgr::PowerMgrClient::GetInstance().IsScreenOn();
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "isScreenOn: %{public}d", isScreenOn);
|
||||
if (!isScreenOn) {
|
||||
PowerMgr::PowerMgrClient::GetInstance().WakeupDevice();
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
@ -298,6 +298,10 @@ ErrCode AbilityManagerShellCommand::CreateMessageMap()
|
||||
KILL_PROCESS_KEEP_ALIVE,
|
||||
"error: keep alive process can not be killed.",
|
||||
},
|
||||
{
|
||||
ERR_UNLOCK_SCREEN_FAILED_IN_DEVELOPER_MODE,
|
||||
"error: unlock screen failed in developer mode."
|
||||
}
|
||||
};
|
||||
|
||||
return OHOS::ERR_OK;
|
||||
|
Loading…
Reference in New Issue
Block a user