xref: /aosp_15_r20/external/leakcanary2/plumber-android/src/main/java/leakcanary/internal/PlumberInstaller.kt (revision d9e8da70d8c9df9a41d7848ae506fb3115cae6e6)
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.AndroidLeakFixes
9 
10 /**
11  * Content providers are loaded before the application class is created. [PlumberInstaller] is
12  * used to install [leakcanary.AndroidLeakFixes] fixes on application start.
13  */
14 internal class PlumberInstaller : ContentProvider() {
15 
onCreatenull16   override fun onCreate(): Boolean {
17     val application = context!!.applicationContext as Application
18     AndroidLeakFixes.applyFixes(application)
19     return true
20   }
21 
querynull22   override fun query(
23     uri: Uri,
24     projectionArg: Array<String>?,
25     selection: String?,
26     selectionArgs: Array<String>?,
27     sortOrder: String?
28   ): Cursor? = null
29 
30   override fun getType(uri: Uri): String? = null
31 
32   override fun insert(uri: Uri, contentValues: ContentValues?): Uri? = null
33 
34   override fun delete(uri: Uri, selection: String?, selectionArgs: Array<out String>?): Int = 0
35 
36   override fun update(
37     uri: Uri, values: ContentValues?, selection: String?, selectionArgs: Array<out String>?
38   ): Int = 0
39 }
40