Skip to content

Commit bb1670f

Browse files
mcleinmanstrseb
andauthored
Adjust fixes for Android client: add a network conf, change how token is passed to gradle (#8824) (#8833)
* Add a network conf to the android client * pass in variable * per review --------- Co-authored-by: Sebastian Streich <strseb@users.noreply.github.com>
1 parent bcd6d9a commit bb1670f

7 files changed

Lines changed: 30 additions & 13 deletions

File tree

android/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
2828
android:extractNativeLibs="true"
2929
android:theme="@style/AppTheme"
3030
android:icon="@mipmap/vpnicon"
31-
android:usesCleartextTraffic="false"> <!-- Set this to "true" if you need to use http, i.e. for a local guardian instance -->
31+
android:networkSecurityConfig="@xml/network_security_config">
3232
<activity
3333
android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density"
3434
android:name="org.mozilla.firefox.vpn.qt.VPNActivity"

android/adjust/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ android {
1010
defaultConfig {
1111
minSdkVersion Config.minSdkVersion
1212
targetSdkVersion Config.targetSdkVersion
13-
14-
buildConfigField "String", "ADJUST_SDK_TOKEN", '"' + System.getenv("ADJUST_SDK_TOKEN") + '"'
13+
14+
buildConfigField "String", "ADJUST_SDK_TOKEN" , '"' + (project.properties["adjusttoken"] ?: "no_token_found") + '"'
1515
}
1616
sourceSets {
1717
main {

android/common/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ android {
1616
Config.targetSdkVersion
1717
buildConfigField "String", "VERSIONCODE" , '"' +System.getenv("VERSIONCODE") + '"'
1818
buildConfigField "String", "SHORTVERSION" , '"' + System.getenv("SHORTVERSION") + '"'
19-
buildConfigField "String", "ADJUST_SDK_TOKEN" , '"' + System.getenv("ADJUST_SDK_TOKEN") + '"'
19+
buildConfigField "String", "ADJUST_SDK_TOKEN" , '"' + (project.properties["adjusttoken"] ?: "no_token_found") + '"'
2020

2121
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
2222
}

android/common/src/main/java/org/mozilla/firefox/qt/common/CoreApplication.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class CoreApplication : org.qtproject.qt.android.bindings.QtApplication(), Confi
3232
private var adjustActive = false
3333

3434
companion object {
35+
private val tag = "CoreApplicationAdjust"
3536
lateinit var instance: CoreApplication
3637
private set
3738

@@ -43,6 +44,7 @@ class CoreApplication : org.qtproject.qt.android.bindings.QtApplication(), Confi
4344
*/
4445
@JvmStatic
4546
fun initializeAdjust(inProduction: Boolean, proxyPort: Int) {
47+
Log.i(tag, "Initializing Adjust")
4648
val appToken: String = BuildConfig.ADJUST_SDK_TOKEN
4749
val environment: String =
4850
if (inProduction) AdjustConfig.ENVIRONMENT_PRODUCTION else AdjustConfig.ENVIRONMENT_SANDBOX

android/daemon/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ android {
5454

5555
buildConfigField "String", "VERSIONCODE" , '"' +System.getenv("VERSIONCODE") + '"'
5656
buildConfigField "String", "SHORTVERSION" , '"' + System.getenv("SHORTVERSION") + '"'
57-
buildConfigField "String", "ADJUST_SDK_TOKEN" , '"' + System.getenv("ADJUST_SDK_TOKEN") + '"'
57+
buildConfigField "String", "ADJUST_SDK_TOKEN" , '"' + (project.properties["adjusttoken"] ?: "no_token_found") + '"'
5858

5959
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
6060
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<network-security-config>
3+
<base-config cleartextTrafficPermitted="true">
4+
<trust-anchors>
5+
<certificates src="system" />
6+
</trust-anchors>
7+
</base-config>
8+
<domain-config cleartextTrafficPermitted="false">
9+
<domain includeSubdomains="true">mozilla.org</domain>
10+
<domain includeSubdomains="true">firefox.com</domain>
11+
<domain includeSubdomains="true">mozgcp.net</domain>
12+
<domain includeSubdomains="true">sentry.io</domain>
13+
<domain includeSubdomains="true">apple.com</domain>
14+
<domain includeSubdomains="true">google.com</domain>
15+
<domain includeSubdomains="true">github.io</domain>
16+
<domain includeSubdomains="true">allizom.org</domain>
17+
<domain includeSubdomains="true">mozaws.net</domain>
18+
<trust-anchors>
19+
<certificates src="system" />
20+
</trust-anchors>
21+
</domain-config>
22+
</network-security-config>

scripts/android/cmake.sh

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,6 @@ export ADJUST_SDK_TOKEN=$ADJUST_SDK_TOKEN # Export it even if it is not set to o
125125
FULLVERSION=$SHORTVERSION.$(date +"%Y%m%d%H%M")
126126
print G "$SHORTVERSION - $FULLVERSION - $VERSIONCODE"
127127
print Y "Configuring the android build"
128-
if [[ "$ADJUST_SDK_TOKEN" ]]; then
129-
print Y "Use adjust config"
130-
ADJUST="CONFIG+=adjust"
131-
else
132-
print Y "No adjust token found."
133-
ADJUST="CONFIG-=adjust"
134-
fi
135128

136129
# Warning: this is hacky.
137130
#
@@ -190,7 +183,7 @@ cd .tmp/src/android-build/
190183
if [[ "$RELEASE" ]]; then
191184
print Y "Generating Release APK..."
192185
./gradlew compileReleaseSources
193-
./gradlew assemble || die
186+
./gradlew assemble -Padjusttoken=$ADJUST_SDK_TOKEN || die
194187

195188
print G "Done 🎉"
196189
print G "Your Release APK is under .tmp/src/android-build/build/outputs/apk/release/"

0 commit comments

Comments
 (0)