To get started with a project, just open it using Android Studio after cloning.
To build the library, run:
./gradlew fingerprint:assemble
The files will appear at fingerprint/build/outputs/aar
.
The Playground application depends on libraries located in fingerprint/build/outputs/aar
with the corresponding build-flavor. So before building the app make sure that the library has been built.
To build the Playground app, run:
./gradlew app:assemble
Also you can perform these actions with Android Studio.
At the moment, library contains unit-tests and lint-checks. To perform the checks, run:
./gradlew fingerprint:lint
./gradlew fingerprint:testDebug
The code style is the default for Kotlin.
Also, add 2 lines of indentation before and after import sections.
If you found and fixed a bug, or you extended the functionality of the library - create a PR.
If you would like to add a new platform-signal follow the next steps:
- Add a new method to a corresponding
datasource
(look thedatasources
package) - Wrap the method inside the
executeSafe
method - this will provide the crash-free property of the library. - Write a simple unit-test, where some exception occurs while calling the method. The expected result is no unhandled exceptions and returning some default value.
An example of the datasource with sensors information is below. The default value here is emptyList().
class SensorDataSourceImpl(
private val sensorManager: SensorManager
) : SensorDataSource {
override fun sensors(): List<SensorData> {
return executeSafe(
{
sensorManager.getSensorList(Sensor.TYPE_ALL).map {
SensorData(it.name, it.vendor)
}
}, emptyList()
)
}
}
Corresponding unit-test is following. The mock()
method will create dummy SensorManager
object, and that will produce NullPointerException. The expected result - is the emptiness of the returned list.
@Test
fun `SensorsDataSource crash free`() {
val sensorsDataSource = SensorDataSourceImpl(
mock()
)
assertEquals(0, sensorsDataSource.sensors().size)
}
If you would like to create new version of fingerprint follow the next steps:
- There is a
signal_providers
package, that contains classes responsible for aggregating datasources and calculating fingerprints. So add new version code for every signal provider, as shown below:
Before the update:
override fun fingerprint(): String {
return when (version) {
1 -> v1()
else -> v1()
}
}
private fun v1(): String {
...
}
After the update:
override fun fingerprint(): String {
return when (version) {
1 -> v1()
2 -> v2()
else -> v2()
}
}
private fun v1(): String {
...
}
private fun v2(): String {
// Implement the new version of fingerprint here
}
- Write unit-tests for every signal providers and the new version. See the examples in test packages .