mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-19 22:29:53 +01:00
Use new IOException(String) for consistency with other calls.
This commit is contained in:
@@ -11,6 +11,9 @@ import net.contentobjects.jnotify.JNotifyListener;
|
|||||||
abstract class UnixRemovableDriveMonitor implements RemovableDriveMonitor,
|
abstract class UnixRemovableDriveMonitor implements RemovableDriveMonitor,
|
||||||
JNotifyListener {
|
JNotifyListener {
|
||||||
|
|
||||||
|
private static boolean triedLoad = false; // Locking: class
|
||||||
|
private static Throwable loadError = null; // Locking: class
|
||||||
|
|
||||||
// Locking: this
|
// Locking: this
|
||||||
private final List<Integer> watches = new ArrayList<Integer>();
|
private final List<Integer> watches = new ArrayList<Integer>();
|
||||||
|
|
||||||
@@ -19,32 +22,23 @@ JNotifyListener {
|
|||||||
|
|
||||||
protected abstract String[] getPathsToWatch();
|
protected abstract String[] getPathsToWatch();
|
||||||
|
|
||||||
private static boolean triedLoad = false;
|
|
||||||
private static Throwable loadError = null;
|
|
||||||
|
|
||||||
private static Throwable tryLoad() {
|
private static Throwable tryLoad() {
|
||||||
try {
|
try {
|
||||||
Class.forName("net.contentobjects.jnotify.JNotify");
|
Class.forName("net.contentobjects.jnotify.JNotify");
|
||||||
return null;
|
return null;
|
||||||
} catch (UnsatisfiedLinkError e) {
|
} catch(UnsatisfiedLinkError e) {
|
||||||
return e;
|
return e;
|
||||||
} catch (ClassNotFoundException e) {
|
} catch(ClassNotFoundException e) {
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized void checkEnabled() throws IOException {
|
public static synchronized void checkEnabled() throws IOException {
|
||||||
if (!triedLoad) {
|
if(!triedLoad) {
|
||||||
loadError = tryLoad();
|
loadError = tryLoad();
|
||||||
triedLoad = true;
|
triedLoad = true;
|
||||||
}
|
}
|
||||||
if (loadError != null) {
|
if(loadError != null) throw new IOException(loadError.toString());
|
||||||
// gymnastics due to having to support earlier Android APIs
|
|
||||||
// TODO(infinity0): add a utility that does this and convert other exceptions too
|
|
||||||
IOException e = new IOException("JNotify not loaded");
|
|
||||||
e.initCause(loadError);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start(Callback callback) throws IOException {
|
public void start(Callback callback) throws IOException {
|
||||||
|
|||||||
Reference in New Issue
Block a user