Commit 91c0e2fbb6193d7d16c1668b7deed5eb6e73e12c
1 parent
e0c3f3a0
--no commit message
Showing
2 changed files
with
15 additions
and
16 deletions
src/com/upc/pbe/upcnews/BandwidthMeasurer.java
@@ -4,24 +4,23 @@ import android.net.TrafficStats; | @@ -4,24 +4,23 @@ import android.net.TrafficStats; | ||
4 | import android.util.Log; | 4 | import android.util.Log; |
5 | 5 | ||
6 | //Mesura la velocitat (Bandwidth) d'Internet | 6 | //Mesura la velocitat (Bandwidth) d'Internet |
7 | -public class BandwidthMeasurer | ||
8 | -{ | ||
9 | - private final static String TAG = "Mesurador"; | ||
10 | - public double Measure(long rxBytes, long Time) | ||
11 | - { | 7 | +public class BandwidthMeasurer { |
8 | + private final static String TAG = "Mesurador de bandwith"; | ||
9 | + | ||
10 | + public double Measure(long rxBytes, long time) { | ||
12 | long AfterTime = System.currentTimeMillis(); | 11 | long AfterTime = System.currentTimeMillis(); |
13 | - double bps; | 12 | + double bps; |
14 | long TotalRxAfterTest = TrafficStats.getTotalRxBytes(); | 13 | long TotalRxAfterTest = TrafficStats.getTotalRxBytes(); |
15 | - double TimeDifference = AfterTime - Time; | 14 | + double TimeDifference = AfterTime - time; |
16 | double rxDiff = TotalRxAfterTest - rxBytes; | 15 | double rxDiff = TotalRxAfterTest - rxBytes; |
17 | - Log.d(TAG,"Diferencia de temps = " + TimeDifference/1000); | 16 | + Log.d(TAG, "Diferencia de temps = " + TimeDifference / 1000); |
18 | Log.d(TAG, "Diferencia de bytes = " + rxDiff); | 17 | Log.d(TAG, "Diferencia de bytes = " + rxDiff); |
19 | - if(rxDiff != 0){ | ||
20 | - bps = ((rxDiff*8) / (TimeDifference/1000)); // total de rx en bits per second. | ||
21 | - Log.d(TAG, "Velocitat actual (KB/s): " + (bps / 8e3)); | ||
22 | - } | ||
23 | - else{ | ||
24 | - bps = -1; //No s'han trasmes dades | 18 | + if (rxDiff != 0) { |
19 | + bps = ((rxDiff * 8) / (TimeDifference / 1000)); // total de rx en | ||
20 | + // bits per segon. | ||
21 | + Log.d(TAG, "Velocitat actual (KB/s): " + (bps / 8e3)); | ||
22 | + } else { | ||
23 | + bps = -1; // No s'han trasmès dades | ||
25 | } | 24 | } |
26 | return bps; | 25 | return bps; |
27 | } | 26 | } |
src/com/upc/pbe/upcnews/MainActivity.java
@@ -130,8 +130,8 @@ public class MainActivity extends Activity implements OnClickListener | @@ -130,8 +130,8 @@ public class MainActivity extends Activity implements OnClickListener | ||
130 | 130 | ||
131 | /* | 131 | /* |
132 | * COSAS POR HACER | 132 | * COSAS POR HACER |
133 | - * (NORMAL) Poner la defaultURL al server de PBE | ||
134 | - * (WHISLIST) Hacer streaming DE VERDAD (appendeando los videos, seria IMPRESIONANTE) | 133 | + * (ABANS DE LA PRESENTACIÓ) Poner la defaultURL al server de PBE |
134 | + * (WHISLIST FOR IMANOL) Hacer streaming DE VERDAD (appendeando los videos, seria IMPRESIONANTE) | ||
135 | * Borrar esta puta mierda | 135 | * Borrar esta puta mierda |
136 | */ | 136 | */ |
137 | } | 137 | } |