Fix kotlin nullable errors in Settings

Fix kotlin nullable errors that were exposed by setting the retention
of android.annotation.NonNull and android.annotation.Nullable to
class retention.

Bug: 294110802
Test: builds
Change-Id: I6aa0516fa4f6443b6d4dff873baf3b08ff9189f0
This commit is contained in:
Colin Cross
2023-08-14 12:29:02 -07:00
parent beea9e488d
commit 87b870a090
12 changed files with 25 additions and 23 deletions

View File

@@ -45,7 +45,7 @@ private class AppButtonsPresenter(private val packageInfoPresenter: PackageInfoP
@Composable
fun getActionButtons() =
packageInfoPresenter.flow.collectAsStateWithLifecycle(initialValue = null).value?.let {
getActionButtons(it.applicationInfo)
getActionButtons(checkNotNull(it.applicationInfo))
} ?: emptyList()
@Composable

View File

@@ -118,7 +118,7 @@ object AppInfoSettingsProvider : SettingsPageProvider {
private fun AppInfoSettings(packageInfoPresenter: PackageInfoPresenter) {
LifecycleEffect(onStart = { packageInfoPresenter.reloadPackageInfo() })
val packageInfo = packageInfoPresenter.flow.collectAsStateWithLifecycle().value ?: return
val app = packageInfo.applicationInfo
val app = checkNotNull(packageInfo.applicationInfo)
RegularScaffold(
title = stringResource(R.string.application_info_label),
actions = {

View File

@@ -41,7 +41,7 @@ private class CloneAppButtonsPresenter(private val packageInfoPresenter: Package
@Composable
fun getActionButtons() =
packageInfoPresenter.flow.collectAsStateWithLifecycle(initialValue = null).value?.let {
getActionButtons(it.applicationInfo)
getActionButtons(checkNotNull(it.applicationInfo))
} ?: emptyList()
@Composable

View File

@@ -77,7 +77,7 @@ class PackageInfoPresenter(
DisposableBroadcastReceiverAsUser(intentFilter, userHandle) { intent ->
if (packageName == intent.data?.schemeSpecificPart) {
val packageInfo = flow.value
if (packageInfo != null && packageInfo.applicationInfo.isSystemApp) {
if (packageInfo != null && packageInfo.applicationInfo?.isSystemApp == true) {
// System app still exists after uninstalling the updates, refresh the page.
reloadPackageInfo()
} else {