Skip to content

Commit

Permalink
Adjust fixes for Android client: add a network conf, change how token…
Browse files Browse the repository at this point in the history
… is passed to gradle (#8824)

* Add a network conf to the android client

* pass in variable

* per review

---------

Co-authored-by: Matt Cleinman <[email protected]>
  • Loading branch information
strseb and mcleinman authored Dec 18, 2023
1 parent 77e59e2 commit a444bb3
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 13 deletions.
2 changes: 1 addition & 1 deletion android/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
android:extractNativeLibs="true"
android:theme="@style/AppTheme"
android:icon="@mipmap/vpnicon"
android:usesCleartextTraffic="false"> <!-- Set this to "true" if you need to use http, i.e. for a local guardian instance -->
android:networkSecurityConfig="@xml/network_security_config">
<activity
android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density"
android:name="org.mozilla.firefox.vpn.qt.VPNActivity"
Expand Down
4 changes: 2 additions & 2 deletions android/adjust/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
defaultConfig {
minSdkVersion Config.minSdkVersion
targetSdkVersion Config.targetSdkVersion
buildConfigField "String", "ADJUST_SDK_TOKEN", '"' + System.getenv("ADJUST_SDK_TOKEN") + '"'

buildConfigField "String", "ADJUST_SDK_TOKEN" , '"' + (project.properties["adjusttoken"] ?: "no_token_found") + '"'
}
sourceSets {
main {
Expand Down
2 changes: 1 addition & 1 deletion android/common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ android {
Config.targetSdkVersion
buildConfigField "String", "VERSIONCODE" , '"' +System.getenv("VERSIONCODE") + '"'
buildConfigField "String", "SHORTVERSION" , '"' + System.getenv("SHORTVERSION") + '"'
buildConfigField "String", "ADJUST_SDK_TOKEN" , '"' + System.getenv("ADJUST_SDK_TOKEN") + '"'
buildConfigField "String", "ADJUST_SDK_TOKEN" , '"' + (project.properties["adjusttoken"] ?: "no_token_found") + '"'

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class CoreApplication : org.qtproject.qt.android.bindings.QtApplication(), Confi
private var adjustActive = false

companion object {
private val tag = "CoreApplicationAdjust"
lateinit var instance: CoreApplication
private set

Expand All @@ -43,6 +44,7 @@ class CoreApplication : org.qtproject.qt.android.bindings.QtApplication(), Confi
*/
@JvmStatic
fun initializeAdjust(inProduction: Boolean, proxyPort: Int) {
Log.i(tag, "Initializing Adjust")
val appToken: String = BuildConfig.ADJUST_SDK_TOKEN
val environment: String =
if (inProduction) AdjustConfig.ENVIRONMENT_PRODUCTION else AdjustConfig.ENVIRONMENT_SANDBOX
Expand Down
2 changes: 1 addition & 1 deletion android/daemon/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ android {

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

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
22 changes: 22 additions & 0 deletions android/resources/all/xml/network_security_config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system" />
</trust-anchors>
</base-config>
<domain-config cleartextTrafficPermitted="false">
<domain includeSubdomains="true">mozilla.org</domain>
<domain includeSubdomains="true">firefox.com</domain>
<domain includeSubdomains="true">mozgcp.net</domain>
<domain includeSubdomains="true">sentry.io</domain>
<domain includeSubdomains="true">apple.com</domain>
<domain includeSubdomains="true">google.com</domain>
<domain includeSubdomains="true">github.io</domain>
<domain includeSubdomains="true">allizom.org</domain>
<domain includeSubdomains="true">mozaws.net</domain>
<trust-anchors>
<certificates src="system" />
</trust-anchors>
</domain-config>
</network-security-config>
9 changes: 1 addition & 8 deletions scripts/android/cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,6 @@ export ADJUST_SDK_TOKEN=$ADJUST_SDK_TOKEN # Export it even if it is not set to o
FULLVERSION=$SHORTVERSION.$(date +"%Y%m%d%H%M")
print G "$SHORTVERSION - $FULLVERSION - $VERSIONCODE"
print Y "Configuring the android build"
if [[ "$ADJUST_SDK_TOKEN" ]]; then
print Y "Use adjust config"
ADJUST="CONFIG+=adjust"
else
print Y "No adjust token found."
ADJUST="CONFIG-=adjust"
fi

# Warning: this is hacky.
#
Expand Down Expand Up @@ -190,7 +183,7 @@ cd .tmp/src/android-build/
if [[ "$RELEASE" ]]; then
print Y "Generating Release APK..."
./gradlew compileReleaseSources
./gradlew assemble || die
./gradlew assemble -Padjusttoken=$ADJUST_SDK_TOKEN || die

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

0 comments on commit a444bb3

Please sign in to comment.