|
|
@ -40,6 +40,7 @@ class MainActivity : AppCompatActivity() {
|
|
|
|
private val TAG = "AICEmu"
|
|
|
|
private val TAG = "AICEmu"
|
|
|
|
private var showCardID: Boolean = false
|
|
|
|
private var showCardID: Boolean = false
|
|
|
|
private var compatibleID: Boolean = false
|
|
|
|
private var compatibleID: Boolean = false
|
|
|
|
|
|
|
|
private var currentCardId: Int = -1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
@ -93,6 +94,8 @@ class MainActivity : AppCompatActivity() {
|
|
|
|
"moe.tqlwsl.aicemu",
|
|
|
|
"moe.tqlwsl.aicemu",
|
|
|
|
"moe.tqlwsl.aicemu.EmuCard"
|
|
|
|
"moe.tqlwsl.aicemu.EmuCard"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
emuCurrentCard()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
override fun onResume() {
|
|
|
|
override fun onResume() {
|
|
|
@ -101,6 +104,7 @@ class MainActivity : AppCompatActivity() {
|
|
|
|
nfcAdapter?.enableForegroundDispatch(this, nfcPendingIntent, null, null)
|
|
|
|
nfcAdapter?.enableForegroundDispatch(this, nfcPendingIntent, null, null)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nfcFCardEmulation?.enableService(this, nfcFComponentName)
|
|
|
|
nfcFCardEmulation?.enableService(this, nfcFComponentName)
|
|
|
|
|
|
|
|
emuCurrentCard()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
override fun onPause() {
|
|
|
|
override fun onPause() {
|
|
|
@ -144,6 +148,7 @@ class MainActivity : AppCompatActivity() {
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
R.string.compatible_on
|
|
|
|
R.string.compatible_on
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
emuCurrentCard()
|
|
|
|
true
|
|
|
|
true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
R.id.toolbar_menu_settings -> {
|
|
|
|
R.id.toolbar_menu_settings -> {
|
|
|
@ -210,8 +215,6 @@ class MainActivity : AppCompatActivity() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun setIDm(idm: String): Boolean {
|
|
|
|
private fun setIDm(idm: String): Boolean {
|
|
|
|
nfcFCardEmulation?.disableService(this)
|
|
|
|
nfcFCardEmulation?.disableService(this)
|
|
|
|
val resultIdm = nfcFCardEmulation?.setNfcid2ForService(nfcFComponentName, idm)
|
|
|
|
val resultIdm = nfcFCardEmulation?.setNfcid2ForService(nfcFComponentName, idm)
|
|
|
@ -226,10 +229,37 @@ class MainActivity : AppCompatActivity() {
|
|
|
|
return resultSys == true
|
|
|
|
return resultSys == true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private fun emuCard(cardView: View) {
|
|
|
|
private fun emuCurrentCard() {
|
|
|
|
val globalVar = this.applicationContext as GlobalVar
|
|
|
|
if (currentCardId != -1) {
|
|
|
|
|
|
|
|
val cardsLayout: ViewGroup = findViewById(R.id.mainList)
|
|
|
|
|
|
|
|
val currentCard = cardsLayout.getChildAt(currentCardId)
|
|
|
|
|
|
|
|
emuCardview(currentCard)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun emuCardview(cardView: View) {
|
|
|
|
val cardIDmTextView = cardView.findViewById<TextView>(R.id.card_id)
|
|
|
|
val cardIDmTextView = cardView.findViewById<TextView>(R.id.card_id)
|
|
|
|
globalVar.IDm = cardIDmTextView.text.toString()
|
|
|
|
val cardNameTextView = cardView.findViewById<TextView>(R.id.card_name)
|
|
|
|
|
|
|
|
emuCard(cardIDmTextView.text.toString(), cardNameTextView.text.toString())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val mainLayout: ViewGroup = findViewById(R.id.mainList)
|
|
|
|
|
|
|
|
for (i in 0 until mainLayout.childCount) {
|
|
|
|
|
|
|
|
val child = mainLayout.getChildAt(i)
|
|
|
|
|
|
|
|
if (child is CardView) {
|
|
|
|
|
|
|
|
val emuMark: ImageButton = child.findViewById(R.id.card_emu_mark_on)
|
|
|
|
|
|
|
|
emuMark.visibility = View.GONE
|
|
|
|
|
|
|
|
if (child == cardView) {
|
|
|
|
|
|
|
|
currentCardId = i
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
val emuMark: ImageButton = cardView.findViewById(R.id.card_emu_mark_on)
|
|
|
|
|
|
|
|
emuMark.visibility = View.VISIBLE
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun emuCard(cardId: String, cardName: String) {
|
|
|
|
|
|
|
|
val globalVar = this.applicationContext as GlobalVar
|
|
|
|
|
|
|
|
globalVar.IDm = cardId
|
|
|
|
var resultIdm = if (compatibleID) {
|
|
|
|
var resultIdm = if (compatibleID) {
|
|
|
|
// hardcoded idm for specific model e.g. Samsung S8
|
|
|
|
// hardcoded idm for specific model e.g. Samsung S8
|
|
|
|
// idm needs to start with 02, or syscode won't be added to polling ack
|
|
|
|
// idm needs to start with 02, or syscode won't be added to polling ack
|
|
|
@ -242,8 +272,6 @@ class MainActivity : AppCompatActivity() {
|
|
|
|
val resultSys = setSys("88B4") // hardcoded syscode for sbga
|
|
|
|
val resultSys = setSys("88B4") // hardcoded syscode for sbga
|
|
|
|
globalVar.isHCEFUnlocked = resultSys
|
|
|
|
globalVar.isHCEFUnlocked = resultSys
|
|
|
|
|
|
|
|
|
|
|
|
val cardNameTextView = cardView.findViewById<TextView>(R.id.card_name)
|
|
|
|
|
|
|
|
val cardName = cardNameTextView.text
|
|
|
|
|
|
|
|
if (!resultIdm) {
|
|
|
|
if (!resultIdm) {
|
|
|
|
Toast.makeText(applicationContext, "Error IDm", Toast.LENGTH_LONG).show()
|
|
|
|
Toast.makeText(applicationContext, "Error IDm", Toast.LENGTH_LONG).show()
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -251,7 +279,7 @@ class MainActivity : AppCompatActivity() {
|
|
|
|
Toast.makeText(applicationContext, "Error Sys", Toast.LENGTH_LONG).show()
|
|
|
|
Toast.makeText(applicationContext, "Error Sys", Toast.LENGTH_LONG).show()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (resultIdm && resultSys) {
|
|
|
|
if (resultIdm && resultSys) {
|
|
|
|
Toast.makeText(applicationContext, "正在模拟$cardName...", Toast.LENGTH_LONG).show()
|
|
|
|
Toast.makeText(applicationContext, "正在模拟 $cardName...", Toast.LENGTH_LONG).show()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -270,10 +298,13 @@ class MainActivity : AppCompatActivity() {
|
|
|
|
menuButton.setOnClickListener {
|
|
|
|
menuButton.setOnClickListener {
|
|
|
|
showCardMenu(it, cardView)
|
|
|
|
showCardMenu(it, cardView)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
val emuButton: ImageButton = cardView.findViewById(R.id.card_emu_mark)
|
|
|
|
|
|
|
|
emuButton.setOnClickListener {
|
|
|
|
|
|
|
|
emuCardview(cardView)
|
|
|
|
|
|
|
|
}
|
|
|
|
cardView.setOnTouchListener { v, _ ->
|
|
|
|
cardView.setOnTouchListener { v, _ ->
|
|
|
|
val editText = v.findViewById<EditText>(R.id.card_name_edit)
|
|
|
|
val editText = v.findViewById<EditText>(R.id.card_name_edit)
|
|
|
|
editText.clearFocus()
|
|
|
|
editText.clearFocus()
|
|
|
|
emuCard(v)
|
|
|
|
|
|
|
|
v.performClick()
|
|
|
|
v.performClick()
|
|
|
|
true
|
|
|
|
true
|
|
|
|
}
|
|
|
|
}
|
|
|
|