Files
firezone/kotlin/android
Jason Elie Bou Kheir c94b2de02a feat(android): use device serial for deviceName (#4180)
Fixes #4042 

The serial number of the device is blocked behind a permission. There's
a couple ways we can go about this:

-----

### (1) Ask the user to (optionally) grant the permission

When we show the grant VPN permission activity, we also mention the
optional READ_PRIVILEGED_PHONE_STATE permission. Here, the user can
decide to grant it or not, and if they decide not to, they can grant it
in the future in the app settings. When the permission is not granted,
the `deviceName` falls back to the `Build.MODEL`

### (2) Force the user to grant the permission

We keep asking them to grant the permission in the splash view.
`deviceName` is always the serial number of the device.

### (3) Let MDM grant the permission

We don't provide a UI to grant the permission in the application.
Instead, the `deviceName` is the `Build.MODEL` by default, unless
advanced users or admins using MDM set the permission, in which case
it's the serial number of the device.

### (4) Let MDM set a custom/override device name

This could be an alternative to (3) if it is easier for customers using
MDM software to manage it this way. Though I doubt it...

-----

Going with option (3) is safe, and the other options can be added
incrementally in the future. However, it requires communicating to the
customer that they should set this permission for the `deviceName` to be
the serial of the device. That's not a problem yet, since the relevant
customer is using MDM to manage the app; it's trivial to set this
permission via that UI.

If we did want to show this permission to the user, I think option (1)
is most likely going to be better than option (2) in most cases.

---------

Signed-off-by: Jamil <jamilbk@users.noreply.github.com>
Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
2024-03-21 12:39:23 +00:00
..
2024-03-08 01:55:27 +00:00
2024-02-20 15:01:17 -06:00

Firezone Android client

This README contains instructions for building and testing the Android client locally.

Dev Setup

  1. Install Rust

  2. Install Android Studio

  3. Install your JDK 17 of choice. We recommend just updating your CLI environment to use the JDK bundled in Android Studio to ensure you're using the same JDK on the CLI as Android Studio.

  4. Install the Android SDK through Android Studio.

    • Open Android studio, go to Android Studio > Preferences
    • Search for sdk
    • Find the Android SDK nav item under System Settings and select
    • Click the Edit button next to the Android SDK Location field
    • Follow the steps presented to install Android SDK
  5. Install NDK using Android Studio

    To see which version is installed, make sure to select the Show Package Details checkbox in the Android SDK settings page in Android Studio

    Android SDK Tools

    Make sure the correct NDK version is installed by looking at: ../../rust/connlib/clients/android/connlib/build.gradle.kts

  6. Set the following ENV variables in the start up config for your shell:

    JAVA_HOME=/Applications/Android\ Studio.app/Contents/jbr/Contents/Home
    ANDROID_HOME=/Users/<username>/Library/Android/sdk
    NDK_HOME=$ANDROID_HOME/ndk-bundle
    PATH=$PATH:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin
    
  7. Make sure the following Rust targets are installed into the correct toolchain.

    aarch64-linux-android
    arm-linux-androideabi
    armv7-linux-androideabi
    i686-linux-android
    x86_64-linux-android
    

    Ensure you've activated the correct toolchain version for your local environment with rustup default <toolchain> (find this from the root /rust/rust-toolchain.toml file), then run:

    rustup target add aarch64-linux-android arm-linux-androideabi armv7-linux-androideabi i686-linux-android x86_64-linux-android
    
  8. Perform a test build: ./gradlew assembleDebug.

Release Setup

We release from GitHub CI, so this shouldn't be necessary. But if you're looking to test the release variant locally:

  1. Download the keystore from 1Pass and save to app/.signing/keystore.jks dir.
  2. Download firebase credentials from 1Pass and save to app/.signing/firebase.json
  3. Now you can execute the *Release tasks with:
export KEYSTORE_PATH="$(pwd)/app/.signing/keystore.jks"
export FIREBASE_CREDENTIALS_PATH="$(pwd)/app/.signing/firebase.json"
HISTCONTROL=ignorespace # prevents saving the next line in shell history
 KEYSTORE_PASSWORD='keystore_password' KEYSTORE_KEY_PASSWORD='keystore_key_password' ./gradlew assembleRelease