mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-24 05:04:50 -04:00
Fix hack for slower devices
- Use Thread.sleep() in SenderDeviceAsyncTask to delay connection to receiver
This commit is contained in:
parent
2d20ac07eb
commit
ce8e3d3136
@ -44,7 +44,7 @@ class ReceiverDeviceAsyncTask extends AsyncTask<Void, Integer, Boolean> {
|
|||||||
@Override
|
@Override
|
||||||
protected Boolean doInBackground(Void... voids) {
|
protected Boolean doInBackground(Void... voids) {
|
||||||
try (ServerSocket serverSocket = new ServerSocket(FILE_TRANSFER_PORT)) {
|
try (ServerSocket serverSocket = new ServerSocket(FILE_TRANSFER_PORT)) {
|
||||||
if (BuildConfig.DEBUG) Log.d(TAG, "Server: Socket opened at " + FILE_TRANSFER_PORT);
|
Log.d(TAG, "Server: Socket opened at " + FILE_TRANSFER_PORT);
|
||||||
|
|
||||||
final String KIWIX_ROOT = wifiDirectManager.getZimStorageRootPath();
|
final String KIWIX_ROOT = wifiDirectManager.getZimStorageRootPath();
|
||||||
int totalFileCount = wifiDirectManager.getTotalFilesForTransfer();
|
int totalFileCount = wifiDirectManager.getTotalFilesForTransfer();
|
||||||
|
@ -47,14 +47,12 @@ class SenderDeviceAsyncTask extends AsyncTask<Uri, Integer, Boolean> {
|
|||||||
@Override
|
@Override
|
||||||
protected Boolean doInBackground(Uri... fileUris) {
|
protected Boolean doInBackground(Uri... fileUris) {
|
||||||
|
|
||||||
/*try {
|
try { // Delay before trying to connect with receiver, to allow slower devices to setup server
|
||||||
Thread.sleep(5000);
|
Thread.sleep(3000);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Log.e(TAG, e.getMessage());
|
Log.e(TAG, e.getMessage());
|
||||||
return false;
|
return false;
|
||||||
}*/
|
}
|
||||||
|
|
||||||
for(int i = 0; i < 2000000000; i++);
|
|
||||||
|
|
||||||
boolean result = true;
|
boolean result = true;
|
||||||
int fileItemIndex = -1;
|
int fileItemIndex = -1;
|
||||||
@ -74,7 +72,7 @@ class SenderDeviceAsyncTask extends AsyncTask<Uri, Integer, Boolean> {
|
|||||||
String hostAddress = wifiDirectManager.getFileReceiverDeviceAddress().getHostAddress();
|
String hostAddress = wifiDirectManager.getFileReceiverDeviceAddress().getHostAddress();
|
||||||
socket.connect((new InetSocketAddress(hostAddress, FILE_TRANSFER_PORT)), 15000);
|
socket.connect((new InetSocketAddress(hostAddress, FILE_TRANSFER_PORT)), 15000);
|
||||||
|
|
||||||
if (BuildConfig.DEBUG) Log.d(TAG, "Sender socket - " + socket.isConnected());
|
Log.d(TAG, "Sender socket connected to server - " + socket.isConnected());
|
||||||
publishProgress(fileItemIndex, SENDING);
|
publishProgress(fileItemIndex, SENDING);
|
||||||
|
|
||||||
OutputStream socketOutputStream = socket.getOutputStream();
|
OutputStream socketOutputStream = socket.getOutputStream();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user