forked from MeloNX/MeloNX
remove unused class
This commit is contained in:
parent
59c34f10aa
commit
c825ab4d6f
@ -22,6 +22,7 @@ namespace LibRyujinx.Android
|
|||||||
internal unsafe static class Interop
|
internal unsafe static class Interop
|
||||||
{
|
{
|
||||||
internal const string BaseClassName = "org/ryujinx/android/RyujinxNative";
|
internal const string BaseClassName = "org/ryujinx/android/RyujinxNative";
|
||||||
|
|
||||||
private static JGlobalRef? _classId;
|
private static JGlobalRef? _classId;
|
||||||
private static ConcurrentDictionary<(string method, string descriptor), JMethodId> _methodCache = new ConcurrentDictionary<(string method, string descriptor), JMethodId>();
|
private static ConcurrentDictionary<(string method, string descriptor), JMethodId> _methodCache = new ConcurrentDictionary<(string method, string descriptor), JMethodId>();
|
||||||
private static (string name, string descriptor)[] _methods = new[]
|
private static (string name, string descriptor)[] _methods = new[]
|
||||||
|
@ -7,242 +7,245 @@ using System;
|
|||||||
|
|
||||||
using Rxmxnx.PInvoke;
|
using Rxmxnx.PInvoke;
|
||||||
|
|
||||||
namespace LibRyujinx.Jni;
|
namespace LibRyujinx.Jni
|
||||||
|
|
||||||
internal static class JniHelper
|
|
||||||
{
|
{
|
||||||
public const Int32 JniVersion = 0x00010006; //JNI_VERSION_1_6;
|
internal static class JniHelper
|
||||||
|
{
|
||||||
|
public const Int32 JniVersion = 0x00010006; //JNI_VERSION_1_6;
|
||||||
|
|
||||||
public static JEnvRef? Attach(JavaVMRef javaVm, IReadOnlyFixedMemory<Byte> threadName, out Boolean newAttach)
|
public static JEnvRef? Attach(JavaVMRef javaVm, IReadOnlyFixedMemory<Byte> threadName, out Boolean newAttach)
|
||||||
{
|
{
|
||||||
ref JavaVMValue value = ref javaVm.VirtualMachine;
|
ref JavaVMValue value = ref javaVm.VirtualMachine;
|
||||||
ref JInvokeInterface jInvoke = ref value.Functions;
|
ref JInvokeInterface jInvoke = ref value.Functions;
|
||||||
|
|
||||||
IntPtr getEnvPtr = jInvoke.GetEnvPointer;
|
IntPtr getEnvPtr = jInvoke.GetEnvPointer;
|
||||||
GetEnvDelegate getEnv = getEnvPtr.GetUnsafeDelegate<GetEnvDelegate>()!;
|
GetEnvDelegate getEnv = getEnvPtr.GetUnsafeDelegate<GetEnvDelegate>()!;
|
||||||
|
|
||||||
if (getEnv(javaVm, out JEnvRef jEnv, JniHelper.JniVersion) == JResult.Ok)
|
if (getEnv(javaVm, out JEnvRef jEnv, JniHelper.JniVersion) == JResult.Ok)
|
||||||
{
|
{
|
||||||
newAttach = false;
|
newAttach = false;
|
||||||
return jEnv;
|
return jEnv;
|
||||||
}
|
}
|
||||||
|
|
||||||
JavaVMAttachArgs args = new() { Version = JniHelper.JniVersion, Name = threadName.ValuePointer, };
|
JavaVMAttachArgs args = new() { Version = JniHelper.JniVersion, Name = threadName.ValuePointer, };
|
||||||
IntPtr attachCurrentThreadPtr = jInvoke.AttachCurrentThreadPointer;
|
IntPtr attachCurrentThreadPtr = jInvoke.AttachCurrentThreadPointer;
|
||||||
AttachCurrentThreadDelegate attachCurrentThread =
|
AttachCurrentThreadDelegate attachCurrentThread =
|
||||||
attachCurrentThreadPtr.GetUnsafeDelegate<AttachCurrentThreadDelegate>()!;
|
attachCurrentThreadPtr.GetUnsafeDelegate<AttachCurrentThreadDelegate>()!;
|
||||||
|
|
||||||
newAttach = true;
|
newAttach = true;
|
||||||
return attachCurrentThread(javaVm, out jEnv, in args) == JResult.Ok ? jEnv : null;
|
return attachCurrentThread(javaVm, out jEnv, in args) == JResult.Ok ? jEnv : null;
|
||||||
}
|
}
|
||||||
public static JEnvRef? AttachDaemon(JavaVMRef javaVm, IReadOnlyFixedMemory<Byte> daemonName)
|
public static JEnvRef? AttachDaemon(JavaVMRef javaVm, IReadOnlyFixedMemory<Byte> daemonName)
|
||||||
{
|
{
|
||||||
ref JavaVMValue value = ref javaVm.VirtualMachine;
|
ref JavaVMValue value = ref javaVm.VirtualMachine;
|
||||||
ref JInvokeInterface jInvoke = ref value.Functions;
|
ref JInvokeInterface jInvoke = ref value.Functions;
|
||||||
|
|
||||||
JavaVMAttachArgs args = new() { Version = JniHelper.JniVersion, Name = daemonName.ValuePointer, };
|
JavaVMAttachArgs args = new() { Version = JniHelper.JniVersion, Name = daemonName.ValuePointer, };
|
||||||
IntPtr attachCurrentThreadAsDaemonPtr = jInvoke.AttachCurrentThreadAsDaemonPointer;
|
IntPtr attachCurrentThreadAsDaemonPtr = jInvoke.AttachCurrentThreadAsDaemonPointer;
|
||||||
AttachCurrentThreadAsDaemonDelegate attachCurrentThreadAsDaemon =
|
AttachCurrentThreadAsDaemonDelegate attachCurrentThreadAsDaemon =
|
||||||
attachCurrentThreadAsDaemonPtr.GetUnsafeDelegate<AttachCurrentThreadAsDaemonDelegate>()!;
|
attachCurrentThreadAsDaemonPtr.GetUnsafeDelegate<AttachCurrentThreadAsDaemonDelegate>()!;
|
||||||
|
|
||||||
return attachCurrentThreadAsDaemon(javaVm, out JEnvRef jEnv, in args) == JResult.Ok ? jEnv : null;
|
return attachCurrentThreadAsDaemon(javaVm, out JEnvRef jEnv, in args) == JResult.Ok ? jEnv : null;
|
||||||
}
|
}
|
||||||
public static void Detach(JavaVMRef javaVm)
|
public static void Detach(JavaVMRef javaVm)
|
||||||
{
|
{
|
||||||
ref JavaVMValue value = ref javaVm.VirtualMachine;
|
ref JavaVMValue value = ref javaVm.VirtualMachine;
|
||||||
ref JInvokeInterface jInvoke = ref value.Functions;
|
ref JInvokeInterface jInvoke = ref value.Functions;
|
||||||
|
|
||||||
IntPtr detachCurrentThreadPtr = jInvoke.DetachCurrentThreadPointer;
|
IntPtr detachCurrentThreadPtr = jInvoke.DetachCurrentThreadPointer;
|
||||||
DetachCurrentThreadDelegate detachCurrentThread =
|
DetachCurrentThreadDelegate detachCurrentThread =
|
||||||
detachCurrentThreadPtr.GetUnsafeDelegate<DetachCurrentThreadDelegate>()!;
|
detachCurrentThreadPtr.GetUnsafeDelegate<DetachCurrentThreadDelegate>()!;
|
||||||
|
|
||||||
detachCurrentThread(javaVm);
|
detachCurrentThread(javaVm);
|
||||||
}
|
}
|
||||||
public static JGlobalRef? GetGlobalClass(JEnvRef jEnv, IReadOnlyFixedMemory<Byte> className)
|
public static JGlobalRef? GetGlobalClass(JEnvRef jEnv, IReadOnlyFixedMemory<Byte> className)
|
||||||
{
|
{
|
||||||
ref readonly JEnvValue value = ref jEnv.Environment;
|
ref readonly JEnvValue value = ref jEnv.Environment;
|
||||||
ref JNativeInterface jInterface = ref value.Functions;
|
ref JNativeInterface jInterface = ref value.Functions;
|
||||||
|
|
||||||
IntPtr findClassPtr = jInterface.FindClassPointer;
|
IntPtr findClassPtr = jInterface.FindClassPointer;
|
||||||
FindClassDelegate findClass = findClassPtr.GetUnsafeDelegate<FindClassDelegate>()!;
|
FindClassDelegate findClass = findClassPtr.GetUnsafeDelegate<FindClassDelegate>()!;
|
||||||
JClassLocalRef jClass = findClass(jEnv, className.ValuePointer);
|
JClassLocalRef jClass = findClass(jEnv, className.ValuePointer);
|
||||||
|
|
||||||
if (JniHelper.ExceptionCheck(jEnv)) return default;
|
if (JniHelper.ExceptionCheck(jEnv))
|
||||||
|
return default;
|
||||||
|
|
||||||
IntPtr newGlobalRefPtr = jInterface.NewGlobalRefPointer;
|
IntPtr newGlobalRefPtr = jInterface.NewGlobalRefPointer;
|
||||||
NewGlobalRefDelegate newGlobalRef = newGlobalRefPtr.GetUnsafeDelegate<NewGlobalRefDelegate>()!;
|
NewGlobalRefDelegate newGlobalRef = newGlobalRefPtr.GetUnsafeDelegate<NewGlobalRefDelegate>()!;
|
||||||
|
|
||||||
JGlobalRef jGlobal = newGlobalRef(jEnv, (JObjectLocalRef)jClass);
|
JGlobalRef jGlobal = newGlobalRef(jEnv, (JObjectLocalRef)jClass);
|
||||||
JniHelper.RemoveLocal(jEnv, (JObjectLocalRef)jClass);
|
JniHelper.RemoveLocal(jEnv, (JObjectLocalRef)jClass);
|
||||||
|
|
||||||
return !JniHelper.ExceptionCheck(jEnv) ? jGlobal : null;
|
return !JniHelper.ExceptionCheck(jEnv) ? jGlobal : null;
|
||||||
|
}
|
||||||
|
public static void RemoveLocal(JEnvRef jEnv, JObjectLocalRef jObject)
|
||||||
|
{
|
||||||
|
ref readonly JEnvValue value = ref jEnv.Environment;
|
||||||
|
ref JNativeInterface jInterface = ref value.Functions;
|
||||||
|
|
||||||
|
IntPtr deleteLocalRefPtr = jInterface.DeleteLocalRefPointer;
|
||||||
|
DeleteLocalRefDelegate deleteLocalRef = deleteLocalRefPtr.GetUnsafeDelegate<DeleteLocalRefDelegate>()!;
|
||||||
|
|
||||||
|
deleteLocalRef(jEnv, jObject);
|
||||||
|
}
|
||||||
|
public static void RemoveGlobal(JEnvRef jEnv, JGlobalRef jObject)
|
||||||
|
{
|
||||||
|
ref readonly JEnvValue value = ref jEnv.Environment;
|
||||||
|
ref JNativeInterface jInterface = ref value.Functions;
|
||||||
|
|
||||||
|
IntPtr deleteGlobalRefPtr = jInterface.DeleteGlobalRefPointer;
|
||||||
|
DeleteGlobalRefDelegate deleteGlobalRef = deleteGlobalRefPtr.GetUnsafeDelegate<DeleteGlobalRefDelegate>()!;
|
||||||
|
|
||||||
|
deleteGlobalRef(jEnv, jObject);
|
||||||
|
}
|
||||||
|
public static void RemoveWeakGlobal(JEnvRef jEnv, JWeakRef jObject)
|
||||||
|
{
|
||||||
|
ref readonly JEnvValue value = ref jEnv.Environment;
|
||||||
|
ref JNativeInterface jInterface = ref value.Functions;
|
||||||
|
|
||||||
|
IntPtr deleteWeakGlobalRefPtr = jInterface.DeleteWeakGlobalRefPointer;
|
||||||
|
DeleteWeakGlobalRefDelegate deleteWeakGlobalRef =
|
||||||
|
deleteWeakGlobalRefPtr.GetUnsafeDelegate<DeleteWeakGlobalRefDelegate>()!;
|
||||||
|
|
||||||
|
deleteWeakGlobalRef(jEnv, jObject);
|
||||||
|
}
|
||||||
|
public static JStringLocalRef? CreateString(JEnvRef jEnv, String textValue)
|
||||||
|
{
|
||||||
|
ref readonly JEnvValue value = ref jEnv.Environment;
|
||||||
|
ref JNativeInterface jInterface = ref value.Functions;
|
||||||
|
|
||||||
|
IntPtr newStringPtr = jInterface.NewStringPointer;
|
||||||
|
NewStringDelegate newString = newStringPtr.GetUnsafeDelegate<NewStringDelegate>()!;
|
||||||
|
using IReadOnlyFixedMemory<Char>.IDisposable ctx = textValue.AsMemory().GetFixedContext();
|
||||||
|
JStringLocalRef jString = newString(jEnv, ctx.ValuePointer, ctx.Values.Length);
|
||||||
|
|
||||||
|
return !JniHelper.ExceptionCheck(jEnv) ? jString : null;
|
||||||
|
}
|
||||||
|
public static JWeakRef? CreateWeakGlobal(JEnvRef jEnv, JObjectLocalRef jObject)
|
||||||
|
{
|
||||||
|
ref readonly JEnvValue value = ref jEnv.Environment;
|
||||||
|
ref JNativeInterface jInterface = ref value.Functions;
|
||||||
|
|
||||||
|
IntPtr newWeakGlobalRefPtr = jInterface.NewWeakGlobalRefPointer;
|
||||||
|
NewWeakGlobalRefDelegate newWeakGlobalRef = newWeakGlobalRefPtr.GetUnsafeDelegate<NewWeakGlobalRefDelegate>()!;
|
||||||
|
JWeakRef jWeak = newWeakGlobalRef(jEnv, jObject);
|
||||||
|
|
||||||
|
return !JniHelper.ExceptionCheck(jEnv) ? jWeak : null;
|
||||||
|
}
|
||||||
|
private static Boolean ExceptionCheck(JEnvRef jEnv)
|
||||||
|
{
|
||||||
|
ref readonly JEnvValue value = ref jEnv.Environment;
|
||||||
|
ref JNativeInterface jInterface = ref value.Functions;
|
||||||
|
|
||||||
|
IntPtr exceptionCheckPtr = jInterface.ExceptionCheckPointer;
|
||||||
|
ExceptionCheckDelegate exceptionCheck = exceptionCheckPtr.GetUnsafeDelegate<ExceptionCheckDelegate>()!;
|
||||||
|
|
||||||
|
if (!exceptionCheck(jEnv))
|
||||||
|
return false;
|
||||||
|
IntPtr exceptionDescribePtr = jInterface.ExceptionDescribePointer;
|
||||||
|
IntPtr exceptionClearPtr = jInterface.ExceptionClearPointer;
|
||||||
|
|
||||||
|
ExceptionDescribeDelegate exceptionDescribe =
|
||||||
|
exceptionDescribePtr.GetUnsafeDelegate<ExceptionDescribeDelegate>()!;
|
||||||
|
ExceptionClearDelegate exceptionClear = exceptionClearPtr.GetUnsafeDelegate<ExceptionClearDelegate>()!;
|
||||||
|
|
||||||
|
exceptionDescribe(jEnv);
|
||||||
|
exceptionClear(jEnv);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public static JavaVMRef? GetVirtualMachine(JEnvRef jEnv)
|
||||||
|
{
|
||||||
|
ref readonly JEnvValue value = ref jEnv.Environment;
|
||||||
|
ref JNativeInterface jInterface = ref value.Functions;
|
||||||
|
|
||||||
|
IntPtr getJavaVmPtr = jInterface.GetJavaVMPointer;
|
||||||
|
GetVirtualMachineDelegate getJavaVm = getJavaVmPtr.GetUnsafeDelegate<GetVirtualMachineDelegate>()!;
|
||||||
|
return getJavaVm(jEnv, out JavaVMRef javaVm) == JResult.Ok ? javaVm : null;
|
||||||
|
}
|
||||||
|
public static Boolean? IsValidGlobalWeak(JEnvRef jEnv, JWeakRef jWeak)
|
||||||
|
{
|
||||||
|
ref readonly JEnvValue value = ref jEnv.Environment;
|
||||||
|
ref JNativeInterface jInterface = ref value.Functions;
|
||||||
|
|
||||||
|
IntPtr isSameObjectPtr = jInterface.IsSameObjectPointer;
|
||||||
|
IsSameObjectDelegate isSameObject = isSameObjectPtr.GetUnsafeDelegate<IsSameObjectDelegate>()!;
|
||||||
|
JBoolean result = isSameObject(jEnv, (JObjectLocalRef)jWeak, default);
|
||||||
|
return !JniHelper.ExceptionCheck(jEnv) ? !result : null;
|
||||||
|
}
|
||||||
|
public static JMethodId? GetMethodId(JEnvRef jEnv, JClassLocalRef jClass, IReadOnlyFixedMemory<Byte> methodName,
|
||||||
|
IReadOnlyFixedMemory<Byte> descriptor)
|
||||||
|
{
|
||||||
|
ref readonly JEnvValue value = ref jEnv.Environment;
|
||||||
|
ref JNativeInterface jInterface = ref value.Functions;
|
||||||
|
|
||||||
|
IntPtr getMethodIdPtr = jInterface.GetMethodIdPointer;
|
||||||
|
GetMethodIdDelegate getMethodId = getMethodIdPtr.GetUnsafeDelegate<GetMethodIdDelegate>()!;
|
||||||
|
JMethodId methodId = getMethodId(jEnv, jClass, methodName.ValuePointer, descriptor.ValuePointer);
|
||||||
|
return !JniHelper.ExceptionCheck(jEnv) ? methodId : null;
|
||||||
|
}
|
||||||
|
public static JMethodId? GetStaticMethodId(JEnvRef jEnv, JClassLocalRef jClass,
|
||||||
|
IReadOnlyFixedMemory<Byte> methodName, IReadOnlyFixedMemory<Byte> descriptor)
|
||||||
|
{
|
||||||
|
ref readonly JEnvValue value = ref jEnv.Environment;
|
||||||
|
ref JNativeInterface jInterface = ref value.Functions;
|
||||||
|
|
||||||
|
IntPtr getStaticMethodIdPtr = jInterface.GetStaticMethodIdPointer;
|
||||||
|
GetStaticMethodIdDelegate getStaticMethodId =
|
||||||
|
getStaticMethodIdPtr.GetUnsafeDelegate<GetStaticMethodIdDelegate>()!;
|
||||||
|
JMethodId jMethodId = getStaticMethodId(jEnv, jClass, methodName.ValuePointer, descriptor.ValuePointer);
|
||||||
|
return !JniHelper.ExceptionCheck(jEnv) ? jMethodId : null;
|
||||||
|
}
|
||||||
|
public static void CallStaticVoidMethod(JEnvRef jEnv, JClassLocalRef jClass, JMethodId jMethodId,
|
||||||
|
params JValue[] args)
|
||||||
|
{
|
||||||
|
ref readonly JEnvValue value = ref jEnv.Environment;
|
||||||
|
ref JNativeInterface jInterface = ref value.Functions;
|
||||||
|
|
||||||
|
IntPtr callStaticVoidMethodPtr = jInterface.CallStaticVoidMethodAPointer;
|
||||||
|
CallStaticVoidMethodADelegate callStaticVoidMethod =
|
||||||
|
callStaticVoidMethodPtr.GetUnsafeDelegate<CallStaticVoidMethodADelegate>()!;
|
||||||
|
|
||||||
|
using IReadOnlyFixedMemory<JValue>.IDisposable fArgs = args.AsMemory().GetFixedContext();
|
||||||
|
callStaticVoidMethod(jEnv, jClass, jMethodId, fArgs.ValuePointer);
|
||||||
|
}
|
||||||
|
public static JObjectLocalRef? CallStaticObjectMethod(JEnvRef jEnv, JClassLocalRef jClass, JMethodId jMethodId,
|
||||||
|
params JValue[] args)
|
||||||
|
{
|
||||||
|
ref readonly JEnvValue value = ref jEnv.Environment;
|
||||||
|
ref JNativeInterface jInterface = ref value.Functions;
|
||||||
|
|
||||||
|
IntPtr callStaticObjectMethodPtr = jInterface.CallStaticObjectMethodAPointer;
|
||||||
|
CallStaticObjectMethodADelegate callStaticObjectMethod =
|
||||||
|
callStaticObjectMethodPtr.GetUnsafeDelegate<CallStaticObjectMethodADelegate>()!;
|
||||||
|
|
||||||
|
using IReadOnlyFixedMemory<JValue>.IDisposable fArgs = args.AsMemory().GetFixedContext();
|
||||||
|
JObjectLocalRef jObject = callStaticObjectMethod(jEnv, jClass, jMethodId, fArgs.ValuePointer);
|
||||||
|
return !JniHelper.ExceptionCheck(jEnv) ? jObject : null;
|
||||||
|
}
|
||||||
|
public static JLong? CallStaticLongMethod(JEnvRef jEnv, JClassLocalRef jClass, JMethodId jMethodId,
|
||||||
|
params JValue[] args)
|
||||||
|
{
|
||||||
|
ref readonly JEnvValue value = ref jEnv.Environment;
|
||||||
|
ref JNativeInterface jInterface = ref value.Functions;
|
||||||
|
|
||||||
|
IntPtr callStaticLongMethodPtr = jInterface.CallStaticLongMethodAPointer;
|
||||||
|
CallStaticLongMethodADelegate callStaticLongMethod =
|
||||||
|
callStaticLongMethodPtr.GetUnsafeDelegate<CallStaticLongMethodADelegate>()!;
|
||||||
|
|
||||||
|
using IReadOnlyFixedMemory<JValue>.IDisposable fArgs = args.AsMemory().GetFixedContext();
|
||||||
|
JLong jLong = callStaticLongMethod(jEnv, jClass, jMethodId, fArgs.ValuePointer);
|
||||||
|
return !JniHelper.ExceptionCheck(jEnv) ? jLong : null;
|
||||||
|
}
|
||||||
|
public static void CallVoidMethod(JEnvRef jEnv, JObjectLocalRef jObject, JMethodId jMethodId, params JValue[] args)
|
||||||
|
{
|
||||||
|
ref readonly JEnvValue value = ref jEnv.Environment;
|
||||||
|
ref JNativeInterface jInterface = ref value.Functions;
|
||||||
|
|
||||||
|
IntPtr callVoidMethodPtr = jInterface.CallVoidMethodAPointer;
|
||||||
|
CallVoidMethodADelegate callVoidMethod = callVoidMethodPtr.GetUnsafeDelegate<CallVoidMethodADelegate>()!;
|
||||||
|
|
||||||
|
using IReadOnlyFixedMemory<JValue>.IDisposable fArgs = args.AsMemory().GetFixedContext();
|
||||||
|
callVoidMethod(jEnv, jObject, jMethodId, fArgs.ValuePointer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public static void RemoveLocal(JEnvRef jEnv, JObjectLocalRef jObject)
|
|
||||||
{
|
|
||||||
ref readonly JEnvValue value = ref jEnv.Environment;
|
|
||||||
ref JNativeInterface jInterface = ref value.Functions;
|
|
||||||
|
|
||||||
IntPtr deleteLocalRefPtr = jInterface.DeleteLocalRefPointer;
|
|
||||||
DeleteLocalRefDelegate deleteLocalRef = deleteLocalRefPtr.GetUnsafeDelegate<DeleteLocalRefDelegate>()!;
|
|
||||||
|
|
||||||
deleteLocalRef(jEnv, jObject);
|
|
||||||
}
|
|
||||||
public static void RemoveGlobal(JEnvRef jEnv, JGlobalRef jObject)
|
|
||||||
{
|
|
||||||
ref readonly JEnvValue value = ref jEnv.Environment;
|
|
||||||
ref JNativeInterface jInterface = ref value.Functions;
|
|
||||||
|
|
||||||
IntPtr deleteGlobalRefPtr = jInterface.DeleteGlobalRefPointer;
|
|
||||||
DeleteGlobalRefDelegate deleteGlobalRef = deleteGlobalRefPtr.GetUnsafeDelegate<DeleteGlobalRefDelegate>()!;
|
|
||||||
|
|
||||||
deleteGlobalRef(jEnv, jObject);
|
|
||||||
}
|
|
||||||
public static void RemoveWeakGlobal(JEnvRef jEnv, JWeakRef jObject)
|
|
||||||
{
|
|
||||||
ref readonly JEnvValue value = ref jEnv.Environment;
|
|
||||||
ref JNativeInterface jInterface = ref value.Functions;
|
|
||||||
|
|
||||||
IntPtr deleteWeakGlobalRefPtr = jInterface.DeleteWeakGlobalRefPointer;
|
|
||||||
DeleteWeakGlobalRefDelegate deleteWeakGlobalRef =
|
|
||||||
deleteWeakGlobalRefPtr.GetUnsafeDelegate<DeleteWeakGlobalRefDelegate>()!;
|
|
||||||
|
|
||||||
deleteWeakGlobalRef(jEnv, jObject);
|
|
||||||
}
|
|
||||||
public static JStringLocalRef? CreateString(JEnvRef jEnv, String textValue)
|
|
||||||
{
|
|
||||||
ref readonly JEnvValue value = ref jEnv.Environment;
|
|
||||||
ref JNativeInterface jInterface = ref value.Functions;
|
|
||||||
|
|
||||||
IntPtr newStringPtr = jInterface.NewStringPointer;
|
|
||||||
NewStringDelegate newString = newStringPtr.GetUnsafeDelegate<NewStringDelegate>()!;
|
|
||||||
using IReadOnlyFixedMemory<Char>.IDisposable ctx = textValue.AsMemory().GetFixedContext();
|
|
||||||
JStringLocalRef jString = newString(jEnv, ctx.ValuePointer, ctx.Values.Length);
|
|
||||||
|
|
||||||
return !JniHelper.ExceptionCheck(jEnv) ? jString : null;
|
|
||||||
}
|
|
||||||
public static JWeakRef? CreateWeakGlobal(JEnvRef jEnv, JObjectLocalRef jObject)
|
|
||||||
{
|
|
||||||
ref readonly JEnvValue value = ref jEnv.Environment;
|
|
||||||
ref JNativeInterface jInterface = ref value.Functions;
|
|
||||||
|
|
||||||
IntPtr newWeakGlobalRefPtr = jInterface.NewWeakGlobalRefPointer;
|
|
||||||
NewWeakGlobalRefDelegate newWeakGlobalRef = newWeakGlobalRefPtr.GetUnsafeDelegate<NewWeakGlobalRefDelegate>()!;
|
|
||||||
JWeakRef jWeak = newWeakGlobalRef(jEnv, jObject);
|
|
||||||
|
|
||||||
return !JniHelper.ExceptionCheck(jEnv) ? jWeak : null;
|
|
||||||
}
|
|
||||||
private static Boolean ExceptionCheck(JEnvRef jEnv)
|
|
||||||
{
|
|
||||||
ref readonly JEnvValue value = ref jEnv.Environment;
|
|
||||||
ref JNativeInterface jInterface = ref value.Functions;
|
|
||||||
|
|
||||||
IntPtr exceptionCheckPtr = jInterface.ExceptionCheckPointer;
|
|
||||||
ExceptionCheckDelegate exceptionCheck = exceptionCheckPtr.GetUnsafeDelegate<ExceptionCheckDelegate>()!;
|
|
||||||
|
|
||||||
if (!exceptionCheck(jEnv)) return false;
|
|
||||||
IntPtr exceptionDescribePtr = jInterface.ExceptionDescribePointer;
|
|
||||||
IntPtr exceptionClearPtr = jInterface.ExceptionClearPointer;
|
|
||||||
|
|
||||||
ExceptionDescribeDelegate exceptionDescribe =
|
|
||||||
exceptionDescribePtr.GetUnsafeDelegate<ExceptionDescribeDelegate>()!;
|
|
||||||
ExceptionClearDelegate exceptionClear = exceptionClearPtr.GetUnsafeDelegate<ExceptionClearDelegate>()!;
|
|
||||||
|
|
||||||
exceptionDescribe(jEnv);
|
|
||||||
exceptionClear(jEnv);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public static JavaVMRef? GetVirtualMachine(JEnvRef jEnv)
|
|
||||||
{
|
|
||||||
ref readonly JEnvValue value = ref jEnv.Environment;
|
|
||||||
ref JNativeInterface jInterface = ref value.Functions;
|
|
||||||
|
|
||||||
IntPtr getJavaVmPtr = jInterface.GetJavaVMPointer;
|
|
||||||
GetVirtualMachineDelegate getJavaVm = getJavaVmPtr.GetUnsafeDelegate<GetVirtualMachineDelegate>()!;
|
|
||||||
return getJavaVm(jEnv, out JavaVMRef javaVm) == JResult.Ok ? javaVm : null;
|
|
||||||
}
|
|
||||||
public static Boolean? IsValidGlobalWeak(JEnvRef jEnv, JWeakRef jWeak)
|
|
||||||
{
|
|
||||||
ref readonly JEnvValue value = ref jEnv.Environment;
|
|
||||||
ref JNativeInterface jInterface = ref value.Functions;
|
|
||||||
|
|
||||||
IntPtr isSameObjectPtr = jInterface.IsSameObjectPointer;
|
|
||||||
IsSameObjectDelegate isSameObject = isSameObjectPtr.GetUnsafeDelegate<IsSameObjectDelegate>()!;
|
|
||||||
JBoolean result = isSameObject(jEnv, (JObjectLocalRef)jWeak, default);
|
|
||||||
return !JniHelper.ExceptionCheck(jEnv) ? !result : null;
|
|
||||||
}
|
|
||||||
public static JMethodId? GetMethodId(JEnvRef jEnv, JClassLocalRef jClass, IReadOnlyFixedMemory<Byte> methodName,
|
|
||||||
IReadOnlyFixedMemory<Byte> descriptor)
|
|
||||||
{
|
|
||||||
ref readonly JEnvValue value = ref jEnv.Environment;
|
|
||||||
ref JNativeInterface jInterface = ref value.Functions;
|
|
||||||
|
|
||||||
IntPtr getMethodIdPtr = jInterface.GetMethodIdPointer;
|
|
||||||
GetMethodIdDelegate getMethodId = getMethodIdPtr.GetUnsafeDelegate<GetMethodIdDelegate>()!;
|
|
||||||
JMethodId methodId = getMethodId(jEnv, jClass, methodName.ValuePointer, descriptor.ValuePointer);
|
|
||||||
return !JniHelper.ExceptionCheck(jEnv) ? methodId : null;
|
|
||||||
}
|
|
||||||
public static JMethodId? GetStaticMethodId(JEnvRef jEnv, JClassLocalRef jClass,
|
|
||||||
IReadOnlyFixedMemory<Byte> methodName, IReadOnlyFixedMemory<Byte> descriptor)
|
|
||||||
{
|
|
||||||
ref readonly JEnvValue value = ref jEnv.Environment;
|
|
||||||
ref JNativeInterface jInterface = ref value.Functions;
|
|
||||||
|
|
||||||
IntPtr getStaticMethodIdPtr = jInterface.GetStaticMethodIdPointer;
|
|
||||||
GetStaticMethodIdDelegate getStaticMethodId =
|
|
||||||
getStaticMethodIdPtr.GetUnsafeDelegate<GetStaticMethodIdDelegate>()!;
|
|
||||||
JMethodId jMethodId = getStaticMethodId(jEnv, jClass, methodName.ValuePointer, descriptor.ValuePointer);
|
|
||||||
return !JniHelper.ExceptionCheck(jEnv) ? jMethodId : null;
|
|
||||||
}
|
|
||||||
public static void CallStaticVoidMethod(JEnvRef jEnv, JClassLocalRef jClass, JMethodId jMethodId,
|
|
||||||
params JValue[] args)
|
|
||||||
{
|
|
||||||
ref readonly JEnvValue value = ref jEnv.Environment;
|
|
||||||
ref JNativeInterface jInterface = ref value.Functions;
|
|
||||||
|
|
||||||
IntPtr callStaticVoidMethodPtr = jInterface.CallStaticVoidMethodAPointer;
|
|
||||||
CallStaticVoidMethodADelegate callStaticVoidMethod =
|
|
||||||
callStaticVoidMethodPtr.GetUnsafeDelegate<CallStaticVoidMethodADelegate>()!;
|
|
||||||
|
|
||||||
using IReadOnlyFixedMemory<JValue>.IDisposable fArgs = args.AsMemory().GetFixedContext();
|
|
||||||
callStaticVoidMethod(jEnv, jClass, jMethodId, fArgs.ValuePointer);
|
|
||||||
}
|
|
||||||
public static JObjectLocalRef? CallStaticObjectMethod(JEnvRef jEnv, JClassLocalRef jClass, JMethodId jMethodId,
|
|
||||||
params JValue[] args)
|
|
||||||
{
|
|
||||||
ref readonly JEnvValue value = ref jEnv.Environment;
|
|
||||||
ref JNativeInterface jInterface = ref value.Functions;
|
|
||||||
|
|
||||||
IntPtr callStaticObjectMethodPtr = jInterface.CallStaticObjectMethodAPointer;
|
|
||||||
CallStaticObjectMethodADelegate callStaticObjectMethod =
|
|
||||||
callStaticObjectMethodPtr.GetUnsafeDelegate<CallStaticObjectMethodADelegate>()!;
|
|
||||||
|
|
||||||
using IReadOnlyFixedMemory<JValue>.IDisposable fArgs = args.AsMemory().GetFixedContext();
|
|
||||||
JObjectLocalRef jObject = callStaticObjectMethod(jEnv, jClass, jMethodId, fArgs.ValuePointer);
|
|
||||||
return !JniHelper.ExceptionCheck(jEnv) ? jObject : null;
|
|
||||||
}
|
|
||||||
public static JLong? CallStaticLongMethod(JEnvRef jEnv, JClassLocalRef jClass, JMethodId jMethodId,
|
|
||||||
params JValue[] args)
|
|
||||||
{
|
|
||||||
ref readonly JEnvValue value = ref jEnv.Environment;
|
|
||||||
ref JNativeInterface jInterface = ref value.Functions;
|
|
||||||
|
|
||||||
IntPtr callStaticLongMethodPtr = jInterface.CallStaticLongMethodAPointer;
|
|
||||||
CallStaticLongMethodADelegate callStaticLongMethod =
|
|
||||||
callStaticLongMethodPtr.GetUnsafeDelegate<CallStaticLongMethodADelegate>()!;
|
|
||||||
|
|
||||||
using IReadOnlyFixedMemory<JValue>.IDisposable fArgs = args.AsMemory().GetFixedContext();
|
|
||||||
JLong jLong = callStaticLongMethod(jEnv, jClass, jMethodId, fArgs.ValuePointer);
|
|
||||||
return !JniHelper.ExceptionCheck(jEnv) ? jLong : null;
|
|
||||||
}
|
|
||||||
public static void CallVoidMethod(JEnvRef jEnv, JObjectLocalRef jObject, JMethodId jMethodId, params JValue[] args)
|
|
||||||
{
|
|
||||||
ref readonly JEnvValue value = ref jEnv.Environment;
|
|
||||||
ref JNativeInterface jInterface = ref value.Functions;
|
|
||||||
|
|
||||||
IntPtr callVoidMethodPtr = jInterface.CallVoidMethodAPointer;
|
|
||||||
CallVoidMethodADelegate callVoidMethod = callVoidMethodPtr.GetUnsafeDelegate<CallVoidMethodADelegate>()!;
|
|
||||||
|
|
||||||
using IReadOnlyFixedMemory<JValue>.IDisposable fArgs = args.AsMemory().GetFixedContext();
|
|
||||||
callVoidMethod(jEnv, jObject, jMethodId, fArgs.ValuePointer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace Ryujinx.Common.SystemInfo
|
|
||||||
{
|
|
||||||
public class SystemInfo
|
|
||||||
{
|
|
||||||
//public static bool IsBionic { get; set; }
|
|
||||||
|
|
||||||
/* public static bool IsAnddroid()
|
|
||||||
{
|
|
||||||
// return OperatingSystem.IsAndroid() || IsBionic;
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
}
|
|
@ -11,8 +11,8 @@ android {
|
|||||||
applicationId "org.ryujinx.android"
|
applicationId "org.ryujinx.android"
|
||||||
minSdk 30
|
minSdk 30
|
||||||
targetSdk 34
|
targetSdk 34
|
||||||
versionCode 10042
|
versionCode 10044
|
||||||
versionName '1.0.42'
|
versionName '1.0.44'
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
vectorDrawables {
|
vectorDrawables {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user