健康使用手机管控问题

Signed-off-by: liusensen <liusen43@huawei.com>
This commit is contained in:
liusensen 2024-11-07 17:02:15 +08:00
parent 4654c86a82
commit fff2de5bbc
7 changed files with 22 additions and 17 deletions

View File

@ -1286,13 +1286,14 @@ void JsSceneSession::ProcessPendingSessionToBackgroundForDelegatorRegister()
void JsSceneSession::ProcessSessionExceptionRegister()
{
WLOGFD("in");
NotifySessionExceptionFunc func = [weakThis = wptr(this)](const SessionInfo& info, bool needRemoveSession) {
NotifySessionExceptionFunc func = [weakThis = wptr(this)](
const SessionInfo& info, bool needRemoveSession, bool startFail) {
auto jsSceneSession = weakThis.promote();
if (!jsSceneSession) {
TLOGE(WmsLogTag::WMS_LIFE, "ProcessSessionExceptionRegister jsSceneSession is null");
return;
}
jsSceneSession->OnSessionException(info, needRemoveSession);
jsSceneSession->OnSessionException(info, needRemoveSession, startFail);
};
auto session = weakSession_.promote();
if (session == nullptr) {
@ -3524,13 +3525,14 @@ void JsSceneSession::UpdateSessionIcon(const std::string& iconPath)
taskScheduler_->PostMainThreadTask(task, "UpdateSessionIcon");
}
void JsSceneSession::OnSessionException(const SessionInfo& info, bool needRemoveSession)
void JsSceneSession::OnSessionException(const SessionInfo& info, bool needRemoveSession, bool startFail)
{
TLOGI(WmsLogTag::WMS_LIFE, "[NAPI]bundleName = %{public}s, abilityName = %{public}s",
info.bundleName_.c_str(), info.abilityName_.c_str());
TLOGI(WmsLogTag::WMS_LIFE, "[NAPI]bundleName = %{public}s, abilityName = %{public}s, startFail = %{public}d",
info.bundleName_.c_str(), info.abilityName_.c_str(), startFail);
std::shared_ptr<SessionInfo> sessionInfo = std::make_shared<SessionInfo>(info);
auto task = [weakThis = wptr(this), persistentId = persistentId_, sessionInfo, needRemoveSession, env = env_] {
auto task = [weakThis = wptr(this), persistentId = persistentId_,
sessionInfo, needRemoveSession, startFail, env = env_] {
auto jsSceneSession = weakThis.promote();
if (!jsSceneSession || jsSceneSessionMap_.find(persistentId) == jsSceneSessionMap_.end()) {
TLOGE(WmsLogTag::WMS_LIFE, "OnSessionException jsSceneSession id:%{public}d has been destroyed",
@ -3548,11 +3550,12 @@ void JsSceneSession::OnSessionException(const SessionInfo& info, bool needRemove
}
napi_value jsSessionInfo = CreateJsSessionInfo(env, *sessionInfo);
napi_value jsNeedRemoveSession = CreateJsValue(env, needRemoveSession);
napi_value jsStartFail = CreateJsValue(env, startFail);
if (jsSessionInfo == nullptr) {
TLOGE(WmsLogTag::WMS_LIFE, "[NAPI]target session info is nullptr");
return;
}
napi_value argv[] = {jsSessionInfo, jsNeedRemoveSession};
napi_value argv[] = {jsSessionInfo, jsNeedRemoveSession, startFail};
napi_call_function(env, NapiGetUndefined(env), jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr);
};
taskScheduler_->PostMainThreadTask(task, "OnSessionException, name" + info.bundleName_);

View File

@ -292,7 +292,7 @@ private:
void TerminateSessionTotal(const SessionInfo& info, TerminateType terminateType);
void UpdateSessionLabel(const std::string& label);
void UpdateSessionIcon(const std::string& iconPath);
void OnSessionException(const SessionInfo& info, bool needRemoveSession);
void OnSessionException(const SessionInfo& info, bool needRemoveSession, bool startFail);
void OnSystemBarPropertyChange(const std::unordered_map<WindowType, SystemBarProperty>& propertyMap);
void OnNeedAvoid(bool status);
void PendingSessionToForeground(const SessionInfo& info);

View File

@ -197,7 +197,8 @@ public:
WSError NotifySessionException(
const sptr<AAFwk::SessionInfo> info, bool needRemoveSession = false) override;
WSError NotifySessionExceptionInner(
const sptr<AAFwk::SessionInfo> info, bool needRemoveSession = false, bool isFromClient = false);
const sptr<AAFwk::SessionInfo> info, bool needRemoveSession = false,
bool isFromClient = false, bool startFail = false);
WSError NotifyClientToUpdateRect(const std::string& updateReason,
std::shared_ptr<RSTransaction> rsTransaction) override;

View File

@ -68,7 +68,7 @@ using NotifyTerminateSessionFuncNew =
using NotifyTerminateSessionFuncTotal = std::function<void(const SessionInfo& info, TerminateType terminateType)>;
using NofitySessionLabelUpdatedFunc = std::function<void(const std::string& label)>;
using NofitySessionIconUpdatedFunc = std::function<void(const std::string& iconPath)>;
using NotifySessionExceptionFunc = std::function<void(const SessionInfo& info, bool needRemoveSession)>;
using NotifySessionExceptionFunc = std::function<void(const SessionInfo& info, bool needRemoveSession, bool startFail)>;
using NotifySessionSnapshotFunc = std::function<void(const int32_t& persistentId)>;
using NotifyPendingSessionToForegroundFunc = std::function<void(const SessionInfo& info)>;
using NotifyPendingSessionToBackgroundForDelegatorFunc = std::function<void(const SessionInfo& info,

View File

@ -4173,9 +4173,9 @@ WSError SceneSession::TerminateSession(const sptr<AAFwk::SessionInfo> abilitySes
}
WSError SceneSession::NotifySessionExceptionInner(const sptr<AAFwk::SessionInfo> abilitySessionInfo,
bool needRemoveSession, bool isFromClient)
bool needRemoveSession, bool isFromClient, bool startFail)
{
auto task = [weakThis = wptr(this), abilitySessionInfo, needRemoveSession, isFromClient]() {
auto task = [weakThis = wptr(this), abilitySessionInfo, needRemoveSession, isFromClient, startFail]() {
auto session = weakThis.promote();
if (!session) {
TLOGE(WmsLogTag::WMS_LIFE, "session is null");
@ -4212,11 +4212,11 @@ WSError SceneSession::NotifySessionExceptionInner(const sptr<AAFwk::SessionInfo>
}
if (session->sessionExceptionFunc_) {
auto exceptionFunc = *(session->sessionExceptionFunc_);
exceptionFunc(info, needRemoveSession);
exceptionFunc(info, needRemoveSession, false);
}
if (session->jsSceneSessionExceptionFunc_) {
auto exceptionFunc = *(session->jsSceneSessionExceptionFunc_);
exceptionFunc(info, needRemoveSession);
exceptionFunc(info, needRemoveSession, startFail);
}
return WSError::WS_OK;
};

View File

@ -1984,7 +1984,7 @@ WSError SceneSessionManager::RequestSceneSessionActivationInner(
if (errCode != ERR_OK) {
TLOGI(WmsLogTag::WMS_MAIN, "failed! errCode: %{public}d", errCode);
sceneSession->NotifySessionExceptionInner(sceneSessionInfo, true);
sceneSession->NotifySessionExceptionInner(sceneSessionInfo, true, false, true);
if (startUIAbilityErrorFunc_ && static_cast<WSError>(errCode) == WSError::WS_ERROR_EDM_CONTROLLED) {
startUIAbilityErrorFunc_(
static_cast<uint32_t>(WS_JS_TO_ERROR_CODE_MAP.at(WSError::WS_ERROR_EDM_CONTROLLED)));
@ -4049,7 +4049,8 @@ void SceneSessionManager::RegisterSessionExceptionFunc(const sptr<SceneSession>&
WLOGFE("session is nullptr");
return;
}
NotifySessionExceptionFunc sessionExceptionFunc = [this](const SessionInfo& info, bool needRemoveSession = false) {
NotifySessionExceptionFunc sessionExceptionFunc = [this](
const SessionInfo& info, bool needRemoveSession = false, bool startFail) {
auto task = [this, info] {
auto session = GetSceneSession(info.persistentId_);
if (session == nullptr) {

View File

@ -2067,7 +2067,7 @@ HWTEST_F(WindowSessionTest2, SetSessionExceptionListener, Function | SmallTest |
{
session_->SetSessionExceptionListener(nullptr, true);
NotifySessionExceptionFunc func = [](const SessionInfo& info, bool needRemoveSession) {};
NotifySessionExceptionFunc func = [](const SessionInfo& info, bool needRemoveSession, bool startFail) {};
session_->SetSessionExceptionListener(func, true);
ASSERT_NE(nullptr, session_->jsSceneSessionExceptionFunc_);