worker package - librespeed/speedtest-android GitHub Wiki
SpeedtestWorker class
Performs the speedtest using a given TestPoint, SpeedtestConfig and TelemetryConfig. This is the Java equivalent of speedtest_worker.js. Creates a Thread. Starts immediately (no need to call start()).
Constructor:
public SpeedtestWorker(TestPoint backend, SpeedtestConfig config, TelemetryConfig telemetryConfig)
backend: the TestPoint to use to perform the speedtestconfig: speedtest settings. Use null to use the default settingstelemetryConfig: telemetry settings. Use null to use the default settings (telemetry disabled)
The GetIP class is used to fetch IP and ISP info.
The download test uses multiple instances of DownloadStream to perform the test. After an initial grace time in which speed data is discarded, speed is measured as the amount of downloaded data over the amount of time it took to download it.
The upload test uses multiple instances of UploadStream to perform the test. After an initial grace time in which speed data is discarded, speed is measured as the amount of uploaded data over the amount of time it took to send it.
The ping test is performed by a single PingStream. The ping reported by the test is the lowest ping measured. Jitter is also calculated as the variance between consecutive pings.
At the end of the test, the Telemetry class is used to send telemetry (if enabled).
Each test can only be ran once.
Callbacks:
onDownloadUpdateis called periodically during the download test to report the download speed.dlis the current speed in Mbps,progressis a number between 0 and 1 representing how close we are to the time limitonUploadUpdateis called periodically during the upload test to report the upload speed.ulis the current speed in Mbps,progressis a number between 0 and 1 representing how close we are to the time limitonPingJitterUpdateis called periodically during the ping+jitter test to report ping and jitter times.pingis the current ping,jitteris the current jitter,progressis a number between 0 and 1 representing how close we are to the time limitonIPInfoUpdateis called when the IP address and ISP information is received.ipInfois a string combining this informationonTestIDReceivedis called at the end of the test when we receive an ID from the telemetry.idis a string containing the test ID that can be used to generate a share linkonEndis called at the end of the testonCriticalFailureis called if the test fails.erris a string containing details about the error
Methods:
abort(): aborts the test as soon as possible. Usejoin()to wait for the test to die.