Esempio n. 1
0
try:
    import jni

    System = jni.cls("java/lang/System")
except:
    print("SKIP")
    raise SystemExit

System.out.println("Hello, Java!")
Esempio n. 2
0
File: object.py Progetto: OS-Q/Y511
import sys
import jni
try:
    Integer = jni.cls("java/lang/Integer")
except:
    print("SKIP")
    sys.exit()

# Create object
i = Integer(42)
print(i)
# Call object method
print(i.hashCode())
# Pass object to another method
System = jni.cls("java/lang/System")
System.out.println(i)
Esempio n. 3
0
import jni
try:
    ArrayList = jni.cls("java/util/ArrayList")
except:
    print("SKIP")
    raise SystemExit

l = ArrayList()
print(l)
l.add("one")
l.add("two")

print(l.toString())
print(l)
print(l[0], l[1])
Esempio n. 4
0
try:
    import jni
    System = jni.cls("java/lang/System")
except:
    print("SKIP")
    raise SystemExit

System.out.println("Hello, Java!")
Esempio n. 5
0
# Implementation of native Android "pm list packages"
# command in MicroPython.
import ffi
import jni

# Bootstrap JVM
jni.cls("java/lang/Object")
rt = ffi.open("/system/lib/libandroid_runtime.so")
# Note in 5.x, function may be called: jint registerFrameworkNatives(JNIEnv* env)
# https://android-review.googlesource.com/#/c/157981/1/core/jni/AndroidRuntime.cpp
registerNatives = rt.func("p", "Java_LoadClass_registerNatives", "pp")
registerNatives(jni.env(), None)

# This is older, Java-level way to register framework natives, but
# "registerNatives" method may be absent in 4.x devices, and class
# itself is removed in 5.x.
#fw = jni.cls("com.android.internal.util.WithFramework")
#fw.registerNatives()

ServiceManager = jni.cls("android/os/ServiceManager")
pm = ServiceManager.getService("package")
#print("Service:", pm)
IPackageManager = jni.cls("android/content/pm/IPackageManager")
#print("IPackageManager", IPackageManager)
IPackageManager_Stub = jni.cls("android/content/pm/IPackageManager$Stub")
#print(IPackageManager_Stub)
mPm = IPackageManager_Stub.asInterface(pm)
#print("mPm:", mPm, mPm.toString())
#print("=================")
res = mPm.getInstalledPackages(0, 0)
#res = pm.getInstalledPackages(0)