mirror of
https://gitee.com/openharmony/request_request
synced 2025-02-06 07:28:55 +00:00
多用户用户切后台bug修复
Signed-off-by: fqwert <yanglv2@huawei.com> Change-Id: I487305730716b263f75f5941107e53e7e69c494a
This commit is contained in:
parent
0b0666679f
commit
b4ae5d2663
@ -18,6 +18,9 @@
|
||||
},
|
||||
{
|
||||
"name": "usual.event.USER_SWITCHED"
|
||||
},
|
||||
{
|
||||
"name": "usual.event.USER_STOPPED"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ use crate::manage::task_manager::TaskManagerTx;
|
||||
pub(crate) enum AccountEvent {
|
||||
Switch,
|
||||
Active,
|
||||
Stop,
|
||||
Remove(i32),
|
||||
}
|
||||
|
||||
@ -81,9 +82,8 @@ impl TaskManager {
|
||||
pub(crate) async fn handle_account_event(&mut self, event: AccountEvent) {
|
||||
update_accounts();
|
||||
match event {
|
||||
AccountEvent::Active => self.scheduler.on_user_change().await,
|
||||
AccountEvent::Switch => self.scheduler.on_user_change().await,
|
||||
AccountEvent::Remove(user_id) => remove_account_tasks(user_id),
|
||||
_ => self.scheduler.on_user_change().await,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -171,7 +171,7 @@ pub(crate) fn registry_account_subscribe(task_manager: TaskManagerTx) {
|
||||
|
||||
let ret = RegistryAccountSubscriber(
|
||||
OS_ACCOUNT_SUBSCRIBE_TYPE::REMOVED,
|
||||
Box::new(task_manager),
|
||||
Box::new(task_manager.clone()),
|
||||
|id, task_manager| {
|
||||
task_manager.send_event(TaskManagerEvent::Account(AccountEvent::Remove(*id)));
|
||||
},
|
||||
@ -179,6 +179,19 @@ pub(crate) fn registry_account_subscribe(task_manager: TaskManagerTx) {
|
||||
);
|
||||
|
||||
if ret != 0 {
|
||||
error!("registry_account_active_subscribe failed: {}", ret);
|
||||
error!("registry_account_remove_subscribe failed: {}", ret);
|
||||
}
|
||||
|
||||
let ret = RegistryAccountSubscriber(
|
||||
OS_ACCOUNT_SUBSCRIBE_TYPE::STOPPED,
|
||||
Box::new(task_manager),
|
||||
|_id, task_manager| {
|
||||
task_manager.send_event(TaskManagerEvent::Account(AccountEvent::Stop));
|
||||
},
|
||||
|_, _, _| {},
|
||||
);
|
||||
|
||||
if ret != 0 {
|
||||
error!("registry_account_stop_subscribe failed: {}", ret);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user