Skip to content

Commit 38c80c3

Browse files
committed
Merge branch 'release/5.208.0' into main
2 parents b03ab19 + bd30c8d commit 38c80c3

File tree

421 files changed

+14636
-13647
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

421 files changed

+14636
-13647
lines changed

anrs/anrs-internal/build.gradle

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/*
2+
* Copyright (c) 2021 DuckDuckGo
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
plugins {
18+
id 'com.android.library'
19+
id 'kotlin-android'
20+
id 'com.squareup.anvil'
21+
id 'com.google.devtools.ksp' version "$ksp_version"
22+
}
23+
24+
apply from: "$rootProject.projectDir/gradle/android-library.gradle"
25+
26+
dependencies {
27+
implementation project(":anrs-api")
28+
implementation project(":anrs-impl")
29+
implementation project(":anrs-store")
30+
31+
anvil project(':anvil-compiler')
32+
implementation project(':anvil-annotations')
33+
implementation project(':di')
34+
implementation project(':common-ui')
35+
implementation project(':common-utils')
36+
implementation project(':navigation-api')
37+
implementation project(':statistics')
38+
implementation project(':internal-features-api')
39+
implementation project(':feature-toggles-api')
40+
implementation project(":app-build-config-api") // needed for feature toggles
41+
implementation project(':browser-api')
42+
43+
ksp AndroidX.room.compiler
44+
45+
implementation KotlinX.coroutines.android
46+
implementation AndroidX.core.ktx
47+
implementation Google.dagger
48+
implementation Google.android.material
49+
implementation AndroidX.constraintLayout
50+
implementation AndroidX.lifecycle.runtime.ktx
51+
52+
// Room
53+
ksp AndroidX.room.compiler
54+
implementation AndroidX.room.runtime
55+
implementation AndroidX.room.rxJava2
56+
implementation AndroidX.room.ktx
57+
testImplementation AndroidX.room.testing
58+
59+
implementation "com.squareup.logcat:logcat:_"
60+
61+
testImplementation Testing.junit4
62+
testImplementation AndroidX.test.ext.junit
63+
testImplementation "org.mockito.kotlin:mockito-kotlin:_"
64+
testImplementation project(':common-test')
65+
testImplementation project(':feature-toggles-test')
66+
testImplementation CashApp.turbine
67+
testImplementation Testing.robolectric
68+
testImplementation(KotlinX.coroutines.test) {
69+
// https://github.com/Kotlin/kotlinx.coroutines/issues/2023
70+
// conflicts with mockito due to direct inclusion of byte buddy
71+
exclude group: "org.jetbrains.kotlinx", module: "kotlinx-coroutines-debug"
72+
}
73+
74+
coreLibraryDesugaring Android.tools.desugarJdkLibs
75+
}
76+
77+
android {
78+
namespace "com.duckduckgo.app.anr.internal"
79+
anvil {
80+
generateDaggerFactories = true // default is false
81+
}
82+
lint {
83+
baseline file("lint-baseline.xml")
84+
}
85+
testOptions {
86+
unitTests {
87+
includeAndroidResources = true
88+
}
89+
}
90+
compileOptions {
91+
coreLibraryDesugaringEnabled = true
92+
}
93+
}
94+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<issues format="6" by="lint 8.1.2" type="baseline" client="gradle" dependencies="false" name="AGP (8.1.2)" variant="all" version="8.1.2">
3+
4+
</issues>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
3+
4+
<application>
5+
<activity
6+
android:name=".feature.CrashANRsInternalSettingsActivity"
7+
android:label="Crash And ANRs Dev Settings"
8+
android:exported="false" />
9+
</application>
10+
11+
</manifest>
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright (c) 2023 DuckDuckGo
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.duckduckgo.app.anr.internal.feature
18+
19+
import android.os.Bundle
20+
import com.duckduckgo.anvil.annotations.ContributeToActivityStarter
21+
import com.duckduckgo.anvil.annotations.InjectWith
22+
import com.duckduckgo.app.anr.internal.databinding.ActivityCrashAnrInternalSettingsBinding
23+
import com.duckduckgo.app.anr.internal.feature.CrashANRsInternalScreens.InternalCrashSettings
24+
import com.duckduckgo.common.ui.DuckDuckGoActivity
25+
import com.duckduckgo.common.ui.viewbinding.viewBinding
26+
import com.duckduckgo.common.utils.plugins.PluginPoint
27+
import com.duckduckgo.di.scopes.ActivityScope
28+
import com.duckduckgo.navigation.api.GlobalActivityStarter
29+
import javax.inject.Inject
30+
31+
@InjectWith(ActivityScope::class)
32+
@ContributeToActivityStarter(InternalCrashSettings::class)
33+
class CrashANRsInternalSettingsActivity : DuckDuckGoActivity() {
34+
35+
@Inject
36+
lateinit var settings: PluginPoint<CrashANRsSettingPlugin>
37+
38+
private val binding: ActivityCrashAnrInternalSettingsBinding by viewBinding()
39+
40+
override fun onCreate(savedInstanceState: Bundle?) {
41+
super.onCreate(savedInstanceState)
42+
setContentView(binding.root)
43+
setupToolbar(binding.toolbar)
44+
45+
setupUiElementState()
46+
}
47+
48+
private fun setupUiElementState() {
49+
settings.getPlugins()
50+
.mapNotNull { it.getView(this) }
51+
.forEach { remoteViewPlugin ->
52+
binding.settingsContent.addView(remoteViewPlugin)
53+
}
54+
}
55+
}
56+
57+
sealed class CrashANRsInternalScreens : GlobalActivityStarter.ActivityParams {
58+
data object InternalCrashSettings : CrashANRsInternalScreens() {
59+
private fun readResolve(): Any = InternalCrashSettings
60+
}
61+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (c) 2024 DuckDuckGo
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.duckduckgo.app.anr.internal.feature
18+
19+
import android.content.*
20+
import android.view.*
21+
import com.duckduckgo.anvil.annotations.ContributesPluginPoint
22+
import com.duckduckgo.di.scopes.ActivityScope
23+
24+
/**
25+
* Use this interface to create a new plugin that will be used to display a specific settings section
26+
*/
27+
@ContributesPluginPoint(ActivityScope::class)
28+
interface CrashANRsSettingPlugin {
29+
/**
30+
* This method returns a [View] that will be used as a setting item
31+
* @return [View]
32+
*/
33+
fun getView(context: Context): View?
34+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (c) 2023 DuckDuckGo
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.duckduckgo.app.anr.internal.feature
18+
19+
import android.content.Context
20+
import com.duckduckgo.anvil.annotations.PriorityKey
21+
import com.duckduckgo.app.anr.internal.feature.CrashANRsInternalScreens.InternalCrashSettings
22+
import com.duckduckgo.di.scopes.AppScope
23+
import com.duckduckgo.internal.features.api.InternalFeaturePlugin
24+
import com.duckduckgo.internal.features.api.InternalFeaturePlugin.Companion.CRASH_ANR_SETTINGS_PRIO_KEY
25+
import com.duckduckgo.navigation.api.GlobalActivityStarter
26+
import com.squareup.anvil.annotations.ContributesMultibinding
27+
import javax.inject.Inject
28+
29+
@ContributesMultibinding(AppScope::class)
30+
@PriorityKey(CRASH_ANR_SETTINGS_PRIO_KEY)
31+
class InternalSettingsActivity @Inject constructor(
32+
private val globalActivityStarter: GlobalActivityStarter,
33+
) : InternalFeaturePlugin {
34+
override fun internalFeatureTitle(): String {
35+
return "Crash and ANRs settings"
36+
}
37+
38+
override fun internalFeatureSubtitle(): String {
39+
return "Crash and ANRs dev settings for internal users"
40+
}
41+
42+
override fun onInternalFeatureClicked(activityContext: Context) {
43+
globalActivityStarter.start(activityContext, InternalCrashSettings)
44+
}
45+
}
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/*
2+
* Copyright (c) 2024 DuckDuckGo
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.duckduckgo.app.anr.internal.setting
18+
19+
import android.content.Context
20+
import android.util.AttributeSet
21+
import android.view.View
22+
import android.widget.FrameLayout
23+
import androidx.lifecycle.findViewTreeLifecycleOwner
24+
import androidx.lifecycle.lifecycleScope
25+
import androidx.recyclerview.widget.LinearLayoutManager
26+
import com.duckduckgo.anvil.annotations.InjectWith
27+
import com.duckduckgo.app.anr.internal.databinding.CrashAnrsListViewBinding
28+
import com.duckduckgo.app.anr.internal.feature.CrashANRsSettingPlugin
29+
import com.duckduckgo.app.anr.internal.setting.VitalsAdapterList.VitalsItems.AnrItem
30+
import com.duckduckgo.app.anr.internal.setting.VitalsAdapterList.VitalsItems.CrashItem
31+
import com.duckduckgo.app.di.AppCoroutineScope
32+
import com.duckduckgo.common.ui.viewbinding.viewBinding
33+
import com.duckduckgo.common.utils.DispatcherProvider
34+
import com.duckduckgo.di.scopes.ActivityScope
35+
import com.duckduckgo.di.scopes.ViewScope
36+
import com.duckduckgo.navigation.api.GlobalActivityStarter
37+
import com.squareup.anvil.annotations.ContributesMultibinding
38+
import dagger.android.support.AndroidSupportInjection
39+
import javax.inject.Inject
40+
import kotlinx.coroutines.CoroutineScope
41+
import kotlinx.coroutines.flow.combine
42+
import kotlinx.coroutines.flow.flowOn
43+
import kotlinx.coroutines.launch
44+
45+
@InjectWith(ViewScope::class)
46+
class CrashANRsListView @JvmOverloads constructor(
47+
context: Context,
48+
attrs: AttributeSet? = null,
49+
defStyle: Int = 0,
50+
) : FrameLayout(context, attrs, defStyle) {
51+
52+
@Inject
53+
lateinit var globalActivityStarter: GlobalActivityStarter
54+
55+
@Inject
56+
lateinit var dispatcherProvider: DispatcherProvider
57+
58+
@Inject
59+
lateinit var crashANRsRepository: CrashANRsRepository
60+
61+
@Inject
62+
@AppCoroutineScope
63+
lateinit var appCoroutineScope: CoroutineScope
64+
65+
private val binding: CrashAnrsListViewBinding by viewBinding()
66+
private lateinit var anrAdapter: VitalsAdapterList
67+
68+
override fun onAttachedToWindow() {
69+
AndroidSupportInjection.inject(this)
70+
super.onAttachedToWindow()
71+
72+
configureANRList()
73+
74+
findViewTreeLifecycleOwner()?.lifecycleScope?.launch {
75+
crashANRsRepository.getANRs().combine(crashANRsRepository.getCrashes()) { anrs, crashes ->
76+
(
77+
anrs.map {
78+
AnrItem(
79+
stackTrace = it.stackTrace,
80+
customTab = it.customTab,
81+
timestamp = it.timestamp,
82+
)
83+
} + crashes.map {
84+
CrashItem(
85+
stackTrace = it.stackTrace,
86+
processName = it.processName,
87+
customTab = it.customTab,
88+
timestamp = it.timestamp,
89+
)
90+
}
91+
).sortedByDescending { it.timestamp }
92+
}.flowOn(dispatcherProvider.io()).collect {
93+
anrAdapter.setItems(it)
94+
}
95+
}
96+
}
97+
98+
private fun configureANRList() {
99+
binding.anrList.layoutManager = LinearLayoutManager(context)
100+
anrAdapter = VitalsAdapterList()
101+
binding.anrList.adapter = anrAdapter
102+
}
103+
}
104+
105+
@ContributesMultibinding(ActivityScope::class)
106+
class CrashANRsListViewPlugin @Inject constructor() : CrashANRsSettingPlugin {
107+
override fun getView(context: Context): View {
108+
return CrashANRsListView(context)
109+
}
110+
}

0 commit comments

Comments
 (0)