| package io.v.android.libs.discovery.ble; |
| |
| import io.v.impl.google.lib.discovery.ScanHandler; |
| import io.v.x.ref.lib.discovery.Advertisement; |
| |
| /** |
| * An implementation of the ScanHandler for use by the discovery frameework. |
| */ |
| class NativeScanHandler implements ScanHandler{ |
| /** |
| * A pointer to the the native channel. |
| */ |
| private long nativeChan; |
| |
| NativeScanHandler(long nativeChan) { |
| this.nativeChan = nativeChan; |
| } |
| |
| private native void nativeHandleUpdate(Advertisement adv, long chan); |
| private native void nativeCleanup(long chan); |
| |
| @Override |
| public void handleUpdate(Advertisement advertisement) { |
| nativeHandleUpdate(advertisement, nativeChan); |
| } |
| |
| @Override |
| protected void finalize() throws Throwable { |
| nativeCleanup(nativeChan); |
| } |
| } |