apply plugin: 'com.android.application'
android {
- compileSdkVersion 28
+ compileSdkVersion 29
defaultConfig {
applicationId "net.osdn.gokigen.pkremote"
minSdkVersion 14
- targetSdkVersion 28
- versionCode 10103
- versionName "1.1.3"
+ targetSdkVersion 29
+ versionCode 10200
+ versionName "1.2.0"
}
buildTypes {
release {
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
+ <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
+ <uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION"/>
<uses-permission android:name="android.permission.VIBRATE" />
<application
// パーミッション群のオプトイン
final int REQUEST_NEED_PERMISSIONS = 1010;
+
if ((ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) ||
+ (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) ||
+ (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_MEDIA_LOCATION) != PackageManager.PERMISSION_GRANTED) ||
(ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_NETWORK_STATE) != PackageManager.PERMISSION_GRANTED) ||
(ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_WIFI_STATE) != PackageManager.PERMISSION_GRANTED) ||
(ContextCompat.checkSelfPermission(this, Manifest.permission.VIBRATE) != PackageManager.PERMISSION_GRANTED) ||
ActivityCompat.requestPermissions(this,
new String[]{
Manifest.permission.WRITE_EXTERNAL_STORAGE,
+ Manifest.permission.READ_EXTERNAL_STORAGE,
+ Manifest.permission.ACCESS_MEDIA_LOCATION,
Manifest.permission.ACCESS_NETWORK_STATE,
Manifest.permission.ACCESS_WIFI_STATE,
Manifest.permission.VIBRATE,
}
@Override
- public void onReceiveProgress(int currentBytes, int totalBytes)
+ public void onReceiveProgress(int currentBytes, int totalBytes, byte[] body)
{
Log.v(TAG, " " + currentBytes + "/" + totalBytes);
}
@Override
+ public boolean isReceiveMulti()
+ {
+ return (false);
+ }
+
+ @Override
public void receivedMessage(int id, byte[] rx_body)
{
//Log.v(TAG, "RECEIVE : " + rx_body.length + " bytes.");
}
@Override
- public void onReceiveProgress(int currentBytes, int totalBytes)
+ public void onReceiveProgress(int currentBytes, int totalBytes, byte[] body)
{
Log.v(TAG, " " + currentBytes + "/" + totalBytes);
}
+
+ @Override
+ public boolean isReceiveMulti()
+ {
+ return (false);
+ }
}
}
@Override
- public void onReceiveProgress(int currentBytes, int totalBytes)
+ public void onReceiveProgress(int currentBytes, int totalBytes, byte[] body)
{
Log.v(TAG, " " + currentBytes + "/" + totalBytes);
}
@Override
+ public boolean isReceiveMulti()
+ {
+ return (false);
+ }
+
+ @Override
public void receivedMessage(int id, byte[] rx_body)
{
if (id == FOCUS_LOCK)
package net.osdn.gokigen.pkremote.camera.vendor.fujix.wrapper;
-import android.content.Context;
import android.util.Log;
import androidx.annotation.NonNull;
import net.osdn.gokigen.pkremote.camera.interfaces.playback.IProgressEvent;
import net.osdn.gokigen.pkremote.camera.vendor.fujix.wrapper.command.IFujiXCommandCallback;
-import java.util.Arrays;
-
public class FujiXFullImageReceiver implements IFujiXCommandCallback
{
private final String TAG = toString();
- private final Context context;
private final IDownloadContentCallback callback;
+ private int receivedLength;
- FujiXFullImageReceiver(Context context, @NonNull IDownloadContentCallback callback)
+ FujiXFullImageReceiver( @NonNull IDownloadContentCallback callback)
{
- this.context = context;
this.callback = callback;
+ this.receivedLength = 0;
}
@Override
{
try
{
- Log.v(TAG, " receivedMessage() " + id + " / " + rx_body.length + " bytes.");
- int offset = 12;
- if (rx_body.length > offset)
- {
- callback.onProgress(Arrays.copyOfRange(rx_body, offset, (rx_body.length - offset)), rx_body.length, new IProgressEvent() {
- @Override
- public float getProgress() {
- return (1.0f);
- }
-
- @Override
- public boolean isCancellable() {
- return (false);
- }
-
- @Override
- public void requestCancellation() { }
- });
- callback.onCompleted();
- }
- else
- {
- Log.v(TAG, "ERROR RESPONSE... : " + rx_body.length);
- callback.onErrorOccurred(new NullPointerException());
- }
+ Log.v(TAG, " receivedMessage() : onCompleted. " + id + " (" + receivedLength + " bytes.)");
+ callback.onCompleted();
}
catch (Exception e)
{
}
@Override
- public void onReceiveProgress(final int currentBytes, final int totalBytes)
+ public void onReceiveProgress(final int currentBytes, final int totalBytes, byte[] body)
{
try
{
- Log.v(TAG, " onReceiveProgress() " + currentBytes + "/" + totalBytes);
+ receivedLength = receivedLength + currentBytes;
+ //Log.v(TAG, " onReceiveProgress() " + receivedLength + "/" + totalBytes);
- callback.onProgress(null, currentBytes, new IProgressEvent() {
+ callback.onProgress(body, currentBytes, new IProgressEvent() {
@Override
public float getProgress() {
- return( (float) currentBytes / (float) totalBytes);
+ return( (float) receivedLength / (float) totalBytes);
}
@Override
}
}
-
+ @Override
+ public boolean isReceiveMulti()
+ {
+ return (true);
+ }
}
}
@Override
- public void onReceiveProgress(int currentBytes, int totalBytes)
+ public void onReceiveProgress(int currentBytes, int totalBytes, byte[] body)
{
Log.v(TAG, " " + currentBytes + "/" + totalBytes);
}
@Override
+ public boolean isReceiveMulti()
+ {
+ return (false);
+ }
+
+ @Override
public void receivedMessage(int id, byte[] rx_body)
{
Log.v(TAG, "RX : " + indexNumber + "(" + id + ") " + rx_body.length + " bytes.");
if ((index > 0)&&(index <= imageInfo.size()))
{
IFujiXCommandPublisher publisher = provider.getCommandPublisher();
- publisher.enqueueCommand(new GetFullImage(index, new FujiXFullImageReceiver(activity, callback)));
+ publisher.enqueueCommand(new GetFullImage(index, new FujiXFullImageReceiver(callback)));
}
}
catch (Exception e)
try
{
imageInfo.clear();
- IFujiXCommandPublisher publisher = provider.getCommandPublisher();
+ //IFujiXCommandPublisher publisher = provider.getCommandPublisher();
for (int index = 1; index <= nofFiles; index++)
{
FujiXImageContentInfo info = new FujiXImageContentInfo(index, null);
}
@Override
- public void onReceiveProgress(int currentBytes, int totalBytes)
+ public void onReceiveProgress(int currentBytes, int totalBytes, byte[] body)
{
Log.v(TAG, " " + currentBytes + "/" + totalBytes);
}
@Override
+ public boolean isReceiveMulti()
+ {
+ return (false);
+ }
+
+ @Override
public void receivedMessage(int id, byte[] rx_body)
{
// イメージ数の一覧が取得できなかった場合にここで作る。
}
@Override
- public void onReceiveProgress(int currentBytes, int totalBytes)
+ public void onReceiveProgress(int currentBytes, int totalBytes, byte[] body)
{
Log.v(TAG, " " + currentBytes + "/" + totalBytes);
}
+
+ @Override
+ public boolean isReceiveMulti()
+ {
+ return (false);
+ }
}
try
{
sleep(delayMs);
- byte[] byte_array = new byte[BUFFER_SIZE];
+ boolean isFirstTime = true;
+ int totalReadBytes;
+ int receive_message_buffer_size = BUFFER_SIZE;
+ byte[] byte_array = new byte[receive_message_buffer_size];
InputStream is = socket.getInputStream();
if (is != null)
{
- int read_bytes = is.read(byte_array, 0, BUFFER_SIZE);
+ int read_bytes = is.read(byte_array, 0, receive_message_buffer_size);
byte[] receive_body;
if (read_bytes > 4)
{
if (receiveAgain)
{
int length = ((((int) byte_array[3]) & 0xff) << 24) + ((((int) byte_array[2]) & 0xff) << 16) + ((((int) byte_array[1]) & 0xff) << 8) + (((int) byte_array[0]) & 0xff);
- while ((length > read_bytes)||((length == read_bytes)&&((int) byte_array[4] == 0x02)))
+ if (length > receive_message_buffer_size)
+ {
+ Log.v(TAG, "+++++ TOTAL RECEIVE MESSAGE SIZE IS " + length + " +++++");
+ }
+ totalReadBytes = read_bytes;
+ while ((length > totalReadBytes)||((length == read_bytes)&&((int) byte_array[4] == 0x02)))
{
// データについて、もう一回受信が必要な場合...
if (isDumpReceiveLog)
Log.v(TAG, "--- RECEIVE AGAIN --- [" + length + "(" + read_bytes + ") " + byte_array[4]+ "] ");
}
sleep(delayMs);
- int read_bytes2 = is.read(byte_array, read_bytes, BUFFER_SIZE - read_bytes);
+ int read_bytes2 = is.read(byte_array, read_bytes, receive_message_buffer_size - read_bytes);
if (read_bytes2 > 0)
{
read_bytes = read_bytes + read_bytes2;
+ totalReadBytes = totalReadBytes + read_bytes2;
}
else
{
- // よみだし
+ // よみだし終了。
+ Log.v(TAG, "FINISHED RECEIVE... ");
break;
}
if (callback != null)
{
- callback.onReceiveProgress(read_bytes, length);
+ if (callback.isReceiveMulti())
+ {
+ int offset = 0;
+ if (isFirstTime)
+ {
+ // 先頭のヘッダ部分をカットして送る
+ offset = 12;
+ isFirstTime = false;
+ //Log.v(TAG, " FIRST TIME : " + read_bytes + " " + offset);
+ }
+ callback.onReceiveProgress(read_bytes - offset, length, Arrays.copyOfRange(byte_array, offset, read_bytes));
+ read_bytes = 0;
+ }
+ else
+ {
+ callback.onReceiveProgress(read_bytes, length, null);
+ }
}
}
}
if (isDumpReceiveLog)
{
// ログに受信メッセージを出力する
- Log.v(TAG, "receive_from_camera() : " + read_bytes + " bytes.");
+ Log.v(TAG, "receive_from_camera() : " + read_bytes + " bytes. [" + receive_message_buffer_size + "]");
dump_bytes("RECV[" + receive_body.length + "] ", receive_body);
}
if (callback != null)
{
- callback.receivedMessage(id, receive_body);
+ if (callback.isReceiveMulti())
+ {
+ callback.receivedMessage(id, null);
+ }
+ else
+ {
+ callback.receivedMessage(id, receive_body);
+ }
}
}
}
- catch (Exception e)
+ catch (Throwable e)
{
e.printStackTrace();
}
public interface IFujiXCommandCallback
{
void receivedMessage(int id, byte[] rx_body);
- void onReceiveProgress(int currentBytes, int totalBytes);
+ void onReceiveProgress(int currentBytes, int totalBytes, byte[] rx_body);
+ boolean isReceiveMulti();
}
// sequence number
(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
- // data ...
+ // data ... (index number)
lower, upper, (byte)0x00, (byte)0x00,
+
+ // 現物合わせ1 : 0~
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ // 現物合わせ2 : ~0x01000000 bytes
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01,
});
}
@Override
}
@Override
- public void onReceiveProgress(int currentBytes, int totalBytes)
+ public void onReceiveProgress(int currentBytes, int totalBytes, byte[] body)
{
Log.v(TAG, " " + currentBytes + "/" + totalBytes);
}
@Override
+ public boolean isReceiveMulti()
+ {
+ return (false);
+ }
+
+ @Override
public void receivedMessage(int id, byte[] rx_body)
{
//Log.v(TAG, "receivedMessage : " + id + "[" + rx_body.length + " bytes]");
}
@Override
- public void onReceiveProgress(int currentBytes, int totalBytes)
+ public void onReceiveProgress(int currentBytes, int totalBytes, byte[] body)
{
Log.v(TAG, " " + currentBytes + "/" + totalBytes);
}
@Override
+ public boolean isReceiveMulti()
+ {
+ return (false);
+ }
+
+ @Override
public void receivedMessage(int id, byte[] rx_body)
{
//Log.v(TAG, "receivedMessage : " + id + "[" + rx_body.length + " bytes]");
}
@Override
- public void onReceiveProgress(int currentBytes, int totalBytes)
+ public void onReceiveProgress(int currentBytes, int totalBytes, byte[] body)
{
Log.v(TAG, " " + currentBytes + "/" + totalBytes);
}
@Override
+ public boolean isReceiveMulti()
+ {
+ return (false);
+ }
+
+ @Override
public void receivedMessage(int id, byte[] rx_body)
{
//Log.v(TAG, "receivedMessage : " + id + "[" + rx_body.length + " bytes]");
}
@Override
- public void onReceiveProgress(int currentBytes, int totalBytes)
+ public void onReceiveProgress(int currentBytes, int totalBytes, byte[] body)
{
Log.v(TAG, " " + currentBytes + "/" + totalBytes);
}
@Override
+ public boolean isReceiveMulti()
+ {
+ return (false);
+ }
+
+ @Override
public void receivedMessage(int id, byte[] rx_body)
{
//Log.v(TAG, "receivedMessage : " + id + "[" + rx_body.length + " bytes]");
}
@Override
- public void onReceiveProgress(int currentBytes, int totalBytes)
+ public void onReceiveProgress(int currentBytes, int totalBytes, byte[] body)
{
Log.v(TAG, " " + currentBytes + "/" + totalBytes);
}
@Override
+ public boolean isReceiveMulti()
+ {
+ return (false);
+ }
+
+ @Override
public void receivedMessage(int id, byte[] rx_body)
{
//Log.v(TAG, "receivedMessage : " + id + "[" + rx_body.length + " bytes]");
}
@Override
- public void onReceiveProgress(int currentBytes, int totalBytes)
+ public void onReceiveProgress(int currentBytes, int totalBytes, byte[] body)
{
Log.v(TAG, " " + currentBytes + "/" + totalBytes);
}
@Override
+ public boolean isReceiveMulti()
+ {
+ return (false);
+ }
+
+ @Override
public void receivedMessage(int id, byte[] data)
{
try