diff options
author | pacien | 2018-02-16 22:21:30 +0100 |
---|---|---|
committer | pacien | 2018-02-16 22:21:30 +0100 |
commit | e38fbf4a348201241522a90d09221e609ad58d2d (patch) | |
tree | 4133bf891ebd0e42309ff7c4782b4fd086d74bd1 /app/src/main | |
parent | 70ee33422d8fd1c7a67217f19780c2638d7fbf3b (diff) | |
download | tincapp-e38fbf4a348201241522a90d09221e609ad58d2d.tar.gz |
Broadcast failed daemon startup and dismiss startup dialog
Diffstat (limited to 'app/src/main')
3 files changed, 9 insertions, 0 deletions
diff --git a/app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt b/app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt index 9fa5e44..2dd1c46 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt | |||
@@ -117,6 +117,7 @@ class StartActivity : BaseActivity() { | |||
117 | } | 117 | } |
118 | 118 | ||
119 | private val startupBroadcastReceiver = SimpleBroadcastReceiver(IntentFilter(Actions.EVENT_CONNECTED), this::onVpnStart) | 119 | private val startupBroadcastReceiver = SimpleBroadcastReceiver(IntentFilter(Actions.EVENT_CONNECTED), this::onVpnStart) |
120 | private val errorBroadcastReceiver = SimpleBroadcastReceiver(IntentFilter(Actions.EVENT_ABORTED), this::onVpnStartError) | ||
120 | 121 | ||
121 | private var connectDialog: ProgressDialog? = null | 122 | private var connectDialog: ProgressDialog? = null |
122 | 123 | ||
@@ -148,10 +149,12 @@ class StartActivity : BaseActivity() { | |||
148 | super.onResume() | 149 | super.onResume() |
149 | if (TincVpnService.isConnected()) openStatusActivity() | 150 | if (TincVpnService.isConnected()) openStatusActivity() |
150 | startupBroadcastReceiver.register() | 151 | startupBroadcastReceiver.register() |
152 | errorBroadcastReceiver.register() | ||
151 | } | 153 | } |
152 | 154 | ||
153 | override fun onPause() { | 155 | override fun onPause() { |
154 | startupBroadcastReceiver.unregister() | 156 | startupBroadcastReceiver.unregister() |
157 | errorBroadcastReceiver.unregister() | ||
155 | super.onPause() | 158 | super.onPause() |
156 | } | 159 | } |
157 | 160 | ||
@@ -169,6 +172,10 @@ class StartActivity : BaseActivity() { | |||
169 | finish() | 172 | finish() |
170 | } | 173 | } |
171 | 174 | ||
175 | private fun onVpnStartError() { | ||
176 | connectDialog?.dismiss() | ||
177 | } | ||
178 | |||
172 | private fun openStatusActivity() = | 179 | private fun openStatusActivity() = |
173 | startActivity(Intent(this, StatusActivity::class.java)) | 180 | startActivity(Intent(this, StatusActivity::class.java)) |
174 | } | 181 | } |
diff --git a/app/src/main/java/org/pacien/tincapp/intent/Actions.kt b/app/src/main/java/org/pacien/tincapp/intent/Actions.kt index 4650952..c6e0fec 100644 --- a/app/src/main/java/org/pacien/tincapp/intent/Actions.kt +++ b/app/src/main/java/org/pacien/tincapp/intent/Actions.kt | |||
@@ -12,6 +12,7 @@ object Actions { | |||
12 | const val ACTION_DISCONNECT = "$PREFIX.DISCONNECT" | 12 | const val ACTION_DISCONNECT = "$PREFIX.DISCONNECT" |
13 | const val EVENT_CONNECTED = "$PREFIX.CONNECTED" | 13 | const val EVENT_CONNECTED = "$PREFIX.CONNECTED" |
14 | const val EVENT_DISCONNECTED = "$PREFIX.DISCONNECTED" | 14 | const val EVENT_DISCONNECTED = "$PREFIX.DISCONNECTED" |
15 | const val EVENT_ABORTED = "$PREFIX.ABORTED" | ||
15 | const val TINC_SCHEME = "tinc" | 16 | const val TINC_SCHEME = "tinc" |
16 | 17 | ||
17 | fun buildNetworkUri(netName: String, passphrase: String? = null): Uri = | 18 | fun buildNetworkUri(netName: String, passphrase: String? = null): Uri = |
diff --git a/app/src/main/java/org/pacien/tincapp/service/TincVpnService.kt b/app/src/main/java/org/pacien/tincapp/service/TincVpnService.kt index ce41b89..0937006 100644 --- a/app/src/main/java/org/pacien/tincapp/service/TincVpnService.kt +++ b/app/src/main/java/org/pacien/tincapp/service/TincVpnService.kt | |||
@@ -118,6 +118,7 @@ class TincVpnService : VpnService() { | |||
118 | else | 118 | else |
119 | Log.e(TAG, msg) | 119 | Log.e(TAG, msg) |
120 | 120 | ||
121 | broadcastEvent(Actions.EVENT_ABORTED) | ||
121 | App.alert(R.string.title_unable_to_start_tinc, msg, | 122 | App.alert(R.string.title_unable_to_start_tinc, msg, |
122 | if (docTopic != null) resources.getString(R.string.app_doc_url_format, docTopic) else null) | 123 | if (docTopic != null) resources.getString(R.string.app_doc_url_format, docTopic) else null) |
123 | } | 124 | } |