feat: compileSdk android 15
Some checks failed
Build-Apk / build (push) Has been cancelled

This commit is contained in:
lisonge 2024-10-08 14:16:23 +08:00
parent 69525c8966
commit 8cca22d697
7 changed files with 28 additions and 27 deletions

View File

@ -22,18 +22,16 @@ data class AppInfo(
) )
val selfAppInfo by lazy { val selfAppInfo by lazy {
app.packageManager.getPackageInfo(app.packageName, 0).toAppInfo()!! app.packageManager.getPackageInfo(app.packageName, 0).toAppInfo()
} }
/** /**
* 平均单次调用时间 11ms * 平均单次调用时间 11ms
*/ */
fun PackageInfo.toAppInfo(): AppInfo? { fun PackageInfo.toAppInfo(): AppInfo {
applicationInfo ?: return null val info = applicationInfo
return AppInfo( return AppInfo(
id = packageName, id = packageName,
name = applicationInfo.loadLabel(app.packageManager).toString(),
icon = applicationInfo.loadIcon(app.packageManager),
versionCode = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { versionCode = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
longVersionCode longVersionCode
} else { } else {
@ -41,8 +39,10 @@ fun PackageInfo.toAppInfo(): AppInfo? {
versionCode.toLong() versionCode.toLong()
}, },
versionName = versionName, versionName = versionName,
isSystem = (ApplicationInfo.FLAG_SYSTEM and applicationInfo.flags) != 0,
mtime = lastUpdateTime, mtime = lastUpdateTime,
hidden = app.packageManager.getLaunchIntentForPackage(packageName) == null hidden = app.packageManager.getLaunchIntentForPackage(packageName) == null,
name = info?.run { loadLabel(app.packageManager).toString() } ?: packageName,
icon = info?.loadIcon(app.packageManager),
isSystem = info?.run { (ApplicationInfo.FLAG_SYSTEM and flags) != 0 } ?: false,
) )
} }

View File

@ -83,9 +83,8 @@ private fun updateAppInfo(appId: String) {
} catch (e: PackageManager.NameNotFoundException) { } catch (e: PackageManager.NameNotFoundException) {
null null
} }
val newAppInfo = info?.toAppInfo() if (info != null) {
if (newAppInfo != null) { newMap[appId] = info.toAppInfo()
newMap[appId] = newAppInfo
} else { } else {
newMap.remove(appId) newMap.remove(appId)
} }
@ -106,10 +105,7 @@ suspend fun initOrResetAppInfoCache() {
withContext(Dispatchers.IO) { withContext(Dispatchers.IO) {
app.packageManager.getInstalledPackages(0).forEach { packageInfo -> app.packageManager.getInstalledPackages(0).forEach { packageInfo ->
if (!oldAppIds.contains(packageInfo.packageName)) { if (!oldAppIds.contains(packageInfo.packageName)) {
val info = packageInfo.toAppInfo() appMap[packageInfo.packageName] = packageInfo.toAppInfo()
if (info != null) {
appMap[packageInfo.packageName] = info
}
} }
} }
} }

View File

@ -1,8 +0,0 @@
package li.songe.gkd.util
import android.graphics.Bitmap
fun Bitmap.isEmptyBitmap(): Boolean {
val emptyBitmap = Bitmap.createBitmap(width, height, config)
return this.sameAs(emptyBitmap)
}

View File

@ -1,6 +1,7 @@
package li.songe.gkd.util package li.songe.gkd.util
import android.content.ComponentName import android.content.ComponentName
import android.graphics.Bitmap
import li.songe.gkd.META import li.songe.gkd.META
import kotlin.reflect.KClass import kotlin.reflect.KClass
import kotlin.reflect.jvm.jvmName import kotlin.reflect.jvm.jvmName
@ -13,3 +14,15 @@ private val componentNameCache by lazy { HashMap<String, ComponentName>() }
val KClass<*>.componentName val KClass<*>.componentName
get() = componentNameCache.getOrPut(jvmName) { ComponentName(META.appId, jvmName) } get() = componentNameCache.getOrPut(jvmName) { ComponentName(META.appId, jvmName) }
fun Bitmap.isEmptyBitmap(): Boolean {
// png
repeat(width) { x ->
repeat(height) { y ->
if (getPixel(x, y) != 0) {
return false
}
}
}
return true
}

View File

@ -3,7 +3,7 @@ android.useAndroidX=true
android.enableJetifier=true android.enableJetifier=true
android.debug.obsoleteApi=true android.debug.obsoleteApi=true
kotlin.code.style=official kotlin.code.style=official
android_compileSdk=34 android_compileSdk=35
android_targetSdk=34 android_targetSdk=35
android_buildToolsVersion=34.0.0 android_buildToolsVersion=35.0.0
android_minSdk=26 android_minSdk=26

View File

@ -1,7 +1,7 @@
[versions] [versions]
kotlin = "2.0.20" kotlin = "2.0.20"
ksp = "2.0.20-1.0.25" ksp = "2.0.20-1.0.25"
android = "8.6.1" android = "8.7.0"
compose = "1.7.3" compose = "1.7.3"
rikka = "4.4.0" rikka = "4.4.0"
room = "2.6.1" room = "2.6.1"

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME