Skip to content

Commit bbaf8d3

Browse files
authored
Merge pull request nextcloud#11073 from nextcloud/chore/strictmode-optional
Disable StrictMode by default
2 parents d584c84 + a2198d3 commit bbaf8d3

3 files changed

Lines changed: 22 additions & 2 deletions

File tree

CONTRIBUTING.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,22 @@ and thereof we'd ask contributors to be mindful of their code testability:
407407
should at least not make future efforts more challenging
408408
3. whenever possible, testability should be improved even if the code is not covered by tests
409409

410+
### Performance
411+
412+
If you're interested in improving the app's performance, please check the [official documentation](https://developer.android.com/topic/performance)
413+
for ways you can inspect and improve performance.
414+
415+
For additional analysis, set the `perfAnalysis` property
416+
in your Gradle build:
417+
418+
```shell
419+
./gradlew installGplayDebug -P perfAnalysis
420+
```
421+
422+
This will install the app with [LeakCanary](https://square.github.io/leakcanary/) and
423+
[StrictMode](https://developer.android.com/reference/android/os/StrictMode) enabled and configured.
424+
These tools can help find memory leaks, foreground operations that should be in background, and other performance
425+
problems.
410426

411427
# Releases
412428
At the moment we are releasing the app in two app stores:

app/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ file("$project.rootDir/ndk.env").readLines().each() {
6969
ndkEnv.put(key, value)
7070
}
7171

72+
def perfAnalysis = project.hasProperty('perfAnalysis')
73+
7274
android {
7375

7476
compileSdkVersion 32
@@ -85,6 +87,7 @@ android {
8587
targetSdkVersion 31
8688

8789
buildConfigField 'boolean', 'CI', ciBuild.toString()
90+
buildConfigField 'boolean', 'RUNTIME_PERF_ANALYSIS', perfAnalysis.toString()
8891

8992
javaCompileOptions {
9093
annotationProcessorOptions {
@@ -309,7 +312,7 @@ dependencies {
309312
}
310313
}
311314

312-
if (project.hasProperty("leakCanary")) {
315+
if (perfAnalysis) {
313316
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.10'
314317
}
315318

app/src/main/java/com/owncloud/android/MainApp.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,8 @@ private void fixStoragePath() {
488488
}
489489

490490
private void enableStrictMode() {
491-
if (BuildConfig.DEBUG) {
491+
if (BuildConfig.DEBUG && BuildConfig.RUNTIME_PERF_ANALYSIS) {
492+
Log_OC.d(TAG, "Enabling StrictMode");
492493
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
493494
.detectDiskReads()
494495
.detectDiskWrites()

0 commit comments

Comments
 (0)