OSDN Git Service

なんどか取得に失敗するのに対策中。
authorMRSa <mrsa@myad.jp>
Sun, 13 Oct 2019 16:04:31 +0000 (01:04 +0900)
committerMRSa <mrsa@myad.jp>
Sun, 13 Oct 2019 16:04:31 +0000 (01:04 +0900)
14 files changed:
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/command/IPtpIpCommand.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/command/PtpIpCommandPublisher.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/command/messages/PtpIpCommandBase.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/command/messages/PtpIpCommandCanonGetPartialObject.java [new file with mode: 0644]
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/command/messages/PtpIpCommandGeneric.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/playback/PtpIpFullImageReceiver.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/playback/PtpIpPlaybackControl.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/playback/PtpIpScreennailImageReceiver.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/playback/PtpIpSmallImageReceiver.java
app/src/main/java/net/osdn/gokigen/pkremote/preference/IPreferencePropertyAccessor.java
app/src/main/java/net/osdn/gokigen/pkremote/preference/canon/CanonPreferenceFragment.java
app/src/main/res/values-ja/strings.xml
app/src/main/res/values/strings.xml
app/src/main/res/xml/preferences_canon.xml

index 3f0bc88..e2f6383 100644 (file)
@@ -26,6 +26,9 @@ public interface IPtpIpCommand
     // 埋め込むシーケンス番号の位置
     int embeddedSequenceNumberIndex3();
 
+    // 予定している受信データのサイズ
+    int estimatedReceiveDataSize();
+
     // 送信するメッセージボディ
     byte[] commandBody();
 
index 182f87b..59e07b7 100644 (file)
@@ -344,26 +344,25 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
     private boolean receive_from_camera(@NonNull IPtpIpCommand command)
     {
         IPtpIpCommandCallback callback = command.responseCallback();
+        int delayMs = command.receiveDelayMs();
+        if ((delayMs < 0)||(delayMs > COMMAND_SEND_RECEIVE_DURATION_MAX))
+        {
+            delayMs = COMMAND_SEND_RECEIVE_DURATION_MS;
+        }
         if ((callback != null)&&(callback.isReceiveMulti()))
         {
             // 受信したら逐次「受信したよ」と応答するパターン
-            return (receive_multi(command));
+            return (receive_multi(command, delayMs));
         }
         //  受信した後、すべてをまとめて「受信したよ」と応答するパターン
-        return (receive_single(command));
+        return (receive_single(command, delayMs));
     }
 
-    private boolean receive_single(@NonNull IPtpIpCommand command)
+    private boolean receive_single(@NonNull IPtpIpCommand command, int delayMs)
     {
         boolean isDumpReceiveLog = command.dumpLog();
         int id = command.getId();
         IPtpIpCommandCallback callback = command.responseCallback();
-        int delayMs = command.receiveDelayMs();
-        if ((delayMs < 0)||(delayMs > COMMAND_SEND_RECEIVE_DURATION_MAX))
-        {
-            delayMs = COMMAND_SEND_RECEIVE_DURATION_MS;
-        }
-
         try
         {
             int receive_message_buffer_size = BUFFER_SIZE;
@@ -412,10 +411,10 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
 
     private void receivedAllMessage(boolean isDumpReceiveLog, int id, byte[] body, IPtpIpCommandCallback callback)
     {
-        if (isDumpReceiveLog)
+        Log.v(TAG, "receivedAllMessage() : " + ((body == null) ? 0 : body.length) + " bytes.");
+        if ((isDumpReceiveLog)&&(body != null))
         {
             // ログに受信メッセージを出力する
-            Log.v(TAG, "receivedAllMessage() : " + body.length + " bytes.");
             dump_bytes("RECV[" + body.length + "] ", body);
         }
         if (callback != null)
@@ -424,15 +423,11 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
         }
     }
 
-    private boolean receive_multi(@NonNull IPtpIpCommand command)
+    private boolean receive_multi(@NonNull IPtpIpCommand command, int delayMs)
     {
+        int estimatedSize = command.estimatedReceiveDataSize();
         int id = command.getId();
         IPtpIpCommandCallback callback = command.responseCallback();
-        int delayMs = command.receiveDelayMs();
-        if ((delayMs < 0)||(delayMs > COMMAND_SEND_RECEIVE_DURATION_MAX))
-        {
-            delayMs = COMMAND_SEND_RECEIVE_DURATION_MS;
-        }
 
         try
         {
@@ -451,7 +446,7 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
             if (read_bytes < 0)
             {
                 // リトライオーバー...
-                Log.v(TAG, " RECEIVE : RETRY OVER...");
+                Log.v(TAG, " RECEIVE : RETRY OVER......");
                 return (true);
             }
 
@@ -474,7 +469,7 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
                 read_bytes = is.read(byte_array, 0, receive_message_buffer_size);
                 if (read_bytes <= 0)
                 {
-                    Log.v(TAG, " RECEIVED MESSAGE FINISHED (" + read_bytes + ")");
+                    Log.v(TAG, "  RECEIVED MESSAGE FINISHED (" + read_bytes + ")");
                     break;
                 }
                 received_length = received_length + read_bytes;
@@ -485,10 +480,14 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
                     //Log.v(TAG, "  --- CALL : read_bytes : "+ read_bytes + " total_read : " + received_length + " : total_length : " + target_length + "  buffer SIZE : " + byte_array.length);
                     callback.onReceiveProgress(received_length, target_length, Arrays.copyOfRange(byte_array, 0, read_bytes));
                 }
-
                 //byteStream.write(byte_array, 0, read_bytes);
-                sleep(delayMs);
-                read_bytes = is.available();
+
+                do
+                {
+                    sleep(delayMs);
+                    read_bytes = is.available();
+                    Log.v(TAG, "  is.available() read_bytes : " + read_bytes + " " + received_length + " < " + estimatedSize);
+                } while ((read_bytes == 0)&&(estimatedSize > 0)&&(received_length < estimatedSize));
             }
             //ByteArrayOutputStream outputStream = cutHeader(byteStream);
             //receivedMessage(isDumpReceiveLog, id, outputStream.toByteArray(), callback);
@@ -496,6 +495,7 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
             //  終了報告...一時的?
             if (callback != null)
             {
+                Log.v(TAG, "  --- receive_multi : receivedMessage() : " + id + "  (" + read_bytes + ") [" + estimatedSize + "] " + receive_message_buffer_size + " (" + received_length + ")");
                 callback.receivedMessage(id, null);
             }
             System.gc();
index 94d84eb..a25c881 100644 (file)
@@ -56,6 +56,12 @@ public class PtpIpCommandBase implements IPtpIpCommand, IPtpIpMessages
     }
 
     @Override
+    public int estimatedReceiveDataSize()
+    {
+        return (-1);
+    }
+
+    @Override
     public byte[] commandBody()
     {
         return (new byte[12]);
diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/command/messages/PtpIpCommandCanonGetPartialObject.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/command/messages/PtpIpCommandCanonGetPartialObject.java
new file mode 100644 (file)
index 0000000..fb7016e
--- /dev/null
@@ -0,0 +1,114 @@
+package net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.messages;
+
+import androidx.annotation.NonNull;
+
+import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.IPtpIpCommandCallback;
+
+public class PtpIpCommandCanonGetPartialObject extends PtpIpCommandBase
+{
+    private final IPtpIpCommandCallback callback;
+    private final boolean isDumpLog;
+    private final int id;
+    private final int holdId;
+    private final int estimatedObjectSize;
+
+    private final byte data0;
+    private final byte data1;
+    private final byte data2;
+    private final byte data3;
+
+    private final byte data4;
+    private final byte data5;
+    private final byte data6;
+    private final byte data7;
+
+    private final byte data8;
+    private final byte data9;
+    private final byte dataA;
+    private final byte dataB;
+
+    public PtpIpCommandCanonGetPartialObject(@NonNull IPtpIpCommandCallback callback, int id, boolean isDumpLog, int holdId, int value, int value2, int value3, int estimatedObjectSize)
+    {
+        this.callback = callback;
+        this.isDumpLog = isDumpLog;
+        this.estimatedObjectSize = estimatedObjectSize;
+
+        this.id = id;
+        this.holdId = holdId;
+
+        data0 = ((byte) (0x000000ff & value));
+        data1 = ((byte)((0x0000ff00 & value) >> 8));
+        data2 = ((byte)((0x00ff0000 & value) >> 16));
+        data3 = ((byte)((0xff000000 & value) >> 24));
+
+        data4 = ((byte) (0x000000ff & value2));
+        data5 = ((byte)((0x0000ff00 & value2) >> 8));
+        data6 = ((byte)((0x00ff0000 & value2) >> 16));
+        data7 = ((byte)((0xff000000 & value2) >> 24));
+
+        data8 = ((byte) (0x000000ff & value3));
+        data9 = ((byte)((0x0000ff00 & value3) >> 8));
+        dataA = ((byte)((0x00ff0000 & value3) >> 16));
+        dataB = ((byte)((0xff000000 & value3) >> 24));
+    }
+
+    @Override
+    public IPtpIpCommandCallback responseCallback()
+    {
+        return (callback);
+    }
+
+    @Override
+    public int estimatedReceiveDataSize()
+    {
+        return (estimatedObjectSize);
+    }
+
+    @Override
+    public int getId()
+    {
+        return (id);
+    }
+
+    @Override
+    public int receiveDelayMs()
+    {
+        return (20);
+    }
+
+    @Override
+    public byte[] commandBody()
+    {
+        return (new byte[]{
+                // packet type
+                (byte) 0x06, (byte) 0x00,  (byte) 0x00, (byte) 0x00,
+
+                // data phase info
+                (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+
+                // operation code
+                (byte) 0x07,  (byte) 0x91,
+
+                // sequence number
+                (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+
+                // data ...
+                data0, data1, data2, data3,
+                data4, data5, data6, data7,
+                data8, data9, dataA, dataB,
+        });
+    }
+
+    @Override
+    public int getHoldId()
+    {
+        return (holdId);
+    }
+
+    @Override
+    public boolean dumpLog()
+    {
+        return (isDumpLog);
+    }
+
+}
index 8278e6a..1d8cfa7 100644 (file)
@@ -12,6 +12,7 @@ public class PtpIpCommandGeneric extends PtpIpCommandBase
     private final int bodySize;
     private final int id;
     private final int holdId;
+    private final int estimatedObjectSize;
 
     private final byte opCode0;
     private final byte opCode1;
@@ -41,6 +42,7 @@ public class PtpIpCommandGeneric extends PtpIpCommandBase
         this.callback = callback;
         this.bodySize = 0;
         this.isDumpLog = isDumpLog;
+        this.estimatedObjectSize = -1;
 
         this.id = id;
         this.holdId = holdId;
@@ -73,6 +75,7 @@ public class PtpIpCommandGeneric extends PtpIpCommandBase
         this.callback = callback;
         this.bodySize = bodySize;
         this.isDumpLog = isDumpLog;
+        this.estimatedObjectSize = -1;
 
         this.id = id;
         this.holdId = holdId;
@@ -105,6 +108,7 @@ public class PtpIpCommandGeneric extends PtpIpCommandBase
         this.callback = callback;
         this.bodySize = bodySize;
         this.isDumpLog = isDumpLog;
+        this.estimatedObjectSize = -1;
 
         this.id = id;
         this.holdId = holdId;
@@ -137,6 +141,7 @@ public class PtpIpCommandGeneric extends PtpIpCommandBase
         this.callback = callback;
         this.bodySize = bodySize;
         this.isDumpLog = isDumpLog;
+        this.estimatedObjectSize = -1;
 
         this.id = id;
         this.holdId = holdId;
@@ -170,6 +175,7 @@ public class PtpIpCommandGeneric extends PtpIpCommandBase
         this.callback = callback;
         this.bodySize = bodySize;
         this.isDumpLog = isDumpLog;
+        this.estimatedObjectSize = -1;
 
         this.id = id;
         this.holdId = holdId;
@@ -210,6 +216,12 @@ public class PtpIpCommandGeneric extends PtpIpCommandBase
     }
 
     @Override
+    public int estimatedReceiveDataSize()
+    {
+        return (estimatedObjectSize);
+    }
+
+    @Override
     public byte[] commandBody()
     {
         if (bodySize == 2)
index c4db4a2..6644de0 100644 (file)
@@ -9,6 +9,7 @@ import net.osdn.gokigen.pkremote.camera.interfaces.playback.IDownloadContentCall
 import net.osdn.gokigen.pkremote.camera.interfaces.playback.IProgressEvent;
 import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.IPtpIpCommandCallback;
 import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.IPtpIpCommandPublisher;
+import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.messages.PtpIpCommandCanonGetPartialObject;
 import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.messages.PtpIpCommandGeneric;
 
 import java.io.ByteArrayOutputStream;
@@ -21,6 +22,7 @@ public class PtpIpFullImageReceiver implements IPtpIpCommandCallback
     private final IPtpIpCommandPublisher publisher;
     private IDownloadContentCallback callback = null;
 
+    private boolean isReceiveMulti = true;
     private int objectId = 0;
 
     private int received_total_bytes = 0;
@@ -45,9 +47,10 @@ public class PtpIpFullImageReceiver implements IPtpIpCommandCallback
         this.callback = callback;
         this.objectId = objectId;
         this.target_image_size = imageSize;
+        this.isReceiveMulti = true;
 
         Log.v(TAG, " getPartialObject (id : " + objectId + ", size:" + imageSize + ")");
-        publisher.enqueueCommand(new PtpIpCommandGeneric(this, (objectId + 1), false, objectId, 0x9107, 12, objectId, 0x00, imageSize)); // 0x9107 : GetPartialObject
+        publisher.enqueueCommand(new PtpIpCommandCanonGetPartialObject(this, (objectId + 1), false, objectId, objectId, 0x00, imageSize, imageSize)); // 0x9107 : GetPartialObject
     }
 
     @Override
@@ -189,7 +192,7 @@ public class PtpIpFullImageReceiver implements IPtpIpCommandCallback
     @Override
     public boolean isReceiveMulti()
     {
-        return (true);
+        return (isReceiveMulti);
     }
 
     private void getPartialObjectFinished()
@@ -198,6 +201,7 @@ public class PtpIpFullImageReceiver implements IPtpIpCommandCallback
         {
             //   すべてのデータを受信した後に...終わりを送信する
             Log.v(TAG, " getPartialObjectFinished(), id : " + objectId + " (size : " + target_image_size + ")");
+            isReceiveMulti = false;
             publisher.enqueueCommand(new PtpIpCommandGeneric(this,  (objectId + 2), false, objectId, 0x9117, 4,0x01));  // 0x9117 : TransferComplete
         }
         catch (Throwable t)
index 63116be..811cea4 100644 (file)
@@ -31,6 +31,7 @@ public class PtpIpPlaybackControl implements IPlaybackControl
     private final PtpIpFullImageReceiver fullImageReceiver;
     private final PtpIpSmallImageReceiver smallImageReciever;
     private String raw_suffix = "CR2";
+    private boolean use_screennail_image = false;
     private CanonImageObjectReceiver canonImageObjectReceiver;
 
     public PtpIpPlaybackControl(Activity activity, PtpIpInterfaceProvider provider)
@@ -45,6 +46,7 @@ public class PtpIpPlaybackControl implements IPlaybackControl
         {
             SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
             raw_suffix = preferences.getString(IPreferencePropertyAccessor.CANON_RAW_SUFFIX, IPreferencePropertyAccessor.CANON_RAW_SUFFIX_DEFAULT_VALUE);
+            use_screennail_image = preferences.getBoolean(IPreferencePropertyAccessor.CANON_USE_SCREENNAIL_AS_SMALL, false);
         }
         catch (Exception e)
         {
@@ -82,8 +84,12 @@ public class PtpIpPlaybackControl implements IPlaybackControl
     {
         Log.v(TAG, " downloadContentScreennail() " + path);
 
-        // Thumbnail と同じ画像を表示する
-        //downloadContentThumbnail(path, callback);
+        if (!use_screennail_image)
+        {
+            // Thumbnail と同じ画像を表示する
+            downloadContentThumbnail(path, callback);
+            return;
+        }
 
         try
         {
index cc755b9..8806395 100644 (file)
@@ -4,6 +4,7 @@ import android.app.Activity;
 import android.graphics.BitmapFactory;
 import android.util.Log;
 
+import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 
 import net.osdn.gokigen.pkremote.camera.interfaces.playback.IDownloadThumbnailImageCallback;
@@ -13,7 +14,7 @@ import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.messages.Pt
 import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.messages.specific.CanonGetPartialObject;
 import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.messages.specific.CanonRequestInnerDevelopEnd;
 
-public class PtpIpScreennailImageReceiver  implements IPtpIpCommandCallback
+public class PtpIpScreennailImageReceiver implements IPtpIpCommandCallback
 {
     private static final String TAG = PtpIpScreennailImageReceiver.class.getSimpleName();
 
@@ -31,7 +32,6 @@ public class PtpIpScreennailImageReceiver  implements IPtpIpCommandCallback
         this.publisher = publisher;
         this.objectId = objectId;
         Log.v(TAG, "PtpIpScreennailImageReceiver CREATED : " + objectId);
-
     }
 
     @Override
@@ -39,6 +39,7 @@ public class PtpIpScreennailImageReceiver  implements IPtpIpCommandCallback
     {
         try
         {
+            /*
             if (rx_body != null)
             {
                 Log.v(TAG, "  receivedMessage() : " + id +  " " + rx_body.length + " bytes.");
@@ -47,6 +48,7 @@ public class PtpIpScreennailImageReceiver  implements IPtpIpCommandCallback
             {
                 Log.v(TAG, "  receivedMessage() : " + id + " NULL.");
             }
+            */
             if (id == objectId)
             {
                 getRequestStatusEvent(rx_body);
@@ -65,7 +67,7 @@ public class PtpIpScreennailImageReceiver  implements IPtpIpCommandCallback
             }
             else if (id == objectId + 4)
             {
-                Log.v(TAG, " RECEIVED  : " + id);
+                Log.v(TAG, " GET SCREEN NAIL COMPLETED  : " + id);
             }
             else if (id == objectId + 5)
             {
@@ -117,21 +119,20 @@ public class PtpIpScreennailImageReceiver  implements IPtpIpCommandCallback
         {
             pictureLength = 0x02000;
         }
-        publisher.enqueueCommand(new CanonGetPartialObject(this, (objectId + 1), true, objectId, 0, pictureLength));
+        publisher.enqueueCommand(new CanonGetPartialObject(this, (objectId + 1), false, objectId, 0, pictureLength));
     }
 
     private void getRequestStatusEvent(byte[] rx_body)
     {
         Log.v(TAG, " getRequestStatusEvent  : " + objectId);
-        publisher.enqueueCommand(new PtpIpCommandGeneric(this,  (objectId + 5), true, objectId, 0x9116));
+        publisher.enqueueCommand(new PtpIpCommandGeneric(this,  (objectId + 5), false, objectId, 0x9116));
     }
 
-    private void getPartialObject(byte[] rx_body)
+    private void getPartialObject(@NonNull byte[] rx_body)
     {
         try
         {
             Log.v(TAG, " getPartialObject(), id : " + objectId + " size: " + rx_body.length);
-
             BitmapFactory.Options opt = new BitmapFactory.Options();
             try
             {
@@ -144,7 +145,7 @@ public class PtpIpScreennailImageReceiver  implements IPtpIpCommandCallback
             catch (Throwable ex)
             {
                 ex.printStackTrace();
-                Log.v(TAG, " LENGTH : " + ((rx_body != null) ? rx_body.length : 0));
+                Log.v(TAG, " LENGTH : " + (rx_body.length));
                 System.gc();
             }
             // 画像の縮小サイズを決定する (縦幅、横幅の小さいほうにあわせる)
@@ -160,10 +161,10 @@ public class PtpIpScreennailImageReceiver  implements IPtpIpCommandCallback
         catch (Throwable t)
         {
             t.printStackTrace();
-            Log.v(TAG, " LENGTH : " + ((rx_body != null) ? rx_body.length : 0));
+            Log.v(TAG, " LENGTH : " + (rx_body.length));
             System.gc();
         }
-        publisher.enqueueCommand(new PtpIpCommandGeneric(this,  (objectId + 2), true, objectId, 0x9117, 4,0x01));  // 0x9117 : TransferComplete
+        publisher.enqueueCommand(new PtpIpCommandGeneric(this,  (objectId + 2), false, objectId, 0x9117, 4,0x01));  // 0x9117 : TransferComplete
 
         // ファイルにバイナリデータをダンプする
         // binaryOutputToFile(activity, objectId + "_", rx_body);
@@ -172,7 +173,7 @@ public class PtpIpScreennailImageReceiver  implements IPtpIpCommandCallback
     private void requestInnerDevelopEnd()
     {
         Log.v(TAG, " requestInnerDevelopEnd() : " + objectId);
-        publisher.enqueueCommand(new CanonRequestInnerDevelopEnd(this, (objectId + 3), true, objectId));  // 0x9143 : RequestInnerDevelopEnd
+        publisher.enqueueCommand(new CanonRequestInnerDevelopEnd(this, (objectId + 3), false, objectId));  // 0x9143 : RequestInnerDevelopEnd
     }
 
     private void finishedGetScreeennail()
index b008ebe..e78e450 100644 (file)
@@ -11,6 +11,7 @@ import net.osdn.gokigen.pkremote.camera.interfaces.playback.IProgressEvent;
 import net.osdn.gokigen.pkremote.camera.utils.SimpleLogDumper;
 import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.IPtpIpCommandCallback;
 import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.IPtpIpCommandPublisher;
+import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.messages.PtpIpCommandCanonGetPartialObject;
 import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.messages.PtpIpCommandGeneric;
 import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.messages.specific.CanonRequestInnerDevelopEnd;
 import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.messages.specific.CanonRequestInnerDevelopStart;
@@ -54,19 +55,18 @@ public class PtpIpSmallImageReceiver implements IPtpIpCommandCallback
             @Override
             public void receivedMessage(int id, byte[] rx_body) {
                 Log.v(TAG, " getRequestStatusEvent  : " + objectId + " " + ((rx_body != null) ? rx_body.length : 0));
-                publisher.enqueueCommand(new PtpIpCommandGeneric(mine,  (objectId + 5), true, objectId, 0x9116));
+                publisher.enqueueCommand(new PtpIpCommandGeneric(mine,  (objectId + 5), false, objectId, 0x9116));
             }
 
             @Override
             public void onReceiveProgress(int currentBytes, int totalBytes, byte[] rx_body) {
-
             }
 
             @Override
             public boolean isReceiveMulti() {
                 return (false);
             }
-        }, objectId, true, objectId, objectId));   // 0x9141 : RequestInnerDevelopStart
+        }, objectId, false, objectId, objectId));   // 0x9141 : RequestInnerDevelopStart
     }
 
     @Override
@@ -74,14 +74,6 @@ public class PtpIpSmallImageReceiver implements IPtpIpCommandCallback
     {
         try
         {
-            if (rx_body != null)
-            {
-                Log.v(TAG, "  receivedMessage() : " + id +  " " + rx_body.length + " bytes.");
-            }
-            else
-            {
-                Log.v(TAG, "  receivedMessage() : " + id + " NULL.");
-            }
             if (id == objectId + 1)
             {
                 sendTransferComplete(rx_body);
@@ -89,11 +81,11 @@ public class PtpIpSmallImageReceiver implements IPtpIpCommandCallback
             else if (id == objectId + 2)
             {
                 Log.v(TAG, " requestInnerDevelopEnd() : " + objectId);
-                publisher.enqueueCommand(new CanonRequestInnerDevelopEnd(this, (objectId + 3), true, objectId));  // 0x9143 : RequestInnerDevelopEnd
+                publisher.enqueueCommand(new CanonRequestInnerDevelopEnd(this, (objectId + 3), false, objectId));  // 0x9143 : RequestInnerDevelopEnd
             }
             else if (id == objectId + 3)
             {
-                Log.v(TAG, "  --- SMALL IMAGE RECV FINISHED. : " + objectId + " --- ");
+                //Log.v(TAG, "  --- COMMAND RESET : " + objectId + " --- ");
 
                 // リセットコマンドを送ってみる
                 publisher.enqueueCommand(new PtpIpCommandGeneric(this, (objectId + 4), false, objectId, 0x902f));
@@ -101,7 +93,7 @@ public class PtpIpSmallImageReceiver implements IPtpIpCommandCallback
             else if (id == objectId + 4)
             {
                 // 画像取得終了
-                Log.v(TAG, " RECEIVED  : " + id);
+                Log.v(TAG, " ----- SMALL IMAGE RECEIVE SEQUENCE FINISHED  : " + objectId);
                 callback.onCompleted();
                 this.objectId = 0;
                 this.callback = null;
@@ -111,7 +103,6 @@ public class PtpIpSmallImageReceiver implements IPtpIpCommandCallback
             }
             else if (id == objectId + 5)
             {
-                Log.v(TAG, " RECEIVED STATUS EVENT : " + id);
                 requestGetPartialObject(rx_body);
             }
             else
@@ -168,9 +159,8 @@ public class PtpIpSmallImageReceiver implements IPtpIpCommandCallback
         }
         else if (received_remain_bytes > 0)
         {
-
-            Log.v(TAG, "  >>> [ remain_bytes : " + received_remain_bytes + "] ( length : " + length + ") " + data_position);
-            SimpleLogDumper.dump_bytes("[zzz]", Arrays.copyOfRange(rx_body, data_position, (data_position + 160)));
+            //Log.v(TAG, "  >>> [ remain_bytes : " + received_remain_bytes + "] ( length : " + length + ") " + data_position);
+            //SimpleLogDumper.dump_bytes("[zzz]", Arrays.copyOfRange(rx_body, data_position, (data_position + 160)));
 
             // データの読み込みが途中だった場合...
             if (length < received_remain_bytes)
@@ -195,17 +185,13 @@ public class PtpIpSmallImageReceiver implements IPtpIpCommandCallback
             if (body_size <= 12)
             {
                 Log.v(TAG, "  BODY SIZE IS SMALL : " + data_position + " (" + body_size + ") [" + received_remain_bytes + "] " + rx_body.length + "  ");
-
-                int startpos = (data_position > 48) ? (data_position - 48) : 0;
-                SimpleLogDumper.dump_bytes("[xxx]", Arrays.copyOfRange(rx_body, startpos, (data_position + 48)));
-
+                //int startpos = (data_position > 48) ? (data_position - 48) : 0;
+                //SimpleLogDumper.dump_bytes("[xxx]", Arrays.copyOfRange(rx_body, startpos, (data_position + 48)));
                 break;
             }
 
-            Log.v(TAG, " RX DATA : " + data_position + " (" + body_size + ") [" + received_remain_bytes + "] (" + received_total_bytes + ")");
-            SimpleLogDumper.dump_bytes("[yyy] " + data_position + ": ", Arrays.copyOfRange(rx_body, data_position, (data_position + 64)));
-
-
+            // Log.v(TAG, " RX DATA : " + data_position + " (" + body_size + ") [" + received_remain_bytes + "] (" + received_total_bytes + ")");
+            //SimpleLogDumper.dump_bytes("[yyy] " + data_position + ": ", Arrays.copyOfRange(rx_body, data_position, (data_position + 64)));
             if ((data_position + body_size) > length)
             {
                 // データがすべてバッファ内になかったときは、バッファすべてコピーして残ったサイズを記憶しておく。
@@ -213,7 +199,7 @@ public class PtpIpSmallImageReceiver implements IPtpIpCommandCallback
                 byteStream.write(rx_body, (data_position + 12), copysize);
                 received_remain_bytes = body_size - copysize - 12;  // マイナス12は、ヘッダ分
                 received_total_bytes = received_total_bytes + copysize;
-                Log.v(TAG, " --- copy : " + (data_position + 12) + " " + copysize + " remain : " + received_remain_bytes + "  body size : " + body_size);
+               // Log.v(TAG, " --- copy : " + (data_position + 12) + " " + copysize + " remain : " + received_remain_bytes + "  body size : " + body_size);
                 break;
             }
             try
@@ -221,8 +207,7 @@ public class PtpIpSmallImageReceiver implements IPtpIpCommandCallback
                 byteStream.write(rx_body, (data_position + 12), (body_size - 12));
                 data_position = data_position + body_size;
                 received_total_bytes = received_total_bytes + 12;
-                Log.v(TAG, " --- COPY : " + (data_position + 12) + " " + (body_size - 12) + " remain : " + received_remain_bytes);
-
+                //Log.v(TAG, " --- COPY : " + (data_position + 12) + " " + (body_size - 12) + " remain : " + received_remain_bytes);
             }
             catch (Exception e)
             {
@@ -258,13 +243,13 @@ public class PtpIpSmallImageReceiver implements IPtpIpCommandCallback
         {
             pictureLength = 0x020000;
         }
-        publisher.enqueueCommand(new PtpIpCommandGeneric(this, (objectId + 1), true, objectId, 0x9107, 12, 0x01, 0x00, pictureLength));
+        publisher.enqueueCommand(new PtpIpCommandCanonGetPartialObject(this, (objectId + 1), false, objectId, 0x01, 0x00, pictureLength, pictureLength));
     }
 
     private void sendTransferComplete(byte[] rx_body)
     {
         Log.v(TAG, " sendTransferComplete(), id : " + objectId + " size: " + ((rx_body != null) ? rx_body.length : 0));
-        publisher.enqueueCommand(new PtpIpCommandGeneric(this,  (objectId + 2), true, objectId, 0x9117, 4,0x01));  // 0x9117 : TransferComplete
+        publisher.enqueueCommand(new PtpIpCommandGeneric(this,  (objectId + 2), false, objectId, 0x9117, 4,0x01));  // 0x9117 : TransferComplete
         isReceiveMulti = false;
     }
 }
index 41660a1..4bbb2fd 100644 (file)
@@ -90,6 +90,8 @@ public interface IPreferencePropertyAccessor
     String CANON_RAW_SUFFIX = "canon_raw_suffix";
     String CANON_RAW_SUFFIX_DEFAULT_VALUE = "CR2";
 
+    String CANON_USE_SCREENNAIL_AS_SMALL = "canon_get_screennail_as_small_picture";
+
     /*
     //String GR2_DISPLAY_MODE = "gr2_display_mode";
     //String GR2_DISPLAY_MODE_DEFAULT_VALUE = "0";
index 6ea85bf..41a717a 100644 (file)
@@ -1,26 +1,26 @@
 package net.osdn.gokigen.pkremote.preference.canon;
 
-        import android.content.Context;
-        import android.content.SharedPreferences;
-        import android.os.Bundle;
-        import android.util.Log;
-
-        import java.util.Map;
-
-        import androidx.annotation.NonNull;
-        import androidx.appcompat.app.AppCompatActivity;
-        import androidx.fragment.app.FragmentActivity;
-        import androidx.preference.CheckBoxPreference;
-        import androidx.preference.ListPreference;
-        import androidx.preference.Preference;
-        import androidx.preference.PreferenceFragmentCompat;
-        import androidx.preference.PreferenceManager;
-
-        import net.osdn.gokigen.pkremote.R;
-        import net.osdn.gokigen.pkremote.camera.vendor.ptpip.operation.PtpIpCameraPowerOff;
-        import net.osdn.gokigen.pkremote.logcat.LogCatViewer;
-        import net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor;
-        import net.osdn.gokigen.pkremote.scene.IChangeScene;
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.util.Log;
+
+import java.util.Map;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.fragment.app.FragmentActivity;
+import androidx.preference.CheckBoxPreference;
+import androidx.preference.ListPreference;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceFragmentCompat;
+import androidx.preference.PreferenceManager;
+
+import net.osdn.gokigen.pkremote.R;
+import net.osdn.gokigen.pkremote.camera.vendor.ptpip.operation.PtpIpCameraPowerOff;
+import net.osdn.gokigen.pkremote.logcat.LogCatViewer;
+import net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor;
+import net.osdn.gokigen.pkremote.scene.IChangeScene;
 
 /**
  *
@@ -120,6 +120,9 @@ public class CanonPreferenceFragment  extends PreferenceFragmentCompat implement
             if (!items.containsKey(IPreferencePropertyAccessor.CANON_RAW_SUFFIX)) {
                 editor.putString(IPreferencePropertyAccessor.CANON_RAW_SUFFIX, IPreferencePropertyAccessor.CANON_RAW_SUFFIX_DEFAULT_VALUE);
             }
+            if (!items.containsKey(IPreferencePropertyAccessor.CANON_USE_SCREENNAIL_AS_SMALL)) {
+                editor.putBoolean(IPreferencePropertyAccessor.CANON_USE_SCREENNAIL_AS_SMALL, false);
+            }
             editor.apply();
         }
         catch (Exception e)
@@ -151,6 +154,11 @@ public class CanonPreferenceFragment  extends PreferenceFragmentCompat implement
                     Log.v(TAG, " " + key + " , " + value);
                     break;
 
+                case IPreferencePropertyAccessor.CANON_USE_SCREENNAIL_AS_SMALL:
+                    value = preferences.getBoolean(key, false);
+                    Log.v(TAG, " " + key + " , " + value);
+                    break;
+
                 default:
                     String strValue = preferences.getString(key, "");
                     setListPreference(key, key, strValue);
@@ -200,7 +208,6 @@ public class CanonPreferenceFragment  extends PreferenceFragmentCompat implement
     {
         super.onResume();
         Log.v(TAG, "onResume() Start");
-
         try
         {
             synchronizedProperty();
@@ -209,9 +216,7 @@ public class CanonPreferenceFragment  extends PreferenceFragmentCompat implement
         {
             e.printStackTrace();
         }
-
         Log.v(TAG, "onResume() End");
-
     }
 
     /**
@@ -303,6 +308,7 @@ public class CanonPreferenceFragment  extends PreferenceFragmentCompat implement
                         // Preferenceの画面に反映させる
                         setBooleanPreference(IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA, IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA, true);
                         setBooleanPreference(IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW, IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW, true);
+                        setBooleanPreference(IPreferencePropertyAccessor.CANON_USE_SCREENNAIL_AS_SMALL, IPreferencePropertyAccessor.CANON_USE_SCREENNAIL_AS_SMALL, false);
                     }
                     catch (Exception e)
                     {
@@ -312,5 +318,4 @@ public class CanonPreferenceFragment  extends PreferenceFragmentCompat implement
             });
         }
     }
-
 }
index 8ccf9ec..a77aae7 100644 (file)
     <string name="canon_connect_connecting4">接続中&#8230;(4/5)</string>
     <string name="canon_connect_connecting5">接続中&#8230;(5/5)</string>
 
+
+    <string name="pref_canon_get_screennail_as_small_picture">表示画像はスモール画像を使用</string>
+    <string name="pref_summary_canon_get_screennail_as_small_picture">すこし時間がかかりますが、画像表示にスモール画像を使用します。</string>
 </resources>
index d96489d..94ecfc1 100644 (file)
     <string name="canon_connect_connecting4">Connecting&#8230;(4/5)</string>
     <string name="canon_connect_connecting5">Connecting&#8230;(5/5)</string>
 
+    <string name="pref_canon_get_screennail_as_small_picture">Use small image as screen nail</string>
+    <string name="pref_summary_canon_get_screennail_as_small_picture">Use small size image as </string>
 </resources>
index d09200e..f7f80b5 100644 (file)
     <PreferenceCategory
         android:title="@string/pref_cat_camera">
 
+        <CheckBoxPreference
+            android:key="canon_get_screennail_as_small_picture"
+            android:title="@string/pref_canon_get_screennail_as_small_picture"
+            android:summary="@string/pref_summary_canon_get_screennail_as_small_picture" />
 
         <EditTextPreference
             android:key="canon_raw_suffix"