Skip to content

Commit

Permalink
Merge branch 'main' into atavism/lantern-http-client
Browse files Browse the repository at this point in the history
  • Loading branch information
atavism committed Sep 14, 2023
2 parents 5118e6c + 8f368aa commit 53ba5bf
Show file tree
Hide file tree
Showing 19 changed files with 212 additions and 211 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
android/app/libs/opuslib-release.aar filter=lfs diff=lfs merge=lfs -text
screenshots/ filter=lfs diff=lfs merge=lfs -text
assets/testing/ filter=lfs diff=lfs merge=lfs -text
android/app/libs/liblantern-all.aar filter=lfs diff=lfs merge=lfs -text
8 changes: 5 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ jobs:
java-version: 11

- name: Setup protoc
uses: arduino/setup-protoc@v1.2.0
uses: arduino/setup-protoc@v2
with:
version: '3.x'
repo-token: ${{ secrets.GH_TOKEN }}

- name: Activate protoc-gen-dart plugin
run: |
Expand Down Expand Up @@ -124,7 +124,9 @@ jobs:
env:
DD_APPLICATION_ID: ${{ secrets.DD_APPLICATION_ID }}
DD_CLIENT_TOKEN: ${{ secrets.DD_CLIENT_TOKEN }}
INTERSTITIAL_AD_UNIT_ID: "${{ secrets.INTERSTITIAL_AD_UNIT_ID }}"
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
DATADOG_SITE: datadoghq.eu
INTERSTITIAL_AD_UNIT: "${{ secrets.INTERSTITIAL_AD_UNIT_ID }}"
VERSION: "${{ env.version }}"

- uses: actions/upload-artifact@v3
Expand Down
8 changes: 8 additions & 0 deletions .run/main.dart.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="main.dart" type="FlutterRunConfigurationType" factoryName="Flutter">
<option name="additionalArgs" value="--dart-define=INTERSTITIAL_AD_UNIT_ID=ca-app-pub-2685698271254859/9922829329 --dart-define=DD_APPLICATION_ID=f8eabf3c-5db3-4f7e-8e6a-5a72433b46d2 --dart-define=DD_CLIENT_TOKEN=puba617ab01333a95a25a9d3709f04e1654" />
<option name="buildFlavor" value="prod" />
<option name="filePath" value="$PROJECT_DIR$/lib/main.dart" />
<method v="2" />
</configuration>
</component>
60 changes: 16 additions & 44 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ BINARIES_BRANCH ?= main
BETA_BASE_NAME ?= $(INSTALLER_NAME)-preview
PROD_BASE_NAME ?= $(INSTALLER_NAME)

## secrets Keys
INTERSTITIAL_AD_UNIT=ca-app-pub-2685698271254859/9922829329
## vault secrets
VAULT_DD_SECRETS_PATH ?= secret/apps/datadog/android
VAULT_ADS_SECRETS_PATH ?= secret/googleAds
Expand Down Expand Up @@ -143,6 +145,7 @@ ANDROID_LIB := $(ANDROID_LIB_BASE)-$(ANDROID_ARCH).aar
BASE_MOBILE_DIR ?= .
MOBILE_DIR ?= $(BASE_MOBILE_DIR)/android
GRADLE := $(MOBILE_DIR)/gradlew
LANTERN_CLOUD := $$GOPATH/src/github.com/getlantern/lantern-cloud
MOBILE_LIBS := $(MOBILE_DIR)/app/libs
MOBILE_ARCHS := x86 x86_64 armeabi-v7a arm64-v8a
MOBILE_ANDROID_LIB := $(MOBILE_LIBS)/$(ANDROID_LIB)
Expand All @@ -154,13 +157,13 @@ MOBILE_DEBUG_APK := $(INSTALLER_NAME)-$(ANDROID_ARCH)-debug.apk
MOBILE_BUNDLE := $(INSTALLER_NAME).aab
MOBILE_TEST_APK := $(BASE_MOBILE_DIR)/build/app/outputs/apk/androidTest/autoTest/debug/app-autoTest-debug-androidTest.apk
MOBILE_TESTS_APK := $(BASE_MOBILE_DIR)/build/app/outputs/apk/autoTest/debug/app-autoTest-debug.apk

CI_APK_PATH := $(BASE_MOBILE_DIR)/build/app/outputs/flutter-apk/app-prod-debug.apk
BUILD_TAGS ?=
BUILD_TAGS += ' lantern'

GO_SOURCES := go.mod go.sum $(shell find internalsdk -type f -name "*.go")
MOBILE_SOURCES := $(shell find Makefile android assets go.mod go.sum lib protos* -type f -not -path "*/libs/$(ANDROID_LIB_BASE)*" -not -iname "router.gr.dart")


.PHONY: dumpvars packages vendor android-debug do-android-release android-release do-android-bundle android-bundle android-debug-install android-release-install android-test android-cloud-test package-android

# dumpvars prints out all variables defined in the Makefile, useful for debugging environment
Expand Down Expand Up @@ -280,33 +283,15 @@ $(MOBILE_ANDROID_LIB): $(ANDROID_LIB)
.PHONY: android-lib
android-lib: $(MOBILE_ANDROID_LIB)


$(MOBILE_TEST_APK) $(MOBILE_TESTS_APK): $(MOBILE_SOURCES) $(MOBILE_ANDROID_LIB)
@$(GRADLE) -PandroidArch=$(ANDROID_ARCH) \
-PandroidArchJava="$(ANDROID_ARCH_JAVA)" \
-b $(MOBILE_DIR)/app/build.gradle \
:app:assembleAutoTestDebug :app:assembleAutoTestDebugAndroidTest

vault-secret-%:
@SECRET=$(shell cd $$GOPATH/src/github.com/getlantern/lantern-cloud && bin/vault kv get -field=${*} ${VAULT_DD_SECRETS_PATH}); \
printf "$$SECRET"

vault-secret-base64:
@SECRET=$(shell cd $$GOPATH/src/github.com/getlantern/lantern-cloud && bin/vault kv get -field=$(VAULT_FIELD) $(VAULT_PATH)); \
echo "Retrieved secret: $$SECRET" 1>&2; \
printf "$$VAULT_FIELD=$$SECRET" | ${BASE64}

dart-defines-debug:
@DART_DEFINES=$(shell make vault-secret-base64 VAULT_FIELD=INTERSTITIAL_AD_UNIT_ID VAULT_PATH=secret/googleAds); \
DART_DEFINES+=$(shell printf ',' && make vault-secret-base64 VAULT_FIELD=DD_APPLICATION_ID VAULT_PATH=secret/apps/datadog/android); \
DART_DEFINES+=$(shell printf ',' && make vault-secret-base64 VAULT_FIELD=DD_CLIENT_TOKEN VAULT_PATH=secret/apps/datadog/android); \
DART_DEFINES+=",$(CIBASE)"; \
echo "$$DART_DEFINES"

do-android-debug: $(MOBILE_SOURCES) $(MOBILE_ANDROID_LIB)
@ln -fs $(MOBILE_DIR)/gradle.properties . && \
DART_DEFINES=`make dart-defines-debug` && \
CI="$$CI" && $(GRADLE) -Pdart-defines="$$DART_DEFINES" -PlanternVersion=$(DEBUG_VERSION) -PddClientToken=$$DD_CLIENT_TOKEN -PddApplicationID=$$DD_APPLICATION_ID \
ln -fs $(MOBILE_DIR)/gradle.properties . && \
CI="$$CI" && $(GRADLE) -PlanternVersion=$(DEBUG_VERSION) -PddClientToken=$$DD_CLIENT_TOKEN -PddApplicationID=$$DD_APPLICATION_ID \
-PproServerUrl=$(PRO_SERVER_URL) -PpaymentProvider=$(PAYMENT_PROVIDER) -Pcountry=$(COUNTRY) \
-PplayVersion=$(FORCE_PLAY_VERSION) -PuseStaging=$(STAGING) -PstickyConfig=$(STICKY_CONFIG) \
-PlanternRevisionDate=$(REVISION_DATE) -PandroidArch=$(ANDROID_ARCH) \
Expand All @@ -321,55 +306,39 @@ $(MOBILE_DEBUG_APK): $(MOBILE_SOURCES) $(GO_SOURCES)
make do-android-debug && \
cp $(MOBILE_ANDROID_DEBUG) $(MOBILE_DEBUG_APK)

env-secret-%:
@SECRET=$(shell echo "$(${*})"); \
printf ${*}=$$SECRET | ${BASE64}

dart-defines-release:
@DART_DEFINES=`make env-secret-INTERSTITIAL_AD_UNIT_ID`; \
DART_DEFINES+=`printf ',' && $(CIBASE)`; \
printf $$DART_DEFINES

$(MOBILE_RELEASE_APK): $(MOBILE_SOURCES) $(GO_SOURCES) $(MOBILE_ANDROID_LIB) require-datadog-ci
echo $(MOBILE_ANDROID_LIB) && \
mkdir -p ~/.gradle && \
ln -fs $(MOBILE_DIR)/gradle.properties . && \
DD_CLIENT_TOKEN="$$DD_CLIENT_TOKEN" && \
DD_APPLICATION_ID="$$DD_APPLICATION_ID" && \
COUNTRY="$$COUNTRY" && \
STAGING="$$STAGING" && \
STICKY_CONFIG="$$STICKY_CONFIG" && \
PAYMENT_PROVIDER="$$PAYMENT_PROVIDER" && \
VERSION_CODE="$$VERSION_CODE" && \
DEVELOPMENT_MODE="$$DEVELOPMENT_MODE" && \
DART_DEFINES=`make dart-defines-release` && \
$(GRADLE) -PlanternVersion=$$VERSION -Pdart-defines="$$DART_DEFINES" -PlanternRevisionDate=$(REVISION_DATE) -PddClientToken="$(DD_CLIENT_TOKEN)" \
-PddApplicationID="$(DD_APPLICATION_ID)" -PandroidArch=$(ANDROID_ARCH) -PandroidArchJava="$(ANDROID_ARCH_JAVA)" -PproServerUrl=$(PRO_SERVER_URL) \
-PpaymentProvider=$(PAYMENT_PROVIDER) -Pcountry=$(COUNTRY) -PplayVersion=$(FORCE_PLAY_VERSION) -PuseStaging=$(STAGING) -PstickyConfig=$(STICKY_CONFIG) \
$(GRADLE) -PlanternVersion=$$VERSION -PlanternRevisionDate=$(REVISION_DATE) -PandroidArch=$(ANDROID_ARCH) \
-PandroidArchJava="$(ANDROID_ARCH_JAVA)" -PproServerUrl=$(PRO_SERVER_URL) -PpaymentProvider=$(PAYMENT_PROVIDER) \
-Pcountry=$(COUNTRY) -PplayVersion=$(FORCE_PLAY_VERSION) -PuseStaging=$(STAGING) -PstickyConfig=$(STICKY_CONFIG) \
-PversionCode=$(VERSION_CODE) -PdevelopmentMode=$(DEVELOPMENT_MODE) -b $(MOBILE_DIR)/app/build.gradle assembleProdSideload && \
datadog-ci flutter-symbols upload --service-name lantern-android --dart-symbols-location build/app/intermediates/merged_native_libs/prodSideload/out/lib \
DATADOG_API_KEY=4901456bb88bbf1dc7799eab7d4f71ae DATADOG_SITE=datadoghq.eu datadog-ci flutter-symbols upload --service-name lantern-android --dart-symbols-location build/app/intermediates/merged_native_libs/prodSideload/out/lib \
--android-mapping-location build/app/outputs/mapping/prodSideload/mapping.txt --android-mapping --ios-dsyms && \
cp $(MOBILE_ANDROID_RELEASE) $(MOBILE_RELEASE_APK) && \
cat $(MOBILE_RELEASE_APK) | bzip2 > lantern_update_android_arm.bz2


$(MOBILE_BUNDLE): $(MOBILE_SOURCES) $(GO_SOURCES) $(MOBILE_ANDROID_LIB) require-datadog-ci
@mkdir -p ~/.gradle && \
ln -fs $(MOBILE_DIR)/gradle.properties . && \
DD_CLIENT_TOKEN="$$DD_CLIENT_TOKEN" && \
DD_APPLICATION_ID="$$DD_APPLICATION_ID" && \
COUNTRY="$$COUNTRY" && \
STAGING="$$STAGING" && \
STICKY_CONFIG="$$STICKY_CONFIG" && \
PAYMENT_PROVIDER="$$PAYMENT_PROVIDER" && \
$(GRADLE) -PlanternVersion=$$VERSION -PlanternRevisionDate=$(REVISION_DATE) -PandroidArch=$(ANDROID_ARCH) -PandroidArchJava="$(ANDROID_ARCH_JAVA)" \
-PddClientToken=$(DD_CLIENT_TOKEN) -PddApplicationID=$(DD_APPLICATION_ID) -PproServerUrl=$(PRO_SERVER_URL) -PpaymentProvider=$(PAYMENT_PROVIDER) \
-Pcountry=$(COUNTRY) -PplayVersion=true -PuseStaging=$(STAGING) -PstickyConfig=$(STICKY_CONFIG) -b $(MOBILE_DIR)/app/build.gradle bundlePlay && \
datadog-ci flutter-symbols upload --service-name lantern-android --dart-symbols-location build/app/intermediates/merged_native_libs/prodPlay/out/lib \
--android-mapping-location build/app/outputs/mapping/prodPlay/mapping.txt --ios-dsyms && \
cp $(MOBILE_ANDROID_BUNDLE) $(MOBILE_BUNDLE)

android-debug:
DD_APPLICATION_ID=`make vault-secret-DD_APPLICATION_ID` DD_CLIENT_TOKEN=`make vault-secret-DD_CLIENT_TOKEN` make $(MOBILE_DEBUG_APK)
android-debug: $(MOBILE_DEBUG_APK)

android-release: pubget $(MOBILE_RELEASE_APK)

Expand All @@ -378,6 +347,9 @@ android-bundle: $(MOBILE_BUNDLE)
android-debug-install: $(MOBILE_DEBUG_APK)
$(ADB) uninstall $(MOBILE_APPID) ; $(ADB) install -r $(MOBILE_DEBUG_APK)

#android-debug-install: $(MOBILE_DEBUG_APK)
# $(ADB) uninstall $(MOBILE_APPID) ; $(ADB) install -r $(MOBILE_DEBUG_APK)

android-release-install: $(MOBILE_RELEASE_APK)
$(ADB) install -r $(MOBILE_RELEASE_APK)

Expand Down
4 changes: 0 additions & 4 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,6 @@ android {
buildConfigField "boolean", "STICKY_CONFIG", getBoolean("stickyConfig")
buildConfigField "boolean", "STAGING", getBoolean("useStaging")
buildConfigField "boolean", "PLAY_VERSION", getBoolean("playVersion")
buildConfigField "String", "DD_CLIENT_TOKEN", ddClientToken()
buildConfigField "String", "DD_APPLICATION_ID", ddApplicationID()
buildConfigField "String", "COUNTRY", userCountry()
buildConfigField "String", "SIGNING_CERTIFICATE_SHA256", "\"\""
buildConfigField "String", "PAYMENT_PROVIDER", paymentProvider()
Expand All @@ -220,8 +218,6 @@ android {
buildConfigField "boolean", "STICKY_CONFIG", getBoolean("stickyConfig")
buildConfigField "boolean", "STAGING", getBoolean("useStaging")
buildConfigField "boolean", "PLAY_VERSION", getBoolean("playVersion")
buildConfigField "String", "DD_CLIENT_TOKEN", ddClientToken()
buildConfigField "String", "DD_APPLICATION_ID", ddApplicationID()
buildConfigField "String", "COUNTRY", userCountry()
buildConfigField "String", "SIGNING_CERTIFICATE_SHA256", "\"108f612ae55354078ec12b10bb705362840d48fa78b9262c11b6d0adeff6f289\""
buildConfigField "String", "PAYMENT_PROVIDER", paymentProvider()
Expand Down
3 changes: 3 additions & 0 deletions android/app/libs/liblantern-all.aar
Git LFS file not shown
12 changes: 11 additions & 1 deletion android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,14 @@

##---------------Begin: proguard configuration for Signal ----------
-keep class org.whispersystems.** { *; }
##---------------End: proguard configuration for Signal ----------
##---------------End: proguard configuration for Signal ----------

-keep class com.google.ads.** # Don't proguard AdMob classes
-dontwarn com.google.ads.
-keep public class com.google.android.gms.ads.** {
public *;
}
-keep public class com.google.ads.** {
public *;
}
-keep public class com.google.android.gms.** { public protected *; }
65 changes: 50 additions & 15 deletions android/app/src/main/kotlin/io/lantern/model/SessionModel.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package io.lantern.model

import android.app.Activity
import android.content.Intent
import android.os.AsyncTask
import android.os.Build
import android.content.Intent
import androidx.core.content.ContextCompat
import com.google.gson.JsonObject
import com.google.protobuf.ByteString
Expand All @@ -23,7 +23,6 @@ import org.getlantern.lantern.MainActivity
import org.getlantern.lantern.R
import org.getlantern.lantern.activity.FreeKassaActivity_
import org.getlantern.lantern.activity.WebViewActivity_
import org.getlantern.mobilesdk.model.IssueReporter
import org.getlantern.lantern.datadog.Datadog
import org.getlantern.lantern.model.LanternHttpClient
import org.getlantern.lantern.model.LanternHttpClient.ProCallback
Expand All @@ -40,6 +39,7 @@ import org.getlantern.lantern.util.restartApp
import org.getlantern.lantern.util.showAlertDialog
import org.getlantern.lantern.util.showErrorDialog
import org.getlantern.mobilesdk.Logger
import org.getlantern.mobilesdk.model.IssueReporter
import org.getlantern.mobilesdk.model.SessionManager

/**
Expand All @@ -66,7 +66,11 @@ class SessionModel(
const val PATH_USER_LEVEL = "userLevel"

const val PATH_SPLIT_TUNNELING = "/splitTunneling"
const val SHOULD_SHOW_CAS_ADS = "shouldShowCASAds"
const val SHOULD_SHOW_GOOGLE_ADS = "shouldShowGoogleAds"
const val PATH_APPS_DATA = "/appsData/"


}

init {
Expand All @@ -89,28 +93,47 @@ class SessionModel(
tx.put(PATH_SDK_VERSION, Internalsdk.sdkVersion())
}
updateAppsData()
checkAdsAvailability()
}

fun checkAdsAvailability() {
//This check is just safe guard
//So if something goes wrong in backend we should not show ads to pro users at any case
if(LanternApp.getSession().isProUser){
db.mutate { tx ->
tx.put(SHOULD_SHOW_GOOGLE_ADS, false)
tx.put(SHOULD_SHOW_CAS_ADS, false)
}
return
}
Logger.debug(TAG, "checkAdsAvailability called")
val googleAds = shouldShowAdsBasedRegion { LanternApp.getSession().shouldShowAdsEnabled() }
Logger.debug(TAG, "checkAdsAvailability with googleAds values $googleAds enable ${LanternApp.getSession().shouldShowAdsEnabled()}")
val casAds = shouldShowAdsBasedRegion { LanternApp.getSession().shouldCASShowAdsEnabled() }
Logger.debug(TAG, "checkAdsAvailability with cas values $googleAds enable ${LanternApp.getSession().shouldCASShowAdsEnabled()}")
db.mutate { tx ->
tx.put(SHOULD_SHOW_GOOGLE_ADS, googleAds)
tx.put(SHOULD_SHOW_CAS_ADS, casAds)
}
}


override fun doOnMethodCall(call: MethodCall, result: MethodChannel.Result) {
when (call.method) {
"authorizeViaEmail" -> authorizeViaEmail(call.argument("emailAddress")!!, result)
"shouldShowAds" -> {
result.success(shouldShowAdsBasedRegion {
LanternApp.getSession().shouldShowAdsEnabled()
})
}
"shouldCASShowAds" -> {
result.success(shouldShowAdsBasedRegion {
LanternApp.getSession().shouldCASShowAdsEnabled()
})
}
"checkEmailExists" -> checkEmailExists(call.argument("emailAddress")!!, result)
"requestLinkCode" -> requestLinkCode(result)
"resendRecoveryCode" -> sendRecoveryCode(result)
"validateRecoveryCode" -> validateRecoveryCode(call.argument("code")!!, result)
"approveDevice" -> approveDevice(call.argument("code")!!, result)
"removeDevice" -> removeDevice(call.argument("deviceId")!!, result)
"reportIssue" -> reportIssue(call.argument("email")!!, call.argument("issue")!!, call.argument("description")!!, result)
"reportIssue" -> reportIssue(
call.argument("email")!!,
call.argument("issue")!!,
call.argument("description")!!,
result
)

"applyRefCode" -> paymentsUtil.applyRefCode(call.argument("refCode")!!, result)
"redeemResellerCode" -> paymentsUtil.redeemResellerCode(
call.argument("email")!!,
Expand Down Expand Up @@ -158,12 +181,15 @@ class SessionModel(
activity.startActivity(intent)
}
}

"trackUserAction" -> {
Datadog.trackUserClick(call.argument("message")!!)
}

"acceptTerms" -> {
LanternApp.getSession().acceptTerms()
}

"setLanguage" -> {
LanternApp.getSession().setLanguage(call.argument("lang"))
}
Expand Down Expand Up @@ -571,9 +597,18 @@ class SessionModel(
)
}

private fun reportIssue(email: String, issue: String, description: String, methodCallResult: MethodChannel.Result) {
private fun reportIssue(
email: String,
issue: String,
description: String,
methodCallResult: MethodChannel.Result
) {
if (!Utils.isNetworkAvailable(activity)) {
methodCallResult.error("errorReportingIssue", activity.getString(R.string.no_internet_connection), null)
methodCallResult.error(
"errorReportingIssue",
activity.getString(R.string.no_internet_connection),
null
)
return
}
Logger.debug(TAG, "Reporting $issue issue on behalf of $email")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ open class LanternApp : Application() {
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
appContext = applicationContext
session = LanternSessionManager(this)
Datadog.initialize()
if (!BuildConfig.DEBUG) Datadog.initialize()

LanternProxySelector(session)

if (session.isPlayVersion) inAppBilling = InAppBilling(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ class MainActivity :
//If user come here it mean user has all permissions needed
// Also user given permission for VPN service dialog as well
LanternApp.getSession().setHasFirstSessionCompleted(true)
sessionModel.checkAdsAvailability()
updateStatus(true)
startVpnService()
}
Expand Down Expand Up @@ -606,6 +607,7 @@ class MainActivity :
// this mean user has already given
// system permissions
LanternApp.getSession().setHasFirstSessionCompleted(true)
sessionModel.checkAdsAvailability()
}

}
Expand Down
Loading

0 comments on commit 53ba5bf

Please sign in to comment.