Merge branch 'ci-35' into 'master'

Install newer build tools for CI job and accept licenses

See merge request fdroid/fdroidclient!1443
This commit is contained in:
Hans-Christoph Steiner
2024-10-08 13:00:32 +00:00
9 changed files with 33 additions and 23 deletions

View File

@@ -219,7 +219,8 @@ libs database schema:
- apt-get -qy --no-install-recommends install openjdk-17-jdk-headless git sdkmanager
- export ANDROID_HOME=/opt/android-sdk
- export ANDROID_COMPILE_SDK=`sed -n 's,.*compileSdk\s*\([0-9][0-9]*\).*,\1,p' app/build.gradle`
- sdkmanager "platforms;android-$ANDROID_COMPILE_SDK" "build-tools;34.0.0"
- sdkmanager "platforms;android-$ANDROID_COMPILE_SDK" "build-tools;$ANDROID_COMPILE_SDK.0.0"
- sdkmanager "build-tools;34.0.0" # still needed until we upgrade android gradle plugin
- ./gradlew :libs:database:kaptDebugKotlin
- git --no-pager diff --exit-code

View File

@@ -9,7 +9,7 @@ plugins {
android {
namespace "org.fdroid.database"
compileSdk 34
compileSdk 35
defaultConfig {
minSdkVersion 21

View File

@@ -91,7 +91,7 @@ kotlin {
android {
namespace "org.fdroid.download"
compileSdk 34
compileSdk 35
sourceSets {
main.manifest.srcFile('src/androidMain/AndroidManifest.xml')
getByName("androidTest").java.srcDir(file("src/androidAndroidTest/kotlin"))

View File

@@ -90,7 +90,7 @@ kotlin {
android {
namespace "org.fdroid.index"
compileSdk 34
compileSdk 35
sourceSets {
main.manifest.srcFile('src/androidMain/AndroidManifest.xml')
getByName("androidTest").java.srcDir(file("src/androidAndroidTest/kotlin"))

View File

@@ -28,7 +28,7 @@ internal class IndexV1CreatorTest {
val repoDir = tmpFolder.newFolder()
val repo = TestDataMinV1.repo
val packageNames = context.packageManager.getInstalledPackages(0).filter {
(it.applicationInfo.flags and FLAG_SYSTEM == 0) and (Random.nextInt(0, 3) == 0)
(it.applicationInfo!!.flags and FLAG_SYSTEM == 0) and (Random.nextInt(0, 3) == 0)
}.map { it.packageName }.toSet()
val indexCreator = IndexV1Creator(context.packageManager, repoDir, packageNames, repo)
val indexV1 = indexCreator.createRepo()

View File

@@ -39,7 +39,7 @@ public class UpdateChecker(
allowedSignersGetter = {
// always gives us the oldest signer, even if they rotated certs by now
@Suppress("DEPRECATION")
packageInfo.signatures.map { getPackageSigner(it.toByteArray()) }.toSet()
packageInfo.signatures?.map { getPackageSigner(it.toByteArray()) }?.toSet()
},
installedVersionCode = PackageInfoCompat.getLongVersionCode(packageInfo),
allowedReleaseChannels = releaseChannels,

View File

@@ -48,10 +48,10 @@ public abstract class IndexCreator<T>(
* Extracts the icon from an APK and writes it to the repo as a PNG.
* @return the name of the written icon file.
*/
protected fun copyIconToRepo(packageInfo: PackageInfo): String {
protected fun copyIconToRepo(packageInfo: PackageInfo): String? {
val packageName = packageInfo.packageName
val versionCode = PackageInfoCompat.getLongVersionCode(packageInfo)
val drawable = packageInfo.applicationInfo.loadIcon(packageManager)
val drawable = packageInfo.applicationInfo?.loadIcon(packageManager) ?: return null
val bitmap: Bitmap
if (drawable is BitmapDrawable) {
bitmap = drawable.bitmap
@@ -71,21 +71,22 @@ public abstract class IndexCreator<T>(
/**
* Symlinks the APK to the repo. Does not support split APKs.
* @return the name of the linked/copied APK file.
* @return the name of the linked/copied APK file or null if no file exists.
*
* Roboletric apparently does not support Os.symlink, and some devices might
* have wonky implementations. Copying is slower and takes more disk space,
* but is much more reliable. So it is a workable fallback.
*/
protected fun copyApkToRepo(packageInfo: PackageInfo): File {
protected fun copyApkToRepo(packageInfo: PackageInfo): File? {
val appInfo = packageInfo.applicationInfo ?: return null
val packageName = packageInfo.packageName
val versionCode = PackageInfoCompat.getLongVersionCode(packageInfo)
val apkName = "${packageName}_$versionCode.apk"
val apkFile = File(repoDir, apkName)
if (apkFile.exists()) apkFile.delete()
symlink(packageInfo.applicationInfo.publicSourceDir, apkFile.absolutePath)
symlink(appInfo.publicSourceDir, apkFile.absolutePath)
if (!apkFile.exists()) {
File(packageInfo.applicationInfo.publicSourceDir).copyTo(apkFile)
File(appInfo.publicSourceDir).copyTo(apkFile)
}
return apkFile
}
@@ -108,7 +109,8 @@ public abstract class IndexCreator<T>(
}
protected fun parseNativeCode(packageInfo: PackageInfo): List<String> {
val apkJar = JarFile(packageInfo.applicationInfo.publicSourceDir)
val appInfo = packageInfo.applicationInfo ?: return emptyList()
val apkJar = JarFile(appInfo.publicSourceDir)
val abis = HashSet<String>()
val jarEntries = apkJar.entries()
while (jarEntries.hasMoreElements()) {

View File

@@ -68,7 +68,12 @@ public class IndexV1Creator(
@Suppress("PackageManagerGetSignatures")
val packageInfo = packageManager.getPackageInfo(packageName, flags)
apps.add(getApp(packageInfo))
packages[packageName] = listOf(getPackage(packageInfo))
val p = getPackage(packageInfo)
if (p == null) {
Log.w("IndexV1Creator", "Got no package for $packageName")
return
}
packages[packageName] = listOf(p)
} catch (e: PackageManager.NameNotFoundException) {
Log.i("IndexV1Creator", "app disappeared during addApp: ", e)
}
@@ -78,18 +83,20 @@ public class IndexV1Creator(
val icon = copyIconToRepo(packageInfo)
return AppV1(
packageName = packageInfo.packageName,
name = packageInfo.applicationInfo.loadLabel(packageManager).toString(),
name = packageInfo.applicationInfo?.loadLabel(packageManager).toString(),
license = "Unknown",
icon = icon,
)
}
private fun getPackage(packageInfo: PackageInfo): PackageV1 {
val apk = copyApkToRepo(packageInfo)
private fun getPackage(packageInfo: PackageInfo): PackageV1? {
val apk = copyApkToRepo(packageInfo) ?: return null
val appInfo = packageInfo.applicationInfo ?: return null
val signatures = packageInfo.signatures ?: return null
val hash = hashFile(apk)
val apkName = apk.name
val sig = getsig(packageInfo.signatures[0].toByteArray())
val signer = getPackageSigner(packageInfo.signatures[0].toByteArray())
val sig = getsig(signatures[0].toByteArray())
val signer = getPackageSigner(signatures[0].toByteArray())
return PackageV1(
packageName = packageInfo.packageName,
versionCode = PackageInfoCompat.getLongVersionCode(packageInfo),
@@ -101,9 +108,9 @@ public class IndexV1Creator(
hashType = "sha256",
sig = sig,
signer = signer,
size = File(packageInfo.applicationInfo.publicSourceDir).length(),
minSdkVersion = if (SDK_INT >= 24) packageInfo.applicationInfo.minSdkVersion else null,
targetSdkVersion = packageInfo.applicationInfo.targetSdkVersion,
size = File(appInfo.publicSourceDir).length(),
minSdkVersion = if (SDK_INT >= 24) appInfo.minSdkVersion else null,
targetSdkVersion = appInfo.targetSdkVersion,
usesPermission = packageInfo.requestedPermissions?.map {
PermissionV1(it)
} ?: emptyList(),

View File

@@ -15,7 +15,7 @@ java {
// not really an Android library, but index is not publishing for JVM at the moment
android {
namespace 'org.fdroid.test'
compileSdk 34
compileSdk 35
defaultConfig {
minSdkVersion 21
}