|
16 | 16 |
|
17 | 17 | package io.objectbox;
|
18 | 18 |
|
| 19 | +import io.objectbox.internal.Feature; |
19 | 20 | import org.greenrobot.essentials.collections.LongHashMap;
|
20 | 21 |
|
21 | 22 | import java.io.Closeable;
|
@@ -186,34 +187,28 @@ static native void nativeRegisterCustomType(long store, int entityId, int proper
|
186 | 187 |
|
187 | 188 | static native long nativeSysProcStatusKb(String key);
|
188 | 189 |
|
189 |
| - /** @return sync availability (0: none; 1: client; 2: server) */ |
190 |
| - static native int nativeGetSupportedSync(); |
| 190 | + private static native boolean nativeHasFeature(int feature); |
191 | 191 |
|
192 |
| - public static boolean isObjectBrowserAvailable() { |
193 |
| - NativeLibraryLoader.ensureLoaded(); |
194 |
| - return nativeIsObjectBrowserAvailable(); |
195 |
| - } |
196 |
| - |
197 |
| - private static int getSupportedSync() { |
198 |
| - NativeLibraryLoader.ensureLoaded(); |
| 192 | + public static boolean hasFeature(Feature feature) { |
199 | 193 | try {
|
200 |
| - int supportedSync = nativeGetSupportedSync(); |
201 |
| - if (supportedSync < 0 || supportedSync > 2) { |
202 |
| - throw new IllegalStateException("Unexpected sync support: " + supportedSync); |
203 |
| - } |
204 |
| - return supportedSync; |
| 194 | + NativeLibraryLoader.ensureLoaded(); |
| 195 | + return nativeHasFeature(feature.id); |
205 | 196 | } catch (UnsatisfiedLinkError e) {
|
206 | 197 | System.err.println("Old JNI lib? " + e); // No stack
|
207 |
| - return 0; |
| 198 | + return false; |
208 | 199 | }
|
209 | 200 | }
|
210 | 201 |
|
| 202 | + public static boolean isObjectBrowserAvailable() { |
| 203 | + return hasFeature(Feature.ADMIN); |
| 204 | + } |
| 205 | + |
211 | 206 | public static boolean isSyncAvailable() {
|
212 |
| - return getSupportedSync() != 0; |
| 207 | + return hasFeature(Feature.SYNC); |
213 | 208 | }
|
214 | 209 |
|
215 | 210 | public static boolean isSyncServerAvailable() {
|
216 |
| - return getSupportedSync() == 2; |
| 211 | + return hasFeature(Feature.SYNC_SERVER); |
217 | 212 | }
|
218 | 213 |
|
219 | 214 | native long nativePanicModeRemoveAllObjects(long store, int entityId);
|
|
0 commit comments