[Android/Api] update condition
authorJaeyun Jung <jy1210.jung@samsung.com>
Sun, 22 Sep 2019 07:00:54 +0000 (16:00 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Mon, 23 Sep 2019 05:57:30 +0000 (14:57 +0900)
1. update condition to check the given params.
2. update api description about ml model.

Signed-off-by: Jaeyun Jung <jy1210.jung@samsung.com>
api/android/api/src/main/java/org/nnsuite/nnstreamer/NNStreamer.java
api/android/api/src/main/java/org/nnsuite/nnstreamer/SingleShot.java
api/android/api/src/main/java/org/nnsuite/nnstreamer/TensorsData.java

index f974d45..5de8c4d 100644 (file)
@@ -26,6 +26,9 @@ import org.freedesktop.gstreamer.GStreamer;
  * NNStreamer is a set of GStreamer plugins that allow GStreamer developers to adopt neural network models easily and efficiently
  * and neural network developers to manage stream pipelines and their filters easily and efficiently.<br>
  * <br>
+ * Note that, to open a machine learning model in the storage,
+ * the permission <code>Manifest.permission.READ_EXTERNAL_STORAGE</code> is required before constructing the pipeline.
+ * <br>
  * See <a href="https://github.com/nnsuite/nnstreamer">https://github.com/nnsuite/nnstreamer</a> for the details.
  */
 public final class NNStreamer {
index 19521f2..a4575ce 100644 (file)
@@ -69,8 +69,8 @@ public final class SingleShot implements AutoCloseable {
      * @throws IllegalStateException if failed to construct the pipeline
      */
     public SingleShot(@NonNull File model, @Nullable TensorsInfo in, @Nullable TensorsInfo out) {
-        if (model == null) {
-            throw new IllegalArgumentException("The param model is null");
+        if (model == null || !model.exists()) {
+            throw new IllegalArgumentException("The param model is invalid");
         }
 
         String path = model.getAbsolutePath();
index 560c8f8..ea66c63 100644 (file)
@@ -35,11 +35,11 @@ public final class TensorsData implements AutoCloseable {
      * @return The new byte buffer
      */
     public static ByteBuffer allocateByteBuffer(int size) {
-        ByteBuffer buffer = ByteBuffer.allocateDirect(size);
-
-        buffer.order(ByteOrder.nativeOrder());
+        if (size <= 0) {
+            throw new IllegalArgumentException("The param size is invalid");
+        }
 
-        return buffer;
+        return ByteBuffer.allocateDirect(size).order(ByteOrder.nativeOrder());
     }
 
     /**