Skip to content

Commit

Permalink
Update compile sdk to 33
Browse files Browse the repository at this point in the history
  • Loading branch information
G00fY2 committed Sep 13, 2022
1 parent cd0b7d8 commit ec08a04
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,15 @@ class ApkFile private constructor() : Comparable<ApkFile> {
size = getFormattedSize(file.length())

file.absolutePath.let { filePath ->
packageManager.getPackageArchiveInfo(filePath, PackageManager.GET_PERMISSIONS)?.let { packageInfo ->
if (VERSION.SDK_INT >= VERSION_CODES.TIRAMISU) {
packageManager.getPackageArchiveInfo(
filePath,
PackageManager.PackageInfoFlags.of(PackageManager.GET_PERMISSIONS.toLong())
)
} else {
@Suppress("DEPRECATION")
packageManager.getPackageArchiveInfo(filePath, PackageManager.GET_PERMISSIONS)
}?.let { packageInfo ->
packageInfo.versionName?.let { versionName = it }
PackageInfoCompat.getLongVersionCode(packageInfo).let { versionCode = it.toString() }
dangerousPermissions = extractDangerousPermissions(packageInfo.requestedPermissions)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.g00fy2.developerwidget.activities.appmanager

import android.content.pm.PackageInfo
import android.content.pm.PackageManager
import android.graphics.drawable.AdaptiveIconDrawable
import android.graphics.drawable.Drawable
import android.graphics.drawable.InsetDrawable
Expand Down Expand Up @@ -60,7 +61,12 @@ class AppInfo private constructor() : Comparable<AppInfo> {
private val packageManager = activity.packageManager

override fun getInstalledPackages(): List<PackageInfo> {
return packageManager.getInstalledPackages(0)
return if (VERSION.SDK_INT >= VERSION_CODES.TIRAMISU) {
packageManager.getInstalledPackages(PackageManager.PackageInfoFlags.of(0))
} else {
@Suppress("DEPRECATION")
packageManager.getInstalledPackages(0)
}
}

override fun build(packageInfo: PackageInfo): AppInfo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.g00fy2.developerwidget.data.device.systemapps
import android.annotation.SuppressLint
import android.content.Context
import android.content.pm.PackageInfo
import android.content.pm.PackageManager
import android.content.pm.PackageManager.NameNotFoundException
import android.os.Build.VERSION
import android.os.Build.VERSION_CODES
Expand All @@ -13,7 +14,7 @@ object SystemAppsDataProvider {

fun getGooglePlayServicesVersion(context: Context): String {
return try {
context.packageManager.getPackageInfo("com.google.android.gms", 0).versionName
context.getPackageInfo("com.google.android.gms").versionName
} catch (e: NameNotFoundException) {
""
}
Expand Down Expand Up @@ -41,11 +42,22 @@ object SystemAppsDataProvider {
Version(VERSION.RELEASE).isAtLeast("4.4.3") -> "WebView v33.0.0.0"
VERSION.SDK_INT >= VERSION_CODES.KITKAT -> "WebView v30.0.0.0"
else -> try {
context.packageManager.getPackageInfo("com.google.android.webview", 0)
context.getPackageInfo("com.google.android.webview")
} catch (e: NameNotFoundException) {
null
}?.let { context.packageManager.getApplicationLabel(it.applicationInfo).toString() + " " + it.versionName }
.orEmpty()
}
}

private fun Context.getPackageInfo(packageName: String): PackageInfo {
return packageManager.run {
if (VERSION.SDK_INT >= VERSION_CODES.TIRAMISU) {
getPackageInfo(packageName, PackageManager.PackageInfoFlags.of(0))
} else {
@Suppress("DEPRECATION")
getPackageInfo(packageName, 0)
}
}
}
}
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
object Versions {

const val androidMinSdk = 14
const val androidCompileSdk = 32
const val androidCompileSdk = 33
const val androidTargetSdk = 29

const val androidBuildTools = "32.0.0"
const val androidBuildTools = "33.0.0"
const val androidGradle = "7.2.2"
const val kotlin = "1.7.10"

Expand Down

0 comments on commit ec08a04

Please sign in to comment.