IDS: Code for the Android App
See Releases »
Research Paper
·
Test Results
·
See Global Usage
Table of Contents
This code will be used in order to receive the anomalies detected by the Arduino and to check if an event is linked to a distant action.
- Android Studio is the preferred way to use this project.
If you don't use Android Studio
- Install the Command line tools for Android and move the content of
cmdline-tools/bininto a newly created tree structure:<android_sdk_path>/cmdline-tools/latest/bin/where<android_sdk_path>is a path of your choice where the SDK will be installed (see: https://developer.android.com/studio/command-line/sdkmanager).cd <android_sdk_path> mkdir -p cmdline-tools/latest cp -r cmdline-tools/* cmdline-tools/latest/
- Install the Android SDK with
sdkmanager:cd <android_sdk_path>/cmdline-tools/latest/bin sdkmanager "platform-tools" "platforms;android-33"
- Clone the project. Then if you use Android Studio, open the project and skip to step 3.
git clone https://github.com/PIR-IDS/IDS-Android-App.git
- If you don't use Android Studio: Create your
local.propertiesfile. Replace<android_sdk_path>with the path to your local Android SDK you installed withsdkmanager.echo "sdk.dir=<android_sdk_path>" > local.properties
- Optional: If you want to test the release version of the app on your device, set up your
keystore.propertiesfile by copyingkeystore.properties.templateand renaming itkeystore.properties. Fill it with the necessary information, i.e. your local development release keys (see: https://developer.android.com/studio/build/building-cmdline#sign_cmdline and https://developer.android.com/studio/publish/app-signing#secure-shared-keystore).cp keystore.properties.template keystore.properties
- IDS Android App is now ready to run.
Use the following script in the project root to install the app in debug mode (with the Android device plugged):
./gradlew installDebugYou can also run the release version when the app is signed (see Installation Step 3) with:
./gradlew installReleaseYou can run the unit tests and the Android tests (with the Android device plugged) powered by JUnit with the following command:
./gradlew test
./gradlew connectedAndroidTestTo generate all the APKs, launch the following script:
./gradlew buildThe APKs are generated in the app/build/outputs/apk directory.
You can also generate the AABs with the following script:
./gradlew bundleThe AABs are generated in the app/build/outputs/bundle directory.
To generate all the Dokka documentation, launch the following script:
./gradlew dokkaHtmlThe documentation is generated in the app/build/dokka directory.
You will find in this section how to add new services and devices to the project.
Add a Service to the compatibility list
To add a new service to the compatible ones, you need to add the necessary resources and then edit some files.
- Add an square icon for the service in the folder
app/src/main/res/drawable-nodpiin PNG, for examplemy_service_logo.png. - Add a string resource for the service description in the folder
app/src/main/res/values/strings.xml, for examplemy_service_description. Do not forget to translate the string in all the languages supported by the app.
- Add an enumeration to ServiceId with a unique tag in
app/src/main/java/fr/pirids/idsapp/data/items/Service.kt. Also add the service to the Service list with the associated devices that will be used to detect the behavioural anomalies. - Add a way to handle the service credentials necessary to interact with the API in a new created file in
app/src/main/java/fr/pirids/idsapp/data/api/auth, namedMyServiceAuth.kt. This class has to inherit fromApiAuth. You will have to provide a way to instanciate this class each time a connection has to be made, notably during thewhenstatements in each of these files:app/src/main/java/fr/pirids/idsapp/controller/detection/Service.kt. - Add a way to handle the service data you get from the API in a new created file in
app/src/main/java/fr/pirids/idsapp/data/api/data, namedMyServiceData.kt. This class has to inherit fromApiData. You will have to provide a way to instanciate this class each time data has to be retrieved, notably during thewhenstatements in each of these files:app/src/main/java/fr/pirids/idsapp/controller/detection/Service.kt,app/src/main/java/fr/pirids/idsapp/ui/views/service/ServiceView.kt,app/src/main/java/fr/pirids/idsapp/controller/detection/Detection.kt,app/src/main/java/fr/pirids/idsapp/controller/daemon/ServiceDaemon.kt. - Create a class that will handle the connection to the service, which inherits from
ApiInterfacein a new created file inapp/src/main/java/fr/pirids/idsapp/controller/api, namedMyServiceApi.kt. You will have to provide a way to instanciate this class each time a connection has to be made, notably during thewhenstatements in each of these files:app/src/main/java/fr/pirids/idsapp/controller/detection/Service,app/src/main/java/fr/pirids/idsapp/controller/daemon/ServiceDaemon.kt. - Add the persistence of the credentials and the data retrieved by creating the entity and DAO linked to the new service. Create a new file in
app/src/main/java/fr/pirids/idsapp/data/model/entity/servicenamedMyServiceAuth.kt. Link a foreign key to theApiAuthentity id. Create a new file inapp/src/main/java/fr/pirids/idsapp/data/model/entity/servicenamedMyServiceData.kt. Link a foreign key to theApiDataentity id. Register the newly created entities into theapp/src/main/java/fr/pirids/idsapp/data/model/AppDatabase.ktfile. Now create the DAO for the new service, following the same logic in theapp/src/main/java/fr/pirids/idsapp/data/model/daopackage. Call themMyServiceAuthDaoandMyServiceDataDaoand add their implementation to theapp/src/main/java/fr/pirids/idsapp/data/model/AppDatabase.ktfile. You will have to use the DAO notably during thewhenstatements in each of these files:app/src/main/java/fr/pirids/idsapp/controller/detection/Service,app/src/main/java/fr/pirids/idsapp/controller/daemon/ServiceDaemon.kt,app/src/main/java/fr/pirids/idsapp/controller/detection/Detection.kt.
Add a BLE Device support
To support a new BLE device, you need to add the necessary resources and then edit some files.
- Add an square icon for the device in the folder
app/src/main/res/drawable-nodpiin PNG, for exampleids_device_name_logo.png. - Add a string resource for the device description in the folder
app/src/main/res/values/strings.xml, for exampledevice_name_desc. Also add a data name, for exampledevice_name_data, an event message, for exampledevice_name_event_messageand an intrusion message, for exampledevice_name_intrusion. Do not forget to translate all the strings in all the languages supported by the app.
- Add an enumeration to DeviceId with a unique tag in
app/src/main/java/fr/pirids/idsapp/data/items/Device.kt. Also add the device to the Device list with the associated Bluetooth services that will be used to transmit the data. You can add the services with their characteristics in their respective files if they are still not added. - Add a way to handle the service data you get from the device in a new created file in
app/src/main/java/fr/pirids/idsapp/data/device/data, namedMyDeviceData.kt. This class has to inherit fromDeviceData, you can also add some Bluetooth characteristics you would want to store during runtime in there. You will have to provide a way to instanciate this class each time data has to be used, notably during thewhenstatements in each of these files:app/src/main/java/fr/pirids/idsapp/controller/view/menus/NotificationViewController.kt,app/src/main/java/fr/pirids/idsapp/ui/views/service/DeviceView.kt,app/src/main/java/fr/pirids/idsapp/controller/detection/Detection.kt,app/src/main/java/fr/pirids/idsapp/controller/daemon/DeviceDaemon.kt,app/src/main/java/fr/pirids/idsapp/controller/bluetooth/Device.kt,app/src/main/java/fr/pirids/idsapp/controller/bluetooth/BluetoothConnection.kt. You will have to handle the BLE communication inapp/src/main/java/fr/pirids/idsapp/controller/bluetooth/BluetoothConnection.kt. - Add the persistence of the device data retrieved by creating the entity and DAO linked to the new device. Create a new file in
app/src/main/java/fr/pirids/idsapp/data/model/entity/devicenamedMyDeviceData.kt. Link a foreign key to theDeviceDataentity id. Register the newly created entity into theapp/src/main/java/fr/pirids/idsapp/data/model/AppDatabase.ktfile. Now create the DAO for the new device, following the same logic in theapp/src/main/java/fr/pirids/idsapp/data/model/daopackage. Call itMyDeviceDataDaoand add its implementation to theapp/src/main/java/fr/pirids/idsapp/data/model/AppDatabase.ktfile. You will have to use the DAO notably during thewhenstatements in each of these files:app/src/main/java/fr/pirids/idsapp/controller/daemon/DeviceDaemon.kt,app/src/main/java/fr/pirids/idsapp/controller/bluetooth/BluetoothConnection.kt.
Details
TODO
Romain Monier [ GitHub ] – Co-developer
Morgan Pelloux [ GitHub ] – Co-developer
David Violes [ GitHub ] – Co-developer
Amélie Muller [ GitHub ] – Co-developer
Malik Sedira [ GitHub ] – Co-developer
Quentin Douarre [ GitHub ] – Co-developer
Noé Chauveau [ GitHub ] – Co-developer
Pierre Favary [ GitHub ] – Co-developer
Project Link : https://github.com/PIR-IDS/IDS-Android-App
Organization Link : https://github.com/PIR-IDS



