25package trial.org.direct_bt;
27import java.lang.invoke.MethodHandles;
28import java.lang.reflect.InvocationTargetException;
31import org.direct_bt.BTAdapter;
32import org.direct_bt.BTDeviceRegistry;
33import org.direct_bt.BTException;
34import org.direct_bt.BTFactory;
35import org.direct_bt.BTManager;
36import org.direct_bt.BTSecurityRegistry;
37import org.jau.io.PrintUtil;
38import org.junit.After;
39import org.junit.AfterClass;
40import org.junit.Assert;
41import org.junit.Before;
42import org.junit.BeforeClass;
43import org.junit.FixMethodOrder;
44import org.junit.runners.MethodSorters;
46import jau.test.junit.util.SingletonJunitCase;
48@FixMethodOrder(MethodSorters.NAME_ASCENDING)
50 static boolean DEBUG =
false;
55 System.setProperty(
"direct_bt.debug",
"true");
63 final Class<?> ThisClazz = MethodHandles.lookup().lookupClass();
64 PrintUtil.println(System.err,
"++++ Test "+ThisClazz.getSimpleName()+
".setupAll()");
77 final Class<?> ThisClazz = MethodHandles.lookup().lookupClass();
78 PrintUtil.println(System.err,
"++++ Test "+ThisClazz.getSimpleName()+
".cleanupAll()");
83 }
catch (
BTException | NoSuchMethodException | SecurityException
84 | IllegalAccessException | IllegalArgumentException
85 | InvocationTargetException | ClassNotFoundException e) {
87 PrintUtil.println(System.err,
"Unable to instantiate Direct-BT BluetoothManager: "+e.getMessage());
90 if(
null != manager ) {
91 final List<BTAdapter> adapters = manager.
getAdapters();
102 private void resetStates() {
106 }
catch (BTException | NoSuchMethodException | SecurityException
107 | IllegalAccessException | IllegalArgumentException
108 | InvocationTargetException | ClassNotFoundException e) {
110 PrintUtil.println(System.err,
"Unable to instantiate Direct-BT BluetoothManager: "+e.getMessage());
113 if(
null != manager ) {
114 final List<BTAdapter> adapters = manager.
getAdapters();
115 for(
final BTAdapter a : adapters) {
116 a.removeAllStatusListener();
119 Assert.assertTrue( a.setPowered(
false) );
123 BTDeviceRegistry.clearWaitForDevices();
124 BTDeviceRegistry.clearProcessedDevices();
125 BTSecurityRegistry.clear();
134 final Class<?> ThisClazz = MethodHandles.lookup().lookupClass();
135 PrintUtil.println(System.err,
"++++ Test "+ThisClazz.getSimpleName()+
".setupTest()");
149 final Class<?> ThisClazz = MethodHandles.lookup().lookupClass();
150 PrintUtil.println(System.err,
"++++ Test "+ThisClazz.getSimpleName()+
".cleanupTest()");
One stop BTManager API entry point.
static synchronized void initDirectBTLibrary()
Preloads the DirectBT native library w/o instantiating BTManager.
static synchronized BTManager getDirectBTManager()
Returns an initialized BluetoothManager instance using the DirectBT implementation.
static final void setupAll()
final void setupTest()
Ensure.
final void cleanupTest()
Ensure.
static final void cleanupAll()
Ensure.
static final boolean mkdirKeyFolder()
static final boolean rmKeyFolder()
BTAdapter represents one local Bluetooth Controller.
A thread safe singleton handler of the BTAdapter manager, e.g.
int removeAllChangedAdapterSetListener()
Remove all added ChangedAdapterSetListener entries from this manager.
List< BTAdapter > getAdapters()
Returns a list of BluetoothAdapters available in the system.
void shutdown()
Release the native memory associated with this object and all related Bluetooth resources.