mirror of
https://gitee.com/openharmony/distributeddatamgr_datamgr_service
synced 2024-11-30 18:40:59 +00:00
feature:add screen unlock event
Signed-off-by: htt1997 <hutao105@huawei.com>
This commit is contained in:
parent
8d39fcc2d2
commit
7a30ea1acd
@ -124,4 +124,12 @@ int32_t FeatureStubImpl::OnSessionReady(const std::string &device)
|
||||
}
|
||||
return featureImpl_->OnSessionReady(device);
|
||||
}
|
||||
|
||||
int32_t FeatureStubImpl::OnScreenUnlocked(int32_t user)
|
||||
{
|
||||
if (featureImpl_ == nullptr) {
|
||||
return -1;
|
||||
}
|
||||
return featureImpl_->OnScreenUnlocked(user);
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ public:
|
||||
int32_t Offline(const std::string &device);
|
||||
int32_t OnReady(const std::string &device);
|
||||
int32_t OnSessionReady(const std::string &device);
|
||||
int32_t OnScreenUnlocked(int32_t user);
|
||||
|
||||
private:
|
||||
std::shared_ptr<FeatureSystem::Feature> featureImpl_;
|
||||
|
@ -60,6 +60,10 @@ void InstallEventSubscriber::OnReceiveEvent(const CommonEventData &event)
|
||||
int32_t appIndex = want.GetIntParam(SANDBOX_APP_INDEX, 0);
|
||||
ZLOGI("bundleName:%{public}s, user:%{public}d, appIndex:%{public}d", bundleName.c_str(), userId, appIndex);
|
||||
(this->*(it->second))(bundleName, userId, appIndex);
|
||||
} else if (action == CommonEventSupport::COMMON_EVENT_SCREEN_UNLOCKED) {
|
||||
int32_t userId = want.GetIntParam(USER_ID, -1);
|
||||
ZLOGI("user:%{public}d ScreenUnlocked", userId);
|
||||
OnScreenUnlocked(userId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,6 +119,11 @@ void InstallEventSubscriber::OnInstall(const std::string &bundleName, int32_t us
|
||||
kvStoreDataService_->OnInstall(bundleName, userId, appIndex);
|
||||
}
|
||||
|
||||
void InstallEventSubscriber::OnScreenUnlocked(int32_t userId)
|
||||
{
|
||||
kvStoreDataService_->OnScreenUnlocked(userId);
|
||||
}
|
||||
|
||||
InstallerImpl::~InstallerImpl()
|
||||
{
|
||||
ZLOGD("destruct");
|
||||
|
@ -36,6 +36,7 @@ private:
|
||||
void OnUninstall(const std::string &bundleName, int32_t userId, int32_t appIndex);
|
||||
void OnUpdate(const std::string &bundleName, int32_t userId, int32_t appIndex);
|
||||
void OnInstall(const std::string &bundleName, int32_t userId, int32_t appIndex);
|
||||
void OnScreenUnlocked(int32_t userId);
|
||||
std::map<std::string, InstallEventCallback> callbacks_;
|
||||
KvStoreDataService *kvStoreDataService_;
|
||||
};
|
||||
|
@ -796,6 +796,15 @@ int32_t KvStoreDataService::OnInstall(const std::string &bundleName, int32_t use
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
int32_t KvStoreDataService::OnScreenUnlocked(int32_t user)
|
||||
{
|
||||
features_.ForEachCopies([user](const auto &key, sptr<DistributedData::FeatureStubImpl> &value) {
|
||||
value->OnScreenUnlocked(user);
|
||||
return false;
|
||||
});
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
int32_t KvStoreDataService::ClearAppStorage(const std::string &bundleName, int32_t userId, int32_t appIndex,
|
||||
int32_t tokenId)
|
||||
{
|
||||
|
@ -118,6 +118,8 @@ public:
|
||||
|
||||
int32_t OnInstall(const std::string &bundleName, int32_t user, int32_t index);
|
||||
|
||||
int32_t OnScreenUnlocked(int32_t user);
|
||||
|
||||
private:
|
||||
void NotifyAccountEvent(const AccountEventInfo &eventInfo);
|
||||
class KvStoreClientDeathObserverImpl {
|
||||
|
@ -125,5 +125,10 @@ int32_t FeatureSystem::Feature::OnBind(const FeatureSystem::Feature::BindInfo &b
|
||||
{
|
||||
return E_OK;
|
||||
}
|
||||
|
||||
int32_t FeatureSystem::Feature::OnScreenUnlocked(int32_t user)
|
||||
{
|
||||
return E_OK;
|
||||
}
|
||||
} // namespace DistributedData
|
||||
} // namespace OHOS
|
@ -56,6 +56,7 @@ public:
|
||||
virtual int32_t Offline(const std::string &device);
|
||||
virtual int32_t OnReady(const std::string &device);
|
||||
virtual int32_t OnSessionReady(const std::string &device);
|
||||
virtual int32_t OnScreenUnlocked(int32_t user);
|
||||
};
|
||||
using Creator = std::function<std::shared_ptr<Feature>()>;
|
||||
static FeatureSystem &GetInstance();
|
||||
|
@ -320,29 +320,19 @@ std::map<std::string, std::vector<std::string>> CloudServiceImpl::GetDbInfoFromE
|
||||
|
||||
bool CloudServiceImpl::DoKvCloudSync(int32_t userId, const std::string &bundleName)
|
||||
{
|
||||
auto dynamicStores = CheckerManager::GetInstance().GetDynamicStores();
|
||||
auto stores = CheckerManager::GetInstance().GetDynamicStores();
|
||||
auto staticStores = CheckerManager::GetInstance().GetStaticStores();
|
||||
stores.insert(stores.end(), staticStores.begin(), staticStores.end());
|
||||
bool found = false;
|
||||
for (auto &dynamicStore : dynamicStores) {
|
||||
if (dynamicStore.bundleName == bundleName) {
|
||||
for (auto &store : stores) {
|
||||
if (store.bundleName == bundleName || bundleName.empty()) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
for (auto &staticStore : staticStores) {
|
||||
if (staticStore.bundleName == bundleName) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
for (auto &dynamicStore : dynamicStores) {
|
||||
syncManager_.DoCloudSync(SyncManager::SyncInfo(userId, dynamicStore.bundleName));
|
||||
}
|
||||
for (auto &staticStore : staticStores) {
|
||||
syncManager_.DoCloudSync(SyncManager::SyncInfo(userId, staticStore.bundleName));
|
||||
for (auto &store : stores) {
|
||||
syncManager_.DoCloudSync(SyncManager::SyncInfo(userId, store.bundleName, store.storeId));
|
||||
}
|
||||
}
|
||||
return found;
|
||||
@ -647,6 +637,12 @@ int32_t CloudServiceImpl::OnUserChange(uint32_t code, const std::string &user, c
|
||||
return E_OK;
|
||||
}
|
||||
|
||||
int32_t CloudServiceImpl::OnScreenUnlocked(int32_t user)
|
||||
{
|
||||
DoKvCloudSync(user);
|
||||
return E_OK;
|
||||
}
|
||||
|
||||
int32_t CloudServiceImpl::OnReady(const std::string& device)
|
||||
{
|
||||
if (device != DeviceManagerAdapter::CLOUD_DEVICE_UUID) {
|
||||
|
@ -67,6 +67,7 @@ public:
|
||||
int32_t OnInitialize() override;
|
||||
int32_t OnBind(const BindInfo &info) override;
|
||||
int32_t OnUserChange(uint32_t code, const std::string &user, const std::string &account) override;
|
||||
int32_t OnScreenUnlocked(int32_t user) override;
|
||||
int32_t OnReady(const std::string &device) override;
|
||||
int32_t Offline(const std::string &device) override;
|
||||
|
||||
@ -157,7 +158,7 @@ private:
|
||||
const DistributedData::ExtraData &extraData, const SchemaMeta &schemaMeta);
|
||||
std::shared_ptr<DistributedData::SharingCenter> GetSharingHandle(const HapInfo& hapInfo);
|
||||
bool GetStoreMetaData(StoreMetaData &meta);
|
||||
bool DoKvCloudSync(int32_t userId, const std::string &bundleName);
|
||||
bool DoKvCloudSync(int32_t userId, const std::string &bundleName = "");
|
||||
|
||||
using SaveStrategy = int32_t (*)(const std::vector<CommonType::Value> &values, const HapInfo &hapInfo);
|
||||
static const SaveStrategy STRATEGY_SAVERS[Strategy::STRATEGY_BUTT];
|
||||
|
Loading…
Reference in New Issue
Block a user