Skip to content

Commit

Permalink
refactor: Record low memory events for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
timschneeb committed Nov 5, 2022
1 parent 5c76969 commit 7caf512
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import org.lsposed.hiddenapibypass.HiddenApiBypass
import timber.log.Timber
import timber.log.Timber.*
import java.io.File
import java.text.SimpleDateFormat
import java.util.*


class MainApplication : Application(), SharedPreferences.OnSharedPreferenceChangeListener {
Expand Down Expand Up @@ -129,6 +131,19 @@ class MainApplication : Application(), SharedPreferences.OnSharedPreferenceChang
super.onTerminate()
}

override fun onLowMemory() {
Timber.w("onLowMemory: Running low on memory")
FirebaseCrashlytics.getInstance().setCustomKey("last_low_memory_event", SimpleDateFormat("yyyyMMdd HHmmss z", Locale.US).format(Date()))
super.onLowMemory()
}

override fun onTrimMemory(level: Int) {
Timber.w("onTrimMemory: Memory trim at level $level requested")
FirebaseCrashlytics.getInstance().setCustomKey("last_memory_trim_event", SimpleDateFormat("yyyyMMdd HHmmss z", Locale.US).format(Date()))
FirebaseCrashlytics.getInstance().setCustomKey("last_memory_trim_level", level)
super.onTrimMemory(level)
}

override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
sharedPreferences ?: return

Expand Down

0 comments on commit 7caf512

Please sign in to comment.