summaryrefslogtreecommitdiffhomepage
path: root/android/lib/common/src
diff options
context:
space:
mode:
Diffstat (limited to 'android/lib/common/src')
-rw-r--r--android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/util/ContextExtensions.kt12
1 files changed, 12 insertions, 0 deletions
diff --git a/android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/util/ContextExtensions.kt b/android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/util/ContextExtensions.kt
index 2d82bc56f4..9da4243631 100644
--- a/android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/util/ContextExtensions.kt
+++ b/android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/util/ContextExtensions.kt
@@ -31,3 +31,15 @@ fun Context.openVpnSettings(): Either<ActivityNotFoundException, Unit> =
}
.onLeft { Logger.e("Failed to open VPN settings", it) }
.mapLeft { it as? ActivityNotFoundException ?: throw it }
+
+fun Context.openAppDetailsSettings(): Either<ActivityNotFoundException, Unit> =
+ Either.catch {
+ val intent =
+ Intent(
+ "android.settings.APPLICATION_DETAILS_SETTINGS",
+ "package:$packageName".toUri(),
+ )
+ startActivity(intent)
+ }
+ .onLeft { Logger.e("Failed to open app details settings", it) }
+ .mapLeft { it as? ActivityNotFoundException ?: throw it }