Skip to content

Commit

Permalink
Closes mozilla-mobile#1151: As a developer, Flipper integration might…
Browse files Browse the repository at this point in the history
… help me with debugging
  • Loading branch information
colintheshots committed Mar 22, 2019
1 parent 1aef612 commit 0acf869
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 2 deletions.
3 changes: 3 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,9 @@ dependencies {

implementation Deps.glide
annotationProcessor Deps.glideAnnotationProcessor

debugImplementation Deps.flipper
debugImplementation Deps.soLoader
}

if (project.hasProperty("raptor")) {
Expand Down
9 changes: 8 additions & 1 deletion app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

<application
tools:replace="android:name"
android:name="org.mozilla.fenix.DebugFenixApplication"/>
android:name="org.mozilla.fenix.DebugFenixApplication">

<activity android:name="com.facebook.flipper.android.diagnostics.FlipperDiagnosticActivity"
android:exported="true"/>
<service android:name="com.facebook.flipper.plugins.leakcanary.RecordLeakService" />
</application>

</manifest>
25 changes: 25 additions & 0 deletions app/src/debug/java/org/mozilla/fenix/DebugFenixApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ package org.mozilla.fenix
import android.content.Context
import android.content.SharedPreferences
import androidx.preference.PreferenceManager
import com.facebook.flipper.android.AndroidFlipperClient
import com.facebook.flipper.android.utils.FlipperUtils
import com.facebook.flipper.plugins.inspector.DescriptorMapping
import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin
import com.facebook.flipper.plugins.leakcanary.LeakCanaryFlipperPlugin
import com.facebook.flipper.plugins.leakcanary.RecordLeakService
import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin
import com.facebook.soloader.SoLoader
import com.squareup.leakcanary.AndroidHeapDumper
import com.squareup.leakcanary.HeapDumper
import com.squareup.leakcanary.LeakCanary
Expand All @@ -17,13 +25,30 @@ import java.io.File

class DebugFenixApplication : FenixApplication() {

override fun onCreate() {
super.onCreate()
SoLoader.init(this, false)

if (FlipperUtils.shouldEnableFlipper(this)) {
AndroidFlipperClient.getInstance(this).apply {
addPlugin(InspectorFlipperPlugin(this@DebugFenixApplication,
DescriptorMapping.withDefaults()))
addPlugin(LeakCanaryFlipperPlugin())
addPlugin(SharedPreferencesFlipperPlugin(this@DebugFenixApplication,
this@DebugFenixApplication.packageName + "_preferences"))
start()
}
}
}

private var heapDumper: ToggleableHeapDumper? = null

override fun setupLeakCanary() {
val leakDirectoryProvider = LeakCanaryInternals.getLeakDirectoryProvider(this)
val defaultDumper = AndroidHeapDumper(this, leakDirectoryProvider)
heapDumper = ToggleableHeapDumper(this, defaultDumper)
LeakCanary.refWatcher(this)
.listenerServiceClass(RecordLeakService::class.java)
.heapDumper(heapDumper)
.buildAndInstall()
}
Expand Down
5 changes: 5 additions & 0 deletions buildSrc/src/main/java/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ private object Versions {
const val mockito = "2.23.0"
const val mockk = "1.9.kotlin12"
const val glide = "4.9.0"
const val flipper = "0.18.0"
const val soLoader = "0.5.1"
}

@Suppress("unused")
Expand Down Expand Up @@ -141,4 +143,7 @@ object Deps {

const val glide = "com.github.bumptech.glide:glide:${Versions.glide}"
const val glideAnnotationProcessor = "com.github.bumptech.glide:compiler:${Versions.glide}"

const val flipper = "com.facebook.flipper:flipper:${Versions.flipper}"
const val soLoader = "com.facebook.soloader:soloader:${Versions.soLoader}"
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
org.gradle.jvmargs=-Xmx2048m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
Expand Down

0 comments on commit 0acf869

Please sign in to comment.