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 <fstream>
|
||||||
|
|
||||||
#include "native_engine/impl/ark/ark_native_engine.h"
|
#include "native_engine/impl/ark/ark_native_engine.h"
|
||||||
|
#include "core/common/container_scope.h"
|
||||||
#include "declarative_module_preloader.h"
|
#include "declarative_module_preloader.h"
|
||||||
|
|
||||||
#include "event_handler.h"
|
#include "event_handler.h"
|
||||||
@@ -175,7 +176,7 @@ NativeValue* CanIUse(NativeEngine* engine, NativeCallbackInfo* info)
|
|||||||
HILOG_ERROR("Get syscap failed with invalid parameter.");
|
HILOG_ERROR("Get syscap failed with invalid parameter.");
|
||||||
return engine->CreateUndefined();
|
return engine->CreateUndefined();
|
||||||
}
|
}
|
||||||
|
|
||||||
char syscap[SYSCAP_MAX_SIZE] = { 0 };
|
char syscap[SYSCAP_MAX_SIZE] = { 0 };
|
||||||
|
|
||||||
NativeString* str = ConvertNativeValueTo<NativeString>(info->argv[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 bufferLen = str->GetLength();
|
||||||
size_t strLen = 0;
|
size_t strLen = 0;
|
||||||
str->GetCString(syscap, bufferLen + 1, &strLen);
|
str->GetCString(syscap, bufferLen + 1, &strLen);
|
||||||
|
|
||||||
bool ret = HasSystemCapability(syscap);
|
bool ret = HasSystemCapability(syscap);
|
||||||
return engine->CreateBoolean(ret);
|
return engine->CreateBoolean(ret);
|
||||||
}
|
}
|
||||||
@@ -422,12 +423,15 @@ bool JsRuntime::LoadModuleFile(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using OHOS::Ace::ContainerScope;
|
||||||
class TimerTask final {
|
class TimerTask final {
|
||||||
public:
|
public:
|
||||||
TimerTask(
|
TimerTask(
|
||||||
JsRuntime& jsRuntime, std::shared_ptr<NativeReference> jsFunction, const std::string &name, int64_t interval)
|
JsRuntime& jsRuntime, std::shared_ptr<NativeReference> jsFunction, const std::string &name, int64_t interval)
|
||||||
: jsRuntime_(jsRuntime), jsFunction_(jsFunction), name_(name), interval_(interval)
|
: jsRuntime_(jsRuntime), jsFunction_(jsFunction), name_(name), interval_(interval)
|
||||||
{}
|
{
|
||||||
|
containerScopeId_ = ContainerScope::CurrentId();
|
||||||
|
}
|
||||||
|
|
||||||
~TimerTask() = default;
|
~TimerTask() = default;
|
||||||
|
|
||||||
@@ -438,6 +442,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// call js function
|
// call js function
|
||||||
|
ContainerScope containerScope(containerScopeId_);
|
||||||
HandleScope handleScope(jsRuntime_);
|
HandleScope handleScope(jsRuntime_);
|
||||||
|
|
||||||
std::vector<NativeValue*> args_;
|
std::vector<NativeValue*> args_;
|
||||||
@@ -461,6 +466,7 @@ private:
|
|||||||
std::vector<std::shared_ptr<NativeReference>> jsArgs_;
|
std::vector<std::shared_ptr<NativeReference>> jsArgs_;
|
||||||
std::string name_;
|
std::string name_;
|
||||||
int64_t interval_ = 0;
|
int64_t interval_ = 0;
|
||||||
|
int32_t containerScopeId_ = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
void JsRuntime::PostTask(const TimerTask& task, const std::string& name, int64_t delayTime)
|
void JsRuntime::PostTask(const TimerTask& task, const std::string& name, int64_t delayTime)
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ ohos_shared_library("runtime") {
|
|||||||
|
|
||||||
deps = [
|
deps = [
|
||||||
"//ark/js_runtime:libark_jsruntime",
|
"//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/ace_engine/interfaces/innerkits/ace:ace_uicontent",
|
||||||
"//foundation/ace/napi:ace_napi",
|
"//foundation/ace/napi:ace_napi",
|
||||||
"//foundation/ace/napi:ace_napi_ark",
|
"//foundation/ace/napi:ace_napi_ark",
|
||||||
|
|||||||
Reference in New Issue
Block a user