File tree 1 file changed +12
-4
lines changed
android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/util
1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -8,13 +8,21 @@ import androidx.activity.result.contract.ActivityResultContract
8
8
9
9
class RequestVpnPermission : ActivityResultContract <Unit , Boolean >() {
10
10
override fun createIntent (context : Context , input : Unit ): Intent {
11
- // We expect this permission to only be requested when the permission is missing, however,
12
- // if it for some reason is called incorrectly we should return an empty intent so we avoid
13
- // a crash.
14
- return VpnService .prepare(context) ? : Intent ()
11
+ return VpnService .prepare(context)!!
15
12
}
16
13
17
14
override fun parseResult (resultCode : Int , intent : Intent ? ): Boolean {
18
15
return resultCode == Activity .RESULT_OK
19
16
}
17
+
18
+ // We expect this permission to only be requested when the permission is missing. However,
19
+ // if it for some reason is called incorrectly we will skip the call to create intent
20
+ // to avoid crashing. The app will then proceed as the user accepted the permission.
21
+ override fun getSynchronousResult (context : Context , input : Unit ): SynchronousResult <Boolean >? {
22
+ return if (VpnService .prepare(context) == null ) {
23
+ SynchronousResult (true )
24
+ } else {
25
+ null
26
+ }
27
+ }
20
28
}
You can’t perform that action at this time.
0 commit comments