Support of targetSdk 31 with its behaviour changes

This commit is contained in:
Dmitriy Karpushin 2023-03-06 12:11:37 +03:00
parent 1dd79d9e31
commit 4bd6fbd445
5 changed files with 8 additions and 7 deletions

View file

@ -135,7 +135,7 @@ android {
defaultConfig { defaultConfig {
resConfig "en" resConfig "en"
minSdkVersion = 24 minSdkVersion = 24
targetSdkVersion = 30 targetSdkVersion = 31
versionCode 10 // Change to a higher number versionCode 10 // Change to a higher number
versionName "2.0.10" // Change to a higher number versionName "2.0.10" // Change to a higher number

View file

@ -53,7 +53,7 @@ dependencies {
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0" implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"
implementation "androidx.room:room-runtime:2.2.5" // runtime implementation "androidx.room:room-runtime:2.2.5" // runtime
implementation "androidx.preference:preference:1.1.0" implementation "androidx.preference:preference:1.1.0"
implementation "androidx.work:work-runtime-ktx:2.3.4" implementation "androidx.work:work-runtime-ktx:2.7.1"
implementation "androidx.browser:browser:1.3.0-alpha01" implementation "androidx.browser:browser:1.3.0-alpha01"
implementation "androidx.constraintlayout:constraintlayout:1.1.3" implementation "androidx.constraintlayout:constraintlayout:1.1.3"
implementation "com.google.android.material:material:1.2.0-alpha05" implementation "com.google.android.material:material:1.2.0-alpha05"

View file

@ -68,7 +68,8 @@
android:name="org.amnezia.vpn.shadowsocks.core.BootReceiver" android:name="org.amnezia.vpn.shadowsocks.core.BootReceiver"
android:directBootAware="true" android:directBootAware="true"
android:enabled="false" android:enabled="false"
android:process=":QtOnlyProcess"> android:process=":QtOnlyProcess"
android:exported="true">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.LOCKED_BOOT_COMPLETED" /> <action android:name="android.intent.action.LOCKED_BOOT_COMPLETED" />

View file

@ -84,8 +84,9 @@ object Core {
fun init(app: Application, configureClass: KClass<out Any>) { fun init(app: Application, configureClass: KClass<out Any>) {
Core.app = app Core.app = app
configureIntent = { configureIntent = {
PendingIntent.getActivity(it, 0, Intent(it, configureClass.java) PendingIntent.getActivity(it, 0,
.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT), 0) Intent(it, configureClass.java).setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT),
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT)
} }
if (Build.VERSION.SDK_INT >= 24) { // migrate old files if (Build.VERSION.SDK_INT >= 24) { // migrate old files
@ -99,7 +100,6 @@ object Core {
// overhead of debug mode is minimal: https://github.com/Kotlin/kotlinx.coroutines/blob/f528898/docs/debugging.md#debug-mode // overhead of debug mode is minimal: https://github.com/Kotlin/kotlinx.coroutines/blob/f528898/docs/debugging.md#debug-mode
System.setProperty(DEBUG_PROPERTY_NAME, DEBUG_PROPERTY_VALUE_ON) System.setProperty(DEBUG_PROPERTY_NAME, DEBUG_PROPERTY_VALUE_ON)
WorkManager.initialize(deviceStorage, Configuration.Builder().build())
// handle data restored/crash // handle data restored/crash
if (Build.VERSION.SDK_INT >= 24 && DataStore.directBootAware && if (Build.VERSION.SDK_INT >= 24 && DataStore.directBootAware &&

View file

@ -99,7 +99,7 @@ object NotificationUtil {
val mainActivityName = "org.amnezia.vpn.qt.VPNActivity" val mainActivityName = "org.amnezia.vpn.qt.VPNActivity"
val activity = Class.forName(mainActivityName) val activity = Class.forName(mainActivityName)
val intent = Intent(service, activity) val intent = Intent(service, activity)
val pendingIntent = PendingIntent.getActivity(service, 0, intent, 0) val pendingIntent = PendingIntent.getActivity(service, 0, intent, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT)
// Build our notification // Build our notification
sNotificationBuilder?.let { sNotificationBuilder?.let {
it.setSmallIcon(org.amnezia.vpn.R.drawable.ic_amnezia_round) it.setSmallIcon(org.amnezia.vpn.R.drawable.ic_amnezia_round)