mirror of
https://gitee.com/openharmony/security_asset
synced 2024-11-23 07:49:41 +00:00
multi account issue
Signed-off-by: 尹耀德 <yinyaode1@huawei.com>
This commit is contained in:
parent
0a1142817b
commit
6df6c2e6ff
@ -50,6 +50,9 @@ pub enum EventType {
|
||||
|
||||
/// Package clear event.
|
||||
OnPackageClear,
|
||||
|
||||
/// User removed.
|
||||
OnUserRemoved,
|
||||
}
|
||||
|
||||
/// param name for bundle name
|
||||
|
@ -192,9 +192,10 @@ pub(crate) extern "C" fn on_package_removed(
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" fn delete_dir_by_user(user_id: i32) {
|
||||
extern "C" fn on_user_removed(user_id: i32) {
|
||||
let _counter_user = AutoCounter::new();
|
||||
let _ = delete_user_de_dir(user_id);
|
||||
notify_on_user_removed(user_id);
|
||||
}
|
||||
|
||||
extern "C" fn delete_crypto_need_unlock() {
|
||||
@ -275,6 +276,19 @@ pub(crate) extern "C" fn on_user_unlocked(user_id: i32) {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn notify_on_user_removed(user_id: i32) {
|
||||
logi!("[INFO]On user remove [{}]", user_id);
|
||||
|
||||
if let Ok(load) = AssetPlugin::get_instance().load_plugin() {
|
||||
let mut params = ExtDbMap::new();
|
||||
params.insert(PARAM_NAME_USER_ID, Value::Number(user_id as u32));
|
||||
match load.process_event(EventType::OnUserRemoved, ¶ms) {
|
||||
Ok(()) => logi!("process user removed event success."),
|
||||
Err(code) => loge!("process user removed event failed, code: {}", code),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) extern "C" fn on_schedule_wakeup() {
|
||||
logi!("[INFO]On SA wakes up at a scheduled time(36H).");
|
||||
let default_user_id = 0;
|
||||
@ -399,7 +413,7 @@ pub(crate) fn subscribe() {
|
||||
unsafe {
|
||||
let call_back = EventCallBack {
|
||||
on_package_remove: on_package_removed,
|
||||
on_user_removed: delete_dir_by_user,
|
||||
on_user_removed,
|
||||
on_screen_off: delete_crypto_need_unlock,
|
||||
on_charging: backup_db,
|
||||
on_app_restore,
|
||||
|
@ -83,6 +83,7 @@ pub(crate) fn handle_common_event(reason: SystemAbilityOnDemandReason) {
|
||||
} else if reason_name == "usual.event.USER_REMOVED" {
|
||||
logi!("on_start by user remove");
|
||||
let _ = delete_user_de_dir(reason.extra_data.code);
|
||||
listener::notify_on_user_removed(reason.extra_data.code);
|
||||
} else if reason_name == "usual.event.CHARGING" {
|
||||
listener::backup_db();
|
||||
} else if reason_name == "usual.event.RESTORE_START" {
|
||||
|
Loading…
Reference in New Issue
Block a user