WIP: feat: supports for google euicc partner customization #200
3 changed files with 67 additions and 0 deletions
|
@ -63,4 +63,9 @@
|
|||
</service>
|
||||
</application>
|
||||
|
||||
<queries>
|
||||
<intent>
|
||||
<action android:name="com.google.android.euicc.action.PARTNER_CUSTOMIZATION" />
|
||||
</intent>
|
||||
</queries>
|
||||
</manifest>
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.annotation.SuppressLint
|
|||
import android.os.Bundle
|
||||
import android.telephony.TelephonyManager
|
||||
import android.telephony.UiccSlotMapping
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
|
@ -45,6 +46,10 @@ class SlotMappingFragment: BaseMaterialDialogFragment(),
|
|||
private lateinit var adapter: SlotMappingAdapter
|
||||
private lateinit var helpTextView: TextView
|
||||
|
||||
private val partner: Partner? by lazy {
|
||||
Partner.getInstance(requireContext())
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
|
@ -67,6 +72,12 @@ class SlotMappingFragment: BaseMaterialDialogFragment(),
|
|||
toolbar.setOnMenuItemClickListener(this)
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
val mappings = partner?.getString("sim_slot_mappings_json")
|
||||
Log.e(TAG, "sim_slot_mappings_json = $mappings")
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
setWidthPercent(85)
|
||||
|
|
51
app/src/main/java/im/angry/openeuicc/util/Partner.kt
Normal file
51
app/src/main/java/im/angry/openeuicc/util/Partner.kt
Normal file
|
@ -0,0 +1,51 @@
|
|||
package im.angry.openeuicc.util
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.content.res.Resources
|
||||
import im.angry.openeuicc.BuildConfig
|
||||
|
||||
|
||||
class Partner {
|
||||
companion object {
|
||||
private const val ACTION = "com.google.android.euicc.action.PARTNER_CUSTOMIZATION"
|
||||
|
||||
private val instances = mutableMapOf<String, Partner?>()
|
||||
|
||||
private val packageFlags: Int
|
||||
get() {
|
||||
val flags = if (BuildConfig.DEBUG)
|
||||
PackageManager.MATCH_UNINSTALLED_PACKAGES else
|
||||
PackageManager.MATCH_SYSTEM_ONLY
|
||||
return flags or PackageManager.MATCH_DISABLED_COMPONENTS
|
||||
}
|
||||
|
||||
fun getInstance(context: Context, action: String = ACTION) = instances.getOrPut(action) {
|
||||
context.packageManager
|
||||
.queryBroadcastReceivers(Intent(action), packageFlags)
|
||||
.mapNotNull { it.activityInfo?.applicationInfo }
|
||||
.firstNotNullOfOrNull {
|
||||
try {
|
||||
context.packageManager.getResourcesForApplication(it)
|
||||
} catch (_: PackageManager.NameNotFoundException) {
|
||||
null
|
||||
}
|
||||
}
|
||||
?.let(::Partner)
|
||||
}
|
||||
}
|
||||
|
||||
private val resources: Resources
|
||||
|
||||
private constructor(resources: Resources) {
|
||||
this.resources = resources
|
||||
}
|
||||
|
||||
private fun getIdentifier(name: String) =
|
||||
resources.getIdentifier(name, null, null).takeIf { it != 0 }
|
||||
|
||||
fun getString(name: String) = getIdentifier(name)?.let(resources::getString)
|
||||
|
||||
fun getBoolean(name: String) = getIdentifier(name)?.let(resources::getBoolean)
|
||||
}
|
Loading…
Add table
Reference in a new issue