Loading android/app/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java +12 −5 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import android.os.Message; import android.os.PowerManager; import android.os.PowerManager.WakeLock; import android.os.Process; import android.os.SystemClock; import android.util.Log; import java.io.BufferedInputStream; Loading Loading @@ -440,6 +441,8 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession { long prevPercent = 0; boolean okToProceed = false; long timestamp = 0; long currentTime = 0; long prevTimestamp = SystemClock.elapsedRealtime(); int outputBufferSize = putOperation.getMaxPacketSize(); byte[] buffer = new byte[outputBufferSize]; BufferedInputStream a = new BufferedInputStream(fileInfo.mInputStream, 0x4000); Loading Loading @@ -491,7 +494,7 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession { while (!mInterrupted && okToProceed && (position < fileInfo.mLength)) { if (V) { timestamp = System.currentTimeMillis(); timestamp = SystemClock.elapsedRealtime(); } readLength = a.read(buffer, 0, outputBufferSize); Loading @@ -508,19 +511,23 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession { okToProceed = false; } else { position += readLength; currentTime = SystemClock.elapsedRealtime(); if (V) { Log.v(TAG, "Sending file position = " + position + " readLength " + readLength + " bytes took " + (System.currentTimeMillis() - timestamp) + " ms"); Log.v(TAG, "Sending file position = " + position + " readLength " + readLength + " bytes took " + (currentTime - timestamp) + " ms"); } // Update the Progress Bar only if there is change in percentage // or once per a period to notify NFC of this transfer is still alive percent = position * 100 / fileInfo.mLength; if (percent > prevPercent) { if (percent > prevPercent || currentTime - prevTimestamp > Constants.NFC_ALIVE_CHECK_MS) { updateValues = new ContentValues(); updateValues.put(BluetoothShare.CURRENT_BYTES, position); mContext1.getContentResolver() .update(contentUri, updateValues, null, null); prevPercent = percent; prevTimestamp = currentTime; } } } Loading android/app/src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java +10 −4 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import android.os.Handler; import android.os.Message; import android.os.PowerManager; import android.os.PowerManager.WakeLock; import android.os.SystemClock; import android.util.Log; import android.webkit.MimeTypeMap; Loading Loading @@ -491,11 +492,13 @@ public class BluetoothOppObexServerSession extends ServerRequestHandler byte[] b = new byte[outputBufferSize]; int readLength = 0; long timestamp = 0; long currentTime = 0; long prevTimestamp = SystemClock.elapsedRealtime(); try { while ((!mInterrupted) && (position != fileInfo.mLength)) { if (V) { timestamp = System.currentTimeMillis(); timestamp = SystemClock.elapsedRealtime(); } readLength = is.read(b); Loading @@ -510,20 +513,23 @@ public class BluetoothOppObexServerSession extends ServerRequestHandler bos.write(b, 0, readLength); position += readLength; percent = position * 100 / fileInfo.mLength; currentTime = SystemClock.elapsedRealtime(); if (V) { Log.v(TAG, "Receive file position = " + position + " readLength " + readLength + " bytes took " + (System.currentTimeMillis() - timestamp) + " ms"); + " bytes took " + (currentTime - timestamp) + " ms"); } // Update the Progress Bar only if there is change in percentage if (percent > prevPercent) { // or once per a period to notify NFC of this transfer is still alive if (percent > prevPercent || currentTime - prevTimestamp > Constants.NFC_ALIVE_CHECK_MS) { ContentValues updateValues = new ContentValues(); updateValues.put(BluetoothShare.CURRENT_BYTES, position); mContext.getContentResolver().update(contentUri, updateValues, null, null); prevPercent = percent; prevTimestamp = currentTime; } } } catch (IOException e1) { Loading android/app/src/com/android/bluetooth/opp/Constants.java +7 −0 Original line number Diff line number Diff line Loading @@ -231,6 +231,13 @@ public class Constants { /** Where we store Bluetooth received files on the external storage */ public static final String DEFAULT_STORE_SUBDIR = "/bluetooth"; /** * Notify NFC of the transfer progress per this period * to NFC Handover still consider this transfer to be "alive" * This value is taken into account the timeout value 20sec in NFC and delaying broadcast */ public static final int NFC_ALIVE_CHECK_MS = 10000; /** * Debug level logging */ Loading Loading
android/app/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java +12 −5 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import android.os.Message; import android.os.PowerManager; import android.os.PowerManager.WakeLock; import android.os.Process; import android.os.SystemClock; import android.util.Log; import java.io.BufferedInputStream; Loading Loading @@ -440,6 +441,8 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession { long prevPercent = 0; boolean okToProceed = false; long timestamp = 0; long currentTime = 0; long prevTimestamp = SystemClock.elapsedRealtime(); int outputBufferSize = putOperation.getMaxPacketSize(); byte[] buffer = new byte[outputBufferSize]; BufferedInputStream a = new BufferedInputStream(fileInfo.mInputStream, 0x4000); Loading Loading @@ -491,7 +494,7 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession { while (!mInterrupted && okToProceed && (position < fileInfo.mLength)) { if (V) { timestamp = System.currentTimeMillis(); timestamp = SystemClock.elapsedRealtime(); } readLength = a.read(buffer, 0, outputBufferSize); Loading @@ -508,19 +511,23 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession { okToProceed = false; } else { position += readLength; currentTime = SystemClock.elapsedRealtime(); if (V) { Log.v(TAG, "Sending file position = " + position + " readLength " + readLength + " bytes took " + (System.currentTimeMillis() - timestamp) + " ms"); Log.v(TAG, "Sending file position = " + position + " readLength " + readLength + " bytes took " + (currentTime - timestamp) + " ms"); } // Update the Progress Bar only if there is change in percentage // or once per a period to notify NFC of this transfer is still alive percent = position * 100 / fileInfo.mLength; if (percent > prevPercent) { if (percent > prevPercent || currentTime - prevTimestamp > Constants.NFC_ALIVE_CHECK_MS) { updateValues = new ContentValues(); updateValues.put(BluetoothShare.CURRENT_BYTES, position); mContext1.getContentResolver() .update(contentUri, updateValues, null, null); prevPercent = percent; prevTimestamp = currentTime; } } } Loading
android/app/src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java +10 −4 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import android.os.Handler; import android.os.Message; import android.os.PowerManager; import android.os.PowerManager.WakeLock; import android.os.SystemClock; import android.util.Log; import android.webkit.MimeTypeMap; Loading Loading @@ -491,11 +492,13 @@ public class BluetoothOppObexServerSession extends ServerRequestHandler byte[] b = new byte[outputBufferSize]; int readLength = 0; long timestamp = 0; long currentTime = 0; long prevTimestamp = SystemClock.elapsedRealtime(); try { while ((!mInterrupted) && (position != fileInfo.mLength)) { if (V) { timestamp = System.currentTimeMillis(); timestamp = SystemClock.elapsedRealtime(); } readLength = is.read(b); Loading @@ -510,20 +513,23 @@ public class BluetoothOppObexServerSession extends ServerRequestHandler bos.write(b, 0, readLength); position += readLength; percent = position * 100 / fileInfo.mLength; currentTime = SystemClock.elapsedRealtime(); if (V) { Log.v(TAG, "Receive file position = " + position + " readLength " + readLength + " bytes took " + (System.currentTimeMillis() - timestamp) + " ms"); + " bytes took " + (currentTime - timestamp) + " ms"); } // Update the Progress Bar only if there is change in percentage if (percent > prevPercent) { // or once per a period to notify NFC of this transfer is still alive if (percent > prevPercent || currentTime - prevTimestamp > Constants.NFC_ALIVE_CHECK_MS) { ContentValues updateValues = new ContentValues(); updateValues.put(BluetoothShare.CURRENT_BYTES, position); mContext.getContentResolver().update(contentUri, updateValues, null, null); prevPercent = percent; prevTimestamp = currentTime; } } } catch (IOException e1) { Loading
android/app/src/com/android/bluetooth/opp/Constants.java +7 −0 Original line number Diff line number Diff line Loading @@ -231,6 +231,13 @@ public class Constants { /** Where we store Bluetooth received files on the external storage */ public static final String DEFAULT_STORE_SUBDIR = "/bluetooth"; /** * Notify NFC of the transfer progress per this period * to NFC Handover still consider this transfer to be "alive" * This value is taken into account the timeout value 20sec in NFC and delaying broadcast */ public static final int NFC_ALIVE_CHECK_MS = 10000; /** * Debug level logging */ Loading