mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-23 12:42:56 -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
|
||||
protected Boolean doInBackground(Void... voids) {
|
||||
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();
|
||||
int totalFileCount = wifiDirectManager.getTotalFilesForTransfer();
|
||||
|
@ -47,14 +47,12 @@ class SenderDeviceAsyncTask extends AsyncTask<Uri, Integer, Boolean> {
|
||||
@Override
|
||||
protected Boolean doInBackground(Uri... fileUris) {
|
||||
|
||||
/*try {
|
||||
Thread.sleep(5000);
|
||||
try { // Delay before trying to connect with receiver, to allow slower devices to setup server
|
||||
Thread.sleep(3000);
|
||||
} catch (InterruptedException e) {
|
||||
Log.e(TAG, e.getMessage());
|
||||
return false;
|
||||
}*/
|
||||
|
||||
for(int i = 0; i < 2000000000; i++);
|
||||
}
|
||||
|
||||
boolean result = true;
|
||||
int fileItemIndex = -1;
|
||||
@ -74,7 +72,7 @@ class SenderDeviceAsyncTask extends AsyncTask<Uri, Integer, Boolean> {
|
||||
String hostAddress = wifiDirectManager.getFileReceiverDeviceAddress().getHostAddress();
|
||||
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);
|
||||
|
||||
OutputStream socketOutputStream = socket.getOutputStream();
|
||||
|
Loading…
x
Reference in New Issue
Block a user