mirror of
https://gitee.com/openharmony/ability_dmsfwk
synced 2024-11-27 00:20:44 +00:00
包信息查询接口优化
Signed-off-by: MisterE <smart_e@126.com>
This commit is contained in:
commit
9b595896cb
@ -23,6 +23,7 @@
|
||||
"ohos.permission.GET_WIFI_INFO",
|
||||
"ohos.permission.MANAGE_LOCAL_ACCOUNTS",
|
||||
"ohos.permission.MANAGE_MISSIONS",
|
||||
"ohos.permission.MANAGE_SECURE_SETTINGS",
|
||||
"ohos.permission.MANAGE_WIFI_CONNECTION",
|
||||
"ohos.permission.MONITOR_DEVICE_NETWORK_STATE",
|
||||
"ohos.permission.PUBLISH_SYSTEM_COMMON_EVENT",
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "common_event_data.h"
|
||||
#include "common_event_manager.h"
|
||||
#include "common_event_support.h"
|
||||
#include "os_account_manager.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedSchedule {
|
||||
@ -30,6 +31,9 @@ public:
|
||||
virtual ~CommonEventListener() = default;
|
||||
|
||||
void OnReceiveEvent(const EventFwk::CommonEventData &eventData);
|
||||
int32_t GetForegroundOsAccountLocalId();
|
||||
AccountSA::OsAccountType GetOsAccountType(int32_t &accountId);
|
||||
void OnUserSwitched();
|
||||
};
|
||||
} // namespace DistributedSchedule
|
||||
} // namespace OHOS
|
||||
|
@ -20,11 +20,10 @@
|
||||
|
||||
#include "datashare_helper.h"
|
||||
#include "data_ability_observer_stub.h"
|
||||
#include "single_instance.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedSchedule {
|
||||
const std::string SETTINGS_DATA_URI =
|
||||
"datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true&key=Continue_Switch_Status";
|
||||
|
||||
class SettingObserver : public AAFwk::DataAbilityObserverStub {
|
||||
public:
|
||||
@ -39,15 +38,23 @@ private:
|
||||
};
|
||||
|
||||
class DataShareManager {
|
||||
DECLARE_SINGLE_INSTANCE(DataShareManager);
|
||||
|
||||
public:
|
||||
void RegisterObserver(const std::string &key, SettingObserver::ObserverCallback &observerCallback);
|
||||
void UnregisterObserver(const std::string &key);
|
||||
|
||||
using ObserverCallback = std::function<void()>;
|
||||
|
||||
int32_t GetLocalAccountId();
|
||||
Uri AssembleUserSecureUri(int userId, const std::string& key);
|
||||
void UpdateSwitchStatus(const std::string &key, const std::string &value);
|
||||
std::atomic<bool> isCurrentContinueSwitchOn_ = true;
|
||||
bool IsCurrentContinueSwitchOn();
|
||||
void SetCurrentContinueSwitch(bool status);
|
||||
|
||||
private:
|
||||
std::shared_ptr<DataShare::DataShareHelper> CreateDataShareHelper();
|
||||
Uri AssembleUri(const std::string &key);
|
||||
sptr<SettingObserver> GetSettingObserver(const std::string &key);
|
||||
|
||||
private:
|
||||
|
@ -350,7 +350,6 @@ private:
|
||||
std::mutex registerMutex_;
|
||||
std::atomic<int32_t> token_ {0};
|
||||
std::map<std::string, sptr<AppStateObserver>> bundleNameMap_;
|
||||
DataShareManager dataShareManager_;
|
||||
sptr<DistributedMissionFocusedListener> missionFocusedListener_ = nullptr;
|
||||
|
||||
#ifdef DMSFWK_INTERACTIVE_ADAPTER
|
||||
|
@ -73,7 +73,7 @@ public:
|
||||
int32_t CloudSync();
|
||||
void FindProvishionInfo(OHOS::sptr<OHOS::AppExecFwk::IBundleMgr> bundleMgr,
|
||||
AppExecFwk::AppProvisionInfo appProvisionInfo, std::vector<AccountSA::OsAccountInfo> accounts,
|
||||
uint32_t result, const std::string& bundleName);
|
||||
int32_t result, const std::string& bundleName);
|
||||
void DmsPutBatch(const std::vector<DmsBundleInfo> &dmsBundleInfos);
|
||||
bool UpdatePublicRecords(const std::string &localUdid);
|
||||
bool DelDataOfLogoutDev(const std::string &udid, const std::string &uuid);
|
||||
|
@ -29,18 +29,18 @@ class SwitchStatusDependency {
|
||||
public:
|
||||
static SwitchStatusDependency &GetInstance();
|
||||
bool IsContinueSwitchOn();
|
||||
|
||||
static const std::string SETTINGS_USER_SECURE_URI;
|
||||
static const std::string SETTINGS_DATA_FIELD_KEY;
|
||||
static const std::string SETTINGS_DATA_FIELD_VAL;
|
||||
static const std::string CONTINUE_SWITCH_STATUS_KEY;
|
||||
static const std::string CONTINUE_SWITCH_OFF;
|
||||
static const std::string CONTINUE_SWITCH_ON;
|
||||
|
||||
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";
|
||||
const std::string SETTINGS_DATA_FIELD_KEY = "KEYWORD";
|
||||
const std::string SETTINGS_DATA_FIELD_VAL = "VALUE";
|
||||
const std::string CONTINUE_SWITCH_STATUS_KEY = "Continue_Switch_Status";
|
||||
const std::string CONTINUE_SWITCH_OFF = "0";
|
||||
const std::string CONTINUE_SWITCH_ON = "1";
|
||||
std::string switchStatus_;
|
||||
};
|
||||
} // namespace DistributedSchedule
|
||||
|
@ -292,7 +292,7 @@ bool BundleManagerInternal::GetAppProvisionInfo4CurrentUser(const std::string &b
|
||||
HILOGE("Get userId from active Os AccountIds fail, ret : %{public}d", ret);
|
||||
return false;
|
||||
}
|
||||
uint32_t result = bundleMgr->GetAppProvisionInfo(bundleName, ids[0], appProvisionInfo);
|
||||
ErrCode result = bundleMgr->GetAppProvisionInfo(bundleName, ids[0], appProvisionInfo);
|
||||
HILOGI("find dst bundle name for diff bundle continue. dst developer id: %{public}s; ",
|
||||
GetAnonymStr(appProvisionInfo.developerId).c_str());
|
||||
return result == ERR_OK;
|
||||
|
@ -15,10 +15,13 @@
|
||||
|
||||
#include "common_event_listener.h"
|
||||
|
||||
#include "datashare_manager.h"
|
||||
#include "dtbschedmgr_log.h"
|
||||
#include "mission/distributed_bm_storage.h"
|
||||
#include "mission/dms_continue_recv_manager.h"
|
||||
#include "mission/dms_continue_send_manager.h"
|
||||
#include "os_account_manager.h"
|
||||
#include "switch_status_dependency.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedSchedule {
|
||||
@ -32,6 +35,7 @@ const uint8_t USER_SWITCHED = 4;
|
||||
const uint8_t PACKAGE_ADDED = 5;
|
||||
const uint8_t PACKAGE_CHANGED = 6;
|
||||
const uint8_t PACKAGE_REMOVED = 7;
|
||||
constexpr static int32_t INVALID_ID = 0;
|
||||
std::map<std::string, uint8_t> receiveEvent = {
|
||||
{EventFwk::CommonEventSupport::COMMON_EVENT_SCREEN_LOCKED, SCREEN_LOCKED},
|
||||
{EventFwk::CommonEventSupport::COMMON_EVENT_SCREEN_OFF, SCREEN_OFF},
|
||||
@ -66,6 +70,7 @@ void CommonEventListener::OnReceiveEvent(const EventFwk::CommonEventData &eventD
|
||||
break;
|
||||
case USER_SWITCHED :
|
||||
HILOGI("USER_SWITCHED");
|
||||
OnUserSwitched();
|
||||
break;
|
||||
case PACKAGE_ADDED :
|
||||
HILOGI("PACKAGE_ADDED: %{public}s", want.GetElement().GetBundleName().c_str());
|
||||
@ -83,5 +88,47 @@ void CommonEventListener::OnReceiveEvent(const EventFwk::CommonEventData &eventD
|
||||
HILOGW("OnReceiveEvent undefined action");
|
||||
}
|
||||
}
|
||||
|
||||
int32_t CommonEventListener::GetForegroundOsAccountLocalId()
|
||||
{
|
||||
int32_t accountId = INVALID_ID;
|
||||
ErrCode err = AccountSA::OsAccountManager::GetForegroundOsAccountLocalId(accountId);
|
||||
if (err != ERR_OK || accountId == INVALID_ID) {
|
||||
HILOGE("GetForegroundOsAccountLocalId passing param invalid or return error!, err : %{public}d", err);
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
}
|
||||
HILOGD("GetForegroundOsAccountLocalId accountId is: %{public}d", accountId);
|
||||
return accountId;
|
||||
}
|
||||
|
||||
AccountSA::OsAccountType 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 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()
|
||||
.CONTINUE_SWITCH_STATUS_KEY, SwitchStatusDependency::GetInstance().CONTINUE_SWITCH_OFF);
|
||||
}
|
||||
|
||||
DataShareManager::GetInstance().SetCurrentContinueSwitch(SwitchStatusDependency::GetInstance()
|
||||
.IsContinueSwitchOn());
|
||||
if (!DataShareManager::GetInstance().IsCurrentContinueSwitchOn()) {
|
||||
DMSContinueRecvMgr::GetInstance().OnContinueSwitchOff();
|
||||
HILOGI("ICurrentContinueSwitch is off, %{public}d", DataShareManager::GetInstance()
|
||||
.IsCurrentContinueSwitchOn());
|
||||
};
|
||||
}
|
||||
} // namespace DistributedSchedule
|
||||
} // namespace OHOS
|
@ -16,17 +16,19 @@
|
||||
#include "datashare_manager.h"
|
||||
|
||||
#include "distributed_sched_utils.h"
|
||||
#include "dsched_continue_manager.h"
|
||||
#include "dtbschedmgr_log.h"
|
||||
#include "mission/dms_continue_recv_manager.h"
|
||||
#include "mission/dms_continue_send_manager.h"
|
||||
#include "os_account_manager.h"
|
||||
#include "switch_status_dependency.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedSchedule {
|
||||
IMPLEMENT_SINGLE_INSTANCE(DataShareManager);
|
||||
namespace {
|
||||
const std::string TAG = "DMSDataShareManager";
|
||||
const std::string SETTINGS_DATA_URI_PREFIX =
|
||||
"datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true";
|
||||
constexpr static int32_t INVALID_ACCOUNT_ID = -1;
|
||||
}
|
||||
SettingObserver::SettingObserver() = default;
|
||||
SettingObserver::~SettingObserver() = default;
|
||||
@ -55,17 +57,12 @@ sptr<SettingObserver> DataShareManager::GetSettingObserver(const std::string &ke
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Uri DataShareManager::AssembleUri(const std::string &key)
|
||||
{
|
||||
return Uri(SETTINGS_DATA_URI_PREFIX + "&key=" + key);
|
||||
}
|
||||
|
||||
std::shared_ptr<DataShare::DataShareHelper> DataShareManager::CreateDataShareHelper()
|
||||
{
|
||||
HILOGI("DataShareManager CreateDataShareHelper start");
|
||||
DataShare::CreateOptions options;
|
||||
options.isProxy_ = true;
|
||||
return DataShare::DataShareHelper::Creator(SETTINGS_DATA_URI_PREFIX, options);
|
||||
return DataShare::DataShareHelper::Creator(SwitchStatusDependency::SETTINGS_USER_SECURE_URI, options);
|
||||
}
|
||||
|
||||
void DataShareManager::RegisterObserver(const std::string &key, SettingObserver::ObserverCallback &observerCallback)
|
||||
@ -81,7 +78,8 @@ void DataShareManager::RegisterObserver(const std::string &key, SettingObserver:
|
||||
HILOGE("Register observer failed, dataShareHelper is null");
|
||||
return;
|
||||
}
|
||||
Uri uri = AssembleUri(key);
|
||||
int32_t userId = GetLocalAccountId();
|
||||
Uri uri(AssembleUserSecureUri(userId, key));
|
||||
sptr<SettingObserver> newObserver(new SettingObserver());
|
||||
observer = newObserver;
|
||||
if (observer == nullptr) {
|
||||
@ -110,7 +108,8 @@ void DataShareManager::UnregisterObserver(const std::string &key)
|
||||
HILOGE("Unregister observer failed with key is %{public}s", key.c_str());
|
||||
return;
|
||||
}
|
||||
Uri uri = AssembleUri(key);
|
||||
int32_t userId = GetLocalAccountId();
|
||||
Uri uri(AssembleUserSecureUri(userId, key));
|
||||
dataShareHelper->UnregisterObserver(uri, observer);
|
||||
dataShareHelper->Release();
|
||||
|
||||
@ -118,5 +117,62 @@ void DataShareManager::UnregisterObserver(const std::string &key)
|
||||
settingObserverMap_.erase(key);
|
||||
HILOGI("DataShareManager UnregisterObserver success with key is %{public}s", key.c_str());
|
||||
}
|
||||
|
||||
Uri DataShareManager::AssembleUserSecureUri(int userId, const std::string &key)
|
||||
{
|
||||
Uri uri(SwitchStatusDependency::SETTINGS_USER_SECURE_URI + "_" + std::to_string(userId) + "?Proxy=true&key=" + key);
|
||||
return uri;
|
||||
}
|
||||
|
||||
int32_t DataShareManager::GetLocalAccountId()
|
||||
{
|
||||
int32_t id = INVALID_ACCOUNT_ID;
|
||||
ErrCode err = AccountSA::OsAccountManager::GetForegroundOsAccountLocalId(id);
|
||||
if (err != ERR_OK || id == INVALID_ACCOUNT_ID) {
|
||||
HILOGE("GetLocalAccountId passing param invalid or return error!, err : %{public}d", err);
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
void DataShareManager::UpdateSwitchStatus(const std::string &key, const std::string &value)
|
||||
{
|
||||
HILOGI("Start UpdateSwitchStatus");
|
||||
std::shared_ptr<DataShare::DataShareHelper> dataShareHelper = CreateDataShareHelper();
|
||||
if (dataShareHelper == nullptr) {
|
||||
HILOGE("dataShareHelper is null, key is %{public}s", key.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
HILOGD("UpdateSwitchStatus key = %{public}s", key.c_str());
|
||||
int32_t userId = GetLocalAccountId();
|
||||
Uri uri(AssembleUserSecureUri(userId, key));
|
||||
DataShare::DataSharePredicates predicates;
|
||||
predicates.EqualTo(SwitchStatusDependency::SETTINGS_DATA_FIELD_KEY, key);
|
||||
|
||||
DataShare::DataShareValuesBucket bucket;
|
||||
bucket.Put(SwitchStatusDependency::SETTINGS_DATA_FIELD_KEY, key);
|
||||
bucket.Put(SwitchStatusDependency::SETTINGS_DATA_FIELD_VAL, value);
|
||||
|
||||
auto result = dataShareHelper->UpdateEx(uri, predicates, bucket);
|
||||
dataShareHelper->Release();
|
||||
if (result.first != ERR_OK) {
|
||||
HILOGE("Update status failed: %{public}d", result.first);
|
||||
}
|
||||
HILOGI("Finish UpdateSwitchStatus, Updata status success: %{public}d", result.first);
|
||||
return;
|
||||
}
|
||||
|
||||
bool DataShareManager::IsCurrentContinueSwitchOn()
|
||||
{
|
||||
HILOGD("IsCurrentContinueSwitchOn start");
|
||||
return isCurrentContinueSwitchOn_.load();
|
||||
}
|
||||
|
||||
void DataShareManager::SetCurrentContinueSwitch(bool status)
|
||||
{
|
||||
HILOGD("SetCurrentContinueSwitch start, status : %{public}d", status);
|
||||
isCurrentContinueSwitchOn_.store(status);
|
||||
}
|
||||
} // namespace DistributedSchedule
|
||||
} // namespace OHOS
|
@ -140,7 +140,7 @@ constexpr int32_t DMSDURATION_SRCTODSTRPCTIME = 5;
|
||||
constexpr int32_t DMSDURATION_STARTABILITY = 6;
|
||||
constexpr int32_t HID_HAP = 10000; /* first hap user */
|
||||
constexpr int32_t WINDOW_MANAGER_SERVICE_ID = 4606;
|
||||
static const std::string CONTINUE_SWITCH_STATUS_KEY = "Continue_Switch_Status";
|
||||
DataShareManager &dataShareManager = DataShareManager::GetInstance();
|
||||
}
|
||||
|
||||
IMPLEMENT_SINGLE_INSTANCE(DistributedSchedService);
|
||||
@ -205,6 +205,7 @@ void DistributedSchedService::OnStop(const SystemAbilityOnDemandReason &stopReas
|
||||
dlclose(dllHandle_);
|
||||
dllHandle_ = nullptr;
|
||||
#endif
|
||||
dataShareManager.UnregisterObserver(SwitchStatusDependency::GetInstance().CONTINUE_SWITCH_STATUS_KEY);
|
||||
HILOGI("OnStop dms service end");
|
||||
}
|
||||
|
||||
@ -325,14 +326,15 @@ void DistributedSchedService::OnAddSystemAbility(int32_t systemAbilityId, const
|
||||
void DistributedSchedService::InitDataShareManager()
|
||||
{
|
||||
DataShareManager::ObserverCallback observerCallback = [this]() {
|
||||
bool IsContinueSwitchOn = SwitchStatusDependency::GetInstance().IsContinueSwitchOn();
|
||||
dataShareManager.SetCurrentContinueSwitch(SwitchStatusDependency::GetInstance().IsContinueSwitchOn());
|
||||
HILOGD("dsMgr IsCurrentContinueSwitchOn : %{public}d", dataShareManager.IsCurrentContinueSwitchOn());
|
||||
int32_t missionId = GetCurrentMissionId();
|
||||
if (missionId <= 0) {
|
||||
HILOGW("GetCurrentMissionId failed, init end. ret: %{public}d", missionId);
|
||||
return;
|
||||
}
|
||||
DmsUE::GetInstance().ChangedSwitchState(IsContinueSwitchOn, ERR_OK);
|
||||
if (IsContinueSwitchOn) {
|
||||
DmsUE::GetInstance().ChangedSwitchState(dataShareManager.IsCurrentContinueSwitchOn(), ERR_OK);
|
||||
if (dataShareManager.IsCurrentContinueSwitchOn()) {
|
||||
DMSContinueSendMgr::GetInstance().NotifyMissionFocused(missionId, FocusedReason::INIT);
|
||||
DSchedContinueManager::GetInstance().Init();
|
||||
} else {
|
||||
@ -341,7 +343,10 @@ void DistributedSchedService::InitDataShareManager()
|
||||
DSchedContinueManager::GetInstance().UnInit();
|
||||
};
|
||||
};
|
||||
dataShareManager_.RegisterObserver(CONTINUE_SWITCH_STATUS_KEY, observerCallback);
|
||||
dataShareManager.SetCurrentContinueSwitch(SwitchStatusDependency::GetInstance().IsContinueSwitchOn());
|
||||
HILOGD("dsMgr IsCurrentContinueSwitchOn : %{public}d", dataShareManager.IsCurrentContinueSwitchOn());
|
||||
dataShareManager.RegisterObserver(SwitchStatusDependency::GetInstance().CONTINUE_SWITCH_STATUS_KEY,
|
||||
observerCallback);
|
||||
DmsUE::GetInstance().OriginalSwitchState(SwitchStatusDependency::GetInstance().IsContinueSwitchOn(), ERR_OK);
|
||||
HILOGI("Init data share manager, register observer end.");
|
||||
}
|
||||
@ -817,8 +822,7 @@ int32_t DistributedSchedService::ContinueLocalMissionDealFreeInstall(OHOS::AAFwk
|
||||
int32_t DistributedSchedService::ContinueLocalMission(const std::string& dstDeviceId, int32_t missionId,
|
||||
const sptr<IRemoteObject>& callback, const OHOS::AAFwk::WantParams& wantParams)
|
||||
{
|
||||
bool IsContinueSwitchOn = SwitchStatusDependency::GetInstance().IsContinueSwitchOn();
|
||||
if (!IsContinueSwitchOn) {
|
||||
if (!dataShareManager.IsCurrentContinueSwitchOn()) {
|
||||
HILOGE("ContinueSwitch status is off");
|
||||
return DMS_PERMISSION_DENIED;
|
||||
}
|
||||
@ -894,7 +898,7 @@ int32_t DistributedSchedService::ContinueAbilityWithTimeout(const std::string& d
|
||||
int32_t DistributedSchedService::ContinueRemoteMission(const std::string& srcDeviceId, const std::string& dstDeviceId,
|
||||
int32_t missionId, const sptr<IRemoteObject>& callback, const OHOS::AAFwk::WantParams& wantParams)
|
||||
{
|
||||
if (!SwitchStatusDependency::GetInstance().IsContinueSwitchOn()) {
|
||||
if (!dataShareManager.IsCurrentContinueSwitchOn()) {
|
||||
HILOGE("ContinueSwitch status is off");
|
||||
return DMS_PERMISSION_DENIED;
|
||||
}
|
||||
@ -3175,7 +3179,7 @@ int32_t DistributedSchedService::StartLocalAbility(const FreeInstallInfo& info,
|
||||
|
||||
int32_t DistributedSchedService::StartAbility(const OHOS::AAFwk::Want& want, int32_t requestCode)
|
||||
{
|
||||
if (!SwitchStatusDependency::GetInstance().IsContinueSwitchOn()) {
|
||||
if (!dataShareManager.IsCurrentContinueSwitchOn()) {
|
||||
HILOGE("ContinueSwitch status is off");
|
||||
return DMS_PERMISSION_DENIED;
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ bool DmsBmStorage::SaveStorageDistributeInfo(const std::string &bundleName, bool
|
||||
|
||||
AppExecFwk::AppProvisionInfo appProvisionInfo;
|
||||
std::vector<AccountSA::OsAccountInfo> accounts;
|
||||
uint32_t result = AccountSA::OsAccountManager::QueryAllCreatedOsAccounts(accounts);
|
||||
ErrCode result = AccountSA::OsAccountManager::QueryAllCreatedOsAccounts(accounts);
|
||||
if (result == ERR_OK && !accounts.empty()) {
|
||||
for (auto &account: accounts) {
|
||||
result = bundleMgr->GetAppProvisionInfo(bundleName, account.GetLocalId(), appProvisionInfo);
|
||||
@ -444,8 +444,9 @@ bool DmsBmStorage::GetDistributedBundleInfo(const std::string &networkId,
|
||||
DelReduData(networkId, reduRiskEntries);
|
||||
return false;
|
||||
}
|
||||
if (remoteEntries.empty()) {
|
||||
if (reduRiskEntries.empty()) {
|
||||
HILOGE("get distributedBundleInfo failed.");
|
||||
return false;
|
||||
}
|
||||
HILOGI("end.");
|
||||
return true;
|
||||
@ -746,7 +747,7 @@ int32_t DmsBmStorage::CloudSync()
|
||||
|
||||
void DmsBmStorage::FindProvishionInfo(OHOS::sptr<OHOS::AppExecFwk::IBundleMgr> bundleMgr,
|
||||
AppExecFwk::AppProvisionInfo appProvisionInfo, std::vector<AccountSA::OsAccountInfo> accounts,
|
||||
uint32_t result, const std::string& bundleName)
|
||||
int32_t result, const std::string& bundleName)
|
||||
{
|
||||
if (result == ERR_OK && !accounts.empty()) {
|
||||
for (auto &account: accounts) {
|
||||
@ -782,7 +783,7 @@ void DmsBmStorage::UpdateDistributedData()
|
||||
|
||||
AppExecFwk::AppProvisionInfo appProvisionInfo;
|
||||
std::vector<AccountSA::OsAccountInfo> accounts;
|
||||
uint32_t result = AccountSA::OsAccountManager::QueryAllCreatedOsAccounts(accounts);
|
||||
int32_t result = AccountSA::OsAccountManager::QueryAllCreatedOsAccounts(accounts);
|
||||
|
||||
std::vector<DmsBundleInfo> dmsBundleInfos;
|
||||
for (const auto &bundleInfo: bundleInfos) {
|
||||
|
@ -98,8 +98,7 @@ void DMSContinueRecvMgr::NotifyDataRecv(std::string& senderNetworkId,
|
||||
HILOGE("Forbid sending and receiving");
|
||||
return;
|
||||
}
|
||||
bool IsContinueSwitchOn = SwitchStatusDependency::GetInstance().IsContinueSwitchOn();
|
||||
if (!IsContinueSwitchOn) {
|
||||
if (!DataShareManager::GetInstance().IsCurrentContinueSwitchOn()) {
|
||||
HILOGE("ContinueSwitch status is off");
|
||||
return;
|
||||
}
|
||||
|
@ -45,7 +45,6 @@ constexpr int64_t TIME_DELAYED = 500; // determines whether normal unfocused or
|
||||
const std::string TAG = "DMSContinueSendMgr";
|
||||
const std::string TIMEOUT_UNFOCUSED_TASK = "timeout_unfocused_task";
|
||||
const std::string SCREEN_OFF_UNFOCUSED_TASK = "screen_off_unfocused_task";
|
||||
static const std::string CONTINUE_SWITCH_STATUS_KEY = "Continue_Switch_Status";
|
||||
}
|
||||
|
||||
IMPLEMENT_SINGLE_INSTANCE(DMSContinueSendMgr);
|
||||
@ -447,8 +446,7 @@ int32_t DMSContinueSendMgr::SendScreenOffEvent(uint8_t type)
|
||||
return REMOTE_DEVICE_BIND_ABILITY_ERR;
|
||||
}
|
||||
|
||||
bool IsContinueSwitchOn = SwitchStatusDependency::GetInstance().IsContinueSwitchOn();
|
||||
if (!IsContinueSwitchOn) {
|
||||
if (!DataShareManager::GetInstance().IsCurrentContinueSwitchOn()) {
|
||||
HILOGE("ContinueSwitch status is off");
|
||||
return DMS_PERMISSION_DENIED;
|
||||
}
|
||||
@ -749,8 +747,7 @@ int32_t DMSContinueSendMgr::SetStateSendEvent(const uint16_t bundleNameId, const
|
||||
AddMMIListener();
|
||||
}
|
||||
|
||||
bool IsContinueSwitchOn = SwitchStatusDependency::GetInstance().IsContinueSwitchOn();
|
||||
if (!IsContinueSwitchOn) {
|
||||
if (!DataShareManager::GetInstance().IsCurrentContinueSwitchOn()) {
|
||||
HILOGE("ContinueSwitch status is off");
|
||||
return DMS_PERMISSION_DENIED;
|
||||
}
|
||||
|
@ -17,26 +17,33 @@
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include "datashare_manager.h"
|
||||
#include "dtbschedmgr_log.h"
|
||||
#include "if_system_ability_manager.h"
|
||||
#include "ipc_skeleton.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "system_ability_definition.h"
|
||||
#include "uri.h"
|
||||
|
||||
#include "dtbschedmgr_log.h"
|
||||
|
||||
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";
|
||||
}
|
||||
const std::string SwitchStatusDependency::SETTINGS_USER_SECURE_URI =
|
||||
"datashare:///com.ohos.settingsdata/entry/settingsdata/USER_SETTINGSDATA_SECURE";
|
||||
const std::string SwitchStatusDependency::SETTINGS_DATA_FIELD_KEY = "KEYWORD";
|
||||
const std::string SwitchStatusDependency::SETTINGS_DATA_FIELD_VAL = "VALUE";
|
||||
const std::string SwitchStatusDependency::CONTINUE_SWITCH_STATUS_KEY = "Continue_Switch_Status";
|
||||
const std::string SwitchStatusDependency::CONTINUE_SWITCH_OFF = "0";
|
||||
const std::string SwitchStatusDependency::CONTINUE_SWITCH_ON = "1";
|
||||
|
||||
SwitchStatusDependency &SwitchStatusDependency::GetInstance()
|
||||
{
|
||||
static SwitchStatusDependency instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
bool SwitchStatusDependency::IsContinueSwitchOn()
|
||||
{
|
||||
HILOGD("IsContinueSwitchOn start");
|
||||
@ -54,7 +61,8 @@ std::string SwitchStatusDependency::GetSwitchStatus(const std::string &key, cons
|
||||
HILOGE("dataShareHelper is null, key is %{public}s", key.c_str());
|
||||
return defaultValue;
|
||||
}
|
||||
Uri uri = Uri(SETTINGS_DATA_URI);
|
||||
int32_t userId = DataShareManager::GetInstance().GetLocalAccountId();
|
||||
Uri uri(DataShareManager::GetInstance().AssembleUserSecureUri(userId, key));
|
||||
DataShare::DataSharePredicates dataSharePredicates;
|
||||
std::vector<std::string> columns;
|
||||
dataSharePredicates.EqualTo(SETTINGS_DATA_FIELD_KEY, key);
|
||||
@ -86,7 +94,6 @@ std::string SwitchStatusDependency::GetSwitchStatus(const std::string &key, cons
|
||||
}
|
||||
resultSet->Close();
|
||||
dataShareHelper->Release();
|
||||
HILOGD("get switch status, query end");
|
||||
HILOGI("GetStringValue, setting value is %{public}s with key is %{public}s", valueResult.c_str(), key.c_str());
|
||||
return valueResult;
|
||||
}
|
||||
@ -96,7 +103,7 @@ std::shared_ptr<DataShare::DataShareHelper> SwitchStatusDependency::GetDataShare
|
||||
HILOGD("create DataShareHelper instance");
|
||||
DataShare::CreateOptions options;
|
||||
options.isProxy_ = true;
|
||||
return DataShare::DataShareHelper::Creator(SETTINGS_DATA_URI, options);
|
||||
return DataShare::DataShareHelper::Creator(SETTINGS_USER_SECURE_URI, options);
|
||||
}
|
||||
} // namespace DistributedSchedule
|
||||
} // namespace OHOS
|
Loading…
Reference in New Issue
Block a user