mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-12-11 18:05:04 +00:00
!205 fix js data ability
Merge pull request !205 from zhanghaibo/master
This commit is contained in:
commit
da6dfb0d0d
@ -102,10 +102,9 @@ void AceDataAbility::OnStop()
|
||||
LOGI("AceDataAbility::OnStop called End");
|
||||
}
|
||||
|
||||
int32_t AceDataAbility::Insert(const Uri& uri, const NativeRdb::ValuesBucket& dummyValue)
|
||||
int32_t AceDataAbility::Insert(const Uri& uri, const NativeRdb::ValuesBucket& value)
|
||||
{
|
||||
LOGI("AceDataAbility::Insert called");
|
||||
OHOS::NativeRdb::ValuesBucket value;
|
||||
int32_t ret = Platform::PaContainer::Insert(abilityId_, uri, value);
|
||||
LOGI("AceDataAbility::Insert called End");
|
||||
return ret;
|
||||
@ -113,41 +112,34 @@ int32_t AceDataAbility::Insert(const Uri& uri, const NativeRdb::ValuesBucket& du
|
||||
|
||||
std::shared_ptr<NativeRdb::AbsSharedResultSet> AceDataAbility::Query(
|
||||
const Uri& uri, const std::vector<std::string>& columns,
|
||||
const NativeRdb::DataAbilityPredicates& dummyPredicates)
|
||||
const NativeRdb::DataAbilityPredicates& predicates)
|
||||
{
|
||||
LOGI("AceDataAbility::Query called");
|
||||
OHOS::NativeRdb::DataAbilityPredicates predicates;
|
||||
auto resultSet = Platform::PaContainer::Query(abilityId_, uri, columns, predicates);
|
||||
(void)resultSet;
|
||||
LOGI("AceDataAbility::Query called End");
|
||||
std::shared_ptr<NativeRdb::AbsSharedResultSet> dummyResultSet;
|
||||
return dummyResultSet;
|
||||
return resultSet;
|
||||
}
|
||||
|
||||
int32_t AceDataAbility::Update(const Uri& uri, const NativeRdb::ValuesBucket& dummyValue,
|
||||
const NativeRdb::DataAbilityPredicates& dummyPredicates)
|
||||
int32_t AceDataAbility::Update(const Uri& uri, const NativeRdb::ValuesBucket& value,
|
||||
const NativeRdb::DataAbilityPredicates& predicates)
|
||||
{
|
||||
LOGI("AceDataAbility::Update called");
|
||||
OHOS::NativeRdb::ValuesBucket value;
|
||||
OHOS::NativeRdb::DataAbilityPredicates predicates;
|
||||
int32_t ret = Platform::PaContainer::Update(abilityId_, uri, value, predicates);
|
||||
LOGI("AceDataAbility::Update called End");
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t AceDataAbility::Delete(const Uri& uri, const NativeRdb::DataAbilityPredicates& dummyPredicates)
|
||||
int32_t AceDataAbility::Delete(const Uri& uri, const NativeRdb::DataAbilityPredicates& predicates)
|
||||
{
|
||||
LOGI("AceDataAbility::Delete called");
|
||||
OHOS::NativeRdb::DataAbilityPredicates predicates;
|
||||
int32_t ret = Platform::PaContainer::Delete(abilityId_, uri, predicates);
|
||||
LOGI("AceDataAbility::Delete called End");
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t AceDataAbility::BatchInsert(const Uri& uri, const std::vector<NativeRdb::ValuesBucket>& dummyValues)
|
||||
int32_t AceDataAbility::BatchInsert(const Uri& uri, const std::vector<NativeRdb::ValuesBucket>& values)
|
||||
{
|
||||
LOGI("AceDataAbility::BatchInsert called");
|
||||
std::vector<OHOS::NativeRdb::ValuesBucket> values;
|
||||
int32_t ret = Platform::PaContainer::BatchInsert(abilityId_, uri, values);
|
||||
LOGI("AceDataAbility::BatchInsert called End");
|
||||
return ret;
|
||||
|
@ -48,6 +48,8 @@
|
||||
#include "frameworks/bridge/js_frontend/engine/common/runtime_constants.h"
|
||||
#include "frameworks/bridge/js_frontend/engine/quickjs/qjs_utils.h"
|
||||
|
||||
#include "napi_common_ability.h"
|
||||
|
||||
namespace OHOS::Ace::Framework {
|
||||
FromBindingData::FromBindingData(JSContext* ctx, JSValue value)
|
||||
{
|
||||
@ -524,11 +526,31 @@ void QjsPaEngine::LoadJs(const std::string& url, const OHOS::AAFwk::Want &want)
|
||||
return;
|
||||
}
|
||||
|
||||
napi_value napiWant = OHOS::AppExecFwk::WrapWant(reinterpret_cast<napi_env>(nativeEngine_), want);
|
||||
NativeValue* nativeWant = reinterpret_cast<NativeValue*>(napiWant);
|
||||
JSValue jsWant = (JSValue)*nativeWant;
|
||||
JSValueConst argv[] = { jsWant };
|
||||
JSValue retVal = QJSUtils::Call(ctx, paStartFunc, paObj, countof(argv), argv);
|
||||
JSValue retVal = JS_UNDEFINED;
|
||||
if (type == BackendType::SERVICE) {
|
||||
JSValueConst argv[] = {};
|
||||
retVal = QJSUtils::Call(ctx, paStartFunc, paObj, countof(argv), argv);
|
||||
} else if (type == BackendType::DATA) {
|
||||
const std::shared_ptr<AppExecFwk::AbilityInfo> abilityInfo =
|
||||
reinterpret_cast<Ability*>(engineInstance_->GetDelegate()->GetAbility())->GetAbilityInfo();
|
||||
const AppExecFwk::AbilityInfo abilityInfoInstance = *(abilityInfo.get());
|
||||
napi_value abilityInfoNapi =
|
||||
AppExecFwk::ConvertAbilityInfo(reinterpret_cast<napi_env>(nativeEngine_), abilityInfoInstance);
|
||||
|
||||
NativeValue* abilityInfoNative = reinterpret_cast<NativeValue*>(abilityInfoNapi);
|
||||
JSValue abilityInfoJS = (JSValue)*abilityInfoNative;
|
||||
JSValueConst argv[] = { abilityInfoJS };
|
||||
retVal = QJSUtils::Call(ctx, paStartFunc, paObj, countof(argv), argv);
|
||||
} else if (type == BackendType::FORM) {
|
||||
napi_value napiWant = OHOS::AppExecFwk::WrapWant(reinterpret_cast<napi_env>(nativeEngine_), want);
|
||||
NativeValue* nativeWant = reinterpret_cast<NativeValue*>(napiWant);
|
||||
JSValue jsWant = (JSValue)*nativeWant;
|
||||
JSValueConst argv[] = { jsWant };
|
||||
retVal = QJSUtils::Call(ctx, paStartFunc, paObj, countof(argv), argv);
|
||||
} else {
|
||||
LOGE("PA: QjsPaEngine backend type not support");
|
||||
}
|
||||
|
||||
if (JS_IsException(retVal)) {
|
||||
LOGE("PA: QjsPaEngine QJSUtils::Call IsException");
|
||||
} else {
|
||||
@ -791,6 +813,7 @@ std::shared_ptr<OHOS::NativeRdb::AbsSharedResultSet> QjsPaEngine::Query(
|
||||
JSValue argColumnsJSValue = (JSValue)*argColumnsNativeValue;
|
||||
|
||||
OHOS::NativeRdb::DataAbilityPredicates* predicatesPtr = new OHOS::NativeRdb::DataAbilityPredicates();
|
||||
*predicatesPtr = predicates;
|
||||
napi_value argPredicatesNapiValue = dataAbilityPredicatesNewInstance_(env, predicatesPtr);
|
||||
NativeValue* argPredicatesNativeValue = reinterpret_cast<NativeValue*>(argPredicatesNapiValue);
|
||||
if (argPredicatesNativeValue == nullptr) {
|
||||
@ -801,7 +824,7 @@ std::shared_ptr<OHOS::NativeRdb::AbsSharedResultSet> QjsPaEngine::Query(
|
||||
|
||||
JSValueConst argv[] = { argUriJSValue, argColumnsJSValue, argPredicatesJSValue };
|
||||
JSValue retVal = QJSUtils::Call(ctx, paFunc, JS_UNDEFINED, countof(argv), argv);
|
||||
if (JS_IsException(retVal)) {
|
||||
if (JS_IsException(retVal) || JS_IsUndefined(retVal)) {
|
||||
LOGE("Qjs paFunc FAILED!");
|
||||
return resultSet;
|
||||
}
|
||||
@ -835,6 +858,7 @@ int32_t QjsPaEngine::Update(const Uri& uri, const OHOS::NativeRdb::ValuesBucket&
|
||||
JSValue argNapiJSValue = (JSValue)*argNapiNativeValue;
|
||||
|
||||
OHOS::NativeRdb::DataAbilityPredicates* predicatesPtr = new OHOS::NativeRdb::DataAbilityPredicates();
|
||||
*predicatesPtr = predicates;
|
||||
napi_value argPredicatesNapiValue = dataAbilityPredicatesNewInstance_(env, predicatesPtr);
|
||||
NativeValue* argPredicatesNativeValue = reinterpret_cast<NativeValue*>(argPredicatesNapiValue);
|
||||
if (argPredicatesNativeValue == nullptr) {
|
||||
@ -865,6 +889,7 @@ int32_t QjsPaEngine::Delete(const Uri& uri, const OHOS::NativeRdb::DataAbilityPr
|
||||
|
||||
napi_env env = reinterpret_cast<napi_env>(nativeEngine_);
|
||||
OHOS::NativeRdb::DataAbilityPredicates* predicatesPtr = new OHOS::NativeRdb::DataAbilityPredicates();
|
||||
*predicatesPtr = predicates;
|
||||
napi_value argPredicatesNapiValue = dataAbilityPredicatesNewInstance_(env, predicatesPtr);
|
||||
NativeValue* argPredicatesNativeValue = reinterpret_cast<NativeValue*>(argPredicatesNapiValue);
|
||||
if (argPredicatesNativeValue == nullptr) {
|
||||
|
Loading…
Reference in New Issue
Block a user