Resolve null-safety errors with newer compileSdk
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
@@ -8,10 +8,10 @@ fun PackageInfo.isApp(): Boolean {
|
|||||||
|
|
||||||
return when {
|
return when {
|
||||||
isQAndAbove() -> {
|
isQAndAbove() -> {
|
||||||
Process.isApplicationUid(this.applicationInfo.uid) &&
|
Process.isApplicationUid(this.applicationInfo!!.uid) &&
|
||||||
!this.applicationInfo.isResourceOverlay && !this.isApex
|
!this.applicationInfo!!.isResourceOverlay && !this.isApex
|
||||||
}
|
}
|
||||||
isNAndAbove() -> Process.isApplicationUid(this.applicationInfo.uid)
|
isNAndAbove() -> Process.isApplicationUid(this.applicationInfo!!.uid)
|
||||||
else -> this.packageName != null && this.versionName != null
|
else -> this.versionName != null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ class AppInstaller @Inject constructor(
|
|||||||
)
|
)
|
||||||
val version = PackageInfoCompat.getLongVersionCode(packageInfo)
|
val version = PackageInfoCompat.getLongVersionCode(packageInfo)
|
||||||
|
|
||||||
packageInfo.applicationInfo.enabled && version >= 9
|
packageInfo.applicationInfo!!.enabled && version >= 9
|
||||||
} catch (exception: Exception) {
|
} catch (exception: Exception) {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class NativeGsfVersionProvider(context: Context) {
|
|||||||
try {
|
try {
|
||||||
val packageInfo = getPackageInfo(context, GOOGLE_VENDING_PACKAGE_ID)
|
val packageInfo = getPackageInfo(context, GOOGLE_VENDING_PACKAGE_ID)
|
||||||
vendingVersionCode = PackageInfoCompat.getLongVersionCode(packageInfo)
|
vendingVersionCode = PackageInfoCompat.getLongVersionCode(packageInfo)
|
||||||
vendingVersionString = packageInfo.versionName
|
vendingVersionString = packageInfo.versionName!!
|
||||||
} catch (e: PackageManager.NameNotFoundException) {
|
} catch (e: PackageManager.NameNotFoundException) {
|
||||||
// com.android.vending not found
|
// com.android.vending not found
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,8 +140,8 @@ class ExportWorker @AssistedInject constructor(
|
|||||||
val packageInfo = getPackageInfo(appContext, packageName, PackageManager.GET_META_DATA)
|
val packageInfo = getPackageInfo(appContext, packageName, PackageManager.GET_META_DATA)
|
||||||
val fileList: MutableList<File?> = mutableListOf()
|
val fileList: MutableList<File?> = mutableListOf()
|
||||||
|
|
||||||
fileList.add(File(packageInfo.applicationInfo.sourceDir))
|
fileList.add(File(packageInfo.applicationInfo!!.sourceDir))
|
||||||
packageInfo.applicationInfo.splitSourceDirs?.let { splits ->
|
packageInfo.applicationInfo!!.splitSourceDirs?.let { splits ->
|
||||||
fileList.addAll(splits.map { File(it) })
|
fileList.addAll(splits.map { File(it) })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -92,14 +92,14 @@ object CertUtil {
|
|||||||
return try {
|
return try {
|
||||||
val packageInfo = getPackageInfoWithSignature(context, packageName)
|
val packageInfo = getPackageInfoWithSignature(context, packageName)
|
||||||
if (isPAndAbove()) {
|
if (isPAndAbove()) {
|
||||||
if (packageInfo.signingInfo.hasMultipleSigners()) {
|
if (packageInfo.signingInfo!!.hasMultipleSigners()) {
|
||||||
packageInfo.signingInfo.apkContentsSigners.map { it.generateX509Certificate() }
|
packageInfo.signingInfo!!.apkContentsSigners.map { it.generateX509Certificate() }
|
||||||
} else {
|
} else {
|
||||||
packageInfo.signingInfo.signingCertificateHistory.map { it.generateX509Certificate() }
|
packageInfo.signingInfo!!.signingCertificateHistory.map { it.generateX509Certificate() }
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
packageInfo.signatures.map { it.generateX509Certificate() }
|
packageInfo.signatures!!.map { it.generateX509Certificate() }
|
||||||
}
|
}
|
||||||
} catch (exception: Exception) {
|
} catch (exception: Exception) {
|
||||||
Log.e(TAG, "Failed to get X509 certificates", exception)
|
Log.e(TAG, "Failed to get X509 certificates", exception)
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ object PackageUtil {
|
|||||||
fun getIconForPackage(context: Context, packageName: String): Bitmap? {
|
fun getIconForPackage(context: Context, packageName: String): Bitmap? {
|
||||||
return try {
|
return try {
|
||||||
val packageInfo = context.packageManager.getPackageInfo(packageName, 0)
|
val packageInfo = context.packageManager.getPackageInfo(packageName, 0)
|
||||||
val icon = packageInfo.applicationInfo.loadIcon(context.packageManager)
|
val icon = packageInfo.applicationInfo!!.loadIcon(context.packageManager)
|
||||||
if (icon.intrinsicWidth > 0 && icon.intrinsicHeight > 0) {
|
if (icon.intrinsicWidth > 0 && icon.intrinsicHeight > 0) {
|
||||||
icon.toBitmap(96, 96)
|
icon.toBitmap(96, 96)
|
||||||
} else {
|
} else {
|
||||||
@@ -214,7 +214,7 @@ object PackageUtil {
|
|||||||
"com.google.toontastic",
|
"com.google.toontastic",
|
||||||
).contains(it.packageName)
|
).contains(it.packageName)
|
||||||
}.filter {
|
}.filter {
|
||||||
it.packageName?.contains("com.google") == false
|
!it.packageName.contains("com.google")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,7 +233,7 @@ object PackageUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!isExtendedUpdateEnabled) {
|
if (!isExtendedUpdateEnabled) {
|
||||||
packageInfoList = packageInfoList.filter { it.applicationInfo.enabled }
|
packageInfoList = packageInfoList.filter { it.applicationInfo!!.enabled }
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Filter F-Droid apps*/
|
/*Filter F-Droid apps*/
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class PermissionBottomSheet : BaseDialogSheet<SheetPermissionsBinding>() {
|
|||||||
currentPerms = try {
|
currentPerms = try {
|
||||||
packageManager.getPackageInfo(
|
packageManager.getPackageInfo(
|
||||||
args.app.packageName, PackageManager.GET_PERMISSIONS
|
args.app.packageName, PackageManager.GET_PERMISSIONS
|
||||||
).requestedPermissions.toList()
|
).requestedPermissions!!.toList()
|
||||||
} catch (_: Exception) {
|
} catch (_: Exception) {
|
||||||
emptyList()
|
emptyList()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user