Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
5f9c644
create empty UI and navigation for tracker export
imbissbudenaesthetik Apr 21, 2025
d672438
initial implementation of the PDF creation
imbissbudenaesthetik Apr 21, 2025
999fb4b
Merge branch 'development' into pdfExport
imbissbudenaesthetik Apr 23, 2025
9ef3744
create necessary views for new pdf creation, hide old approach
imbissbudenaesthetik Apr 23, 2025
d2af954
basic pdf creation
imbissbudenaesthetik Apr 25, 2025
f601522
implement working map and pagination
imbissbudenaesthetik Apr 26, 2025
b8a3b66
add warning for 15 minute algorithm matching in pdf export
imbissbudenaesthetik Apr 26, 2025
219fa4e
add preview before creating pdf document
imbissbudenaesthetik Apr 26, 2025
010ee3f
Merge branch 'development' into pdfExport
imbissbudenaesthetik Apr 26, 2025
c930c85
add error message, when no internet connection during pdf creation is…
imbissbudenaesthetik Apr 29, 2025
e2e733f
Merge branch 'development' into pdfExport
imbissbudenaesthetik Apr 30, 2025
674eab5
fix build error
imbissbudenaesthetik Apr 30, 2025
106fb0e
Merge branch 'development' into pdfExport
imbissbudenaesthetik Apr 30, 2025
4893204
add Debug Mode toggle for disabling ble error messages
imbissbudenaesthetik May 2, 2025
07095dd
update gradle and some dependencies
imbissbudenaesthetik May 7, 2025
ea8726e
safer thread handling of PermanentBluetoothScanner
imbissbudenaesthetik May 7, 2025
9d75911
add Website to InformationFragment
imbissbudenaesthetik May 7, 2025
c3c64ab
add Website to InformationFragment
imbissbudenaesthetik May 18, 2025
95a39b3
Merge branch 'development' into pdfExport
imbissbudenaesthetik May 18, 2025
a06f081
show AirGuard Version Number on pdf report
imbissbudenaesthetik May 18, 2025
86f68a5
handle tracker ignored as additional state for pdf export, fix colors…
imbissbudenaesthetik May 18, 2025
c8d1668
update kotlin version to 2.1.21 and update dependencies
imbissbudenaesthetik May 23, 2025
2a23bcc
fix onboarding loop bug
imbissbudenaesthetik May 23, 2025
61699fd
adjust Android 15 System Bar Configuration
imbissbudenaesthetik May 23, 2025
786c67e
initial implementation of review controller
imbissbudenaesthetik May 26, 2025
18cf393
update gradle
imbissbudenaesthetik Jun 7, 2025
1d7ab6a
update dependencies
imbissbudenaesthetik Jun 11, 2025
4b6f86c
fix: pdf export shows that the tracker is following even if the notif…
imbissbudenaesthetik Jun 20, 2025
8996f73
pdf export: optimize loading times by creating map of locations inste…
imbissbudenaesthetik Jun 20, 2025
f169784
optimize loading in pdf export by adding new indices to beacon
imbissbudenaesthetik Jun 20, 2025
2adf75a
fix intent handling for notifications on newer android versions
imbissbudenaesthetik Jun 21, 2025
9c85ad2
update dependencies, kotlin version to 2.2.0 and gradle
imbissbudenaesthetik Jun 25, 2025
36dc91e
change last name of maintainer
imbissbudenaesthetik Jul 2, 2025
3c7b460
update dependencies
imbissbudenaesthetik Jul 2, 2025
412b411
fix crash in some navigation cases in TrackingFragment
imbissbudenaesthetik Jul 7, 2025
87d111b
update dependencies
imbissbudenaesthetik Jul 7, 2025
9954db4
update grade and some dependencies
imbissbudenaesthetik Jul 16, 2025
adc51a2
update some dependencies
imbissbudenaesthetik Jul 23, 2025
21f24af
fix some issues with the PermanentBluetoothScanner
imbissbudenaesthetik Jul 23, 2025
d99750d
fix issues in BluetoothLeService
imbissbudenaesthetik Jul 23, 2025
b2788d7
fix issues with gatt disconnect in Utility
imbissbudenaesthetik Jul 23, 2025
478b5ba
increment version number to 2.5.1
imbissbudenaesthetik Jul 27, 2025
81e0f6c
show error message on home screen if samsung android 15 ble bug occurs
imbissbudenaesthetik Aug 5, 2025
6d80330
update gradle and dependencies
imbissbudenaesthetik Aug 5, 2025
fad4852
Merge branch 'development' into optimized_scanning
imbissbudenaesthetik Aug 5, 2025
69725af
improve Bluetooth Error Detection
imbissbudenaesthetik Aug 11, 2025
1f60b11
add ScanOrchestrator to avoid accessing Bluetooth Resources on too ma…
imbissbudenaesthetik Aug 11, 2025
150a4dd
add Listeners to check if bluetooth or location is enabled in the system
imbissbudenaesthetik Aug 13, 2025
10d318a
replace specific bluetooth error message on main page with generic one
imbissbudenaesthetik Aug 13, 2025
eb9166a
bypass High Priority Scan in ScanOrchestrator immediately to ensure c…
imbissbudenaesthetik Aug 18, 2025
1fe4965
upgrade gradle, dependencies and kotlin version and target Android 16
imbissbudenaesthetik Aug 22, 2025
6281681
add dependency for Android 16 predictive back compatibility
imbissbudenaesthetik Aug 23, 2025
14fdc75
make PermanentBluetoothScheduler a toggle in the expert settings
imbissbudenaesthetik Aug 25, 2025
200d8b7
increase version number to 2.6.0
imbissbudenaesthetik Aug 28, 2025
beda836
update dependencies
imbissbudenaesthetik Aug 29, 2025
57de63e
add comment function for each individual tracker
imbissbudenaesthetik Sep 1, 2025
3404af0
show comment function only if database device exists
imbissbudenaesthetik Sep 1, 2025
8541049
add japanese and german translations
imbissbudenaesthetik Sep 1, 2025
f3f3184
reduce throttle window in ScanOrchestrator to ensure bluetooth scan a…
imbissbudenaesthetik Sep 4, 2025
3dc5d05
Merge branch 'development' into reviewController
imbissbudenaesthetik Sep 4, 2025
7ed71f4
upgrade gradle and some dependencies
imbissbudenaesthetik Sep 4, 2025
dbacf89
update proguard rules for ScanOrchestrator
imbissbudenaesthetik Sep 8, 2025
dd95266
fix default value for permanent bluetooth scanner
imbissbudenaesthetik Sep 8, 2025
8515c92
set permanentscanner default to disabled
imbissbudenaesthetik Sep 9, 2025
e10abe6
F-Droid Release 2.6.0
imbissbudenaesthetik Sep 9, 2025
4455f38
Merge branch 'development' into reviewController
imbissbudenaesthetik Sep 9, 2025
1337f58
update dependencies
imbissbudenaesthetik Sep 9, 2025
32cca2c
fix screenshots in ReadMe
imbissbudenaesthetik Sep 9, 2025
ec506f9
Merge branch 'main' into development
imbissbudenaesthetik Sep 9, 2025
ee7785f
Notification permission can now be denied, if disabled a warning will…
imbissbudenaesthetik Sep 15, 2025
6217e79
Background Location can now be denied, if disabled a warning will be …
imbissbudenaesthetik Sep 16, 2025
708b530
fix a bug where false alarm toggle was not displayed correctly
imbissbudenaesthetik Sep 16, 2025
c0d57d6
fix issue where notification buttons where not properly processed and…
imbissbudenaesthetik Sep 18, 2025
60554d0
fix issue where notification dismissal was not processed properly
imbissbudenaesthetik Sep 18, 2025
6ccbd99
fix map render issue under certain memory conditions when accessing t…
imbissbudenaesthetik Sep 20, 2025
6545c72
fix edge to edge problems with menus accessed from a notification
imbissbudenaesthetik Sep 20, 2025
f7b7b4a
fix old tracker deletion calculating with outdated times
imbissbudenaesthetik Sep 21, 2025
3a464e5
fix back navigation not working when application is accessed through …
imbissbudenaesthetik Sep 21, 2025
30a60c0
update dependencies, increase Version number to 2.6.1
imbissbudenaesthetik Sep 22, 2025
2a05525
F-Droid Release 2.6.1
imbissbudenaesthetik Sep 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
API_KEY="0pGhFp5V.3Me6ZeM4hqFnu8FDMrqZwpaau1fdE98Y"
API_KEY="3acPl2TP.lAyeGkWWlqPrgfWI9WbzqKKHejOmahJ3"
API_BASE_ADDRESS="https://tpe.seemoo.tu-darmstadt.de/api/"
33 changes: 19 additions & 14 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ android {
applicationId "de.seemoo.at_tracking_detection"
minSdkVersion 28
targetSdk = 36
versionCode 54
versionName "2.6.0"
versionCode 55
versionName "2.6.1"
buildConfigField "String", "API_KEY", apiProperties["API_KEY"]
buildConfigField "String", "API_BASE_ADDRESS", apiProperties["API_BASE_ADDRESS"]

Expand Down Expand Up @@ -92,23 +92,23 @@ dependencies {
implementation 'com.google.android.material:material:1.13.0'
implementation 'androidx.constraintlayout:constraintlayout:2.2.1'
implementation 'androidx.vectordrawable:vectordrawable:1.2.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.9.3'
implementation 'androidx.navigation:navigation-ui-ktx:2.9.3'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.9.3'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.9.3'
implementation 'androidx.navigation:navigation-fragment-ktx:2.9.4'
implementation 'androidx.navigation:navigation-ui-ktx:2.9.4'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.9.4'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.9.4'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.preference:preference-ktx:1.2.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.4.0'
implementation "androidx.profileinstaller:profileinstaller:1.4.1"
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0'

implementation "androidx.activity:activity-ktx:1.10.1"
implementation "androidx.activity:activity-ktx:1.11.0"
implementation 'com.squareup.retrofit2:retrofit:3.0.0'
implementation 'com.squareup.retrofit2:converter-gson:3.0.0'
implementation 'com.squareup.okhttp3:okhttp:5.1.0'
implementation 'com.squareup.okhttp3:logging-interceptor:5.1.0'
implementation 'com.google.code.gson:gson:2.13.1'
implementation 'com.google.code.gson:gson:2.13.2'
implementation "androidx.work:work-testing:$work_version"
implementation 'androidx.core:core-ktx:1.17.0'
debugImplementation 'com.squareup.okhttp3:logging-interceptor:5.1.0'
Expand All @@ -128,7 +128,7 @@ dependencies {

implementation 'com.github.mukeshsolanki:MarkdownView-Android:2.0.0'

implementation 'com.github.bumptech.glide:glide:5.0.4'
implementation 'com.github.bumptech.glide:glide:5.0.5'

ksp "com.google.dagger:hilt-compiler:$hilt_compiler_version"
ksp "androidx.hilt:hilt-compiler:$hilt_version"
Expand Down Expand Up @@ -157,20 +157,25 @@ dependencies {

//Compose
// Integration with activities
implementation 'androidx.activity:activity-compose:1.10.1'
implementation 'androidx.activity:activity-compose:1.11.0'
// Compose Material3 Design
implementation 'androidx.compose.material3:material3:1.3.2'
implementation 'androidx.compose.material3:material3-window-size-class:1.3.2'
// Animations
implementation 'androidx.compose.animation:animation:1.9.0'
implementation 'androidx.compose.animation:animation:1.9.1'
// Tooling support (Previews, etc.)
implementation 'androidx.compose.ui:ui-tooling:1.9.0'
implementation 'androidx.compose.ui:ui-tooling:1.9.1'
// Integration with ViewModels
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.9.3'
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.9.4'
// UI Tests
androidTestImplementation 'androidx.compose.ui:ui-test-junit4:1.9.0'
androidTestImplementation 'androidx.compose.ui:ui-test-junit4:1.9.1'
// When using a MDC theme
implementation "com.google.android.material:compose-theme-adapter:1.2.1"

// Google Review Handling
implementation("com.google.android.play:review:2.0.2")
implementation("com.google.android.play:review-ktx:2.0.2")
implementation("com.google.android.gms:play-services-base:18.8.0")
}

ksp {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,23 @@ class ATTrackingDetectionApplication : Application(), Configuration.Provider {
requiredPermissions.add(Manifest.permission.BLUETOOTH_CONNECT)
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
requiredPermissions.add(Manifest.permission.POST_NOTIFICATIONS)
// requiredPermissions.add(Manifest.permission.POST_NOTIFICATIONS)
SharedPrefs.showMissingNotificationPermissionWarning =
ContextCompat.checkSelfPermission(
applicationContext,
Manifest.permission.POST_NOTIFICATIONS
) != PackageManager.PERMISSION_GRANTED
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
val backgroundLocationPermission =
ContextCompat.checkSelfPermission(
applicationContext,
Manifest.permission.ACCESS_BACKGROUND_LOCATION
) == PackageManager.PERMISSION_GRANTED
SharedPrefs.showMissingBackgroundLocationPermissionWarning = !backgroundLocationPermission
if (backgroundLocationPermission) {
SharedPrefs.useLocationInTrackingDetection = true
}
}

for (permission in requiredPermissions) {
Expand Down Expand Up @@ -217,7 +233,7 @@ class ATTrackingDetectionApplication : Application(), Configuration.Provider {
fun getCurrentApp(): ATTrackingDetectionApplication {
return instance
}
//TODO: Add real survey URL

const val SURVEY_URL = "https://survey.seemoo.tu-darmstadt.de/index.php/117478?G06Q39=AirGuardAppAndroid&newtest=Y&lang=en"
const val SURVEY_IS_RUNNING = false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ interface NotificationDao {
@Query("SELECT COUNT(*) FROM notification WHERE deviceAddress == :deviceAddress AND createdAt >= :since AND falseAlarm = 1")
fun getFalseAlarmForDeviceSinceCount(deviceAddress: String, since: LocalDateTime): Int

@Query("SELECT COUNT(*) FROM notification WHERE deviceAddress == :deviceAddress AND falseAlarm = 1")
fun getFalseAlarmForDeviceCount(deviceAddress: String): Int

@Transaction
@RewriteQueriesToDropUnusedColumns
@Query("SELECT * FROM notification")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class NotificationRepository @Inject constructor(

fun getFalseAlarmForDeviceSinceCount(deviceAddress: String, since: LocalDateTime): Int = notificationDao.getFalseAlarmForDeviceSinceCount(deviceAddress, since)

fun getFalseAlarmForDeviceCount(deviceAddress: String): Int = notificationDao.getFalseAlarmForDeviceCount(deviceAddress)

fun existsNotificationForDevice(deviceAddress: String): Boolean = notificationDao.existsNotificationForDevice(deviceAddress)

fun getAllNotifications(): List<Notification> = notificationDao.getAllNotifications()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ class NotificationActionReceiver : BroadcastReceiver() {
Timber.e("Notification id missing!")
return
}
val notificationTag = intent.getStringExtra("notificationTag")

fun cancelNotification() {
if (notificationTag.isNullOrEmpty()) {
notificationManagerCompat.cancel(notificationId)
} else {
notificationManagerCompat.cancel(notificationTag, notificationId)
}
}

when (intent.action) {
NotificationConstants.FALSE_ALARM_ACTION -> {
Expand All @@ -46,7 +55,8 @@ class NotificationActionReceiver : BroadcastReceiver() {
notificationRepository.setFalseAlarm(notificationId, true)
}
// Dismiss the notification immediately for this action.
notificationManagerCompat.cancel(notificationId)
cancelNotification()
backgroundWorkScheduler.scheduleFalseAlarm(notificationId, notificationTag)
}
NotificationConstants.IGNORE_DEVICE_ACTION -> {
val deviceAddress = intent.getStringExtra("deviceAddress")
Expand All @@ -59,13 +69,14 @@ class NotificationActionReceiver : BroadcastReceiver() {
deviceRepository.setIgnoreFlag(deviceAddress, true)
}
// Dismiss the notification immediately for this action.
notificationManagerCompat.cancel(notificationId)
cancelNotification()
backgroundWorkScheduler.scheduleIgnoreDevice(deviceAddress, notificationId, notificationTag)
}
NotificationConstants.CLICKED_ACTION -> {
GlobalScope.launch(Dispatchers.IO) {
notificationRepository.setClicked(notificationId, true)
}
notificationManagerCompat.cancel(notificationId)
cancelNotification()
}
NotificationConstants.DISMISSED_ACTION -> {
GlobalScope.launch(Dispatchers.IO) {
Expand All @@ -75,4 +86,3 @@ class NotificationActionReceiver : BroadcastReceiver() {
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import android.os.Build
import android.os.Bundle
import android.os.SystemClock
import androidx.core.app.NotificationCompat
import androidx.core.net.toUri
import dagger.hilt.android.qualifiers.ApplicationContext
import de.seemoo.at_tracking_detection.ATTrackingDetectionApplication
import de.seemoo.at_tracking_detection.R
Expand All @@ -29,7 +30,7 @@ import javax.inject.Singleton

@Singleton
class NotificationBuilder @Inject constructor(
@ApplicationContext private val context: Context
@param:ApplicationContext private val context: Context
) {

private fun pendingNotificationIntent(bundle: Bundle, notificationId: Int): PendingIntent {
Expand Down Expand Up @@ -83,11 +84,14 @@ class NotificationBuilder @Inject constructor(
private fun buildPendingIntent(
bundle: Bundle,
notificationAction: String,
notificationId: Int,
code: Int
): PendingIntent {
val intent = Intent(context, NotificationActionReceiver::class.java).apply {
action = notificationAction
putExtras(bundle)
val tag = bundle.getString("notificationTag") ?: "none"
data = "airguard://notif/$tag/$notificationId/$notificationAction".toUri()
}

val flags = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
Expand All @@ -96,9 +100,11 @@ class NotificationBuilder @Inject constructor(
PendingIntent.FLAG_UPDATE_CURRENT
}

val uniqueRequestCode = (notificationId and 0x7FFFFFFF) xor (code shl 16)

return PendingIntent.getBroadcast(
context,
code,
uniqueRequestCode,
intent,
flags
)
Expand All @@ -118,7 +124,10 @@ class NotificationBuilder @Inject constructor(
}
?: "UNKNOWN"

val bundle: Bundle = packBundle(deviceAddress, deviceTypeString, notificationId)
val bundle: Bundle = packBundle(deviceAddress, deviceTypeString, notificationId).apply {
// Provide the tag so the receiver can cancel using tag+id
putString("notificationTag", NotificationService.TRACKING_NOTIFICATION_TAG)
}
val device = baseDevice.device
val notificationText: String
val notificationTitle: String
Expand Down Expand Up @@ -165,6 +174,7 @@ class NotificationBuilder @Inject constructor(
buildPendingIntent(
bundle,
NotificationConstants.FALSE_ALARM_ACTION,
notificationId,
NotificationConstants.FALSE_ALARM_CODE
)
).setAutoCancel(true)
Expand All @@ -176,6 +186,7 @@ class NotificationBuilder @Inject constructor(
buildPendingIntent(
bundle,
NotificationConstants.IGNORE_DEVICE_ACTION,
notificationId,
NotificationConstants.IGNORE_DEVICE_CODE
)
).setAutoCancel(true)
Expand All @@ -185,6 +196,7 @@ class NotificationBuilder @Inject constructor(
buildPendingIntent(
bundle,
NotificationConstants.DISMISSED_ACTION,
notificationId,
NotificationConstants.DISMISSED_CODE
)
).setAutoCancel(true)
Expand All @@ -200,7 +212,9 @@ class NotificationBuilder @Inject constructor(
observationPositive: Boolean
): Notification {
Timber.d("Notification with id $notificationId for device $deviceAddress has been build!")
val bundle: Bundle = packBundle(deviceAddress, deviceTypeString, notificationId)
val bundle: Bundle = packBundle(deviceAddress, deviceTypeString, notificationId).apply {
putString("notificationTag", NotificationService.OBSERVE_TRACKER_NOTIFICATION_TAG)
}

val notifyText = if (observationPositive) {
context.resources.getQuantityString(
Expand All @@ -227,6 +241,7 @@ class NotificationBuilder @Inject constructor(
buildPendingIntent(
bundle,
NotificationConstants.DISMISSED_ACTION,
notificationId,
NotificationConstants.DISMISSED_CODE
)
).setAutoCancel(true)
Expand All @@ -236,7 +251,10 @@ class NotificationBuilder @Inject constructor(
}

fun buildObserveTrackerFailedNotification(notificationId: Int): Notification {
val bundle: Bundle = Bundle().apply { putInt("notificationId", notificationId) }
val bundle: Bundle = Bundle().apply {
putInt("notificationId", notificationId)
putString("notificationTag", NotificationService.OBSERVE_TRACKER_NOTIFICATION_TAG)
}

return NotificationCompat.Builder(context, NotificationConstants.CHANNEL_ID)
.setContentTitle(context.getString(R.string.notification_observe_tracker_title_base))
Expand All @@ -251,7 +269,10 @@ class NotificationBuilder @Inject constructor(

fun buildBluetoothErrorNotification(): Notification {
val notificationId = -100
val bundle: Bundle = Bundle().apply { putInt("notificationId", notificationId) }
val bundle: Bundle = Bundle().apply {
putInt("notificationId", notificationId)
putString("notificationTag", NotificationService.BLE_SCAN_ERROR_TAG)
}

return NotificationCompat.Builder(context, NotificationConstants.CHANNEL_ID)
.setContentTitle(context.getString(R.string.notification_title_ble_error))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ class NotificationService @Inject constructor(
) {
@SuppressLint("MissingPermission")
suspend fun sendTrackingNotification(baseDevice: BaseDevice) {
val notificationId = generateUniqueNotificationId()
notificationViewModel.insertToDb(deviceAddress = baseDevice.address)
val notificationId = notificationViewModel.insertToDb(deviceAddress = baseDevice.address)
with(notificationManagerCompat) {
if (this.areNotificationsEnabled() && !SharedPrefs.deactivateBackgroundScanning) {
notify(
Expand Down Expand Up @@ -175,7 +174,7 @@ class NotificationService @Inject constructor(
"de.seemoo.at_tracking_detection.ble_scan_error_notification"
const val OBSERVE_TRACKER_NOTIFICATION_TAG =
"de.seemoo.at_tracking_detection.observe_tracker_notification"
// const val SURVEY_INFO_TAG = "de.seemoo.at_tracking_detection.survey_info"
const val SURVEY_INFO_TAG = "de.seemoo.at_tracking_detection.survey_info"

fun generateUniqueNotificationId(): Int {
return Random.nextInt()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,23 @@ class FalseAlarmWorker @AssistedInject constructor(
private val notificationViewModel: NotificationViewModel,
private val notificationManagerCompat: NotificationManagerCompat
) : CoroutineWorker(appContext, workerParams) {

override suspend fun doWork(): Result {
val notificationId = inputData.getInt("notificationId", -1)
if (notificationId == -1) {
Timber.e("No notification id passed!")
return Result.failure()
}
val notificationTag = inputData.getString("notificationTag")

notificationViewModel.setFalseAlarm(notificationId, true)
//TODO: cancel specific notification by calling cancel(notificationId) which somehow doesn't work...
notificationManagerCompat.cancelAll()
Timber.d("Marked notification $notificationId as false alarm!")

if (notificationTag.isNullOrEmpty()) {
notificationManagerCompat.cancel(notificationId)
} else {
notificationManagerCompat.cancel(notificationTag, notificationId)
}

Timber.d("Marked notification $notificationId as false alarm and canceled it!")
return Result.success()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,16 @@ class IgnoreDeviceWorker @AssistedInject constructor(
Timber.e("No notification id passed!")
return Result.failure()
}
val notificationTag = inputData.getString("notificationTag")

deviceViewModel.setIgnoreFlag(deviceAddress, true)
//TODO: cancel specific notification by calling cancel(notificationId) which somehow doesn't work...
notificationManagerCompat.cancelAll()

if (notificationTag.isNullOrEmpty()) {
notificationManagerCompat.cancel(notificationId)
} else {
notificationManagerCompat.cancel(notificationTag, notificationId)
}

Timber.d("Added device $deviceAddress to the ignored devices list!")
return Result.success()
}
Expand Down
Loading
Loading