treewide: Nullability fixes for AOSP 14 r29
All checks were successful
/ build-debug (push) Successful in 4m48s

Mainly a treewide `findViewById` -> `requireViewById`, with
miscellaneous fixes.
This commit is contained in:
Peter Cai 2024-03-11 18:55:32 -04:00
parent 348395c48d
commit 3a0d805eb2
16 changed files with 58 additions and 58 deletions

View file

@ -58,9 +58,9 @@ open class EuiccManagementFragment : Fragment(), EuiccProfilesChangedListener,
): View { ): View {
val view = inflater.inflate(R.layout.fragment_euicc, container, false) val view = inflater.inflate(R.layout.fragment_euicc, container, false)
swipeRefresh = view.findViewById(R.id.swipe_refresh) swipeRefresh = view.requireViewById(R.id.swipe_refresh)
fab = view.findViewById(R.id.fab) fab = view.requireViewById(R.id.fab)
profileList = view.findViewById(R.id.profile_list) profileList = view.requireViewById(R.id.profile_list)
return view return view
} }
@ -191,11 +191,11 @@ open class EuiccManagementFragment : Fragment(), EuiccProfilesChangedListener,
} }
inner class ProfileViewHolder(private val root: View) : ViewHolder(root) { inner class ProfileViewHolder(private val root: View) : ViewHolder(root) {
private val iccid: TextView = root.findViewById(R.id.iccid) private val iccid: TextView = root.requireViewById(R.id.iccid)
private val name: TextView = root.findViewById(R.id.name) private val name: TextView = root.requireViewById(R.id.name)
private val state: TextView = root.findViewById(R.id.state) private val state: TextView = root.requireViewById(R.id.state)
private val provider: TextView = root.findViewById(R.id.provider) private val provider: TextView = root.requireViewById(R.id.provider)
private val profileMenu: ImageButton = root.findViewById(R.id.profile_menu) private val profileMenu: ImageButton = root.requireViewById(R.id.profile_menu)
init { init {
iccid.setOnClickListener { iccid.setOnClickListener {

View file

@ -39,12 +39,12 @@ class LogsActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_logs) setContentView(R.layout.activity_logs)
setSupportActionBar(findViewById(R.id.toolbar)) setSupportActionBar(requireViewById(R.id.toolbar))
supportActionBar!!.setDisplayHomeAsUpEnabled(true) supportActionBar!!.setDisplayHomeAsUpEnabled(true)
swipeRefresh = findViewById(R.id.swipe_refresh) swipeRefresh = requireViewById(R.id.swipe_refresh)
scrollView = findViewById(R.id.scroll_view) scrollView = requireViewById(R.id.scroll_view)
logText = findViewById(R.id.log_text) logText = requireViewById(R.id.log_text)
swipeRefresh.setOnRefreshListener { swipeRefresh.setOnRefreshListener {
lifecycleScope.launch { lifecycleScope.launch {

View file

@ -36,9 +36,9 @@ open class MainActivity : AppCompatActivity(), OpenEuiccContextMarker {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main) setContentView(R.layout.activity_main)
setSupportActionBar(findViewById(R.id.toolbar)) setSupportActionBar(requireViewById(R.id.toolbar))
noEuiccPlaceholder = findViewById(R.id.no_euicc_placeholder) noEuiccPlaceholder = requireViewById(R.id.no_euicc_placeholder)
tm = telephonyManager tm = telephonyManager

View file

@ -37,14 +37,14 @@ class NotificationsActivity: AppCompatActivity(), OpenEuiccContextMarker {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_notifications) setContentView(R.layout.activity_notifications)
setSupportActionBar(findViewById(R.id.toolbar)) setSupportActionBar(requireViewById(R.id.toolbar))
supportActionBar!!.setDisplayHomeAsUpEnabled(true) supportActionBar!!.setDisplayHomeAsUpEnabled(true)
euiccChannel = euiccChannelManager euiccChannel = euiccChannelManager
.findEuiccChannelBySlotBlocking(intent.getIntExtra("logicalSlotId", 0))!! .findEuiccChannelBySlotBlocking(intent.getIntExtra("logicalSlotId", 0))!!
swipeRefresh = findViewById(R.id.swipe_refresh) swipeRefresh = requireViewById(R.id.swipe_refresh)
notificationList = findViewById(R.id.recycler_view) notificationList = requireViewById(R.id.recycler_view)
notificationList.layoutManager = notificationList.layoutManager =
LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false) LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)
@ -118,8 +118,8 @@ class NotificationsActivity: AppCompatActivity(), OpenEuiccContextMarker {
@SuppressLint("ClickableViewAccessibility") @SuppressLint("ClickableViewAccessibility")
inner class NotificationViewHolder(private val root: View): inner class NotificationViewHolder(private val root: View):
RecyclerView.ViewHolder(root), View.OnCreateContextMenuListener, OnMenuItemClickListener { RecyclerView.ViewHolder(root), View.OnCreateContextMenuListener, OnMenuItemClickListener {
private val address: TextView = root.findViewById(R.id.notification_address) private val address: TextView = root.requireViewById(R.id.notification_address)
private val profileName: TextView = root.findViewById(R.id.notification_profile_name) private val profileName: TextView = root.requireViewById(R.id.notification_profile_name)
private lateinit var notification: LocalProfileNotificationWrapper private lateinit var notification: LocalProfileNotificationWrapper

View file

@ -69,13 +69,13 @@ class ProfileDownloadFragment : BaseMaterialDialogFragment(),
): View { ): View {
val view = inflater.inflate(R.layout.fragment_profile_download, container, false) val view = inflater.inflate(R.layout.fragment_profile_download, container, false)
toolbar = view.findViewById(R.id.toolbar) toolbar = view.requireViewById(R.id.toolbar)
profileDownloadServer = view.findViewById(R.id.profile_download_server) profileDownloadServer = view.requireViewById(R.id.profile_download_server)
profileDownloadCode = view.findViewById(R.id.profile_download_code) profileDownloadCode = view.requireViewById(R.id.profile_download_code)
profileDownloadConfirmationCode = view.findViewById(R.id.profile_download_confirmation_code) profileDownloadConfirmationCode = view.requireViewById(R.id.profile_download_confirmation_code)
profileDownloadIMEI = view.findViewById(R.id.profile_download_imei) profileDownloadIMEI = view.requireViewById(R.id.profile_download_imei)
profileDownloadFreeSpace = view.findViewById(R.id.profile_download_free_space) profileDownloadFreeSpace = view.requireViewById(R.id.profile_download_free_space)
progress = view.findViewById(R.id.progress) progress = view.requireViewById(R.id.progress)
toolbar.inflateMenu(R.menu.fragment_profile_download) toolbar.inflateMenu(R.menu.fragment_profile_download)

View file

@ -46,9 +46,9 @@ class ProfileRenameFragment : BaseMaterialDialogFragment(), EuiccChannelFragment
): View { ): View {
val view = inflater.inflate(R.layout.fragment_profile_rename, container, false) val view = inflater.inflate(R.layout.fragment_profile_rename, container, false)
toolbar = view.findViewById(R.id.toolbar) toolbar = view.requireViewById(R.id.toolbar)
profileRenameNewName = view.findViewById(R.id.profile_rename_new_name) profileRenameNewName = view.requireViewById(R.id.profile_rename_new_name)
progress = view.findViewById(R.id.progress) progress = view.requireViewById(R.id.progress)
toolbar.inflateMenu(R.menu.fragment_profile_rename) toolbar.inflateMenu(R.menu.fragment_profile_rename)

View file

@ -9,7 +9,7 @@ class SettingsActivity: AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_settings) setContentView(R.layout.activity_settings)
setSupportActionBar(findViewById(R.id.toolbar)) setSupportActionBar(requireViewById(R.id.toolbar))
supportActionBar!!.setDisplayHomeAsUpEnabled(true) supportActionBar!!.setDisplayHomeAsUpEnabled(true)
supportFragmentManager.beginTransaction() supportFragmentManager.beginTransaction()
.replace(R.id.settings_container, SettingsFragment()) .replace(R.id.settings_container, SettingsFragment())

View file

@ -39,13 +39,13 @@ class SlotSelectFragment : BaseMaterialDialogFragment(), OpenEuiccContextMarker
): View? { ): View? {
val view = inflater.inflate(R.layout.fragment_slot_select, container, false) val view = inflater.inflate(R.layout.fragment_slot_select, container, false)
toolbar = view.findViewById(R.id.toolbar) toolbar = view.requireViewById(R.id.toolbar)
toolbar.setTitle(R.string.slot_select) toolbar.setTitle(R.string.slot_select)
toolbar.inflateMenu(R.menu.fragment_slot_select) toolbar.inflateMenu(R.menu.fragment_slot_select)
val adapter = ArrayAdapter<String>(inflater.context, R.layout.spinner_item) val adapter = ArrayAdapter<String>(inflater.context, R.layout.spinner_item)
spinner = view.findViewById(R.id.spinner) spinner = view.requireViewById(R.id.spinner)
spinner.adapter = adapter spinner.adapter = adapter
channels.forEach { channel -> channels.forEach { channel ->

View file

@ -18,4 +18,4 @@ class LongSummaryPreferenceCategory: PreferenceCategory {
summaryText.isSingleLine = false summaryText.isSingleLine = false
summaryText.maxLines = 10 summaryText.maxLines = 10
} }
} }

View file

@ -24,7 +24,7 @@ val Context.selfAppVersion: String
get() = get() =
try { try {
val pInfo = packageManager.getPackageInfo(packageName, 0) val pInfo = packageManager.getPackageInfo(packageName, 0)
pInfo.versionName pInfo.versionName!!
} catch (e: PackageManager.NameNotFoundException) { } catch (e: PackageManager.NameNotFoundException) {
throw RuntimeException(e) throw RuntimeException(e)
} }
@ -91,4 +91,4 @@ suspend fun connectSEService(context: Context): SEService = suspendCoroutine { c
} }
} }
} }
} }

View file

@ -24,10 +24,10 @@ class CompatibilityCheckActivity: AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_compatibility_check) setContentView(R.layout.activity_compatibility_check)
setSupportActionBar(findViewById(R.id.toolbar)) setSupportActionBar(requireViewById(R.id.toolbar))
supportActionBar!!.setDisplayHomeAsUpEnabled(true) supportActionBar!!.setDisplayHomeAsUpEnabled(true)
compatibilityCheckList = findViewById(R.id.recycler_view) compatibilityCheckList = requireViewById(R.id.recycler_view)
compatibilityCheckList.layoutManager = compatibilityCheckList.layoutManager =
LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false) LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)
compatibilityCheckList.addItemDecoration(DividerItemDecoration(this, LinearLayoutManager.VERTICAL)) compatibilityCheckList.addItemDecoration(DividerItemDecoration(this, LinearLayoutManager.VERTICAL))
@ -51,9 +51,9 @@ class CompatibilityCheckActivity: AppCompatActivity() {
} }
inner class ViewHolder(private val root: View): RecyclerView.ViewHolder(root) { inner class ViewHolder(private val root: View): RecyclerView.ViewHolder(root) {
private val titleView: TextView = root.findViewById(R.id.compatibility_check_title) private val titleView: TextView = root.requireViewById(R.id.compatibility_check_title)
private val descView: TextView = root.findViewById(R.id.compatibility_check_desc) private val descView: TextView = root.requireViewById(R.id.compatibility_check_desc)
private val statusContainer: ViewGroup = root.findViewById(R.id.compatibility_check_status_container) private val statusContainer: ViewGroup = root.requireViewById(R.id.compatibility_check_status_container)
fun bindItem(item: CompatibilityCheck) { fun bindItem(item: CompatibilityCheck) {
titleView.text = item.title titleView.text = item.title
@ -65,16 +65,16 @@ class CompatibilityCheckActivity: AppCompatActivity() {
when (item.state) { when (item.state) {
CompatibilityCheck.State.SUCCESS -> { CompatibilityCheck.State.SUCCESS -> {
root.findViewById<View>(R.id.compatibility_check_checkmark).visibility = View.VISIBLE root.requireViewById<View>(R.id.compatibility_check_checkmark).visibility = View.VISIBLE
} }
CompatibilityCheck.State.FAILURE -> { CompatibilityCheck.State.FAILURE -> {
root.findViewById<View>(R.id.compatibility_check_error).visibility = View.VISIBLE root.requireViewById<View>(R.id.compatibility_check_error).visibility = View.VISIBLE
} }
CompatibilityCheck.State.FAILURE_UNKNOWN -> { CompatibilityCheck.State.FAILURE_UNKNOWN -> {
root.findViewById<View>(R.id.compatibility_check_unknown).visibility = View.VISIBLE root.requireViewById<View>(R.id.compatibility_check_unknown).visibility = View.VISIBLE
} }
else -> { else -> {
root.findViewById<View>(R.id.compatibility_check_progress_bar).visibility = View.VISIBLE root.requireViewById<View>(R.id.compatibility_check_progress_bar).visibility = View.VISIBLE
} }
} }
} }

View file

@ -104,9 +104,9 @@ class OpenEuiccService : EuiccService(), OpenEuiccContextMarker {
return GetDefaultDownloadableSubscriptionListResult(RESULT_OK, arrayOf()) return GetDefaultDownloadableSubscriptionListResult(RESULT_OK, arrayOf())
} }
override fun onGetEuiccProfileInfoList(slotId: Int): GetEuiccProfileInfoListResult? { override fun onGetEuiccProfileInfoList(slotId: Int): GetEuiccProfileInfoListResult {
Log.i(TAG, "onGetEuiccProfileInfoList slotId=$slotId") Log.i(TAG, "onGetEuiccProfileInfoList slotId=$slotId")
val channel = findChannel(slotId) ?: return null val channel = findChannel(slotId)!!
val profiles = channel.lpa.profiles.operational.map { val profiles = channel.lpa.profiles.operational.map {
EuiccProfileInfo.Builder(it.iccid).apply { EuiccProfileInfo.Builder(it.iccid).apply {
setProfileName(it.name) setProfileName(it.name)
@ -256,4 +256,4 @@ class OpenEuiccService : EuiccService(), OpenEuiccContextMarker {
// No-op -- we do not care // No-op -- we do not care
return RESULT_FIRST_USER return RESULT_FIRST_USER
} }
} }

View file

@ -10,10 +10,10 @@ class LuiActivity : AppCompatActivity() {
super.onStart() super.onStart()
setContentView(R.layout.activity_lui) setContentView(R.layout.activity_lui)
findViewById<View>(R.id.lui_skip).setOnClickListener { finish() } requireViewById<View>(R.id.lui_skip).setOnClickListener { finish() }
// TODO: Deactivate LuiActivity if there is no eSIM found. // TODO: Deactivate LuiActivity if there is no eSIM found.
// TODO: Support pre-filled download info (from carrier apps); UX // TODO: Support pre-filled download info (from carrier apps); UX
findViewById<View>(R.id.lui_download).setOnClickListener { requireViewById<View>(R.id.lui_download).setOnClickListener {
startActivity(Intent(this, DirectProfileDownloadActivity::class.java)) startActivity(Intent(this, DirectProfileDownloadActivity::class.java))
} }
} }

View file

@ -17,7 +17,7 @@ class PrivilegedEuiccManagementFragment: EuiccManagementFragment() {
override suspend fun onCreateFooterViews(parent: ViewGroup): List<View> = override suspend fun onCreateFooterViews(parent: ViewGroup): List<View> =
if (channel.isMEP) { if (channel.isMEP) {
val view = layoutInflater.inflate(R.layout.footer_mep, parent, false) val view = layoutInflater.inflate(R.layout.footer_mep, parent, false)
view.findViewById<Button>(R.id.footer_mep_slot_mapping).setOnClickListener { view.requireViewById<Button>(R.id.footer_mep_slot_mapping).setOnClickListener {
(requireActivity() as PrivilegedMainActivity).showSlotMappingFragment() (requireActivity() as PrivilegedMainActivity).showSlotMappingFragment()
} }
listOf(view) listOf(view)

View file

@ -51,12 +51,12 @@ class SlotMappingFragment: BaseMaterialDialogFragment(),
savedInstanceState: Bundle? savedInstanceState: Bundle?
): View? { ): View? {
val view = inflater.inflate(R.layout.fragment_slot_mapping, container, false) val view = inflater.inflate(R.layout.fragment_slot_mapping, container, false)
toolbar = view.findViewById(R.id.toolbar) toolbar = view.requireViewById(R.id.toolbar)
toolbar.inflateMenu(R.menu.fragment_slot_mapping) toolbar.inflateMenu(R.menu.fragment_slot_mapping)
recyclerView = view.findViewById(R.id.mapping_list) recyclerView = view.requireViewById(R.id.mapping_list)
recyclerView.layoutManager = recyclerView.layoutManager =
LinearLayoutManager(view.context, LinearLayoutManager.VERTICAL, false) LinearLayoutManager(view.context, LinearLayoutManager.VERTICAL, false)
helpTextView = view.findViewById(R.id.mapping_help) helpTextView = view.requireViewById(R.id.mapping_help)
return view return view
} }
@ -148,8 +148,8 @@ class SlotMappingFragment: BaseMaterialDialogFragment(),
} }
inner class ViewHolder(root: View): RecyclerView.ViewHolder(root), OnItemSelectedListener { inner class ViewHolder(root: View): RecyclerView.ViewHolder(root), OnItemSelectedListener {
private val textViewLogicalSlot: TextView = root.findViewById(R.id.slot_mapping_logical_slot) private val textViewLogicalSlot: TextView = root.requireViewById(R.id.slot_mapping_logical_slot)
private val spinnerPorts: Spinner = root.findViewById(R.id.slot_mapping_ports) private val spinnerPorts: Spinner = root.requireViewById(R.id.slot_mapping_ports)
init { init {
spinnerPorts.adapter = ArrayAdapter(requireContext(), im.angry.openeuicc.common.R.layout.spinner_item, portsDesc) spinnerPorts.adapter = ArrayAdapter(requireContext(), im.angry.openeuicc.common.R.layout.spinner_item, portsDesc)

View file

@ -95,9 +95,9 @@ fun TelephonyManager.iccOpenLogicalChannelByPortCompat(
slotIndex: Int, portIndex: Int, aid: String?, p2: Int slotIndex: Int, portIndex: Int, aid: String?, p2: Int
): IccOpenLogicalChannelResponse = ): IccOpenLogicalChannelResponse =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
iccOpenLogicalChannelByPort(slotIndex, portIndex, aid, p2) iccOpenLogicalChannelByPort(slotIndex, portIndex, aid, p2)!!
} else { } else {
iccOpenLogicalChannelBySlot(slotIndex, aid, p2) iccOpenLogicalChannelBySlot(slotIndex, aid, p2)!!
} }
fun TelephonyManager.iccCloseLogicalChannelByPortCompat( fun TelephonyManager.iccCloseLogicalChannelByPortCompat(
@ -121,4 +121,4 @@ fun TelephonyManager.iccTransmitApduLogicalChannelByPortCompat(
iccTransmitApduLogicalChannelBySlot( iccTransmitApduLogicalChannelBySlot(
slotIndex, channel, cla, inst, p1, p2, p3, data slotIndex, channel, cla, inst, p1, p2, p3, data
) )
} }