mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-24 22:21:36 -04:00
fix instance id bug in timetask
Signed-off-by: lushi <lushi@huawei.com> Change-Id: Id18ddaa793e2c7ef17d56b5b552dfb875e3a0902
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#include <fstream>
|
||||
|
||||
#include "native_engine/impl/ark/ark_native_engine.h"
|
||||
#include "core/common/container_scope.h"
|
||||
#include "declarative_module_preloader.h"
|
||||
|
||||
#include "event_handler.h"
|
||||
@@ -175,7 +176,7 @@ NativeValue* CanIUse(NativeEngine* engine, NativeCallbackInfo* info)
|
||||
HILOG_ERROR("Get syscap failed with invalid parameter.");
|
||||
return engine->CreateUndefined();
|
||||
}
|
||||
|
||||
|
||||
char syscap[SYSCAP_MAX_SIZE] = { 0 };
|
||||
|
||||
NativeString* str = ConvertNativeValueTo<NativeString>(info->argv[0]);
|
||||
@@ -186,7 +187,7 @@ NativeValue* CanIUse(NativeEngine* engine, NativeCallbackInfo* info)
|
||||
size_t bufferLen = str->GetLength();
|
||||
size_t strLen = 0;
|
||||
str->GetCString(syscap, bufferLen + 1, &strLen);
|
||||
|
||||
|
||||
bool ret = HasSystemCapability(syscap);
|
||||
return engine->CreateBoolean(ret);
|
||||
}
|
||||
@@ -422,12 +423,15 @@ bool JsRuntime::LoadModuleFile(
|
||||
return true;
|
||||
}
|
||||
|
||||
using OHOS::Ace::ContainerScope;
|
||||
class TimerTask final {
|
||||
public:
|
||||
TimerTask(
|
||||
JsRuntime& jsRuntime, std::shared_ptr<NativeReference> jsFunction, const std::string &name, int64_t interval)
|
||||
: jsRuntime_(jsRuntime), jsFunction_(jsFunction), name_(name), interval_(interval)
|
||||
{}
|
||||
{
|
||||
containerScopeId_ = ContainerScope::CurrentId();
|
||||
}
|
||||
|
||||
~TimerTask() = default;
|
||||
|
||||
@@ -438,6 +442,7 @@ public:
|
||||
}
|
||||
|
||||
// call js function
|
||||
ContainerScope containerScope(containerScopeId_);
|
||||
HandleScope handleScope(jsRuntime_);
|
||||
|
||||
std::vector<NativeValue*> args_;
|
||||
@@ -461,6 +466,7 @@ private:
|
||||
std::vector<std::shared_ptr<NativeReference>> jsArgs_;
|
||||
std::string name_;
|
||||
int64_t interval_ = 0;
|
||||
int32_t containerScopeId_ = 0;
|
||||
};
|
||||
|
||||
void JsRuntime::PostTask(const TimerTask& task, const std::string& name, int64_t delayTime)
|
||||
|
||||
@@ -58,6 +58,7 @@ ohos_shared_library("runtime") {
|
||||
|
||||
deps = [
|
||||
"//ark/js_runtime:libark_jsruntime",
|
||||
"//foundation/ace/ace_engine/frameworks/core:ace_container_scope",
|
||||
"//foundation/ace/ace_engine/interfaces/innerkits/ace:ace_uicontent",
|
||||
"//foundation/ace/napi:ace_napi",
|
||||
"//foundation/ace/napi:ace_napi_ark",
|
||||
|
||||
Reference in New Issue
Block a user