Add FileObserver to detect local file change
Description
Add FileObserver on user's media directory.
Issue(s)
closes https://gitlab.e.foundation/e/os/backlog/-/issues/2
Test environment
- Root your device (App is now persistent, so it's Required) (
adb root
) - Download artifact from latest pipeline
- Extract the release-unsigned APK
- Sign the APK accordingly to your test devices (
apksigner sign --key xxx.pk8 --cert xxx.x509.pem --out eDrive.apk xxxx.apk
) - Manually push the signed APK on the device (
adb remount
thenadb push eDrive.apk /system/app/eDrive/eDrive.apk
) - Reboot the device. (
adb reboot
) - Register an /e/ account if no one is already registered.
Test procedures
Check FileObserver start/stop with adb logcat | grep 'EdriveApplication*'
- Recursive File Observer must start to watch on:
- first /e/ account registration
- On device reboot if an account is registered
- RecursiveFileObserver must stop to watch on:
- /e/ account deletion
EdriveApplication logcat example:
- waiting for device -
03-08 18:39:34.689 1996 1996 I EdriveApplication: Starting
03-08 18:39:34.745 1996 1996 D EdriveApplication: Account already registered
03-08 18:39:34.901 1996 1996 D EdriveApplication: Starting RecursiveFileObserver on media's root folder
check FileEvent is detected with adb logcat | grep 'FileEventListener*'
- DELETE when file/folder is deleted
- CLOSE_WRITE when file/folder is created/deleted/moved/edited
FileEvent logcat example:
03-08 18:18:42.301 2004 2209 D FileEventListener: CLOSE_WRITE event for :96.jpg
03-08 18:18:52.943 2004 2209 D FileEventListener: DELETE event for :96.jpg
03-08 18:18:52.962 2004 2209 D FileEventListener: DELETE event for :Screenshot_20220308-181736_Gallery.png
03-08 18:35:27.708 2004 2209 D FileEventListener: CLOSE_WRITE event for :Screenshot_20220308-183527_Gallery.png
Technical details
Branch built over the one managed by MR !73 (merged) There was also a rebase, so code review can be started from 277bb13c
Screenshots
Check list
-
Self review -
Test procedure explained -
Tested on fresh install -
Tested applied as an update -
License
Edited by Vincent Bourgmayer