New countryIfOriginLabel

And display this label as fallback when Regulatory Image is missing.

Bug: 329378943
Test: manual - on SIMs
Test: unit test
Change-Id: I0b8851da20face9ca444b3e6456a4a662b944b65
This commit is contained in:
Chaohui Wang
2024-03-15 13:32:23 +08:00
parent 67bfb4141f
commit 87318b10cd
10 changed files with 46 additions and 56 deletions

View File

@@ -23,6 +23,7 @@ import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.app.AlertDialog
import com.android.settings.deviceinfo.regulatory.RegulatoryInfo.getRegulatoryInfo
import com.android.settings.overlay.FeatureFactory.Companion.featureFactory
/**
* [Activity] that displays regulatory information for the "Regulatory information"
@@ -53,8 +54,8 @@ class RegulatoryInfoDisplayActivity : Activity() {
return
}
val regulatoryText = resources.getText(R.string.regulatory_info_text)
if (regulatoryText.isNotEmpty()) {
val regulatoryText = getRegulatoryText()
if (!regulatoryText.isNullOrEmpty()) {
builder.setMessage(regulatoryText)
val dialog = builder.show()
// we have to show the dialog first, or the setGravity() call will throw a NPE
@@ -64,4 +65,10 @@ class RegulatoryInfoDisplayActivity : Activity() {
finish()
}
}
private fun getRegulatoryText(): CharSequence? {
val regulatoryInfoText = resources.getText(R.string.regulatory_info_text)
if (regulatoryInfoText.isNotBlank()) return regulatoryInfoText
return featureFactory.hardwareInfoFeatureProvider?.countryIfOriginLabel
}
}