1-1
1-2
2-1
GPS Device
GPS Driver
HAL
GonkGPSLocationProvider
GonkGPSGeolocationProvider::LocationCallback
Pack the location info, network infrastructure info into a file (json format) called stumble
2-2
stumbles.json.gz
When stumbles > 15 KB
stumbles.done.json.gz
If the upload file is older than 1day, we try to upload the file.
Each upload is triggered by a new location.
The maxium of upload attempt is 20 times a day.
https://location.services.mozilla.com
2-3
2-4
2-5
If there is stumble that needed to be uploaded?
Check if there consecutive GPS locations are 30 meters and 3 seconds apart?
False
True
True
False
Exit
Trigger WriteStumbleOnThread with an empty string. Then exit.
Dispatch a RequestCellInfoEvent with StumblerInfo to main thread.
Then exit.
2-6
Set the number of expected Cell-Info responses according to the number of SIM cards.
1. Trigger a cell-tower scan.
Use "GetCellInfoList" with specific callback(nsICellInfoListCallback).
2. Trigger a WiFi AP scan.
Use "GetWifiScanResults" with specific callback(nsIWifiScanResultsReady).
2-7
StumblerInfo
Callback for the scan result of Cell-Tower
Callback for the scan result of WiFi AP
Prepare the string with all needed information. (Location Info/Cell Network/Wifi AP)
Trigger WriteStumbleOnThread to generate a stumble
2-8
stumbles.json.gz
When stumbles > 15 KB
stumbles.done.json.gz
If the upload file is older than 1day, we try to upload the file.
Each upload is triggered by a new location.
The maxium of upload attempt is 20 times a day.
https://location.services.mozilla.com
UploadStumbleRunnable
WriteStumbleOnThread
3-1
GetUploadFileStatus()
Trigger UploadStumbleOnThread
ExistsAndReadyToUpload
NoFile
WriteJSON()
Exists
No action. (stumbles.done.json.gz is less than one day old)
The file will rename from "stumbles.json.gz" to "stumbles.done.json.gz" when the size is over 15KB
3-2
3-3
1. Do GeoSubmit [1]
2. Listen several events
(abort, error, load, timeout)
UploadEnded(doDelete=true)
(200 || 400)
other statusCode
Check the XMLHttpRequest status code when observing the events above
UploadEnded(doDelete=false)
The stumble will be deleted if doDelete is true. Otherwise, we will keep the stumble and retry uploading next time.
3-4
3-5
stumbles.json.gz
When stumbles > 15 KB
stumbles.done.json.gz
If the upload file is older than 1 day old, we will try to upload the file.
Each upload is triggered by a new location.
The maximum of upload attempt is 20 times a day.
https://location.services.mozilla.com
UploadStumbleRunnable
WriteStumbleOnThread
3-1
A better event to trigger the upload. Ideally we would preferentially upload when connected to WiFi.
Maximum upload currently: 15 KB per day.
Show the contribution of stumbling in Gaia.
number | size |
---|---|
1 item | 609 bytes |
20 - 30 | 15 KB |
Date-1.json.gz
Date-2.json.gz
Date-3.json.gz
Date-4.json.gz
All files are less than "12.5 KB"
Date-1.json.gz
Date-1.json.gz
Remove
Rename
Rename
Rename
When Data-4.json is more than 12.5 KB
Date-4.json.gz
Date-3.json.gz
Date-2.json.gz
#define OLDEST_FILE_NUMBER 1
#define MAXFILENUM 4
#define MAXFILESIZE_KB 12.5 * 1024
feeding-1.json.gz
Date-1.json.gz
Move to Upload List
Rename
Rename
Rename
When Data-4.json is more than 12.5 KB
feeding-4.json.gz
feeding-3.json.gz
feeding-2.json.gz
upload01.json.gz
Move to Upload List
upload02.json.gz
upload03.json.gz
upload04.json.gz
#define OLDEST_FILE_NUMBER 1
#define MAXUPLOADFILENUM 15
#define MAXFILESIZE_KB 12.5 * 1024
{"items":
[{"accuracy":100.000000,
"altitude":0.000000,
"altitudeAccuracy":100.000000,
"heading":0.000000,
"latitude":25.032472,
"longitude":121.566065,
"speed":0.000000,
"timestamp":1439457536722,
"cellTowers":
[{"radioType":"wcdma","asu":14,"cellId":9111196,
"locationAreaCode":11115,"mobileCountryCode":466,"mobileNetworkCode":97,
"psc":108,"serving":1},
{"radioType":"wcdma","asu":12,"psc":109,"serving":0},
{"radioType":"wcdma","asu":10,"psc":292,"serving":0}],
"wifiAccessPoints":
[{"macAddress":"3c1e040a2f0e","signalStrength":-39},
{"macAddress":"dc38e1832980","signalStrength":-50}]
}]
}
nsRefPtr<StumblerInfo> requestCallback = new StumblerInfo(position);
nsRefPtr<RequestCellInfoEvent> runnable = new RequestCellInfoEvent(requestCallback);
class StumblerInfo final : public nsICellInfoListCallback,
public nsIWifiScanResultsReady
{
public:
...
private:
int mCellInfoResponsesExpected;
int mCellInfoResponsesReceived;
bool mIsWifiInfoResponseReceived;
}