Skip to content

Commit a4f522f

Browse files
committed
Merge branch 'release/5.204.0' into main
2 parents fd47562 + 68c3710 commit a4f522f

File tree

142 files changed

+4688
-1296
lines changed

Some content is hidden

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

142 files changed

+4688
-1296
lines changed

app-tracking-protection/vpn-impl/src/main/java/com/duckduckgo/mobile/android/vpn/feature/AppTpRemoteFeatures.kt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,10 @@ class AppTpRemoteFeaturesStore @Inject constructor(
6969

7070
private val togglesCache = ConcurrentHashMap<String, State>()
7171

72-
private val preferences: SharedPreferences by lazy {
73-
sharedPreferencesProvider.getSharedPreferences(PREFS_FILENAME, multiprocess = true, migrate = false)
72+
private val preferences: SharedPreferences? by lazy {
73+
runCatching {
74+
sharedPreferencesProvider.getSharedPreferences(PREFS_FILENAME, multiprocess = true, migrate = false)
75+
}.getOrNull()
7476
}
7577
private val stateAdapter: JsonAdapter<State> by lazy {
7678
moshi.newBuilder().add(KotlinJsonAdapterFactory()).build().adapter(State::class.java)
@@ -90,14 +92,14 @@ class AppTpRemoteFeaturesStore @Inject constructor(
9092

9193
init {
9294
coroutineScope.launch(dispatcherProvider.io()) {
93-
preferences.load()
94-
preferences.registerOnSharedPreferenceChangeListener(listener)
95+
preferences?.load()
96+
preferences?.registerOnSharedPreferenceChangeListener(listener)
9597
}
9698
}
9799

98100
override fun set(key: String, state: State) {
99101
togglesCache[key] = state
100-
preferences.save(key, state)
102+
preferences?.save(key, state)
101103
}
102104

103105
override fun get(key: String): State? {
@@ -112,7 +114,7 @@ class AppTpRemoteFeaturesStore @Inject constructor(
112114

113115
private suspend fun SharedPreferences.load() = withContext(dispatcherProvider.io()) {
114116
togglesCache.clear()
115-
preferences.all.keys.forEach { key ->
117+
preferences?.all?.keys?.forEach { key ->
116118
load(key)?.let {
117119
togglesCache[key] = it
118120
}

app-tracking-protection/vpn-impl/src/main/java/com/duckduckgo/mobile/android/vpn/pixels/DeviceShieldPixelNames.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ enum class DeviceShieldPixelNames(override val pixelName: String, val enqueue: B
224224

225225
VPN_MOTO_G_FIX_DAILY("m_vpn_ev_moto_g_fix_d", enqueue = true),
226226
VPN_START_ATTEMPT("m_vpn_ev_start_attempt_c", enqueue = true),
227+
VPN_START_ATTEMPT_SUCCESS("m_vpn_ev_start_attempt_success_c", enqueue = true),
227228
VPN_START_ATTEMPT_FAILURE("m_vpn_ev_start_attempt_failure_c", enqueue = true),
228229
;
229230
}

app-tracking-protection/vpn-impl/src/main/java/com/duckduckgo/mobile/android/vpn/pixels/DeviceShieldPixels.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,8 @@ interface DeviceShieldPixels {
361361
fun reportMotoGFix()
362362

363363
fun reportVpnStartAttempt()
364+
365+
fun reportVpnStartAttemptSuccess()
364366
}
365367

366368
@ContributesBinding(AppScope::class)
@@ -774,6 +776,10 @@ class RealDeviceShieldPixels @Inject constructor(
774776
firePixel(DeviceShieldPixelNames.VPN_START_ATTEMPT)
775777
}
776778

779+
override fun reportVpnStartAttemptSuccess() {
780+
firePixel(DeviceShieldPixelNames.VPN_START_ATTEMPT_SUCCESS)
781+
}
782+
777783
private fun suddenKill() {
778784
firePixel(DeviceShieldPixelNames.ATP_KILLED)
779785
}

app-tracking-protection/vpn-impl/src/main/java/com/duckduckgo/mobile/android/vpn/service/DeviceShieldTileService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class DeviceShieldTileService : TileService() {
8787
}
8888
}
8989

90-
@SuppressLint("NewApi") // IDE doesn't get we use appBuildConfig
90+
@SuppressLint("NewApi", "StartActivityAndCollapseDeprecated") // IDE doesn't get we use appBuildConfig
9191
private fun launchActivity() {
9292
val intent = Intent(this, VpnPermissionRequesterActivity::class.java).apply { addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) }
9393
if (appBuildConfig.sdkInt >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {

app-tracking-protection/vpn-impl/src/main/java/com/duckduckgo/mobile/android/vpn/service/TrackerBlockingVpnService.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,8 @@ class TrackerBlockingVpnService : VpnService(), CoroutineScope by MainScope(), V
393393
stopVpn(VpnStopReason.ERROR, true)
394394
}
395395

396+
deviceShieldPixels.reportVpnStartAttemptSuccess()
397+
396398
// This is something temporary while we confirm whether we're able to fix the moto g issues with appTP
397399
// see https://app.asana.com/0/488551667048375/1203410036713941/f for more info
398400
tunnelConfig?.let { config ->

app-tracking-protection/vpn-impl/src/test/java/com/duckduckgo/mobile/android/vpn/feature/AppTpRemoteFeaturesStoreTest.kt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import com.duckduckgo.feature.toggles.api.Toggle
99
import com.duckduckgo.feature.toggles.api.Toggle.State
1010
import com.squareup.moshi.Moshi
1111
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
12+
import java.io.IOException
1213
import kotlinx.coroutines.test.runTest
1314
import org.junit.Assert.assertEquals
1415
import org.junit.Assert.assertNull
@@ -115,4 +116,34 @@ class AppTpRemoteFeaturesStoreTest {
115116

116117
assertEquals(expected, appTpRemoteFeaturesStore.get("key"))
117118
}
119+
120+
@Test
121+
fun `test shared preferences creation exception`() {
122+
val appTpRemoteFeaturesStore = AppTpRemoteFeaturesStore(
123+
coroutineRule.testScope,
124+
coroutineRule.testDispatcherProvider,
125+
object : SharedPreferencesProvider {
126+
override fun getSharedPreferences(
127+
name: String,
128+
multiprocess: Boolean,
129+
migrate: Boolean,
130+
): SharedPreferences {
131+
throw IOException("test")
132+
}
133+
134+
override fun getEncryptedSharedPreferences(
135+
name: String,
136+
multiprocess: Boolean,
137+
): SharedPreferences? {
138+
throw IOException("test")
139+
}
140+
},
141+
Moshi.Builder().build(),
142+
)
143+
144+
assertNull(appTpRemoteFeaturesStore.get("key"))
145+
val expected = State(enable = true)
146+
appTpRemoteFeaturesStore.set("key", expected)
147+
assertEquals(expected, appTpRemoteFeaturesStore.get("key"))
148+
}
118149
}

app/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ fladle {
166166
}
167167

168168
dependencies {
169+
implementation project(":history-impl")
170+
implementation project(":history-api")
169171
implementation project(":data-store-impl")
170172
implementation project(":data-store-api")
171173
implementation project(":verified-installation-impl")

app/lint-baseline.xml

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -162,28 +162,6 @@
162162
column="42"/>
163163
</issue>
164164

165-
<issue
166-
id="MissingQuantity"
167-
message="For locale &quot;fr&quot; (French) the following quantities should also be defined: `many`"
168-
errorLine1=" &lt;plurals name=&quot;daxTrackersBlockedCtaText&quot;>"
169-
errorLine2=" ^">
170-
<location
171-
file="src/main/res/values-fr/strings.xml"
172-
line="417"
173-
column="5"/>
174-
</issue>
175-
176-
<issue
177-
id="MissingQuantity"
178-
message="For locale &quot;fr&quot; (French) the following quantities should also be defined: `many`"
179-
errorLine1=" &lt;plurals name=&quot;daxTrackersBlockedCtaZeroText&quot;>"
180-
errorLine2=" ^">
181-
<location
182-
file="src/main/res/values-fr/strings.xml"
183-
line="421"
184-
column="5"/>
185-
</issue>
186-
187165
<issue
188166
id="MissingQuantity"
189167
message="For locale &quot;fr&quot; (French) the following quantities should also be defined: `many`"
@@ -1977,28 +1955,6 @@
19771955
column="5"/>
19781956
</issue>
19791957

1980-
<issue
1981-
id="UnusedQuantity"
1982-
message="For language &quot;hr&quot; (Croatian) the following quantities are not relevant: `many`"
1983-
errorLine1=" &lt;plurals name=&quot;daxTrackersBlockedCtaText&quot;>"
1984-
errorLine2=" ^">
1985-
<location
1986-
file="src/main/res/values-hr/strings.xml"
1987-
line="417"
1988-
column="5"/>
1989-
</issue>
1990-
1991-
<issue
1992-
id="UnusedQuantity"
1993-
message="For language &quot;hr&quot; (Croatian) the following quantities are not relevant: `many`"
1994-
errorLine1=" &lt;plurals name=&quot;daxTrackersBlockedCtaZeroText&quot;>"
1995-
errorLine2=" ^">
1996-
<location
1997-
file="src/main/res/values-hr/strings.xml"
1998-
line="423"
1999-
column="5"/>
2000-
</issue>
2001-
20021958
<issue
20031959
id="UnusedQuantity"
20041960
message="For language &quot;hr&quot; (Croatian) the following quantities are not relevant: `many`"

0 commit comments

Comments
 (0)