| // Copyright 2015 The Vanadium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| |
| // +build android |
| |
| package jni |
| import ( |
| jutil "v.io/x/jni/util" |
| "v.io/x/jni/libs/discovery" |
| |
| _ "v.io/x/ref/runtime/factories/android" |
| "v.io/x/ref/lib/discovery/factory" |
| ) |
| |
| // #include "jni.h" |
| import "C" |
| |
| var ( |
| // Global reference for io.v.android.libs.discovery.ble.BlePlugin |
| jBlePlugin jutil.Class |
| // Global reference for io.v.v23.context.CancelableVContext class. |
| jCancelableVContextClass jutil.Class |
| // Global reference for java.jutil.concurrent.CountDownLatch class. |
| jCountDownLatchClass jutil.Class |
| ) |
| |
| //export Java_io_v_v23_V_nativeInit |
| func Java_io_v_v23_V_nativeInit(jenv *C.JNIEnv, jVRuntimeClass C.jclass, androidCtx C.jobject) { |
| env := jutil.Env(uintptr(unsafe.Pointer(jenv))) |
| setupUtil(env) |
| err := discovery.Init(env) |
| if err != nil { |
| return |
| } |
| |
| factory.SetAndroidBleCreator(discovery.NewBleCreator(env, androidCtx)) |
| |
| setupV23(env) |
| } |
| |
| func main() { |
| } |