Collect sensor data and system information to a websocket server
- Add Jitpack repository to your root
build.gradle:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}- Add the dependency:
dependencies {
implementation 'com.github.ignassew:AndroidSensorCollector:v1.0.4'
}- Add necessary permissions
- Initialize the Collector class when the app starts:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Collector(application, "<server address>")
// ...
}This library doesn't state any permissions in its manifest, but it does require internet access. You will need to add android.permission.INTERNETto your AndroidManifest.xml
If your WebSocket server is not behind TLS,
you will have to add android:usesCleartextTraffic="true" attribute
to application
in AndroidManifest.xml.
All data being collected is anonymous.
- Manufacturer
- Hardware
- Model
- Bootloader
- Product
- Tags
- Type
- User
- Display
- Board
- Brand
- Device
- Fingerprint
- Host
- Id
- Version
- Screen
- width
- height
- pixel density
- List of available sensors
- Performance micro-benchmarks (e.g. square root of a number ran n times)
- SHA-256 hash of ANDROID_ID and Build.FINGERPRINT combined
To prevent battery drain, this library will collect at least 1024 events of each type and then turn off. This takes around 4 minutes.
This library collects only following sensor events:
My server is currently not open source.
If you want to build your own server, read the spec below:
This library uses WebSockets to communicate with the server. There are only 4 message types sent by the client. Messages are encoded in JSON. Server is not expected to ever send anything back.
Identity
This message has to be sent before any other message. Otherwise server shall close the connection.
{
"messageType": "identity",
"packageName": "com.ignassew.myapplication"
}System Info
{
"build": {
"board": "string",
"bootloader": "string",
"brand": "string",
"device": "string",
"display": "string",
"fingerprint": "string",
"hardware": "string",
"host": "string",
"id": "string",
"manufacturer": "string",
"model": "string",
"product": "string",
"tags": "string",
"type": "string",
"user": "string",
"version": {
"codename": "string",
"incremental": "string",
"release": "string",
"sdk_int": "int"
}
},
"id": "string",
"messageType": "systemInfo",
"perfBench": "list<string>",
"screen": {
"density": "float",
"heightPixels": "int",
"widthPixels": "int"
},
"sensorList": "list<string>"
}Sensor
{
"accuracy": "int",
"messageType": "sensor",
"timestamp": "int (nanoseconds)",
"type": "int",
"x": "float",
"y": "float",
"z": "float"
}
Error
{
"messageType": "error",
"message": "string"
}Copyright 2023 Ignacy Sewastianowicz
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.