1 package leakcanary.internal
2 
3 import android.app.Application
4 import android.content.ContentProvider
5 import android.content.ContentValues
6 import android.database.Cursor
7 import android.net.Uri
8 import leakcanary.AppWatcher
9 
10 /**
11  * Content providers are loaded before the application class is created. [MainProcessAppWatcherInstaller] is
12  * used to install [leakcanary.AppWatcher] on application start.
13  *
14  * [MainProcessAppWatcherInstaller] automatically sets up the LeakCanary code that runs in the main
15  * app process.
16  */
17 internal class MainProcessAppWatcherInstaller : ContentProvider() {
18 
onCreatenull19   override fun onCreate(): Boolean {
20     val application = context!!.applicationContext as Application
21     AppWatcher.manualInstall(application)
22     return true
23   }
24 
querynull25   override fun query(
26     uri: Uri,
27     projectionArg: Array<String>?,
28     selection: String?,
29     selectionArgs: Array<String>?,
30     sortOrder: String?
31   ): Cursor? = null
32 
33   override fun getType(uri: Uri): String? = null
34 
35   override fun insert(uri: Uri, contentValues: ContentValues?): Uri? = null
36 
37   override fun delete(uri: Uri, selection: String?, selectionArgs: Array<out String>?): Int = 0
38 
39   override fun update(
40     uri: Uri, values: ContentValues?, selection: String?, selectionArgs: Array<out String>?
41   ): Int = 0
42 }
43