diff --git a/leakcanary/leakcanary-android-core/src/main/java/leakcanary/internal/activity/db/Cursors.kt b/leakcanary/leakcanary-android-core/src/main/java/leakcanary/internal/activity/db/Cursors.kt index 8e9277520..2793a2af4 100644 --- a/leakcanary/leakcanary-android-core/src/main/java/leakcanary/internal/activity/db/Cursors.kt +++ b/leakcanary/leakcanary-android-core/src/main/java/leakcanary/internal/activity/db/Cursors.kt @@ -6,7 +6,7 @@ import kotlin.concurrent.getOrSet /** * Similar to the more generic use() for Closable. - * Cursor implements Closable on all supported API levels (21+). + * Cursor implements Closable on all supported API levels (26+). */ internal inline fun Cursor.use(block: (Cursor) -> R): R { var exception: Throwable? = null diff --git a/plumber/plumber-android-core/src/main/java/leakcanary/AndroidLeakFixes.kt b/plumber/plumber-android-core/src/main/java/leakcanary/AndroidLeakFixes.kt index f223ad44b..bd8a00e97 100644 --- a/plumber/plumber-android-core/src/main/java/leakcanary/AndroidLeakFixes.kt +++ b/plumber/plumber-android-core/src/main/java/leakcanary/AndroidLeakFixes.kt @@ -1,7 +1,6 @@ package leakcanary import android.annotation.SuppressLint -import android.annotation.TargetApi import android.app.Activity import android.app.Application import android.content.Context @@ -49,9 +48,8 @@ enum class AndroidLeakFixes { */ MEDIA_SESSION_LEGACY_HELPER { override fun apply(application: Application) { - if (SDK_INT != 21) { - return - } + // This fix was only needed for API 21, minimum SDK is now 26+ + return backgroundHandler.post { try { val clazz = Class.forName("android.media.session.MediaSessionLegacyHelper") @@ -246,9 +244,8 @@ enum class AndroidLeakFixes { */ CONNECTIVITY_MANAGER { override fun apply(application: Application) { - if (SDK_INT > 23) { - return - } + // This fix was only needed for API ≤23, minimum SDK is now 26+ + return try { application.getSystemService(Context.CONNECTIVITY_SERVICE) @@ -353,9 +350,8 @@ enum class AndroidLeakFixes { */ ACTIVITY_MANAGER { override fun apply(application: Application) { - if (MANUFACTURER != SAMSUNG || SDK_INT != 22) { - return - } + // This fix was only needed for Samsung API 22, minimum SDK is now 26+ + return backgroundHandler.post { val contextField: Field @@ -416,15 +412,10 @@ enum class AndroidLeakFixes { * the reference to the detached view with a reference to the decor view. */ IMM_FOCUSED_VIEW { - // mServedView should not be accessed on API 29+. Make this clear to Lint with the - // TargetApi annotation. - @TargetApi(23) @SuppressLint("PrivateApi") override fun apply(application: Application) { - // Fixed in API 24. - if (SDK_INT > 23) { - return - } + // This fix was only needed for API ≤23, minimum SDK is now 26+ + return val inputMethodManager = application.getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager val mServedViewField: Field @@ -612,12 +603,10 @@ enum class AndroidLeakFixes { * https://android.googlesource.com/platform/frameworks/base/+/marshmallow-release/core/java/android/view/ViewRootImpl.java */ SPELL_CHECKER { - @TargetApi(23) @SuppressLint("PrivateApi") override fun apply(application: Application) { - if (SDK_INT != 23) { - return - } + // This fix was only needed for API 23, minimum SDK is now 26+ + return try { val textServiceClass = TextServicesManager::class.java diff --git a/plumber/plumber-android-core/src/main/java/leakcanary/FixedWindowCallback.java b/plumber/plumber-android-core/src/main/java/leakcanary/FixedWindowCallback.java index 533d4e7be..957d5091b 100644 --- a/plumber/plumber-android-core/src/main/java/leakcanary/FixedWindowCallback.java +++ b/plumber/plumber-android-core/src/main/java/leakcanary/FixedWindowCallback.java @@ -105,7 +105,6 @@ class FixedWindowCallback implements Window.Callback { return delegate.onSearchRequested(); } - @RequiresApi(23) @Override public boolean onSearchRequested(SearchEvent searchEvent) { return delegate.onSearchRequested(searchEvent); } @@ -114,7 +113,7 @@ class FixedWindowCallback implements Window.Callback { return delegate.onWindowStartingActionMode(callback); } - @RequiresApi(23) @Nullable @Override + @Nullable @Override public ActionMode onWindowStartingActionMode(ActionMode.Callback callback, int type) { return delegate.onWindowStartingActionMode(callback, type); @@ -128,13 +127,11 @@ class FixedWindowCallback implements Window.Callback { delegate.onActionModeFinished(mode); } - @RequiresApi(24) @Override public void onProvideKeyboardShortcuts(List data, @Nullable Menu menu, int deviceId) { delegate.onProvideKeyboardShortcuts(data, menu, deviceId); } - @RequiresApi(26) @Override public void onPointerCaptureChanged(boolean hasCapture) { delegate.onPointerCaptureChanged(hasCapture); }