mirror of
https://gitee.com/openharmony/ability_dmsfwk
synced 2024-11-27 00:20:44 +00:00
add OnUserSwitched
Signed-off-by: dengxiaoyu <dengxiaoyu6@huawei.com>
This commit is contained in:
parent
8dd6726bed
commit
c21b65ab37
@ -31,7 +31,8 @@ public:
|
||||
|
||||
void OnReceiveEvent(const EventFwk::CommonEventData &eventData);
|
||||
int32_t GetForegroundOsAccountLocalId();
|
||||
void OnUserSwitched(int32_t &accountId);
|
||||
int32_t GetOsAccountType(int32_t &accountId);
|
||||
void OnUserSwitched();
|
||||
};
|
||||
} // namespace DistributedSchedule
|
||||
} // namespace OHOS
|
||||
|
@ -42,8 +42,6 @@ private:
|
||||
std::string GetSwitchStatus(const std::string &key, const std::string &defaultValue);
|
||||
std::shared_ptr<DataShare::DataShareHelper> GetDataShareHelper();
|
||||
std::mutex dataShareMutex_;
|
||||
const std::string SETTINGS_DATA_URI_PREFIX =
|
||||
"datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true";
|
||||
std::string switchStatus_;
|
||||
};
|
||||
} // namespace DistributedSchedule
|
||||
|
@ -70,7 +70,7 @@ void CommonEventListener::OnReceiveEvent(const EventFwk::CommonEventData &eventD
|
||||
break;
|
||||
case USER_SWITCHED :
|
||||
HILOGI("USER_SWITCHED");
|
||||
GetForegroundOsAccountLocalId();
|
||||
OnUserSwitched();
|
||||
break;
|
||||
case PACKAGE_ADDED :
|
||||
HILOGI("PACKAGE_ADDED: %{public}s", want.GetElement().GetBundleName().c_str());
|
||||
@ -98,17 +98,25 @@ int32_t CommonEventListener::GetForegroundOsAccountLocalId()
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
}
|
||||
HILOGD("GetForegroundOsAccountLocalId accountId is: %{public}d", accountId);
|
||||
OnUserSwitched(accountId);
|
||||
return accountId;
|
||||
}
|
||||
|
||||
void CommonEventListener::OnUserSwitched(int32_t& accountId)
|
||||
int32_t CommonEventListener::GetOsAccountType(int32_t& accountId)
|
||||
{
|
||||
AccountSA::OsAccountType type;
|
||||
ErrCode err = AccountSA::OsAccountManager::GetOsAccountType(accountId, type);
|
||||
if (err != ERR_OK) {
|
||||
HILOGE("GetOsAccountType passing param invalid or return error!, err : %{public}d", err);
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
void CommonEventListener::OnUserSwitched()
|
||||
{
|
||||
int32_t accountId = GetForegroundOsAccountLocalId();
|
||||
AccountSA::OsAccountType type = GetOsAccountType(accountId);
|
||||
HILOGI("OnUserSwitched called, accountId = %{public}d, type = %{public}d", accountId, type);
|
||||
if (type == AccountSA::OsAccountType::PRIVATE) {
|
||||
HILOGI("GetOsAccountType : OsAccountType is PRIVATE, type : %{public}d", type);
|
||||
DataShareManager::GetInstance().UpdateSwitchStatus(SwitchStatusDependency::GetInstance()
|
||||
|
@ -29,8 +29,6 @@ namespace OHOS {
|
||||
namespace DistributedSchedule {
|
||||
namespace {
|
||||
const std::string TAG = "DMSSwitchStatusDep";
|
||||
const std::string SETTINGS_DATA_URI =
|
||||
"datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true&key=Continue_Switch_Status";
|
||||
}
|
||||
SwitchStatusDependency &SwitchStatusDependency::GetInstance()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user