26 auto defaultQAbility = jsState.defaultQAbilityPeer()->qAbility();
27 if (defaultQAbility.IsEmpty()) {
32 jsState.eval<QNapi::Promise>(
33 "@ohos.settings.getValue(*)",
34 {defaultQAbility.get(
"context"), name, domainName})
35 .withContext(std::move(resultConsumer))
36 .onThenWithContext([](
const QtOhos::CallbackInfo &cbInfo,
auto &resultConsumer) {
37 std::string result = cbInfo.getFirstArg<QNapi::String>(Q_FUNC_INFO);
38 resultConsumer(makeQOhosOptional(result));
40 .onCatchWithContext([name, domainName](
const QtOhos::CallbackInfo &,
auto &resultConsumer) {
42 "Got error from @ohos.settings.getValue(..., '%s', '%s').",
43 name.c_str(), domainName.c_str());
44 resultConsumer(makeEmptyQOhosOptional());
101 constexpr auto statusTrueStr =
"true";
102 constexpr auto statusFalseStr =
"false";
104 auto maybeWindowPcModeSwitchStatus = tryGetDataItemValue(
105 windowPcModeSwitchStatusPropertyName, getOhosSettingsUserPropertyDomainName());
107 if (!maybeWindowPcModeSwitchStatus.hasValue()) {
109 "Cannot obtain '%s' property. Assuming it is NOT enabled.",
114 auto windowPcModeSwitchStatus = maybeWindowPcModeSwitchStatus.value();
115 if (windowPcModeSwitchStatus != statusTrueStr && windowPcModeSwitchStatus != statusFalseStr) {
117 "Unexpected value of '%s': %s (expected: '%s' or '%s').",
119 statusTrueStr, statusFalseStr);
122 return windowPcModeSwitchStatus == statusTrueStr;