diff --git a/.github/workflows/browerstack.yml b/.github/workflows/browerstack.yml index 7de76e9fb..2da8b7f40 100644 --- a/.github/workflows/browerstack.yml +++ b/.github/workflows/browerstack.yml @@ -10,8 +10,8 @@ env: jobs: build: - runs-on: - group: large-runners + runs-on: macos-13 +# group: large-runners steps: - uses: actions/checkout@v4 with: @@ -36,40 +36,12 @@ jobs: run: | git config --global url."https://${{ secrets.CI_PRIVATE_REPOS_GH_TOKEN }}:x-oauth-basic@github.com/".insteadOf "https://github.com/" - - name: Setup Sentry CLI - uses: mathieu-bour/setup-sentry-cli@v1 - with: - version: latest - token: ${{ SECRETS.SENTRY_TOKEN }} # from GitHub secrets - organization: getlantern - project: android - - name: Setup JDK 17 uses: actions/setup-java@v3 with: distribution: temurin java-version: 17 - - name: Setup protoc - uses: arduino/setup-protoc@v2 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - - - name: Clear Go Modules cache - run: go clean -modcache - - - name: Install protoc-gen-go - run: | - go get google.golang.org/protobuf/cmd/protoc-gen-go - echo "$(go env GOPATH)/bin" >> $GITHUB_PATH - - - name: Activate protoc-gen-dart plugin - run: | - echo "${HOME}/.pub-cache/bin" >> $GITHUB_PATH - dart pub global activate protoc_plugin - mkdir -p "${HOME}/.pub-cache/bin" - mv "${FLUTTER_ROOT}/.pub-cache/bin/protoc-gen-dart" "${HOME}/.pub-cache/bin" - - name: Build Android-Lib run: make android-lib ANDROID_ARCH=all diff --git a/Makefile b/Makefile index 32b27eed0..b60c35192 100644 --- a/Makefile +++ b/Makefile @@ -21,8 +21,15 @@ lib/messaging/protos_flutteronly/messaging.pb.dart: protos_flutteronly/messaging lib/vpn/protos_shared/vpn.pb.dart: protos_shared/vpn.proto @protoc --dart_out=./lib/vpn --plugin=protoc-gen-dart=$$HOME/.pub-cache/bin/protoc-gen-dart protos_shared/vpn.proto -internalsdk/protos/vpn.pb.go: protos_shared/vpn.proto - @protoc --go_out=internalsdk protos_shared/vpn.proto +internalsdk/protos/%.pb.go: protos_shared/%.proto + @echo "Generating Go protobuf for $<" + @protoc --plugin=protoc-gen-go=build/protoc-gen-go \ + --go_out=internalsdk \ + $< + + +#internalsdk/protos/vpn.pb.go: protos_shared/vpn.proto +# @protoc --go_out=internalsdk protos_shared/vpn.proto # Compiles autorouter routes routes: lib/core/router/router.gr.dart @@ -269,7 +276,7 @@ release-autoupdate: require-version release: require-version require-s3cmd require-wget require-lantern-binaries require-release-track release-prod copy-beta-installers-to-mirrors invalidate-getlantern-dot-org upload-aab-to-play -$(ANDROID_LIB): $(GO_SOURCES) +$(ANDROID_LIB): $(call check-go-version) && \ go env -w 'GOPRIVATE=github.com/getlantern/*' && \ go install golang.org/x/mobile/cmd/gomobile && \ diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift index 39ca7153d..a05c21497 100644 --- a/ios/Runner/AppDelegate.swift +++ b/ios/Runner/AppDelegate.swift @@ -15,7 +15,7 @@ import UIKit // Model Properties var sessionModel: SessionModel! var lanternModel: LanternModel! - var navigationModel: NavigationModel! + // var navigationModel: NavigationModel! var vpnModel: VpnModel! var messagingModel: MessagingModel! // IOS @@ -45,9 +45,20 @@ import UIKit // Intlize this GO model and callback private func setupAppComponents() throws { - try setupModels() - startUpSequency() - setupLoadingBar() + DispatchQueue.global(qos: .userInitiated).async { + do { + try self.setupModels() + DispatchQueue.main.async { + self.startUpSequency() + self.setupLoadingBar() + } + } catch { + DispatchQueue.main.async { + logger.error("Unexpected error setting up models: \(error)") + } + } + } + } // Init all the models @@ -56,7 +67,7 @@ import UIKit sessionModel = try SessionModel(flutterBinary: flutterbinaryMessenger) lanternModel = LanternModel(flutterBinary: flutterbinaryMessenger) vpnModel = try VpnModel(flutterBinary: flutterbinaryMessenger, vpnBase: VPNManager.appDefault) - navigationModel = NavigationModel(flutterBinary: flutterbinaryMessenger) + // navigationModel = NavigationModel(flutterBinary: flutterbinaryMessenger) messagingModel = try MessagingModel(flutterBinary: flutterbinaryMessenger) } diff --git a/ios/Runner/Lantern/Models/BaseModel.swift b/ios/Runner/Lantern/Models/BaseModel.swift index 71f00ef75..b9d733160 100644 --- a/ios/Runner/Lantern/Models/BaseModel.swift +++ b/ios/Runner/Lantern/Models/BaseModel.swift @@ -27,7 +27,10 @@ open class BaseModel: NSObject, FlutterStreamHandle self.model = model self.binaryMessenger = flutterBinary super.init() - setupFlutterChannels() + DispatchQueue.main.async { + self.setupFlutterChannels() + } + } internal static func getDB() throws -> MinisqlDBProtocol { diff --git a/ios/Runner/Lantern/Models/LanternModel.swift b/ios/Runner/Lantern/Models/LanternModel.swift index 15953d3ae..07fe74f69 100644 --- a/ios/Runner/Lantern/Models/LanternModel.swift +++ b/ios/Runner/Lantern/Models/LanternModel.swift @@ -22,12 +22,15 @@ class LanternModel: NSObject, FlutterStreamHandler { init(flutterBinary: FlutterBinaryMessenger) { self.flutterbinaryMessenger = flutterBinary super.init() - lanternMethodChannel = FlutterMethodChannel( - name: LANTERN_METHOED_CHANNEL, binaryMessenger: flutterBinary) - lanternMethodChannel.setMethodCallHandler(handleMethodCall) - lanternEventChannel = FlutterEventChannel( - name: LANTERN_EVENT_CHANNEL, binaryMessenger: flutterBinary) - lanternEventChannel.setStreamHandler(self) + + DispatchQueue.main.async { + self.lanternMethodChannel = FlutterMethodChannel( + name: self.LANTERN_METHOED_CHANNEL, binaryMessenger: flutterBinary) + self.lanternMethodChannel.setMethodCallHandler(self.handleMethodCall) + self.lanternEventChannel = FlutterEventChannel( + name: self.LANTERN_EVENT_CHANNEL, binaryMessenger: flutterBinary) + self.lanternEventChannel.setStreamHandler(self) + } } diff --git a/ios/Runner/Lantern/Models/NavigationModel.swift b/ios/Runner/Lantern/Models/NavigationModel.swift index 856102bf1..640921a60 100644 --- a/ios/Runner/Lantern/Models/NavigationModel.swift +++ b/ios/Runner/Lantern/Models/NavigationModel.swift @@ -1,42 +1,42 @@ +//// +//// NavigationModel.swift +//// Runner +//// +//// Created by jigar fumakiya on 12/09/23. +//// // -// NavigationModel.swift -// Runner -// -// Created by jigar fumakiya on 12/09/23. -// - -import Flutter -import Foundation - -class NavigationModel { - let navigationMethodChannel = "lantern_method_channel" - - var flutterbinaryMessenger: FlutterBinaryMessenger - - init(flutterBinary: FlutterBinaryMessenger) { - self.flutterbinaryMessenger = flutterBinary - prepareNavigationChannel() - } - - private func prepareNavigationChannel() { - - // Navigation Channel - let navigationChannel = FlutterMethodChannel( - name: navigationMethodChannel, binaryMessenger: flutterbinaryMessenger) - navigationChannel.setMethodCallHandler(handleNavigationethodCall) - } - - func handleNavigationethodCall(_ call: FlutterMethodCall, result: @escaping FlutterResult) { - // Handle your method calls here - // The 'call' contains the method name and arguments - // The 'result' can be used to send back the data to Flutter - switch call.method { - case "yourMethod": - // handle yourMethod - break - default: - result(FlutterMethodNotImplemented) - } - } - -} +//import Flutter +//import Foundation +// +//class NavigationModel { +// let navigationMethodChannel = "lantern_method_channel" +// +// var flutterbinaryMessenger: FlutterBinaryMessenger +// +// init(flutterBinary: FlutterBinaryMessenger) { +// self.flutterbinaryMessenger = flutterBinary +// prepareNavigationChannel() +// } +// +// private func prepareNavigationChannel() { +// +// // Navigation Channel +// let navigationChannel = FlutterMethodChannel( +// name: navigationMethodChannel, binaryMessenger: flutterbinaryMessenger) +// navigationChannel.setMethodCallHandler(handleNavigationethodCall) +// } +// +// func handleNavigationethodCall(_ call: FlutterMethodCall, result: @escaping FlutterResult) { +// // Handle your method calls here +// // The 'call' contains the method name and arguments +// // The 'result' can be used to send back the data to Flutter +// switch call.method { +// case "yourMethod": +// // handle yourMethod +// break +// default: +// result(FlutterMethodNotImplemented) +// } +// } +// +//} diff --git a/ios/Runner/Lantern/Models/SessionModel.swift b/ios/Runner/Lantern/Models/SessionModel.swift index ed7b56d43..a068ddffe 100644 --- a/ios/Runner/Lantern/Models/SessionModel.swift +++ b/ios/Runner/Lantern/Models/SessionModel.swift @@ -42,8 +42,10 @@ class SessionModel: BaseModel { throw error! } try super.init(flutterBinary, model) - startService() -// getBandwidth() + DispatchQueue.global(qos: .userInitiated).async { + self.startService() + } + // getBandwidth() } func startService() { diff --git a/lib/app.dart b/lib/app.dart index de628f448..44a86eef4 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -57,7 +57,8 @@ class LanternApp extends StatelessWidget { void toggleConnectivityWarningIfNecessary() { final shouldShowConnectivityWarning = !sessionModel.networkAvailable.value || - (sessionModel.proxyAvailable.value!=null && sessionModel.proxyAvailable.value==false); + (sessionModel.proxyAvailable.value != null && + sessionModel.proxyAvailable.value == false); if (shouldShowConnectivityWarning != showConnectivityWarning) { showConnectivityWarning = shouldShowConnectivityWarning; if (showConnectivityWarning) { @@ -138,7 +139,13 @@ class LanternApp extends StatelessWidget { return const Locale('en', 'US'); } final codes = lang.split('_'); - return Locale(codes[0], codes[1]); + // Check if the split code has more than one part + if (codes.length > 1) { + return Locale(codes[0], codes[1]); + } else { + // If not, return default locale + return const Locale('en', 'US'); + } } String _getLocaleBasedFont(Locale locale) {