This commit is contained in:
helloworldlv
2024-07-26 21:06:28 +08:00
parent 7031e1dd61
commit e34b4b2871
10 changed files with 34 additions and 12 deletions
+1 -1
View File
@@ -21,7 +21,7 @@
#ifdef WIN32
extern void SetNameInternal(unsigned int thread_id, const char* name);
#elif ANDROID || OHOS
#elif defined(ANDROID) || defined(OHOS)
#include <sys/syscall.h>
#include <unistd.h>
#define gettidv1() syscall(__NR_gettid)
+1 -1
View File
@@ -21,7 +21,7 @@
#ifdef WIN32
extern void SetNameInternal(unsigned int thread_id, const char* name);
#elif ANDROID || OHOS
#elif defined(ANDROID) || defined(OHOS)
#include <sys/syscall.h>
#include <unistd.h>
#define gettidv1() syscall(__NR_gettid)
+1 -1
View File
@@ -157,7 +157,7 @@ namespace laya{
LOGI("start thread:%s,%d", m_strName.c_str(), thid);
//threadInfoLog("start thread:%s,%d", m_strName.c_str(), thid);
}
#elif ANDROID || OHOS
#elif defined(ANDROID) || defined(OHOS)
{
LOGI("start thread:%s,%d", m_strName.c_str(), (int)gettidv1());
//threadInfoLog("start thread:%s,%ld", m_strName.c_str(), gettidv1());
+2 -2
View File
@@ -19,7 +19,7 @@
#include <sys/time.h>
#include <time.h>
#include <mach/mach_time.h>
#elif ANDROID || OHOS
#elif defined(ANDROID) || defined(OHOS)
#include <time.h>
#elif WIN32
#include <windows.h>
@@ -660,7 +660,7 @@ namespace laya
int64_t nanosec = mach_absolute_time()*info.numer / info.denom;
return (nanosec / 1e6);
#elif ANDROID || OHOS
#elif defined(ANDROID) || defined(OHOS)
struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
return now.tv_sec * 1000.0 + now.tv_nsec / 1e6;
@@ -77,18 +77,30 @@ namespace laya
break;
}
#else
switch (logLevel)
switch (logLevel)
{
case Warn:
# ifdef OHOS
LOGI(" %{public}s", p_sBuffer);
# else
LOGI(" %s", p_sBuffer);
break;
#endif
break;
case Error:
#ifdef OHOS
LOGI(" %{public}s", p_sBuffer);
#else
LOGI(" %s", p_sBuffer);
#endif
break;
default:
#ifdef OHOS
LOGI(" %{public}s", p_sBuffer);
#else
LOGI(" %s", p_sBuffer);
break;
}
#endif
break;
}
#endif
#ifdef JS_V8
if (gLayaLogNoParam)
+1 -1
View File
@@ -731,7 +731,7 @@ lws_vhost* WebSocket::createVhost(struct lws_protocols* protocols, int& sslConne
{
if (isCAFileExist)
{
#ifdef ANDROID || OHOS
#ifdef defined(ANDROID) || defined(OHOS)
// if ca file is in the apk, try to extract it to writable path
std::string writablePath = gRedistPath;
static std::string newCaFilePath = writablePath + caFileName;
+5
View File
@@ -230,6 +230,10 @@ void NAPIFun::ConchNAPI_handleDeviceOrientationEvent(float ra, float rb, float r
strncpy(e.type, "deviceorientation", 256);
JCScriptRuntime::s_JSRT->dispatchInputEvent(e);
}
void NAPIFun::ConchNAPI_RunJS(const std::string &js)
{
JCScriptRuntime::s_JSRT->callJSString(js);
}
JSBIND_GLOBAL()
{
JSBIND_FUNCTION(NAPIFun::ConchNAPI_configSetParamExt, "ConchNAPI_configSetParamExt");
@@ -252,4 +256,5 @@ JSBIND_GLOBAL()
JSBIND_FUNCTION(NAPIFun::ConchNAPI_captureScreenCallBack, "ConchNAPI_captureScreenCallBack");
JSBIND_FUNCTION(NAPIFun::ConchNAPI_handleDeviceMotionEvent, "ConchNAPI_handleDeviceMotionEvent");
JSBIND_FUNCTION(NAPIFun::ConchNAPI_handleDeviceOrientationEvent, "ConchNAPI_handleDeviceOrientationEvent");
JSBIND_FUNCTION(NAPIFun::ConchNAPI_RunJS, "ConchNAPI_RunJS");
}
+1
View File
@@ -54,6 +54,7 @@ public:
static void ConchNAPI_handleDeviceMotionEvent(float ax,float ay,float az,float agx,float agy,
float agz,float ra,float rb,float rg,float interval);
static void ConchNAPI_handleDeviceOrientationEvent(float ra,float rb,float rg);
static void ConchNAPI_RunJS(const std::string &js);
private:
bool g_bEngineInited =false;
@@ -28,4 +28,5 @@ export const ConchNAPI_SetLocalStoragePath:(p_strLocalStorage: string) => void;
export const ConchNAPI_setLocalizable: (p_bIsLocalPackage: boolean) => void;
export const ConchNAPI_OnAppStart: () => void;
export const ConchNAPI_handleDeviceMotionEvent: (ax: number, ay: number, az: number, agx: number, agy: number, agz: number, ra: number, rb: number, rg: number, interval: number) => void;
export const ConchNAPI_handleDeviceOrientationEvent: (ra: number, rb: number, rg: number) => void;
export const ConchNAPI_handleDeviceOrientationEvent: (ra: number, rb: number, rg: number) => void;
export const ConchNAPI_RunJS: (js: string) => void;
@@ -1,8 +1,11 @@
import { GlobalContext, GlobalContextConstants } from "../common/GlobalContext";
import laya from "liblaya.so";
export default class HandleMessageUtils {
private static context = GlobalContext.loadGlobalThis(GlobalContextConstants.LAYA_ABILITY_CONTEXT);
static RunJS(data: string): void {
laya.ConchNAPI_RunJS(data);
}
/**
*
* @param eventName