Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ooni/probe-android into dev/ooni-…
Browse files Browse the repository at this point in the history
…run-v2
  • Loading branch information
aanorbel committed Jul 15, 2024
2 parents 9b59c20 + 3106d03 commit 7f4e51e
Show file tree
Hide file tree
Showing 112 changed files with 5,626 additions and 138 deletions.
40 changes: 24 additions & 16 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ jobs:
strategy:
matrix:
version:
- "StableFullRelease"
- "StableFdroidRelease"
- "OoniStableFullRelease"
- "OoniStableFdroidRelease"
- "DwStableFullRelease"
- "DwStableFdroidRelease"

steps:
- name: Set up JDK 17
Expand Down Expand Up @@ -47,14 +49,14 @@ jobs:
uses: actions/checkout@v4

- name: Run unit tests
run: ./gradlew testStableFullRelease
run: ./gradlew testOoniStableFullRelease

- name: Uploads test reports
uses: actions/upload-artifact@v4
if: failure()
with:
name: test-report
path: app/build/test-results/testStableFullDebugUnitTest
path: app/build/test-results/testOoniStableFullReleaseUnitTest

instrumented-test:
name: Run instrumented tests
Expand Down Expand Up @@ -85,14 +87,14 @@ jobs:
profile: pixel_3_xl
ram-size: 4096M
disable-animations: true
script: ./gradlew connectedStableFullDebugAndroidTest
script: ./gradlew connectedOoniStableFullDebugAndroidTest

- name: uploads test reports
uses: actions/upload-artifact@v4
if: failure()
with:
name: emulator-test-reports
path: app/build/reports/androidTests/connected/debug/flavors/stableFull/
path: app/build/reports/androidTests/connected/debug/flavors/ooniStableFull/

assemble-archive:
name: Archive APKs
Expand All @@ -101,10 +103,13 @@ jobs:
strategy:
matrix:
version:
- "StableFullDebug"
- "StableFdroidDebug"
- "DevFullDebug"
- "DevFullDebugAndroidTest"
- "OoniStableFullDebug"
- "OoniStableFdroidDebug"
- "OoniDevFullDebug"
- "OoniDevFullDebugAndroidTest"
- "DwStableFullDebug"
- "DwStableFdroidDebug"
- "DwDevFullDebug"
needs: [ build ]

steps:
Expand Down Expand Up @@ -148,10 +153,13 @@ jobs:
with:
name: ${{ matrix.version }}Apk
path: |
app/build/outputs/apk/devFull/debug/app-dev-full-debug.apk
app/build/outputs/apk/androidTest/devFull/debug/app-dev-full-debug-androidTest.apk
app/build/outputs/apk/stableFull/debug/app-stable-full-debug.apk
app/build/outputs/apk/stableFdroid/debug/app-stable-fdroid-debug.apk
app/build/outputs/apk/ooniStableFull/debug/app-ooni-stable-full-debug.apk
app/build/outputs/apk/ooniStableFdroid/debug/app-ooni-stable-fdroid-debug.apk
app/build/outputs/apk/ooniDevFull/debug/app-ooni-dev-full-debug.apk
app/build/outputs/apk/androidTest/ooniDevFull/debug/app-ooni-dev-full-debug-androidTest.apk
app/build/outputs/apk/dwStableFull/debug/app-dw-stable-full-debug.apk
app/build/outputs/apk/dwStableFdroid/debug/app-dw-stable-fdroid-debug.apk
app/build/outputs/apk/dwDevFull/debug/app-dw-dev-full-debug.apk
distribute:
name: Upload artifact to Firebase App Distribution
Expand All @@ -165,7 +173,7 @@ jobs:
- name: Download app APK
uses: actions/download-artifact@v4
with:
name: DevFullDebugApk
name: OoniDevFullDebugApk

- name: Upload artifact to Firebase App Distribution
uses: wzieba/Firebase-Distribution-Github-Action@v1.7.0
Expand All @@ -174,7 +182,7 @@ jobs:
appId: ${{secrets.FIREBASE_APP_ID}}
serviceCredentialsFileContent: ${{ secrets.CREDENTIAL_FILE_CONTENT }}
groups: testers
file: devFull/debug/app-dev-full-debug.apk
file: ooniDevFull/debug/app-ooni-dev-full-debug.apk
- name: Write Summary
run: |
echo "View this release in the Firebase console: ${{ steps.uploadArtifact.outputs.FIREBASE_CONSOLE_URI }}" >> $GITHUB_STEP_SUMMARY
69 changes: 34 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,85 +61,84 @@ implement the following flavours:

- `full` and `fdroid` (dimension: `license`).

- `ooni` and `dw` (dimension: `brand`).

The `testing` dimension controls whether we're building a release
or a more unstable version. We build releases using the `stable`
flavour. The `dev` flavour builds the version of the app that should
be released on the store as the beta channel. The `experimental`
flavour, instead, allows a developer to build a one-off version of
the app that uses a custom build of the `oonimkall` library.

For `stable` and `dev`, we fetch `oonimkall` from the
[Maven central](https://search.maven.org/artifact/org.ooni/oonimkall)
repository. The `experimental` flavour, instead, requires you to
put the `oonimkall.aar` you built inside `engine-experimental`.

The `license` dimension controls which proprietary libraries to include
into the build. The `full` flavour includes all such dependencies,
while the `fdroid` flavour does not include any of them.

The variant names are therefore:
The `brand` dimension controls the branding of the application. The `ooni` flavour is the default branding, while the `dw` flavour is for the "News Media Scan" branding.

- `experimentalFullDebug`
- `experimentalFullRelease`
- `devFullDebug`
- `devFullRelease`
- `stableFullDebug`
- `stableFullRelease`
The variant names are therefore:

We additionally have `stableFdroidDebug` and `stableFdroidRelease`.
- `ooniExperimentalFullDebug`
- `ooniExperimentalFullRelease`
- `ooniDevFullDebug`
- `ooniDevFullRelease`
- `ooniStableFullDebug`
- `ooniStableFullRelease`
- `dwExperimentalFullDebug`
- `dwExperimentalFullRelease`
- `dwDevFullDebug`
- `dwDevFullRelease`
- `dwStableFullDebug`
- `dwStableFullRelease`

We additionally have `ooniStableFdroidDebug`, `ooniStableFdroidRelease`, `dwStableFdroidDebug` and `dwStableFdroidRelease`.

All of this is controlled by [app/build.gradle](app/build.gradle).

## Gradle modules

- [app](app) contains the mobile app;
- [engine](engine) contains wrappers for `oonimkall`, the
measurement engine library;
- [engine-experimental](engine-experimental) allows us
to implement the `experimental` build flavour where you
put the `oonimkall.aar` file you built inside `engine-experimental`
rather than downloading it from Maven Central.
- [engine](engine) contains wrappers for `oonimkall`, the measurement engine library;
- [engine-experimental](engine-experimental) allows us to implement the `experimental` build flavour where you put the `oonimkall.aar` file you built inside `engine-experimental` rather than downloading it from Maven Central.

## Building an apk

Ensure you have Android Studio and Android SDK installed. Build the `devFullRelease`
Ensure you have Android Studio and Android SDK installed. Build the `ooniDevFullRelease`
variant using Android Studio or this command line:

```
./gradlew assembleDevFullRelease
```sh
./gradlew assembleOoniDevFullRelease
```

## Building the app for f-droid

Instead to build the app to stay compliant to F-Droid use `fdroid`, which
contains small tweaks required to have the app accepted by [f-droid](https://f-droid.org/).
Instead to build the app to stay compliant to F-Droid use `fdroid`, which contains small tweaks required to have the app accepted by [f-droid](https://f-droid.org/).

```
./gradlew assembleFdroid
```sh
./gradlew assembleOoniDevFullRelease
```

## Testing

Run unit tests
Run unit tests/

```
./gradlew testStableFullDebug
```sh
./gradlew testOoniStableFullDebug
```

Run instrumented tests

_Note: To also run the automation tests (to generate screenshots), set the Build Config flag
`RUN_AUTOMATION` as true._
_Note: To also run the automation tests (to generate screenshots), set the Build Config flag `RUN_AUTOMATION` as true._

```
./gradlew connectedStableFullDebugAndroidTest
```sh
./gradlew connectedOoniStableFullDebugAndroidTest
```

Generate code coverage report (after all unit and instrumented tests successfully passed)

```
```sh
./gradlew jacocoAndroidTestReport
```
```

## Managing translations

Expand Down
28 changes: 25 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ android {
buildConfigField 'String', 'SOFTWARE_NAME', 'BASE_SOFTWARE_NAME+IS_DEBUG'
buildConfigField 'String', 'COUNTLY_KEY', '"146836f41172f9e3287cab6f2cc347de3f5ddf3b"'
buildConfigField "boolean", "RUN_AUTOMATION", "false"
buildConfigField "boolean", "SHOW_DISABLED_CARDS", "true"
}

buildTypes {
Expand All @@ -47,8 +48,21 @@ android {
}
}

flavorDimensions 'testing', 'license'
flavorDimensions = ['brand', 'testing', 'license']

productFlavors {
ooni {
getIsDefault().set(true)
dimension 'brand'
}
dw {
dimension 'brand'
applicationId 'com.dw.ooniprobe'
resValue "string", "APP_ID", 'com.dw.ooniprobe'
resValue "string", "APP_NAME", "News Media Scan"
buildConfigField 'String', 'BASE_SOFTWARE_NAME', '"news-media-scan-android"'
buildConfigField "boolean", "SHOW_DISABLED_CARDS", "false"
}
stable {
dimension 'testing'
buildConfigField 'String', 'BASE_SOFTWARE_NAME', '"ooniprobe-android"'
Expand All @@ -61,7 +75,6 @@ android {
versionNameSuffix resolveVersionSuffix('beta')
versionCode resolveVersionCode()
buildConfigField 'String', 'BASE_SOFTWARE_NAME', '"ooniprobe-android-dev"'
resValue "string", "APP_ID", 'org.openobservatory.ooniprobe.dev'
resValue "string", "APP_NAME", "OONI Dev"
buildConfigField 'String', 'OONI_API_BASE_URL', '"https://api.dev.ooni.io"'
buildConfigField 'String', 'COUNTLY_KEY', '"e6c2cfe53e85951d50567467cef3f9fa2eab32c3"'
Expand All @@ -72,7 +85,6 @@ android {
versionNameSuffix resolveVersionSuffix('experimental')
versionCode resolveVersionCode()
buildConfigField 'String', 'BASE_SOFTWARE_NAME', '"ooniprobe-android-experimental"'
resValue "string", "APP_ID", 'org.openobservatory.ooniprobe.experimental'
resValue "string", "APP_NAME", "OONI Exp"
buildConfigField 'String', 'OONI_API_BASE_URL', '"https://api.dev.ooni.io"'
buildConfigField 'String', 'COUNTLY_KEY', '"e6c2cfe53e85951d50567467cef3f9fa2eab32c3"'
Expand All @@ -84,6 +96,16 @@ android {
dimension 'license'
}
}

bundle {
language {
enableSplit = false
}
}

applicationVariants.all { variant ->
variant.resValue "string", "APP_ID", "\"${applicationId}\""
}
variantFilter { variant ->
def names = variant.flavors*.name
if (names.contains("fdroid") && (names.contains("experimental") || names.contains("dev"))) {
Expand Down
54 changes: 54 additions & 0 deletions app/src/dw/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application>
<activity
android:name=".activity.InfoActivity"
android:exported="false"
android:label="@string/Settings_About_Label"
android:parentActivityName=".activity.PreferenceActivity"
android:screenOrientation="userPortrait"
android:theme="@style/Theme.MaterialComponents.Light.DarkActionBar.App.NoActionBar">
<intent-filter>
<action android:name=".activity.InfoActivity" />

<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".activity.ProxyActivity"
android:exported="false"
android:label="Proxy"
android:parentActivityName=".activity.PreferenceActivity"
android:screenOrientation="userPortrait"
android:theme="@style/Theme.MaterialComponents.Light.DarkActionBar.App">
<intent-filter>
<action android:name=".activity.ProxyActivity" />

<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".activity.CustomWebsiteActivity"
android:exported="false"
android:label="@string/Settings_Websites_CustomURL_Title"
android:parentActivityName=".activity.PreferenceActivity"
android:screenOrientation="userPortrait">
<intent-filter>
<action android:name=".activity.CustomWebsiteActivity" />

<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".activity.LogActivity"
android:exported="false"
android:label="LogActivity"
android:parentActivityName=".activity.PreferenceActivity">
<intent-filter>
<action android:name=".activity.LogActivity" />

<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
4 changes: 4 additions & 0 deletions app/src/dw/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Changes required.

- [] Translation updates
- [] Onboarding override
1 change: 1 addition & 0 deletions app/src/dw/assets/anim/websites.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions app/src/dw/dev/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# News Media Scan Dev
This is a collection of resources to be used by the News Media Scan specific flavors of the application.
A corresponding directory exits in [app/src/ooni](../../ooni).
Loading

0 comments on commit 7f4e51e

Please sign in to comment.