Merge pull request #579 from seedvault-app/staging/android14-bp

Get app working in Android 14, built via Android.bp
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 65a4b9c..925a65b 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -2,6 +2,9 @@
 
 on:
   push:
+    branches:
+      - android*
+  pull_request:
 
 concurrency:
   group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
diff --git a/app/build.gradle b/app/build.gradle
index 08d3782..9df1732 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -45,12 +45,12 @@
         abortOnError true
     }
     compileOptions {
-        sourceCompatibility = JavaVersion.VERSION_11
-        targetCompatibility = JavaVersion.VERSION_11
+        sourceCompatibility = JavaVersion.VERSION_17
+        targetCompatibility = JavaVersion.VERSION_17
     }
     kotlinOptions {
-        jvmTarget = JavaVersion.VERSION_11.toString()
-        languageVersion = "1.7"
+        jvmTarget = JavaVersion.VERSION_17.toString()
+        languageVersion = "1.8"
     }
     testOptions {
         unitTests.all {
diff --git a/app/libs/android.jar b/app/libs/android.jar
index 5e9d53d..66649a8 100644
--- a/app/libs/android.jar
+++ b/app/libs/android.jar
Binary files differ
diff --git a/app/libs/libcore.jar b/app/libs/libcore.jar
index 2c0049b..a43e54f 100644
--- a/app/libs/libcore.jar
+++ b/app/libs/libcore.jar
Binary files differ
diff --git a/app/src/main/java/com/stevesoltys/seedvault/restore/install/ApkInstaller.kt b/app/src/main/java/com/stevesoltys/seedvault/restore/install/ApkInstaller.kt
index cfb1c54..4affa6d 100644
--- a/app/src/main/java/com/stevesoltys/seedvault/restore/install/ApkInstaller.kt
+++ b/app/src/main/java/com/stevesoltys/seedvault/restore/install/ApkInstaller.kt
@@ -1,5 +1,6 @@
 package com.stevesoltys.seedvault.restore.install
 
+import android.annotation.SuppressLint
 import android.app.PendingIntent
 import android.app.PendingIntent.FLAG_MUTABLE
 import android.app.PendingIntent.FLAG_UPDATE_CURRENT
@@ -62,6 +63,7 @@
         install(cachedApks, installerPackageName)
     }
 
+    @SuppressLint("NewApi")
     private fun install(cachedApks: List<File>, installerPackageName: String?) {
         val sessionParams = SessionParams(MODE_FULL_INSTALL).apply {
             setInstallerPackageName(installerPackageName)
diff --git a/build.gradle b/build.gradle
index 2a1fe90..c694898 100644
--- a/build.gradle
+++ b/build.gradle
@@ -3,15 +3,16 @@
     // 1.4.30 Android 12
     // 1.6.10 Android 13
     // 1.7.20 Android 13 (QPR2)
+    // 1.8.10 Android 14
     // Check:
-    // https://android.googlesource.com/platform/external/kotlinc/+/refs/tags/android-13.0.0_r32/build.txt
-    ext.aosp_kotlin_version = '1.7.20'  // 1.7.20-release-201 in AOSP
-    ext.kotlin_version = '1.7.20'
+    // https://android.googlesource.com/platform/external/kotlinc/+/refs/tags/android-14.0.0_r1/build.txt
+    ext.aosp_kotlin_version = '1.8.10'  // 1.8.10-release-430 in AOSP
+    ext.kotlin_version = '1.8.10'
 }
 
 plugins {
-    id 'com.android.application' version '8.1.0' apply false
-    id 'com.android.library' version '8.1.0' apply false
+    id 'com.android.application' version '8.1.2' apply false
+    id 'com.android.library' version '8.1.2' apply false
     id 'com.google.protobuf' version '0.9.4' apply false
     id 'org.jetbrains.kotlin.android' version "$kotlin_version" apply false
     id 'org.jetbrains.kotlin.kapt' version "$kotlin_version" apply false
@@ -20,9 +21,9 @@
 }
 
 ext {
-    compileSdk = 33
+    compileSdk = 34
     minSdk = 32
-    targetSdk = 33
+    targetSdk = 34
 }
 
 apply from: 'gradle/dependencies.gradle'
diff --git a/contactsbackup/build.gradle b/contactsbackup/build.gradle
index a3d885a..c00a4b4 100644
--- a/contactsbackup/build.gradle
+++ b/contactsbackup/build.gradle
@@ -22,12 +22,12 @@
     }
 
     compileOptions {
-        sourceCompatibility = JavaVersion.VERSION_11
-        targetCompatibility = JavaVersion.VERSION_11
+        sourceCompatibility = JavaVersion.VERSION_17
+        targetCompatibility = JavaVersion.VERSION_17
     }
 
     kotlinOptions {
-        jvmTarget = JavaVersion.VERSION_11.toString()
+        jvmTarget = JavaVersion.VERSION_17.toString()
     }
 
     testOptions {
diff --git a/contactsbackup/libs/com.android.vcard.jar b/contactsbackup/libs/com.android.vcard.jar
index 8060d84..bd4da8b 100644
--- a/contactsbackup/libs/com.android.vcard.jar
+++ b/contactsbackup/libs/com.android.vcard.jar
Binary files differ
diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle
index e132341..34b00b9 100644
--- a/gradle/dependencies.gradle
+++ b/gradle/dependencies.gradle
@@ -1,8 +1,8 @@
 ext {
     // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-13.0.0_r3/current/androidx/Android.bp#3901
     ext.room_version = "2.4.0-alpha05" // 2.5.0-alpha01 in AOSP but needs testing
-    // https://android.googlesource.com/platform/external/protobuf/+/refs/tags/android-13.0.0_r32/java/pom.xml#7
-    ext.protobuf_version = "3.9.1"
+    // https://android.googlesource.com/platform/external/protobuf/+/refs/tags/android-14.0.0_r1/java/pom.xml#7
+    ext.protobuf_version = "3.21.7"
 
     // test dependencies below - these do not care about AOSP and can be freely updated
     junit4_version = "4.13.2"
@@ -39,11 +39,11 @@
     ],
     coroutines: [
         dependencies.create('org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm') {
-            // https://android.googlesource.com/platform/external/kotlinx.coroutines/+/refs/tags/android-13.0.0_r32/CHANGES.md
+            // https://android.googlesource.com/platform/external/kotlinx.coroutines/+/refs/tags/android-14.0.0_r1/CHANGES.md
             version { strictly '1.6.4' }
         },
         dependencies.create('org.jetbrains.kotlinx:kotlinx-coroutines-android') {
-            // https://android.googlesource.com/platform/external/kotlinx.coroutines/+/refs/tags/android-13.0.0_r32/CHANGES.md
+            // https://android.googlesource.com/platform/external/kotlinx.coroutines/+/refs/tags/android-14.0.0_r1/CHANGES.md
             version { strictly '1.6.4' }
         },
     ],
@@ -51,44 +51,44 @@
 
 ext.std_libs = [
     androidx_core: [
-        // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-13.0.0_r32/current/androidx/Android.bp#2275
+        // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-14.0.0_r1/current/androidx/Android.bp#2420
         dependencies.create('androidx.core:core') {
             version { strictly '1.9.0-alpha05' } // 1.9.0-alpha03 in AOSP but has SDK version issues
         },
-        // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-13.0.0_r32/current/androidx/Android.bp#2241
+        // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-14.0.0_r1/current/androidx/Android.bp#2386
         dependencies.create('androidx.core:core-ktx') {
             version { strictly '1.9.0-alpha05' } // 1.9.0-alpha03 in AOSP but has SDK version issues
         },
     ],
-    // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-13.0.0_r32/current/androidx/Android.bp#2705
+    // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-14.0.0_r1/current/androidx/Android.bp#2849
     androidx_fragment: dependencies.create('androidx.fragment:fragment-ktx') {
         version { strictly '1.5.0-alpha03' }
     },
-    // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-13.0.0_r32/current/androidx/Android.bp#61
+    // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-14.0.0_r1/current/androidx/Android.bp#61
     androidx_activity: dependencies.create('androidx.activity:activity-ktx') {
         version { strictly '1.5.0-alpha03' }
     },
-    // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-13.0.0_r32/current/androidx/Android.bp#4275
+    // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-14.0.0_r1/current/androidx/Android.bp#4420
     androidx_preference: dependencies.create('androidx.preference:preference') {
         version { strictly '1.2.0-alpha01' }
     },
-    // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-13.0.0_r3/current/androidx/Android.bp#3376
+    // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-13.0.0_r3/current/androidx/Android.bp#3521
     androidx_lifecycle_viewmodel_ktx: dependencies.create('androidx.lifecycle:lifecycle-viewmodel-ktx') {
         version { strictly '2.5.0-alpha03' }
     },
-    // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-13.0.0_r32/current/androidx/Android.bp#3134
+    // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-14.0.0_r1/current/androidx/Android.bp#3279
     androidx_lifecycle_livedata_ktx: dependencies.create('androidx.lifecycle:lifecycle-livedata-ktx') {
         version { strictly '2.5.0-alpha03' }
     },
-    // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-13.0.0_r3/current/extras/constraint-layout-x/Android.bp#64
+    // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-14.0.0_r1/current/androidx/Android.bp#2244
     androidx_constraintlayout: dependencies.create('androidx.constraintlayout:constraintlayout') {
         version { strictly '2.2.0-alpha05' }
     },
-    // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-13.0.0_r32/current/androidx/Android.bp#2411
+    // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-14.0.0_r1/current/androidx/Android.bp#2556
     androidx_documentfile: dependencies.create('androidx.documentfile:documentfile') {
         version { strictly '1.1.0-alpha01' } // 1.1.0-alpha02 in AOSP but not released yet
     },
-    // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-13.0.0_r32/current/extras/material-design-x/Android.bp#6
+    // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-14.0.0_r1/current/extras/material-design-x/Android.bp#15
     com_google_android_material: dependencies.create('com.google.android.material:material') {
         version { strictly '1.7.0-alpha03' }
     },
diff --git a/settings.gradle b/settings.gradle
index ae99556..8725f6c 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,4 +1,16 @@
 pluginManagement {
+    buildscript {
+        repositories {
+            mavenCentral()
+            maven { url = uri("https://storage.googleapis.com/r8-releases/raw") }
+        }
+        dependencies {
+            // https://issuetracker.google.com/issues/227160052#comment37
+            // This can be removed when we switch to Android Gradle plugin 8.2.
+            classpath("com.android.tools:r8:8.2.28")
+        }
+    }
+
     repositories {
         gradlePluginPortal()
         google()
diff --git a/storage/demo/build.gradle b/storage/demo/build.gradle
index ead579a..130a49d 100644
--- a/storage/demo/build.gradle
+++ b/storage/demo/build.gradle
@@ -32,11 +32,11 @@
         }
     }
     compileOptions {
-        sourceCompatibility = JavaVersion.VERSION_11
-        targetCompatibility = JavaVersion.VERSION_11
+        sourceCompatibility = JavaVersion.VERSION_17
+        targetCompatibility = JavaVersion.VERSION_17
     }
     kotlinOptions {
-        jvmTarget = JavaVersion.VERSION_11.toString()
+        jvmTarget = JavaVersion.VERSION_17.toString()
         freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn"
     }
     lint {
diff --git a/storage/lib/build.gradle b/storage/lib/build.gradle
index 861ca2a..447b284 100644
--- a/storage/lib/build.gradle
+++ b/storage/lib/build.gradle
@@ -33,12 +33,12 @@
         }
     }
     compileOptions {
-        sourceCompatibility = JavaVersion.VERSION_11
-        targetCompatibility = JavaVersion.VERSION_11
+        sourceCompatibility = JavaVersion.VERSION_17
+        targetCompatibility = JavaVersion.VERSION_17
     }
     kotlinOptions {
-        jvmTarget = JavaVersion.VERSION_11.toString()
-        languageVersion = "1.7"
+        jvmTarget = JavaVersion.VERSION_17.toString()
+        languageVersion = "1.8"
         freeCompilerArgs += '-opt-in=kotlin.RequiresOptIn'
         freeCompilerArgs += '-Xexplicit-api=strict'
     }