privacy mode disable switch

Signed-off-by: dengxiaoyu <dengxiaoyu6@huawei.com>
This commit is contained in:
dengxiaoyu 2024-09-05 15:37:04 +08:00
parent d0dac211e4
commit bed83154cc
12 changed files with 53 additions and 48 deletions

View File

@ -21,15 +21,15 @@
"ohos.permission.INPUT_MONITORING", "ohos.permission.INPUT_MONITORING",
"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"ohos.permission.GET_WIFI_INFO", "ohos.permission.GET_WIFI_INFO",
"ohos.permission.MANAGE_LOCAL_ACCOUNTS",
"ohos.permission.MANAGE_MISSIONS", "ohos.permission.MANAGE_MISSIONS",
"ohos.permission.MANAGE_SECURE_SETTINGS",
"ohos.permission.MANAGE_WIFI_CONNECTION", "ohos.permission.MANAGE_WIFI_CONNECTION",
"ohos.permission.MONITOR_DEVICE_NETWORK_STATE", "ohos.permission.MONITOR_DEVICE_NETWORK_STATE",
"ohos.permission.PUBLISH_SYSTEM_COMMON_EVENT", "ohos.permission.PUBLISH_SYSTEM_COMMON_EVENT",
"ohos.permission.REPORT_RESOURCE_SCHEDULE_EVENT", "ohos.permission.REPORT_RESOURCE_SCHEDULE_EVENT",
"ohos.permission.RUNNING_STATE_OBSERVER", "ohos.permission.RUNNING_STATE_OBSERVER",
"ohos.permission.START_INVISIBLE_ABILITY", "ohos.permission.START_INVISIBLE_ABILITY"
"ohos.permission.MANAGE_LOCAL_ACCOUNTS",
"ohos.permission.MANAGE_SECURE_SETTINGS"
], ],
"permission_acls" : [ "permission_acls" : [
"ohos.permission.INPUT_MONITORING", "ohos.permission.INPUT_MONITORING",

View File

@ -19,9 +19,6 @@
#include "common_event_data.h" #include "common_event_data.h"
#include "common_event_manager.h" #include "common_event_manager.h"
#include "common_event_support.h" #include "common_event_support.h"
#include "datashare_manager.h"
#include "os_account_manager.h"
#include "switch_status_dependency.h"
namespace OHOS { namespace OHOS {
namespace DistributedSchedule { namespace DistributedSchedule {
@ -35,7 +32,6 @@ public:
void OnReceiveEvent(const EventFwk::CommonEventData &eventData); void OnReceiveEvent(const EventFwk::CommonEventData &eventData);
ErrCode GetForegroundOsAccountLocalId(int32_t &accountId); ErrCode GetForegroundOsAccountLocalId(int32_t &accountId);
ErrCode GetOsAccountType(int32_t &accountId); ErrCode GetOsAccountType(int32_t &accountId);
DataShareManager dataShareManager_;
}; };
} // namespace DistributedSchedule } // namespace DistributedSchedule
} // namespace OHOS } // namespace OHOS

View File

@ -20,6 +20,7 @@
#include "datashare_helper.h" #include "datashare_helper.h"
#include "data_ability_observer_stub.h" #include "data_ability_observer_stub.h"
#include "single_instance.h"
namespace OHOS { namespace OHOS {
namespace DistributedSchedule { namespace DistributedSchedule {
@ -41,6 +42,8 @@ private:
}; };
class DataShareManager { class DataShareManager {
DECLARE_SINGLE_INSTANCE(DataShareManager);
public: public:
void RegisterObserver(const std::string &key, SettingObserver::ObserverCallback &observerCallback); void RegisterObserver(const std::string &key, SettingObserver::ObserverCallback &observerCallback);
void UnregisterObserver(const std::string &key); void UnregisterObserver(const std::string &key);
@ -50,7 +53,9 @@ public:
int32_t GetLocalAccountId(); int32_t GetLocalAccountId();
Uri AssembleUserSecureUri(int userId, const std::string& key); Uri AssembleUserSecureUri(int userId, const std::string& key);
void UpdateSwitchStatus(const std::string &key, const std::string &value); void UpdateSwitchStatus(const std::string &key, const std::string &value);
std::atomic<bool> isContinueSwitchOn_ = false; std::atomic<bool> isCurrentContinueSwitchOn_ = true;
bool IsCurrentContinueSwitchOn();
void SetCurrentContinueSwitch(bool status);
private: private:
std::shared_ptr<DataShare::DataShareHelper> CreateDataShareHelper(); std::shared_ptr<DataShare::DataShareHelper> CreateDataShareHelper();

View File

@ -25,7 +25,6 @@
#include <vector> #include <vector>
#include "bundle/bundle_manager_internal.h" #include "bundle/bundle_manager_internal.h"
#include "datashare_manager.h"
#include "distributed_mission_broadcast_listener.h" #include "distributed_mission_broadcast_listener.h"
#include "distributed_mission_died_listener.h" #include "distributed_mission_died_listener.h"
#include "distributed_mission_focused_listener.h" #include "distributed_mission_focused_listener.h"
@ -98,7 +97,6 @@ private:
std::mutex iconMutex_; std::mutex iconMutex_;
std::shared_ptr<OHOS::AppExecFwk::EventHandler> eventHandler_; std::shared_ptr<OHOS::AppExecFwk::EventHandler> eventHandler_;
bool hasRegSoftbusEventListener_ = false; bool hasRegSoftbusEventListener_ = false;
DataShareManager dataShareManager_;
}; };
} // namespace DistributedSchedule } // namespace DistributedSchedule
} // namespace OHOS } // namespace OHOS

View File

@ -25,7 +25,6 @@
#include <vector> #include <vector>
#include "bundle/bundle_manager_internal.h" #include "bundle/bundle_manager_internal.h"
#include "datashare_manager.h"
#include "distributed_mission_died_listener.h" #include "distributed_mission_died_listener.h"
#include "event_handler.h" #include "event_handler.h"
#include "mission_info.h" #include "mission_info.h"
@ -158,7 +157,6 @@ private:
std::shared_ptr<ScreenOffHandler> screenOffHandler_; std::shared_ptr<ScreenOffHandler> screenOffHandler_;
int32_t mmiMonitorId_ = INVALID_MISSION_ID; int32_t mmiMonitorId_ = INVALID_MISSION_ID;
std::map<int32_t, AliveMissionInfo> aliveMission_; std::map<int32_t, AliveMissionInfo> aliveMission_;
DataShareManager dataShareManager_;
}; };
} // namespace DistributedSchedule } // namespace DistributedSchedule
} // namespace OHOS } // namespace OHOS

View File

@ -21,7 +21,6 @@
#include <vector> #include <vector>
#include "json/json.h" #include "json/json.h"
#include "datashare_helper.h" #include "datashare_helper.h"
#include "datashare_manager.h"
namespace OHOS { namespace OHOS {
namespace DistributedSchedule { namespace DistributedSchedule {
@ -45,7 +44,6 @@ private:
const std::string CONTINUE_SWITCH_OFF = "0"; const std::string CONTINUE_SWITCH_OFF = "0";
const std::string CONTINUE_SWITCH_ON = "1"; const std::string CONTINUE_SWITCH_ON = "1";
std::string switchStatus_; std::string switchStatus_;
DataShareManager dataShareManager_;
}; };
} // namespace DistributedSchedule } // namespace DistributedSchedule
} // namespace OHOS } // namespace OHOS

View File

@ -20,7 +20,6 @@
#include "mission/distributed_bm_storage.h" #include "mission/distributed_bm_storage.h"
#include "mission/dms_continue_recv_manager.h" #include "mission/dms_continue_recv_manager.h"
#include "mission/dms_continue_send_manager.h" #include "mission/dms_continue_send_manager.h"
#include "os_account_manager.h"
#include "switch_status_dependency.h" #include "switch_status_dependency.h"
namespace OHOS { namespace OHOS {
@ -45,8 +44,6 @@ std::map<std::string, uint8_t> receiveEvent = {
{EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_CHANGED, PACKAGE_CHANGED}, {EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_CHANGED, PACKAGE_CHANGED},
{EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_REMOVED, PACKAGE_REMOVED}, {EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_REMOVED, PACKAGE_REMOVED},
}; };
const std::string CONTINUE_SWITCH_STATUS_KEY = "Continue_Switch_Status";
const std::string CONTINUE_SWITCH_OFF = "0";
} }
void CommonEventListener::OnReceiveEvent(const EventFwk::CommonEventData &eventData) void CommonEventListener::OnReceiveEvent(const EventFwk::CommonEventData &eventData)
{ {
@ -111,9 +108,10 @@ ErrCode CommonEventListener::GetOsAccountType(int32_t& accountId)
HILOGE("GetOsAccountType passing param invalid or return error!, err : %{public}d", err); HILOGE("GetOsAccountType passing param invalid or return error!, err : %{public}d", err);
return INVALID_PARAMETERS_ERR; return INVALID_PARAMETERS_ERR;
} }
if (type == OsAccountType::PRIVATE) { if (type == AccountSA::OsAccountType::PRIVATE) {
HILOGI("GetOsAccountType : OsAccountType is PRIVATE, type : %{public}d", type); HILOGI("GetOsAccountType : OsAccountType is PRIVATE, type : %{public}d", type);
dataShareManager_.UpdateSwitchStatus(CONTINUE_SWITCH_STATUS_KEY, CONTINUE_SWITCH_OFF); DataShareManger::GetInstance().UpdateSwitchStatus(SwitchStatusDependency::GetInstance()
.CONTINUE_SWITCH_STATUS_KEY, SwitchStatusDependency::GetInstance().CONTINUE_SWITCH_OFF);
} }
return ERR_OK; return ERR_OK;
} }

View File

@ -26,6 +26,7 @@
namespace OHOS { namespace OHOS {
namespace DistributedSchedule { namespace DistributedSchedule {
IMPLEMENT_SINGLE_INSTANCE(DataShareManager);
namespace { namespace {
const std::string TAG = "DMSDataShareManager"; const std::string TAG = "DMSDataShareManager";
const std::string SETTINGS_DATA_URI_PREFIX = const std::string SETTINGS_DATA_URI_PREFIX =
@ -61,11 +62,6 @@ sptr<SettingObserver> DataShareManager::GetSettingObserver(const std::string &ke
return nullptr; return nullptr;
} }
Uri DataShareManager::AssembleUri(const std::string &key)
{
return Uri(SETTINGS_DATA_URI_PREFIX + "&key=" + key);
}
std::shared_ptr<DataShare::DataShareHelper> DataShareManager::CreateDataShareHelper() std::shared_ptr<DataShare::DataShareHelper> DataShareManager::CreateDataShareHelper()
{ {
HILOGI("DataShareManager CreateDataShareHelper start"); HILOGI("DataShareManager CreateDataShareHelper start");
@ -122,6 +118,7 @@ void DataShareManager::UnregisterObserver(const std::string &key)
dataShareHelper->UnregisterObserver(uri, observer); dataShareHelper->UnregisterObserver(uri, observer);
dataShareHelper->Release(); dataShareHelper->Release();
if (observer != nullptr){ if (observer != nullptr){
HILOGI("UnregisterObserver delete observer");
delete observer; delete observer;
} }
std::lock_guard<std::mutex> lockGuard(observerMapMutex_); std::lock_guard<std::mutex> lockGuard(observerMapMutex_);
@ -131,7 +128,7 @@ void DataShareManager::UnregisterObserver(const std::string &key)
Uri DataShareManager::AssembleUserSecureUri(int userId, const std::string &key) Uri DataShareManager::AssembleUserSecureUri(int userId, const std::string &key)
{ {
Uri uri(SETTING_USER_SECURE_URI + "_" + std::to_string(userId) + "?Proxy=true&key" + key); Uri uri(SETTING_USER_SECURE_URI + "_" + std::to_string(userId) + "?Proxy=true&key=" + key);
return uri; return uri;
} }
@ -146,11 +143,11 @@ int32_t DataShareManager::GetLocalAccountId()
return id; return id;
} }
int32_t DataShareManager::UpdateSwitchStatus(const std::string &key, const std::string &value) void DataShareManager::UpdateSwitchStatus(const std::string &key, const std::string &value)
{ {
HILOGI("Start UpdateSwitchStatus"); HILOGI("Start UpdateSwitchStatus");
std::shared_ptr<DataShare::DataShareHelper> dataShareHelper = CreateDataShareHelper(); std::shared_ptr<DataShare::DataShareHelper> dataShareHelper = CreateDataShareHelper();
if ( dataShareHelper == nullptr) { if (dataShareHelper == nullptr) {
HILOGE("dataShareHelper is null, key is %{public}s", key.c_str()); HILOGE("dataShareHelper is null, key is %{public}s", key.c_str());
return; return;
} }
@ -159,19 +156,33 @@ int32_t DataShareManager::UpdateSwitchStatus(const std::string &key, const std::
int32_t userId = GetLocalAccountId(); int32_t userId = GetLocalAccountId();
Uri uri(AssembleUserSecureUri(userId, key)); Uri uri(AssembleUserSecureUri(userId, key));
DataShare::DataSharePredicates predicates; DataShare::DataSharePredicates predicates;
predicates.EqualTo(SETTINGS_DATA_FIELD_KEY, KEY); predicates.EqualTo(SETTINGS_DATA_FIELD_KEY, key);
DataShare::DataShareValuesBucket bucket; DataShare::DataShareValuesBucket bucket;
bucket.Put(SETTINGS_DATA_FIELD_KEY, key); bucket.Put(SETTINGS_DATA_FIELD_KEY, key);
bucket.Put(SETTINGS_DATA_FIELD_VAL, value); bucket.Put(SETTINGS_DATA_FIELD_VAL, value);
auto result = dataShareHelper->UpDateEx(uri, predicates, bucket); auto result = dataShareHelper->UpdateEx(uri, predicates, bucket);
dataShareHelper->Release(); dataShareHelper->Release();
if (result.first != 0) { if (result.first != ERR_OK) {
HILOGE("Updata status failed: %{public}d", result.first); HILOGE("Update status failed: %{public}d", result.first);
} }
HILOGD("Finish UpdateSwitchStatus, Updata status success: %{public}d", result.first); HILOGI("Finish UpdateSwitchStatus, Updata status success: %{public}d", result.first);
return; return;
} }
bool DataShareManager::IsCurrentContinueSwitchOn()
{
HILOGD(IsCurrentContinueSwitchOn start);
return isCurrentContinueSwitchOn_.load();
}
void DataShareManager::SetCurrentContinueSwitch(bool status)
{
HILOGD(SetCurrentContinueSwitch start);
isCurrentContinueSwitchOn_.store(status);
}
} // namespace DistributedSchedule } // namespace DistributedSchedule
} // namespace OHOS } // namespace OHOS

View File

@ -140,7 +140,7 @@ constexpr int32_t DMSDURATION_SRCTODSTRPCTIME = 5;
constexpr int32_t DMSDURATION_STARTABILITY = 6; constexpr int32_t DMSDURATION_STARTABILITY = 6;
constexpr int32_t HID_HAP = 10000; /* first hap user */ constexpr int32_t HID_HAP = 10000; /* first hap user */
constexpr int32_t WINDOW_MANAGER_SERVICE_ID = 4606; 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); IMPLEMENT_SINGLE_INSTANCE(DistributedSchedService);
@ -205,6 +205,7 @@ void DistributedSchedService::OnStop(const SystemAbilityOnDemandReason &stopReas
dlclose(dllHandle_); dlclose(dllHandle_);
dllHandle_ = nullptr; dllHandle_ = nullptr;
#endif #endif
dataShareManager.UnregisterObserver(SwitchStatusDependency::GetInstance().CONTINUE_SWITCH_STATUS_KEY);
HILOGI("OnStop dms service end"); HILOGI("OnStop dms service end");
} }
@ -325,15 +326,15 @@ void DistributedSchedService::OnAddSystemAbility(int32_t systemAbilityId, const
void DistributedSchedService::InitDataShareManager() void DistributedSchedService::InitDataShareManager()
{ {
DataShareManager::ObserverCallback observerCallback = [this]() { DataShareManager::ObserverCallback observerCallback = [this]() {
dataShareManager_.isContinueSwitchOn_.store(SwitchStatusDependency::GetInstance().IsContinueSwitchOn()); dataShareManager.SetCurrentContinueSwitch(SwitchStatusDependency::GetInstance().IsContinueSwitchOn());
HILOGD("dataShareManager_.isContinueSwitchOn_ : %{public}d", dataShareManager_.isContinueSwitchOn_.load()); HILOGD("dataShareManager.IsCurrentContinueSwitchOn : %{public}d", dataShareManager.IsCurrentContinueSwitchOn());
int32_t missionId = GetCurrentMissionId(); int32_t missionId = GetCurrentMissionId();
if (missionId <= 0) { if (missionId <= 0) {
HILOGW("GetCurrentMissionId failed, init end. ret: %{public}d", missionId); HILOGW("GetCurrentMissionId failed, init end. ret: %{public}d", missionId);
return; return;
} }
DmsUE::GetInstance().ChangedSwitchState(dataShareManager_.isContinueSwitchOn_.load(), ERR_OK); DmsUE::GetInstance().ChangedSwitchState(dataShareManager.IsCurrentContinueSwitchOn(), ERR_OK);
if (dataShareManager_.isContinueSwitchOn_.load()) { if (dataShareManager.IsCurrentContinueSwitchOn()) {
DMSContinueSendMgr::GetInstance().NotifyMissionFocused(missionId, FocusedReason::INIT); DMSContinueSendMgr::GetInstance().NotifyMissionFocused(missionId, FocusedReason::INIT);
DSchedContinueManager::GetInstance().Init(); DSchedContinueManager::GetInstance().Init();
} else { } else {
@ -342,7 +343,8 @@ void DistributedSchedService::InitDataShareManager()
DSchedContinueManager::GetInstance().UnInit(); DSchedContinueManager::GetInstance().UnInit();
}; };
}; };
dataShareManager_.RegisterObserver(CONTINUE_SWITCH_STATUS_KEY, observerCallback); dataShareManager.SetCurrentContinueSwitch(SwitchStatusDependency::GetInstance().CONTINUE_SWITCH_STATUS_KEY)
dataShareManager.RegisterObserver(SwitchStatusDependency::GetInstance().CONTINUE_SWITCH_STATUS_KEY, observerCallback);
DmsUE::GetInstance().OriginalSwitchState(SwitchStatusDependency::GetInstance().IsContinueSwitchOn(), ERR_OK); DmsUE::GetInstance().OriginalSwitchState(SwitchStatusDependency::GetInstance().IsContinueSwitchOn(), ERR_OK);
HILOGI("Init data share manager, register observer end."); HILOGI("Init data share manager, register observer end.");
} }
@ -818,7 +820,7 @@ int32_t DistributedSchedService::ContinueLocalMissionDealFreeInstall(OHOS::AAFwk
int32_t DistributedSchedService::ContinueLocalMission(const std::string& dstDeviceId, int32_t missionId, int32_t DistributedSchedService::ContinueLocalMission(const std::string& dstDeviceId, int32_t missionId,
const sptr<IRemoteObject>& callback, const OHOS::AAFwk::WantParams& wantParams) const sptr<IRemoteObject>& callback, const OHOS::AAFwk::WantParams& wantParams)
{ {
if (!dataShareManager_.isContinueSwitchOn_.load()) { if (!dataShareManager.IsCurrentContinueSwitchOn()) {
HILOGE("ContinueSwitch status is off"); HILOGE("ContinueSwitch status is off");
return DMS_PERMISSION_DENIED; return DMS_PERMISSION_DENIED;
} }
@ -894,7 +896,7 @@ int32_t DistributedSchedService::ContinueAbilityWithTimeout(const std::string& d
int32_t DistributedSchedService::ContinueRemoteMission(const std::string& srcDeviceId, const std::string& dstDeviceId, int32_t DistributedSchedService::ContinueRemoteMission(const std::string& srcDeviceId, const std::string& dstDeviceId,
int32_t missionId, const sptr<IRemoteObject>& callback, const OHOS::AAFwk::WantParams& wantParams) int32_t missionId, const sptr<IRemoteObject>& callback, const OHOS::AAFwk::WantParams& wantParams)
{ {
if (!dataShareManager_.isContinueSwitchOn_.load()) { if (!dataShareManager.IsCurrentContinueSwitchOn()) {
HILOGE("ContinueSwitch status is off"); HILOGE("ContinueSwitch status is off");
return DMS_PERMISSION_DENIED; return DMS_PERMISSION_DENIED;
} }
@ -3175,7 +3177,7 @@ int32_t DistributedSchedService::StartLocalAbility(const FreeInstallInfo& info,
int32_t DistributedSchedService::StartAbility(const OHOS::AAFwk::Want& want, int32_t requestCode) int32_t DistributedSchedService::StartAbility(const OHOS::AAFwk::Want& want, int32_t requestCode)
{ {
if (!SwitchStatusDependency::GetInstance().IsContinueSwitchOn()) { if (!dataShareManager.IsCurrentContinueSwitchOn()) {
HILOGE("ContinueSwitch status is off"); HILOGE("ContinueSwitch status is off");
return DMS_PERMISSION_DENIED; return DMS_PERMISSION_DENIED;
} }

View File

@ -93,7 +93,7 @@ void DMSContinueRecvMgr::NotifyDataRecv(std::string& senderNetworkId,
HILOGE("Forbid sending and receiving"); HILOGE("Forbid sending and receiving");
return; return;
} }
if (!dataShareManager_.isContinueSwitchOn_.load()) { if (!DataShareManager::GetInstance().IsCurrentContinueSwitchOn()) {
HILOGE("ContinueSwitch status is off"); HILOGE("ContinueSwitch status is off");
return; return;
} }

View File

@ -45,7 +45,6 @@ constexpr int64_t TIME_DELAYED = 250; // determines whether normal unfocused or
const std::string TAG = "DMSContinueSendMgr"; const std::string TAG = "DMSContinueSendMgr";
const std::string TIMEOUT_UNFOCUSED_TASK = "timeout_unfocused_task"; const std::string TIMEOUT_UNFOCUSED_TASK = "timeout_unfocused_task";
const std::string SCREEN_OFF_UNFOCUSED_TASK = "screen_off_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); IMPLEMENT_SINGLE_INSTANCE(DMSContinueSendMgr);
@ -444,7 +443,7 @@ int32_t DMSContinueSendMgr::SendScreenOffEvent(uint8_t type)
return REMOTE_DEVICE_BIND_ABILITY_ERR; return REMOTE_DEVICE_BIND_ABILITY_ERR;
} }
if (!dataShareManager_.isContinueSwitchOn_.load()) { if (!DataShareManager::GetInstance().IsCurrentContinueSwitchOn()) {
HILOGE("ContinueSwitch status is off"); HILOGE("ContinueSwitch status is off");
return DMS_PERMISSION_DENIED; return DMS_PERMISSION_DENIED;
} }
@ -741,7 +740,7 @@ int32_t DMSContinueSendMgr::SetStateSendEvent(const uint16_t bundleNameId, const
AddMMIListener(); AddMMIListener();
} }
if (!dataShareManager_.isContinueSwitchOn_.load()) { if (!DataShareManager::GetInstance().IsCurrentContinueSwitchOn()) {
HILOGE("ContinueSwitch status is off"); HILOGE("ContinueSwitch status is off");
return DMS_PERMISSION_DENIED; return DMS_PERMISSION_DENIED;
} }

View File

@ -37,6 +37,7 @@ SwitchStatusDependency &SwitchStatusDependency::GetInstance()
static SwitchStatusDependency instance; static SwitchStatusDependency instance;
return instance; return instance;
} }
bool SwitchStatusDependency::IsContinueSwitchOn() bool SwitchStatusDependency::IsContinueSwitchOn()
{ {
HILOGD("IsContinueSwitchOn start"); HILOGD("IsContinueSwitchOn start");
@ -54,8 +55,8 @@ std::string SwitchStatusDependency::GetSwitchStatus(const std::string &key, cons
HILOGE("dataShareHelper is null, key is %{public}s", key.c_str()); HILOGE("dataShareHelper is null, key is %{public}s", key.c_str());
return defaultValue; return defaultValue;
} }
int32_t userId = dataShareManager_.GetLocalAccountId(); int32_t userId = DataShareManager::GetInstance().GetLocalAccountId();
Uri uri(dataShareManager_.AssembleUserSecureUri(userId, key)); Uri uri(DataShareManager::GetInstance().AssembleUserSecureUri(userId, key));
DataShare::DataSharePredicates dataSharePredicates; DataShare::DataSharePredicates dataSharePredicates;
std::vector<std::string> columns; std::vector<std::string> columns;
dataSharePredicates.EqualTo(SETTINGS_DATA_FIELD_KEY, key); dataSharePredicates.EqualTo(SETTINGS_DATA_FIELD_KEY, key);
@ -87,7 +88,6 @@ std::string SwitchStatusDependency::GetSwitchStatus(const std::string &key, cons
} }
resultSet->Close(); resultSet->Close();
dataShareHelper->Release(); 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()); HILOGI("GetStringValue, setting value is %{public}s with key is %{public}s", valueResult.c_str(), key.c_str());
return valueResult; return valueResult;
} }