<commit_before>/*
 * Copyright (C) 2019. <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.sweers.catchup.app

import android.annotation.SuppressLint
import android.app.Activity
import android.app.Application
import android.app.Application.ActivityLifecycleCallbacks
import android.os.Build
import android.os.Bundle
import android.os.StrictMode
import android.os.StrictMode.VmPolicy
import android.os.strictmode.DiskReadViolation
import android.os.strictmode.UntaggedSocketViolation
import android.util.Log
import com.facebook.flipper.android.AndroidFlipperClient
import com.facebook.flipper.android.utils.FlipperUtils
import com.facebook.flipper.core.FlipperPlugin
import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin
import com.facebook.soloader.SoLoader
import dagger.Module
import dagger.Provides
import dagger.multibindings.IntoSet
import io.sweers.catchup.app.ApplicationModule.AsyncInitializers
import io.sweers.catchup.app.ApplicationModule.Initializers
import io.sweers.catchup.base.ui.CatchUpObjectWatcher
import io.sweers.catchup.data.LumberYard
import io.sweers.catchup.util.sdk
import leakcanary.AppWatcher
import leakcanary.LeakCanary
import shark.AndroidReferenceMatchers
import timber.log.Timber
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit
import javax.inject.Qualifier
import kotlin.annotation.AnnotationRetention.BINARY

@Module
object DebugApplicationModule {

  @Qualifier
  @Retention(BINARY)
  private annotation class LeakCanaryEnabled

  /**
   * Disabled on API 28 because there's a pretty vicious memory leak that constantly triggers
   * https://github.com/square/leakcanary/issues/1081
   */
  @JvmStatic // https://github.com/google/dagger/issues/1648
  @LeakCanaryEnabled
  @Provides
  fun provideLeakCanaryEnabled(): Boolean = Build.VERSION.SDK_INT != 28

  @Provides
  fun provideObjectWatcher(@LeakCanaryEnabled leakCanaryEnabled: Boolean): CatchUpObjectWatcher {
    return if (leakCanaryEnabled) {
      object : CatchUpObjectWatcher {
        override fun watch(watchedReference: Any) {
          AppWatcher.objectWatcher.watch(watchedReference)
        }
      }
    } else {
      CatchUpObjectWatcher.None
    }
  }

  @Provides
  fun provideLeakCanaryConfig(@LeakCanaryEnabled leakCanaryEnabled: Boolean): LeakCanary.Config {
    return if (leakCanaryEnabled) {
      LeakCanary.config.copy(referenceMatchers = AndroidReferenceMatchers.appDefaults)
    } else {
      LeakCanary.config
    }
  }<commit_msg>Update leakcanary method<commit_after>/*
 * Copyright (C) 2019. <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.sweers.catchup.app

import android.annotation.SuppressLint
import android.app.Activity
import android.app.Application
import android.app.Application.ActivityLifecycleCallbacks
import android.os.Build
import android.os.Bundle
import android.os.StrictMode
import android.os.StrictMode.VmPolicy
import android.os.strictmode.DiskReadViolation
import android.os.strictmode.UntaggedSocketViolation
import android.util.Log
import com.facebook.flipper.android.AndroidFlipperClient
import com.facebook.flipper.android.utils.FlipperUtils
import com.facebook.flipper.core.FlipperPlugin
import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin
import com.facebook.soloader.SoLoader
import dagger.Module
import dagger.Provides
import dagger.multibindings.IntoSet
import io.sweers.catchup.app.ApplicationModule.AsyncInitializers
import io.sweers.catchup.app.ApplicationModule.Initializers
import io.sweers.catchup.base.ui.CatchUpObjectWatcher
import io.sweers.catchup.data.LumberYard
import io.sweers.catchup.util.sdk
import leakcanary.AppWatcher
import leakcanary.LeakCanary
import shark.AndroidReferenceMatchers
import timber.log.Timber
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit
import javax.inject.Qualifier
import kotlin.annotation.AnnotationRetention.BINARY

@Module
object DebugApplicationModule {

  @Qualifier
  @Retention(BINARY)
  private annotation class LeakCanaryEnabled

  /**
   * Disabled on API 28 because there's a pretty vicious memory leak that constantly triggers
   * https://github.com/square/leakcanary/issues/1081
   */
  @JvmStatic // https://github.com/google/dagger/issues/1648
  @LeakCanaryEnabled
  @Provides
  fun provideLeakCanaryEnabled(): Boolean = Build.VERSION.SDK_INT != 28

  @Provides
  fun provideObjectWatcher(@LeakCanaryEnabled leakCanaryEnabled: Boolean): CatchUpObjectWatcher {
    return if (leakCanaryEnabled) {
      object : CatchUpObjectWatcher {
        override fun watch(watchedReference: Any) {
          AppWatcher.objectWatcher.watch(watchedReference, "Uhhh because reasons")
        }
      }
    } else {
      CatchUpObjectWatcher.None
    }
  }

  @Provides
  fun provideLeakCanaryConfig(@LeakCanaryEnabled leakCanaryEnabled: Boolean): LeakCanary.Config {
    return if (leakCanaryEnabled) {
      LeakCanary.config.copy(referenceMatchers = AndroidReferenceMatchers.appDefaults)
    } else {
      LeakCanary.config
    }
  }
{'fraction_non_alphanumeric': 0.07727199092823586, 'fraction_numerical': 0.0064798315243803665, 'mean_word_length': 4.748603351955308, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4154467', 'n_tokens_mistral': 1834, 'n_tokens_neox': 1780, 'n_words': 435}