Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add service connection manager #890

Closed
wants to merge 44 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
700308f
fix double close of file descriptor issue detected by fdscan
Jul 24, 2023
1309284
merge latest
Aug 1, 2023
a3b41c4
merge latest
Aug 1, 2023
64bf7fd
merge latest
Aug 1, 2023
15f6b04
initial commit
Aug 1, 2023
1530e75
initial commit
Aug 1, 2023
563939e
Add vpn service connection manager
Aug 1, 2023
4e49e1b
Add SurveyHelper
Aug 1, 2023
9e7e716
move code for processing surveys out of MainActivity
Aug 1, 2023
8b18818
Additional updates to VpnServiceManager, add service connection class
Aug 2, 2023
fc46297
Additional updates to VpnServiceManager, add service connection class
Aug 2, 2023
4cb3ffa
apply formatting changes
Aug 2, 2023
fcdc458
apply formatting changes
Aug 2, 2023
c9ddaad
move notifications to LanternApp, add service notification to helper
Aug 2, 2023
c21a4f1
make sure to disconnect service connection when main activity is dest…
Aug 2, 2023
d41045f
Move code for a service connection state to manager, remove GoTun2Soc…
Aug 3, 2023
868ad66
Remove unused imports
Aug 3, 2023
a99e957
Add survey/loconf helper, move loconf processing out of the MainActivity
Aug 3, 2023
4650c54
remove lines commented out
Aug 3, 2023
3fbe4ce
additional clean-ups
Aug 3, 2023
887cca9
Merge branch 'atavism/vpn-connection-manager' into atavism/loconf-upd…
Aug 3, 2023
1b87dbc
Merge pull request #891 from getlantern/atavism/loconf-updates
atavism Aug 3, 2023
7b4cd03
Merge remote-tracking branch 'origin/main' into atavism/vpn-connectio…
Aug 7, 2023
d8094a0
Updates to LanternService
Aug 7, 2023
ff62b0b
Merge branch 'atavism/vpn-connection-manager' of github.com:getlanter…
Aug 7, 2023
d9b2dc4
update service check in onServiceConnected
Aug 7, 2023
35e44f6
merge latest
Aug 7, 2023
769f922
merge latest
Aug 15, 2023
3cc1dca
merge latest
Aug 17, 2023
d54d711
merge latest
Aug 23, 2023
beefe0b
Merge remote-tracking branch 'origin/main' into atavism/vpn-connectio…
Aug 25, 2023
aa50215
merge latest
Aug 25, 2023
b26c154
merge latest
Aug 30, 2023
cd3bb67
Merge remote-tracking branch 'origin/main' into atavism/vpn-connectio…
Aug 30, 2023
9f8b365
remove vpnStateChanged method
Sep 6, 2023
b09340e
Merge remote-tracking branch 'origin/main' into atavism/vpn-connectio…
Sep 7, 2023
1c6def0
Merge remote-tracking branch 'origin/main' into atavism/vpn-connectio…
Sep 12, 2023
de362e1
merge latest
Sep 12, 2023
5e5b1a7
Merge branch 'main' into atavism/vpn-connection-manager
Sep 14, 2023
e929813
merge latest
atavism Sep 27, 2023
359ffb4
Add missing imports
atavism Sep 27, 2023
c4032b4
Merge remote-tracking branch 'origin/main' into atavism/vpn-connectio…
atavism Oct 3, 2023
9836398
merge latest
atavism Oct 10, 2023
8cda501
merge latest
atavism Oct 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions android/app/libs/liblantern-all.aar
Git LFS file not shown
32 changes: 4 additions & 28 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,12 @@
</activity>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@atavism On this file WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE both are deprecated for SDK version 33, Do you think we should of ahead and change this now?

<service
android:enabled="true"
android:exported="false"
android:stopWithTask="false"
android:name=".service.LanternService_">
android:process=":bg"
android:name=".service.LanternService">
</service>

<receiver android:name = ".model.DeclineCallBroadcastReceiver" />

<receiver android:name="org.getlantern.lantern.notification.NotificationReceiver" android:exported="true">
<intent-filter>
<action android:name="org.getlantern.lantern.intent.VPN_DISCONNECTED"/>
</intent-filter>
</receiver>

<activity
android:name=".activity.FreeKassaActivity_"
android:screenOrientation="portrait">
Expand Down Expand Up @@ -117,29 +109,13 @@

<service android:name="org.getlantern.lantern.vpn.LanternVpnService"
android:exported="false"
android:permission="android.permission.BIND_VPN_SERVICE">
android:permission="android.permission.BIND_VPN_SERVICE"
android:process=":bg">
<intent-filter>
<action android:name="android.net.VpnService"/>
</intent-filter>
</service>

<receiver android:name=".notification.Notifier"
android:exported="false"> <!-- since we do specify an intent filter, this receiver will
be available to other apps by default, which is not what we want. We have to explicitly state that it's private within our app -->
<intent-filter>
<action android:name="${applicationId}.intent.DATA_USAGE" />
</intent-filter>
</receiver>

<!-- <receiver android:enabled="true" android:name=".service.AutoStarter"-->
<!-- android:permission="android.permission.RECEIVE_BOOT_COMPLETED"-->
<!-- android:exported="true">-->
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.BOOT_COMPLETED" />-->
<!-- <category android:name="android.intent.category.DEFAULT" />-->
<!-- </intent-filter>-->
<!-- </receiver>-->

<meta-data android:name="google_analytics_adid_collection_enabled" android:value="false" />
<meta-data android:name="google_analytics_ssaid_collection_enabled" android:value="false" />

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.getlantern.lantern

object Actions {
const val CONNECT_VPN = "org.getlantern.lantern.intent.VPN_CONNECTED"
const val DISCONNECT_VPN = "org.getlantern.lantern.intent.VPN_DISCONNECTED"

const val STOP_SERVICE = "org.getlantern.lantern.service.STOP"
const val SERVICE = "org.getlantern.lantern.service"
}
23 changes: 23 additions & 0 deletions android/app/src/main/kotlin/org/getlantern/lantern/LanternApp.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
package org.getlantern.lantern

import android.app.Application
import android.app.NotificationManager
import android.content.Context
import android.content.Intent
import android.os.StrictMode
import androidx.appcompat.app.AppCompatDelegate
import androidx.core.content.ContextCompat
import androidx.multidex.MultiDex
import org.getlantern.lantern.model.InAppBilling
import org.getlantern.lantern.model.LanternHttpClient
import org.getlantern.lantern.model.LanternSessionManager
import org.getlantern.lantern.notification.Notifications
import org.getlantern.lantern.service.LanternConnection
import org.getlantern.lantern.util.debugOnly
import org.getlantern.lantern.util.LanternProxySelector
import org.getlantern.lantern.util.SentryUtil
Expand Down Expand Up @@ -60,6 +65,7 @@ open class LanternApp : Application() {

override fun attachBaseContext(base: Context) {
super.attachBaseContext(base)
application = this
// this is necessary running earlier versions of Android
// multidex support has to be added manually
// in addition to being enabled in the app build.gradle
Expand All @@ -69,11 +75,28 @@ open class LanternApp : Application() {

companion object {
private val TAG = LanternApp::class.java.simpleName

lateinit var application: LanternApp

private lateinit var appContext: Context
private lateinit var inAppBilling: InAppBilling
private lateinit var lanternHttpClient: LanternHttpClient
private lateinit var session: LanternSessionManager

val notificationManager by lazy { application.
getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager }

fun startService(connection: LanternConnection) = ContextCompat.startForegroundService(
application, Intent(application, connection.serviceClass).apply {
action = if (connection.isVpnService) Actions.CONNECT_VPN else null
}
)

fun stopService(connection: LanternConnection) =
application.sendBroadcast(Intent(Actions.STOP_SERVICE).
setPackage(application.packageName))


@JvmStatic
fun getAppContext(): Context {
return appContext
Expand Down
Loading
Loading