forked from commons-app/apps-android-commons
/
UploadWorker.kt
695 lines (629 loc) · 27.1 KB
/
UploadWorker.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
package fr.free.nrw.commons.upload.worker
import android.annotation.SuppressLint
import android.app.Notification
import android.app.PendingIntent
import android.app.TaskStackBuilder
import android.content.Context
import android.content.Intent
import android.database.sqlite.SQLiteDatabase
import android.database.sqlite.SQLiteException
import android.graphics.BitmapFactory
import android.os.Build
import android.util.Log
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import androidx.multidex.BuildConfig
import androidx.work.CoroutineWorker
import androidx.work.Data
import androidx.work.ForegroundInfo
import androidx.work.WorkerParameters
import com.facebook.drawee.backends.pipeline.Fresco
import dagger.android.ContributesAndroidInjector
import fr.free.nrw.commons.CommonsApplication
import fr.free.nrw.commons.Media
import fr.free.nrw.commons.R
import fr.free.nrw.commons.auth.LoginActivity
import fr.free.nrw.commons.auth.SessionManager
import fr.free.nrw.commons.bookmarks.items.BookmarkItemsDao
import fr.free.nrw.commons.bookmarks.locations.BookmarkLocationsDao
import fr.free.nrw.commons.bookmarks.pictures.BookmarkPicturesDao
import fr.free.nrw.commons.category.CategoryDao
import fr.free.nrw.commons.contributions.ChunkInfo
import fr.free.nrw.commons.contributions.Contribution
import fr.free.nrw.commons.contributions.ContributionDao
import fr.free.nrw.commons.contributions.MainActivity
import fr.free.nrw.commons.customselector.database.UploadedStatus
import fr.free.nrw.commons.customselector.database.UploadedStatusDao
import fr.free.nrw.commons.data.DBOpenHelper
import fr.free.nrw.commons.di.ApplicationlessInjection
import fr.free.nrw.commons.media.MediaClient
import fr.free.nrw.commons.theme.BaseActivity
import fr.free.nrw.commons.upload.FileUtilsWrapper
import fr.free.nrw.commons.upload.StashUploadResult
import fr.free.nrw.commons.upload.StashUploadState
import fr.free.nrw.commons.upload.UploadClient
import fr.free.nrw.commons.upload.UploadResult
import fr.free.nrw.commons.wikidata.WikidataEditService
import io.reactivex.Completable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.flow.asFlow
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import timber.log.Timber
import java.util.*
import java.util.regex.Pattern
import javax.inject.Inject
class UploadWorker(var appContext: Context, workerParams: WorkerParameters) :
CoroutineWorker(appContext, workerParams) {
private var notificationManager: NotificationManagerCompat? = null
@Inject
lateinit var dbOpenHelper: DBOpenHelper
@Inject
lateinit var wikidataEditService: WikidataEditService
@Inject
lateinit var sessionManager: SessionManager
@Inject
lateinit var contributionDao: ContributionDao
@Inject
lateinit var uploadedStatusDao: UploadedStatusDao
@Inject
lateinit var uploadClient: UploadClient
@Inject
lateinit var mediaClient: MediaClient
@Inject
lateinit var fileUtilsWrapper: FileUtilsWrapper
private val PROCESSING_UPLOADS_NOTIFICATION_TAG = BuildConfig.APPLICATION_ID + " : upload_tag"
private val PROCESSING_UPLOADS_NOTIFICATION_ID = 101
private val INVALID_TOKEN_ERROR_MESSAGE = "Invalid token, or login failure."
//Attributes of the current-upload notification
private var currentNotificationID: Int = -1// lateinit is not allowed with primitives
private lateinit var currentNotificationTag: String
private var curentNotification: NotificationCompat.Builder
private val statesToProcess= ArrayList<Int>()
private val loginUsername = "loginUsername"
private val loginMessage = "loginMessage"
private val STASH_ERROR_CODES = Arrays
.asList(
"uploadstash-file-not-found",
"stashfailed",
"verification-error",
"chunk-too-small"
)
init {
ApplicationlessInjection
.getInstance(appContext)
.commonsApplicationComponent
.inject(this)
curentNotification =
getNotificationBuilder(CommonsApplication.NOTIFICATION_CHANNEL_ID_ALL)!!
statesToProcess.add(Contribution.STATE_QUEUED)
statesToProcess.add(Contribution.STATE_QUEUED_LIMITED_CONNECTION_MODE)
}
@dagger.Module
interface Module {
@ContributesAndroidInjector
fun worker(): UploadWorker
}
open inner class NotificationUpdateProgressListener(
private var notificationFinishingTitle: String?,
var contribution: Contribution?
) {
fun onProgress(transferred: Long, total: Long) {
if (transferred == total) {
// Completed!
curentNotification.setContentTitle(notificationFinishingTitle)
.setProgress(0, 100, true)
} else {
curentNotification
.setProgress(
100,
(transferred.toDouble() / total.toDouble() * 100).toInt(),
false
)
}
notificationManager?.cancel(PROCESSING_UPLOADS_NOTIFICATION_TAG, PROCESSING_UPLOADS_NOTIFICATION_ID)
notificationManager?.notify(
currentNotificationTag,
currentNotificationID,
curentNotification.build()!!
)
contribution!!.transferred = transferred
contributionDao.update(contribution).blockingAwait()
}
open fun onChunkUploaded(contribution: Contribution, chunkInfo: ChunkInfo?) {
contribution.chunkInfo = chunkInfo
contributionDao.update(contribution).blockingAwait()
}
}
private fun getNotificationBuilder(channelId: String): NotificationCompat.Builder? {
return NotificationCompat.Builder(appContext, channelId)
.setAutoCancel(true)
.setSmallIcon(R.drawable.ic_launcher)
.setLargeIcon(
BitmapFactory.decodeResource(
appContext.resources,
R.drawable.ic_launcher
)
)
.setAutoCancel(true)
.setOnlyAlertOnce(true)
.setProgress(100, 0, true)
.setOngoing(true)
}
override suspend fun doWork(): Result {
var countUpload = 0
// Start a foreground service
setForeground(createForegroundInfo())
notificationManager = NotificationManagerCompat.from(appContext)
val processingUploads = getNotificationBuilder(
CommonsApplication.NOTIFICATION_CHANNEL_ID_ALL
)!!
withContext(Dispatchers.IO) {
/*
queuedContributions receives the results from a one-shot query.
This means that once the list has been fetched from the database,
it does not get updated even if some changes (insertions, deletions, etc.)
are made to the contribution table afterwards.
Related issues (fixed):
https://github.com/commons-app/apps-android-commons/issues/5136
https://github.com/commons-app/apps-android-commons/issues/5346
*/
val queuedContributions = contributionDao.getContribution(statesToProcess)
.blockingGet()
//Showing initial notification for the number of uploads being processed
Timber.e("Queued Contributions: " + queuedContributions.size)
processingUploads.setContentTitle(appContext.getString(R.string.starting_uploads))
processingUploads.setContentText(
appContext.resources.getQuantityString(
R.plurals.starting_multiple_uploads,
queuedContributions.size,
queuedContributions.size
)
)
notificationManager?.notify(
PROCESSING_UPLOADS_NOTIFICATION_TAG,
PROCESSING_UPLOADS_NOTIFICATION_ID,
processingUploads.build()
)
/**
* To avoid race condition when multiple of these workers are working, assign this state
so that the next one does not process these contribution again
*/
queuedContributions.forEach {
it.state = Contribution.STATE_IN_PROGRESS
contributionDao.saveSynchronous(it)
}
queuedContributions.asFlow().map { contribution ->
// Upload the contribution if it has not been cancelled by the user
if (!CommonsApplication.cancelledUploads.contains(contribution.pageId)) {
/**
* If the limited connection mode is on, lets iterate through the queued
* contributions
* and set the state as STATE_QUEUED_LIMITED_CONNECTION_MODE ,
* otherwise proceed with the upload
*/
if (isLimitedConnectionModeEnabled()) {
if (contribution.state == Contribution.STATE_QUEUED) {
contribution.state = Contribution.STATE_QUEUED_LIMITED_CONNECTION_MODE
contributionDao.saveSynchronous(contribution)
}
} else {
contribution.transferred = 0
contribution.state = Contribution.STATE_IN_PROGRESS
contributionDao.saveSynchronous(contribution)
setProgressAsync(Data.Builder().putInt("progress", countUpload).build())
countUpload++
uploadContribution(contribution = contribution)
}
} else {
/* We can remove the cancelled upload from the hashset
as this contribution will not be processed again
*/
removeUploadFromInMemoryHashSet(contribution)
}
}.collect()
//Dismiss the global notification
notificationManager?.cancel(
PROCESSING_UPLOADS_NOTIFICATION_TAG,
PROCESSING_UPLOADS_NOTIFICATION_ID
)
}
// Trigger WorkManager to process any new contributions that may have been added to the queue
val updatedContributionQueue = withContext(Dispatchers.IO) {
contributionDao.getContribution(statesToProcess).blockingGet()
}
if (updatedContributionQueue.isNotEmpty()) {
return Result.retry()
}
return Result.success()
}
/**
* Removes the processed contribution from the cancelledUploads in-memory hashset
*/
private fun removeUploadFromInMemoryHashSet(contribution: Contribution) {
CommonsApplication.cancelledUploads.remove(contribution.pageId)
}
/**
* Create new notification for foreground service
*/
private fun createForegroundInfo(): ForegroundInfo {
return ForegroundInfo(
1,
createNotificationForForegroundService()
)
}
override suspend fun getForegroundInfo(): ForegroundInfo {
return createForegroundInfo()
}
private fun createNotificationForForegroundService(): Notification {
// TODO: Improve notification for foreground service
return getNotificationBuilder(
CommonsApplication.NOTIFICATION_CHANNEL_ID_ALL)!!
.setContentTitle(appContext.getString(R.string.upload_in_progress))
.build()
}
/**
* Returns true is the limited connection mode is enabled
*/
private fun isLimitedConnectionModeEnabled(): Boolean {
return sessionManager.getPreference(CommonsApplication.IS_LIMITED_CONNECTION_MODE_ENABLED)
}
/**
* Upload the contribution
* @param contribution
*/
@SuppressLint("StringFormatInvalid", "CheckResult")
private suspend fun uploadContribution(contribution: Contribution) {
if (contribution.localUri == null || contribution.localUri.path == null) {
Timber.e("""upload: ${contribution.media.filename} failed, file path is null""")
}
val media = contribution.media
val displayTitle = contribution.media.displayTitle
currentNotificationTag = contribution.localUri.toString()
currentNotificationID =
(contribution.localUri.toString() + contribution.media.filename).hashCode()
curentNotification
getNotificationBuilder(CommonsApplication.NOTIFICATION_CHANNEL_ID_ALL)!!
curentNotification.setContentTitle(
appContext.getString(
R.string.upload_progress_notification_title_start,
displayTitle
)
)
notificationManager?.notify(
currentNotificationTag,
currentNotificationID,
curentNotification.build()!!
)
val filename = media.filename
val notificationProgressUpdater = NotificationUpdateProgressListener(
appContext.getString(
R.string.upload_progress_notification_title_finishing,
displayTitle
),
contribution
)
try {
//Upload the file to stash
val stashUploadResult = uploadClient.uploadFileToStash(
appContext, filename, contribution, notificationProgressUpdater
).onErrorReturn{
return@onErrorReturn StashUploadResult(StashUploadState.FAILED,fileKey = null,errorMessage = it.message)
}.blockingSingle()
when (stashUploadResult.state) {
StashUploadState.SUCCESS -> {
//If the stash upload succeeds
Timber.d("Upload to stash success for fileName: $filename")
Timber.d("Ensure uniqueness of filename");
val uniqueFileName = findUniqueFileName(filename!!)
try {
//Upload the file from stash
val uploadResult = uploadClient.uploadFileFromStash(
contribution, uniqueFileName, stashUploadResult.fileKey
).onErrorReturn {
return@onErrorReturn null
}.blockingSingle()
if (null != uploadResult && uploadResult.isSuccessful()) {
Timber.d(
"Stash Upload success..proceeding to make wikidata edit"
)
wikidataEditService.addDepictionsAndCaptions(uploadResult, contribution)
.blockingSubscribe();
if(contribution.wikidataPlace==null){
Timber.d(
"WikiDataEdit not required, upload success"
)
saveCompletedContribution(contribution,uploadResult)
}else{
Timber.d(
"WikiDataEdit not required, making wikidata edit"
)
makeWikiDataEdit(uploadResult, contribution)
}
showSuccessNotification(contribution)
} else {
Timber.e("Stash Upload failed")
showFailedNotification(contribution)
contribution.state = Contribution.STATE_FAILED
contribution.chunkInfo = null
contributionDao.save(contribution).blockingAwait()
}
}catch (exception : Exception){
Timber.e(exception)
Timber.e("Upload from stash failed for contribution : $filename")
showFailedNotification(contribution)
contribution.state=Contribution.STATE_FAILED
contributionDao.saveSynchronous(contribution)
if (STASH_ERROR_CODES.contains(exception.message)) {
clearChunks(contribution)
}
}
}
StashUploadState.PAUSED -> {
showPausedNotification(contribution)
contribution.state = Contribution.STATE_PAUSED
contributionDao.saveSynchronous(contribution)
}
else -> {
Timber.e("""upload file to stash failed with status: ${stashUploadResult.state}""")
showInvalidLoginNotification(contribution)
contribution.state = Contribution.STATE_FAILED
contribution.chunkInfo = null
contributionDao.saveSynchronous(contribution)
if (stashUploadResult.errorMessage.equals(INVALID_TOKEN_ERROR_MESSAGE)) {
Timber.e("Invalid Login, logging out")
val username = sessionManager.userName
sessionManager.logout()
.andThen(Completable.fromAction {
Timber.d("All accounts have been removed")
clearImageCache()
updateAllDatabases()
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
{
val intent = Intent(appContext, LoginActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
intent.putExtra(loginMessage, appContext.getString(R.string.invalid_login_message))
intent.putExtra(loginUsername,username)
appContext.startActivity(intent)
}
) { t: Throwable? -> Timber.e(t) }
} else {
}
}
}
}catch (exception: Exception){
Timber.e(exception)
Timber.e("Stash upload failed for contribution: $filename")
showFailedNotification(contribution)
contribution.state=Contribution.STATE_FAILED
clearChunks(contribution)
}
}
private fun clearChunks(contribution: Contribution) {
contribution.chunkInfo=null
contributionDao.saveSynchronous(contribution)
}
/**
* Make the WikiData Edit, if applicable
*/
private suspend fun makeWikiDataEdit(uploadResult: UploadResult, contribution: Contribution) {
val wikiDataPlace = contribution.wikidataPlace
if (wikiDataPlace != null && wikiDataPlace.imageValue == null) {
if (!contribution.hasInvalidLocation()) {
var revisionID: Long?=null
try {
revisionID = wikidataEditService.createClaim(
wikiDataPlace, uploadResult.filename,
contribution.media.captions
)
if (null != revisionID) {
showSuccessNotification(contribution)
}
}catch (exception: Exception){
Timber.e(exception)
}
withContext(Dispatchers.Main) {
wikidataEditService.handleImageClaimResult(
contribution.wikidataPlace,
revisionID
)
}
} else {
withContext(Dispatchers.Main) {
wikidataEditService.handleImageClaimResult(
contribution.wikidataPlace, null
)
}
}
}
saveCompletedContribution(contribution, uploadResult)
}
private fun saveCompletedContribution(contribution: Contribution, uploadResult: UploadResult) {
val contributionFromUpload = mediaClient.getMedia("File:" + uploadResult.filename)
.map { media: Media? -> contribution.completeWith(media!!) }
.blockingGet()
contributionFromUpload.dateModified=Date()
contributionDao.deleteAndSaveContribution(contribution, contributionFromUpload)
// Upload success, save to uploaded status.
saveIntoUploadedStatus(contribution)
}
/**
* Save to uploadedStatusDao.
*/
private fun saveIntoUploadedStatus(contribution: Contribution) {
contribution.contentUri?.let {
val imageSha1 = contribution.imageSHA1.toString()
val modifiedSha1 = fileUtilsWrapper.getSHA1(fileUtilsWrapper.getFileInputStream(contribution.localUri?.path))
MainScope().launch {
uploadedStatusDao.insertUploaded(
UploadedStatus(
imageSha1,
modifiedSha1,
imageSha1 == modifiedSha1,
true
)
);
}
}
}
private fun findUniqueFileName(fileName: String): String {
var sequenceFileName: String?
var sequenceNumber = 1
while (true) {
sequenceFileName = if (sequenceNumber == 1) {
fileName
} else {
if (fileName.indexOf('.') == -1) {
"$fileName $sequenceNumber"
} else {
val regex =
Pattern.compile("^(.*)(\\..+?)$")
val regexMatcher = regex.matcher(fileName)
regexMatcher.replaceAll("$1 $sequenceNumber$2")
}
}
if (!mediaClient.checkPageExistsUsingTitle(
String.format(
"File:%s",
sequenceFileName
)
)
.blockingGet()
) {
break
}
sequenceNumber++
}
return sequenceFileName!!
}
/**
* Notify that the current upload has succeeded
* @param contribution
*/
@SuppressLint("StringFormatInvalid")
private fun showSuccessNotification(contribution: Contribution) {
val displayTitle = contribution.media.displayTitle
contribution.state=Contribution.STATE_COMPLETED
curentNotification.setContentTitle(
appContext.getString(
R.string.upload_completed_notification_title,
displayTitle
)
)
.setContentText(appContext.getString(R.string.upload_completed_notification_text))
.setProgress(0, 0, false)
.setOngoing(false)
notificationManager?.notify(
currentNotificationTag, currentNotificationID,
curentNotification.build()
)
}
/**
* Notify that the current upload has failed
* @param contribution
*/
@SuppressLint("StringFormatInvalid")
private fun showFailedNotification(contribution: Contribution) {
val displayTitle = contribution.media.displayTitle
curentNotification.setContentIntent(getPendingIntent(MainActivity::class.java))
curentNotification.setContentTitle(
appContext.getString(
R.string.upload_failed_notification_title,
displayTitle
)
)
.setContentText(appContext.getString(R.string.upload_failed_notification_subtitle))
.setProgress(0, 0, false)
.setOngoing(false)
notificationManager?.notify(
currentNotificationTag, currentNotificationID,
curentNotification.build()
)
}
@SuppressLint("StringFormatInvalid")
private fun showInvalidLoginNotification(contribution: Contribution) {
val displayTitle = contribution.media.displayTitle
curentNotification.setContentTitle(
appContext.getString(
R.string.upload_failed_notification_title,
displayTitle
)
)
.setContentText(appContext.getString(R.string.invalid_login_message))
.setProgress(0, 0, false)
.setOngoing(false)
notificationManager?.notify(
currentNotificationTag, currentNotificationID,
curentNotification.build()
)
}
/**
* Notify that the current upload is paused
* @param contribution
*/
private fun showPausedNotification(contribution: Contribution) {
val displayTitle = contribution.media.displayTitle
curentNotification.setContentTitle(
appContext.getString(
R.string.upload_paused_notification_title,
displayTitle
)
)
.setContentText(appContext.getString(R.string.upload_paused_notification_subtitle))
.setProgress(0, 0, false)
.setOngoing(false)
notificationManager!!.notify(
currentNotificationTag, currentNotificationID,
curentNotification.build()
)
}
/**
* Method used to get Pending intent for opening different screen after clicking on notification
* @param toClass
*/
private fun getPendingIntent(toClass:Class<out BaseActivity>):PendingIntent
{
val intent = Intent(appContext,toClass)
return TaskStackBuilder.create(appContext).run {
addNextIntentWithParentStack(intent)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
getPendingIntent(0,
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT)
} else {
getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT)
}
};
}
private fun clearImageCache() {
val imagePipeline = Fresco.getImagePipeline()
imagePipeline.clearCaches()
}
private fun updateAllDatabases() {
dbOpenHelper.getReadableDatabase().close()
val db: SQLiteDatabase = dbOpenHelper.getWritableDatabase()
CategoryDao.Table.onDelete(db)
dbOpenHelper.deleteTable(
db,
DBOpenHelper.CONTRIBUTIONS_TABLE
) //Delete the contributions table in the existing db on older versions
Log.d("CommonsApplication", "All tables have been deleted....updating now...")
try {
contributionDao.deleteAll()
} catch (e: SQLiteException) {
Log.d("CommonsApplication", "Error while deleting all contributions " + e.message)
Timber.e(e)
}
Log.d("CommonsApplication", "All contributions have been deleted")
BookmarkPicturesDao.Table.onDelete(db)
BookmarkLocationsDao.Table.onDelete(db)
BookmarkItemsDao.Table.onDelete(db)
}
}