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

Remove the use of intent provider for request vpn permission #7198

Merged
merged 2 commits into from
Dec 13, 2024

Conversation

Pururun
Copy link
Contributor

@Pururun Pururun commented Nov 19, 2024

Continuation from: #6592

Also removes intent holder (but still uses intents) for api overrides that comes for intents.


This change is Reviewable

@Pururun Pururun added the Android Issues related to Android label Nov 19, 2024
@Pururun Pururun requested a review from Rawa November 19, 2024 07:23
Copy link

linear bot commented Nov 19, 2024

Copy link
Contributor

@Rawa Rawa left a comment

Choose a reason for hiding this comment

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

Reviewed all commit messages.
Reviewable status: 0 of 6 files reviewed, 3 unresolved discussions (waiting on @Pururun)


-- commits line 2 at r1:
I'm a bit on the fence about this, feels like we are going the wrong way about this solution.

If I understand correctly this is the case where a user click on a notification because they lack the permission of VPN? Wouldn't it be more natural to utilize deeplinks for this? Show a page saying helping the user to setup a VPN profile. Then I believe we should be able to avoid doing any dance with passing intents from the activity to the view.


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/MullvadApp.kt line 52 at r1 (raw file):

            mullvadAppViewModel.connect()
        }
    val activity = LocalContext.current.getActivity() as ComponentActivity

Feels a bit weird that we have to grab the activity, and cast it. Would be nice if we can avoid this.


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/MullvadApp.kt line 53 at r1 (raw file):

        }
    val activity = LocalContext.current.getActivity() as ComponentActivity
    LaunchedEffect(navHostController) {

What is the reasoning behind using navHostController as key for the launch effect?

Copy link
Contributor Author

@Pururun Pururun left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 6 files reviewed, 3 unresolved discussions (waiting on @Rawa)


-- commits line 2 at r1:

Previously, Rawa (David Göransson) wrote…

I'm a bit on the fence about this, feels like we are going the wrong way about this solution.

If I understand correctly this is the case where a user click on a notification because they lack the permission of VPN? Wouldn't it be more natural to utilize deeplinks for this? Show a page saying helping the user to setup a VPN profile. Then I believe we should be able to avoid doing any dance with passing intents from the activity to the view.

I avoided using a deep link because it was not clear where it would deep link to. I guess you could deep link to a dummy screen that then navigates to the correct screen or I guess a dedicated set up vpn permission screen.


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/MullvadApp.kt line 52 at r1 (raw file):

Previously, Rawa (David Göransson) wrote…

Feels a bit weird that we have to grab the activity, and cast it. Would be nice if we can avoid this.

You think we should move the cast somewhere else?


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/MullvadApp.kt line 53 at r1 (raw file):

Previously, Rawa (David Göransson) wrote…

What is the reasoning behind using navHostController as key for the launch effect?

Probably a remnant from a previous solution, will remove.

@Pururun
Copy link
Contributor Author

Pururun commented Nov 22, 2024

Setting this as on hold since we have other vpn permission work ongoing.

@Pururun Pururun added the On hold Means the PR is paused for some reason. No need to review it for now label Nov 22, 2024
@Pururun Pururun force-pushed the use-deeplink-to-do-vpnpermission-intent-droid-1110 branch 3 times, most recently from 20a9b5d to d312f47 Compare December 2, 2024 10:18
@Pururun Pururun removed the On hold Means the PR is paused for some reason. No need to review it for now label Dec 3, 2024
@Pururun Pururun force-pushed the use-deeplink-to-do-vpnpermission-intent-droid-1110 branch from e924b4a to 070231d Compare December 10, 2024 21:58
Copy link
Contributor Author

@Pururun Pururun left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 16 files reviewed, 3 unresolved discussions (waiting on @Rawa)


-- commits line 2 at r1:

Previously, Pururun (Jonatan Rhodin) wrote…

I avoided using a deep link because it was not clear where it would deep link to. I guess you could deep link to a dummy screen that then navigates to the correct screen or I guess a dedicated set up vpn permission screen.

Updated code based on our discussion.


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/MullvadApp.kt line 52 at r1 (raw file):

Previously, Pururun (Jonatan Rhodin) wrote…

You think we should move the cast somewhere else?

No longer relevant.

@Pururun Pururun force-pushed the use-deeplink-to-do-vpnpermission-intent-droid-1110 branch from 070231d to 2678bf8 Compare December 10, 2024 22:01
Copy link
Contributor

@Rawa Rawa left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 6 files at r1, 13 of 15 files at r2, all commit messages.
Reviewable status: 14 of 16 files reviewed, 2 unresolved discussions (waiting on @Pururun)


android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt line 134 at r2 (raw file):

    private fun setUpIntentListener() {
        lifecycleScope.launch {
            intents().collect {

Small remark regarding clarity.

I think we should do it in the following way:

onCreate() {
    ...
    lifecycleScope.launch{
        intents().collect(::handleIntent)
    }
    ...
}

private fun handleIntent(intent: Intent) {
    when(val action = intent.action) {
        KEY_REQUEST_VPN_PROFILE -> requestVpnProfile()
        KEY_SET_API_OVERRIDE -> apiEndpointOverrideHolder.set(intent.data.parse()) // or something like this
        else -> Log.w("Unhandled intent action: $action")
    }
}

android/lib/endpoint/src/debug/kotlin/net/mullvad/mullvadvpn/lib/endpoint/ApiEndpointFromIntentHolder.kt line 10 at r2 (raw file):

    fun handleIntent(intent: Intent) {
        apiEndpointOverride = intent.getApiEndpointConfigurationExtras()

Would be nice if this one isn't aware of intent.

@Pururun Pururun force-pushed the use-deeplink-to-do-vpnpermission-intent-droid-1110 branch from 2678bf8 to f35e848 Compare December 11, 2024 19:15
Copy link
Contributor Author

@Pururun Pururun left a comment

Choose a reason for hiding this comment

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

Reviewable status: 11 of 16 files reviewed, 2 unresolved discussions (waiting on @Rawa)


android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt line 134 at r2 (raw file):

Previously, Rawa (David Göransson) wrote…

Small remark regarding clarity.

I think we should do it in the following way:

onCreate() {
    ...
    lifecycleScope.launch{
        intents().collect(::handleIntent)
    }
    ...
}

private fun handleIntent(intent: Intent) {
    when(val action = intent.action) {
        KEY_REQUEST_VPN_PROFILE -> requestVpnProfile()
        KEY_SET_API_OVERRIDE -> apiEndpointOverrideHolder.set(intent.data.parse()) // or something like this
        else -> Log.w("Unhandled intent action: $action")
    }
}

Done.


android/lib/endpoint/src/debug/kotlin/net/mullvad/mullvadvpn/lib/endpoint/ApiEndpointFromIntentHolder.kt line 10 at r2 (raw file):

Previously, Rawa (David Göransson) wrote…

Would be nice if this one isn't aware of intent.

Done.

Copy link
Contributor

@Rawa Rawa left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 15 files at r2, 4 of 4 files at r3, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @Pururun)


android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt line 134 at r3 (raw file):

    private fun handleIntent(intent: Intent) {
        if (intent.action == KEY_REQUEST_VPN_PROFILE) {

Don't forget when statement, with warning logging if unsupported action.

Copy link
Contributor

@Rawa Rawa left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @Pururun)


android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt line 134 at r3 (raw file):

Previously, Rawa (David Göransson) wrote…

Don't forget when statement, with warning logging if unsupported action.

when(val action = intent.action) {
        KEY_REQUEST_VPN_PROFILE -> requestVpnProfile()
        KEY_SET_API_OVERRIDE -> apiEndpointOverrideHolder.set(intent.data.parse()) // or something like this
        else -> Log.w("Unhandled intent action: $action")
    }```

@Pururun Pururun force-pushed the use-deeplink-to-do-vpnpermission-intent-droid-1110 branch from f35e848 to dd3019e Compare December 12, 2024 09:56
Copy link
Contributor Author

@Pururun Pururun left a comment

Choose a reason for hiding this comment

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

Reviewable status: 13 of 16 files reviewed, 2 unresolved discussions (waiting on @Rawa)


android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt line 134 at r3 (raw file):

Previously, Rawa (David Göransson) wrote…
when(val action = intent.action) {
        KEY_REQUEST_VPN_PROFILE -> requestVpnProfile()
        KEY_SET_API_OVERRIDE -> apiEndpointOverrideHolder.set(intent.data.parse()) // or something like this
        else -> Log.w("Unhandled intent action: $action")
    }```

Ah sorry missed that part. Done

@Pururun Pururun force-pushed the use-deeplink-to-do-vpnpermission-intent-droid-1110 branch from dd3019e to be31028 Compare December 12, 2024 15:50
Copy link
Contributor

@Rawa Rawa left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 3 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@Pururun Pururun force-pushed the use-deeplink-to-do-vpnpermission-intent-droid-1110 branch from be31028 to b247a36 Compare December 13, 2024 08:15
@Pururun Pururun force-pushed the use-deeplink-to-do-vpnpermission-intent-droid-1110 branch from b247a36 to b95e54a Compare December 13, 2024 08:50
@Pururun Pururun merged commit 87669a9 into main Dec 13, 2024
28 checks passed
@Pururun Pururun deleted the use-deeplink-to-do-vpnpermission-intent-droid-1110 branch December 13, 2024 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android Issues related to Android
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants