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

Fix crash with auto-connect and no permission #5492

Conversation

Rawa
Copy link
Contributor

@Rawa Rawa commented Nov 23, 2023


This change is Reviewable

Copy link

linear bot commented Nov 23, 2023

DROID-533 Crash on auto-connect enabled when missing VPN permission on API 34

  1. Start the app
  2. Accept privacy
  3. Create account
  4. Settings
  5. Vpn Settings
  6. Enable "auto connect"
  7. Force stop & start the app
  8. Frozen in loading screen 🙃

Secondary way to reproduce

  1. Have app with VPN setup and running, using auto connect
  2. Kill the app
  3. Remove Mullvad VPN from settings
  4. Start the app.
  5. Frozen in loading screen
FATAL EXCEPTION: main
    Process: net.mullvad.mullvadvpn:mullvadvpn_daemon, PID: 32297
    java.lang.SecurityException: Starting FGS with type systemExempted callerApp=ProcessRecord{aeb05dc 32297:net.mullvad.mullvadvpn:mullvadvpn_daemon/u0a530} targetSDK=34 requires permissions: all of the permissions allOf=true [android.permission.FOREGROUND_SERVICE_SYSTEM_EXEMPTED] any of the permissions allOf=false [android.permission.SCHEDULE_EXACT_ALARM, android.permission.USE_EXACT_ALARM, android:activate_vpn] 

@Pururun Pururun added the Android Issues related to Android label Nov 23, 2023
Copy link
Contributor

@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.

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @Rawa)


android/tile/src/main/kotlin/net/mullvad/mullvadvpn/tile/MullvadTileService.kt line 99 at r1 (raw file):

                    action = Intent.ACTION_MAIN
                }
            val pendingIntent =

This could be inside the if below since it is only use if it is Android 14 or below.
One other idea would be to add an extension function called startActivityAndCollapseSupport or something.
Something like this:

Code snippet:

fun MullvadTileService.startActivityAndCollapseCompat(intent: Intent) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
            val pendingIntent =
                PendingIntent.getActivity(
                    applicationContext,
                    0,
                    intent,
                    SdkUtils.getSupportedPendingIntentFlags()
                )
            startActivityAndCollapse(pendingIntent)
        } else {
            startActivityAndCollapse(intent)
        }
    }

@Rawa Rawa force-pushed the crash-on-auto-connect-enabled-when-missing-vpn-permission-on-droid-533 branch 2 times, most recently from 3d00000 to 157c2b0 Compare November 27, 2023 08:51
Copy link
Contributor Author

@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: 1 of 2 files reviewed, 1 unresolved discussion (waiting on @Pururun)


android/tile/src/main/kotlin/net/mullvad/mullvadvpn/tile/MullvadTileService.kt line 99 at r1 (raw file):

Previously, Pururun (Jonatan Rhodin) wrote…

This could be inside the if below since it is only use if it is Android 14 or below.
One other idea would be to add an extension function called startActivityAndCollapseSupport or something.
Something like this:

Nice suggestion, fixed now :)

@Rawa Rawa force-pushed the crash-on-auto-connect-enabled-when-missing-vpn-permission-on-droid-533 branch from 157c2b0 to 111deb6 Compare November 27, 2023 09:48
Copy link
Contributor

@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.

:lgtm:

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

@Pururun Pururun force-pushed the crash-on-auto-connect-enabled-when-missing-vpn-permission-on-droid-533 branch from 111deb6 to e1bf8a4 Compare November 27, 2023 11:11
@Pururun Pururun merged commit 57a1c4c into main Nov 27, 2023
15 checks passed
@Pururun Pururun deleted the crash-on-auto-connect-enabled-when-missing-vpn-permission-on-droid-533 branch November 27, 2023 11:31
@Rawa Rawa self-assigned this Dec 19, 2023
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