Skip to content

Commit

Permalink
Merge branch 'main' into jigar/audit-suggestion-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jigar-f committed Jun 3, 2024
2 parents c2cbfc5 + ca0c869 commit 4adb2b4
Show file tree
Hide file tree
Showing 173 changed files with 3,359 additions and 21,952 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-darwin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ jobs:
- uses: subosito/flutter-action@v2
with:
channel: "stable"
flutter-version-file: pubspec.yaml

- run: flutter --version

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ jobs:
- uses: subosito/flutter-action@v2
with:
channel: "stable"
flutter-version-file: pubspec.yaml

- run: flutter --version

Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: "3.8"
python-version: "3.12"

- name: Install s3cmd
run: pip install s3cmd
Expand All @@ -129,11 +129,13 @@ jobs:
- uses: actions/checkout@v3
with:
lfs: true

# Using flutter-version-file requires yq, which is not pre-installed in windows images
- run: choco install yq
# Install Flutter
- uses: subosito/flutter-action@v2.12.0
- uses: subosito/flutter-action@v2
with:
channel: "stable"
flutter-version-file: pubspec.yaml

- run: flutter --version

Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Publish releases

on:
push:
branches: [ atavism/pro-client-updates ]
branches: [ main ]
tags:
- '*'

Expand Down Expand Up @@ -119,6 +119,8 @@ jobs:
- uses: subosito/flutter-action@v2
with:
channel: "stable"
flutter-version-file: pubspec.yaml

- run: flutter --version

- name: Setup Go
Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ STAGING = false
UPDATE_SERVER_URL ?=
VERSION ?= 9999.99.99
# Note - we don't bother stripping symbols or DWARF table as Android's packaging seems to take care of that for us
LDFLAGS := -X github.com/getlantern/lantern-client/internalsdk/common.RevisionDate=$(REVISION_DATE) -X github.com/getlantern/lantern-client/internalsdk/common.ApplicationVersion=$(VERSION)
LDFLAGS := -X github.com/getlantern/lantern-client/internalsdk/common.RevisionDate=$(REVISION_DATE) \
-X github.com/getlantern/lantern-client/internalsdk/common.ApplicationVersion=$(VERSION) \
-X github.com/getlantern/lantern-client/internalsdk/common.BuildDate=$(BUILD_DATE)

# Ref https://pkg.go.dev/cmd/link
# -w omits the DWARF table
Expand Down Expand Up @@ -672,7 +674,7 @@ build-framework: assert-go-version install-gomobile
-tags='headless lantern ios netgo' \
-ldflags="$(LDFLAGS)" \
$(GOMOBILE_EXTRA_BUILD_FLAGS) \
github.com/getlantern/lantern-client/internalsdk github.com/getlantern/pathdb/testsupport github.com/getlantern/pathdb/minisql github.com/getlantern/flashlight/v7/ios
github.com/getlantern/lantern-client/internalsdk github.com/getlantern/pathdb/testsupport github.com/getlantern/pathdb/minisql github.com/getlantern/lantern-client/internalsdk/ios
@echo "moving framework"
mkdir -p $(INTERNALSDK_FRAMEWORK_DIR)
mv ./$(INTERNALSDK_FRAMEWORK_NAME) $(INTERNALSDK_FRAMEWORK_DIR)/$(INTERNALSDK_FRAMEWORK_NAME)
Expand Down
115 changes: 68 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,33 @@ Note - you might see an error like `Can't load Kernel binary: Invalid SDK hash.`

### Dependencies

All those dependencies must be in your PATH
All these dependencies must be in your PATH. Some of this is Android specific, see below for other platforms.

* Java 11 or greater
* [Android Studio](https://developer.android.com/studio)
* [Android Studio](https://developer.android.com/studio?_gl=1*1wowe6v*_up*MQ..&gclid=Cj0KCQjw6auyBhDzARIsALIo6v-bn0juONfkfmQAJtwssRCQWADJMgGfRBisMNTSXHt5CZnyZVSK2Y8aAgCmEALw_wcB&gclsrc=aw.ds) (Android Studio Jellyfish | 2023.3.1 Patch 1)
* [Xcode](https://developer.apple.com/xcode/resources/)
* [Git](https://git-scm.com/downloads)
* [Android NDK](#steps-to-run-the-project)
* NDK should be version 26.x, for example 26.0.10792818.
* [Git LFS](https://git-lfs.github.com)
- more information in [Usage](#usage)
* [Flutter (3.13.5)](https://flutter.dev)
* [Flutter (3.19.6)](https://flutter.dev)
* [sentry-cli](https://docs.sentry.io/product/cli/installation/)
- This is used for uploading native debug symbols to Sentry
* [gomobile](https://github.com/golang/go/wiki/Mobile#tools)
* [json-server](https://github.com/typicode/json-server)
* Only necessary for testing Replica
* CMake 3.22.1
* You can get this from Android SDK Manager

* [CocoaPods](https://cocoapods.org/)
* Possibly this is only needed on Apple platforms.

### 🚀 Setup Project:

* Install all prerequisites
* Run `git submodule update --init --recursive`
* Run `git lfs install && git pull`
* Run `git lfs install && git pull`.
* Put the [app.env](https://my.1password.com/vaults/all/allitems/adqasjh2hspgjgvgfllyekhcrq) file from 1Password in the repo root.
* Go to the **SDK MANAGER**
* Select **Android SDK**
* Check the SDK from android 5.0(LOLLIPOP) up to the Latest Version at the moment.
Expand All @@ -59,13 +61,13 @@ All those dependencies must be in your PATH
* On the NDK(Side by side) check the latest version of 22.x (not anything newer)
* Make sure that you have the latest **Android SDK Command-line Tools**
* Finally select the following:
- Android Emulator
- Android SDK Platform-Tools
- Google play APK Expansion Library
- Google play Instant Development SDK
- Google Play Licensing Library
- Google Play Services
- Intel x86 Emulator Accelerator (HAXM installer)
- Android Emulator
- Android SDK Platform-Tools
- Google play APK Expansion Library
- Google play Instant Development SDK
- Google Play Licensing Library
- Google Play Services
- Intel x86 Emulator Accelerator (HAXM installer)
* Click on Apply and accept the Terms and Conditions.
* If you are opening Xcode first time open Xcode and install necessary components
* Lastly `Flutter Doctor` to confirm that your setup is correct and ready!
Expand All @@ -76,7 +78,6 @@ All those dependencies must be in your PATH
* `flutter pub get`
* `flutter run --flavor prod`


### 🍏 Running the project on iOS

* `make build-framework` (you need to generated Internalsdk.xcframework. containing the Go backend code in order for the project to compile.)
Expand All @@ -85,7 +86,25 @@ All those dependencies must be in your PATH

**Note**: If you're using an M1 or M2 chip, navigate to the ios folder and run `arch -x86_64 pod install`

### 💻 Running the Project on Desktop

**Note**: Make sure to run all the commands from the root of the project.

#### macOS

* `make darwin`
* `make ffigen`
* `flutter run -d macos`

#### Other OS

* Windows run `make windows` Linux run `linux-amd64`
* `make ffigen`
* `flutter pub get`
* `flutter run --flavor prod` or if you are using android studio use desktop configuration

### Running on emulators

You can easily run emulators directly from the command line with the following:

* `flutter devices`
Expand All @@ -98,46 +117,43 @@ We've got you covered! If you prefer using Android Studio, we have already set u
You can build an emulator with `./scripts/run_avd.rb`. Here's an example run: `./scripts/run_avd.rb --level=30 --abi=x86 --use_google_apis --window`.
You'll need Ruby >= 2.3 installed and `colorize` gem (i.e., `gem install colorize`).

#### Flutter Logging
[//]: # (#### Flutter Logging)

The Flutter component uses [logger](https://pub.dev/packages/logger) package for logging.
See `home.dart#build()` to know where it's configured.
[//]: # ()
[//]: # (The Flutter component uses [logger](https://pub.dev/packages/logger) package for logging.)

During development, you'll notice a lot of `GoLog`-tagged code. Feel-free to comment that out during your flutter work.
A sane terminal command (using [pidcat](https://github.com/JakeWharton/pidcat)) is `pidcat org.getlantern.lantern -i GoLog -i System.out -w 3`.
[//]: # (See `home.dart#build()` to know where it's configured.)

### Building the InternalSdk (AKA Lantern Core) as a library
[//]: # ()
[//]: # (During development, you'll notice a lot of `GoLog`-tagged code. Feel-free to comment that out during your flutter work.)

[//]: # (A sane terminal command (using [pidcat](https://github.com/JakeWharton/pidcat)) is `pidcat org.getlantern.lantern -i GoLog -i System.out -w 3`.)

### Building the InternalSdk (AKA Lantern Core) as a library

The core Lantern functionality is written in Go and lives in `./internalsdk`.
It is compiled from Go using [Gomobile](https://github.com/golang/mobile) to an AAR file that
It is compiled from Go using [Gomobile](https://github.com/golang/mobile) to appropriate formats for each platform.

#### Android
For compiled code lives in `./android/app/libs` and is called `liblantern-ARCH.aar`.
* To generate AAR run `make android-lib ANDROID_ARCH=all`

Package the AAR with `make android-lib ANDROID_ARCH=all`
* For compiled code lives in `./android/app/libs` and is called `liblantern-ARCH.aar`.

#### IOS
For compiled code lives in `./ios/internalsdk/` and is called `Internalsdk.xcframework`.
* To generate XCodeFramework run `make build-framework`

For compiled code lives in `./ios/internalsdk/` and is called `Internalsdk.xcframework`.

#### Desktop

The desktop app lives under `desktop` .. To build the Go shared library on macOS:

```
make darwin ffigen
```

Then to run the Flutter app on macOS:
* To build for desktop `make darwin` for macOS, `make windows` for Windows, and `make linux-amd64` for Linux.
* Generate the FFI bindings `make ffigen`

```
flutter run -d macOS
```

#### Testing against Lantern's staging servers
[//]: # (#### Testing against Lantern's staging servers)

Package the AAR with `make android-lib ANDROID_ARCH=all STAGING=true`
[//]: # ()
[//]: # (Package the AAR with `make android-lib ANDROID_ARCH=all STAGING=true`)

### Making Android debug builds (Not yet implemented on IOS)

Expand All @@ -159,16 +175,21 @@ or
make android-release-install
```

### 🚧 Making Staging Builds
[//]: # (### 🚧 Making Staging Builds)

[//]: # ()
[//]: # ()
[//]: # (To build mobile for staging, use the STAGING command line argument:)

To build mobile for staging, use the STAGING command line argument:
[//]: # ()
[//]: # (```)

```
STAGING=true make android-debug android-install
```
[//]: # (STAGING=true make android-debug android-install)

[//]: # (```)

This will build Flashlight with the same [STAGING flag](https://github.com/getlantern/flashlight/v7/blob/9eb8abbe036e86b9e72a1a938f29e59f75391676/common/const.go#L43), which allows your client to use the [staging pro-server](https://github.com/getlantern/pro-server-neu/blob/fa2859edf213998e15cd7c00461e52fd97a9e570/README.md#L125) instance instead of the production one.
[//]: # ()
[//]: # (This will build Flashlight with the same [STAGING flag](https://github.com/getlantern/flashlight/v7/blob/9eb8abbe036e86b9e72a1a938f29e59f75391676/common/const.go#L43), which allows your client to use the [staging pro-server](https://github.com/getlantern/pro-server-neu/blob/fa2859edf213998e15cd7c00461e52fd97a9e570/README.md#L125) instance instead of the production one.)

### 🎉 Making Release Builds

Expand All @@ -178,7 +199,7 @@ Do this to make a release build:
```
VERSION=x.x.x make ios-release
```
**Note**: Replace x.x.x with the version number of your release.
**Note**: Replace x.x.x with the version number of your release.

This will
- Set the version number in the info.plist file and increment the build number 1
Expand Down Expand Up @@ -300,10 +321,10 @@ You can run integration tests from the integration_test directory against a live
5. All tests should start with testing device showing Chats tab.
6. Start by running test `1A`.
7. A handful of tests have specific requirements, marked by a "Test requirements" comment at the start of the test:
1. `6A_scan_QR_code_test` needs another phone to do the QR scanning process with
2. `6B_request_flow_test` requires a message request to have just been received
3. `6C_introductions_test` requires the testing device/emulator to have received an introduction to another contact
4. `17C_verify_contact_test` requires the most recent message to have been shared in conversation with an unverified contact
1. `6A_scan_QR_code_test` needs another phone to do the QR scanning process with
2. `6B_request_flow_test` requires a message request to have just been received
3. `6C_introductions_test` requires the testing device/emulator to have received an introduction to another contact
4. `17C_verify_contact_test` requires the most recent message to have been shared in conversation with an unverified contact
8. We will have some duplicate screenshots in there - run `python3 scripts/screenshot_generation_assets/remove_dups.py [your android-lantern-path]/screenshots/` to deduplicate.
9. To generate stitched landscape images for all screenshots in a given test folder, run `python3 scripts/screenshot_generation_assets/merge_screenshots.py [your android-lantern-path]/screenshots/[a locale e.g. en_US]`

Expand Down Expand Up @@ -400,7 +421,7 @@ appium driver install espresso
```

3. Generate a debug build with `CI=true make android-debug ANDROID_ARCH=all` ... CI needs to be set to true to enable the
Flutter driver extension.
Flutter driver extension.

4. Modify [local_config.json](appium_kotlin/app/src/test/resources/local/local_config.json) to specify the path of a debug build APK on your system, and change `appium:udid` to specify your device ID (you can get this from `adb devices`)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ public String getDescription() {
return description;
}

public void setDescription(String desc) {
description = desc;
}

public String getCostStr() {
return costStr;
}
Expand Down
9 changes: 3 additions & 6 deletions android/app/src/main/kotlin/io/lantern/model/SessionModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import org.getlantern.lantern.plausible.Plausible
import org.getlantern.lantern.util.AutoUpdater
import org.getlantern.lantern.util.PaymentsUtil
import org.getlantern.lantern.util.PermissionUtil
import org.getlantern.lantern.util.PlansUtil
import org.getlantern.lantern.util.castToBoolean
import org.getlantern.lantern.util.restartApp
import org.getlantern.lantern.util.showErrorDialog
Expand Down Expand Up @@ -288,7 +287,7 @@ class SessionModel(
}
}

fun updatePaymentMethods(result: MethodChannel.Result?) {
private fun updatePaymentMethods(result: MethodChannel.Result?) {
val userId = LanternApp.getSession().userId()
//Check if not found then call createUserAndFetchPaymentMethods
if (userId == 0L) {
Expand Down Expand Up @@ -352,10 +351,8 @@ class SessionModel(
paymentMethods: List<PaymentMethods>,

) {
for (planId in proPlans.keys) {
proPlans[planId]?.let { PlansUtil.updatePrice(activity, it) }
}
LanternApp.getSession().setUserPlans(proPlans)

LanternApp.getSession().setUserPlans(activity, proPlans)
LanternApp.getSession().setPaymentMethods(paymentMethods)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ open class LanternApp : Application() {

LanternProxySelector(session)

inAppBilling = InAppBilling(this)

lanternHttpClient = LanternHttpClient()

// When the app starts, reset our "hasSucceedingProxy" flag to clear any old warnings
// about proxies being unavailable.
session.resetHasSucceedingProxy()

inAppBilling = InAppBilling(this)
}

companion object {
Expand Down
Loading

0 comments on commit 4adb2b4

Please sign in to comment.