add HCEF and Unlocker status in setting

master
wlt233 2 years ago
parent b82dcdf122
commit 60224d6613

@ -42,9 +42,11 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.1.3' implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.navigation:navigation-fragment-ktx:2.4.1' implementation 'androidx.navigation:navigation-fragment-ktx:2.4.1'
implementation 'androidx.navigation:navigation-ui-ktx:2.4.1' implementation 'androidx.navigation:navigation-ui-ktx:2.4.1'
implementation 'androidx.preference:preference:1.2.0'
testImplementation 'junit:junit:4.13.2' testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.google.code.gson:gson:2.8.9' implementation 'com.google.code.gson:gson:2.8.9'
compileOnly 'de.robv.android.xposed:api:82' compileOnly 'de.robv.android.xposed:api:82'
implementation 'org.lsposed.hiddenapibypass:hiddenapibypass:4.3'
} }

@ -1,11 +1,12 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"> xmlns:tools="http://schemas.android.com/tools" >
<uses-permission android:name="android.permission.NFC" /> <uses-permission android:name="android.permission.NFC" />
<uses-permission android:name="android.permission.NFC_TRANSACTION_EVENT" /> <uses-permission android:name="android.permission.NFC_TRANSACTION_EVENT" />
<application <application
android:name=".GlobalVar"
android:allowBackup="true" android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules" android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules" android:fullBackupContent="@xml/backup_rules"
@ -13,28 +14,45 @@
android:label="@string/app_name" android:label="@string/app_name"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.AICEmu" android:theme="@style/Theme.AICEmu"
android:name=".GlobalVar" tools:targetApi="31" >
tools:targetApi="31">
<meta-data
android:name="xposedmodule"
android:value="true" />
<meta-data
android:name="xposedminversion"
android:value="30" />
<meta-data
android:name="xposeddescription"
android:value="Emulate every AIC Card" />
<meta-data
android:name="xposedscope"
android:resource="@array/xposed_scope" />
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:exported="true" android:exported="true"
android:theme="@style/Theme.AICEmu"> android:theme="@style/Theme.AICEmu" >
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name=".ReadCard" <activity
android:name=".ReadCard"
android:theme="@style/CardActivityTheme" /> android:theme="@style/CardActivityTheme" />
<activity
android:name=".SettingActivity"
android:exported="false"
android:label="@string/title_activity_setting"
android:theme="@style/Theme.AICEmuActionBar" />
<service <service
android:name=".EmuCard" android:name=".EmuCard"
android:exported="true" android:exported="true"
android:permission="android.permission.BIND_NFC_SERVICE"> android:permission="android.permission.BIND_NFC_SERVICE" >
<intent-filter> <intent-filter>
<action android:name="android.nfc.cardemulation.action.HOST_NFCF_SERVICE" /> <action android:name="android.nfc.cardemulation.action.HOST_NFCF_SERVICE" />
</intent-filter> </intent-filter>
@ -43,16 +61,5 @@
android:resource="@xml/host_nfcf_service" /> android:resource="@xml/host_nfcf_service" />
</service> </service>
<meta-data
android:name="xposedmodule"
android:value="true" />
<meta-data
android:name="xposedminversion"
android:value="30" />
<meta-data
android:name="xposeddescription"
android:value="Emulate every AIC Card" />
</application> </application>
</manifest> </manifest>

@ -4,4 +4,5 @@ import android.app.Application
class GlobalVar : Application() { class GlobalVar : Application() {
var IDm: String = "02fe000000000000" var IDm: String = "02fe000000000000"
var isHCEFUnlocked: Boolean = false
} }

@ -148,7 +148,8 @@ class MainActivity : AppCompatActivity() {
} }
R.id.toolbar_menu_settings -> { R.id.toolbar_menu_settings -> {
Toast.makeText(applicationContext, "还没做()\nUnder constuction...", Toast.LENGTH_LONG).show() Toast.makeText(applicationContext, "还没做()\nUnder constuction...", Toast.LENGTH_LONG).show()
// TODO val settingIntent = Intent(this, SettingActivity::class.java)
startActivity(settingIntent)
true true
} }
else -> super.onOptionsItemSelected(item) else -> super.onOptionsItemSelected(item)
@ -239,6 +240,7 @@ class MainActivity : AppCompatActivity() {
setIDm(globalVar.IDm) setIDm(globalVar.IDm)
} }
val resultSys = setSys("88B4") // hardcoded syscode for sbga val resultSys = setSys("88B4") // hardcoded syscode for sbga
globalVar.isHCEFUnlocked = resultSys
val cardNameTextView = cardView.findViewById<TextView>(R.id.card_name) val cardNameTextView = cardView.findViewById<TextView>(R.id.card_name)
val cardName = cardNameTextView.text val cardName = cardNameTextView.text

@ -0,0 +1,67 @@
package moe.tqlwsl.aicemu
import android.annotation.SuppressLint
import android.content.pm.PackageManager
import android.graphics.Color
import android.os.Build
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.widget.TextView
import org.lsposed.hiddenapibypass.HiddenApiBypass
class SettingActivity : AppCompatActivity() {
private var isHCEFSupported: Boolean = false
private var isHCEFUnlocked: Boolean = false
val TAG: String = "AICEmu"
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_setting)
isHCEFSupported =
packageManager.hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION_NFCF)
Log.d(TAG, "isHCEFSupported:$isHCEFSupported")
val textHCEF = findViewById<TextView>(R.id.hcef_support_text)
if (isHCEFSupported) {
textHCEF.setText(R.string.HCEF_support_true)
textHCEF.setTextColor(Color.GREEN)
} else {
textHCEF.setText(R.string.HCEF_support_false)
textHCEF.setTextColor(Color.RED)
}
if (isHCEFSupported) {
val textUnlocker = findViewById<TextView>(R.id.unlocker_work_text)
try {
val globalVar = this.applicationContext as GlobalVar
isHCEFUnlocked = globalVar.isHCEFUnlocked
Log.d(TAG, "isHCEFUnlocked:$isHCEFUnlocked")
if (isHCEFUnlocked) {
textUnlocker.setText(R.string.Unlocker_work_true)
textUnlocker.setTextColor(Color.GREEN)
} else {
textUnlocker.setText(R.string.Unlocker_work_false)
textUnlocker.setTextColor(Color.RED)
}
} catch (e: Exception) {
e.printStackTrace()
textUnlocker.setText(R.string.Unlocker_work_error)
}
}
}
companion object {
@SuppressLint("SoonBlockedPrivateApi")
private fun isValidSystemCode(systemCode: String): Boolean {
val clazz = Class.forName("android.nfc.cardemulation.NfcFCardEmulation")
return if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
val method = clazz.getDeclaredMethod("isValidSystemCode", String::class.java)
method.invoke(null, systemCode) as Boolean
} else {
HiddenApiBypass.invoke(clazz, null, "isValidSystemCode", systemCode) as Boolean
}
}
}
}

@ -73,7 +73,7 @@ public class xp implements IXposedHookLoadPackage {
} }
}); });
XposedBridge.log("Hook successed!!!"); XposedBridge.log("Hook succeeded!!!");
} }
} }
} }

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".SettingActivity">
<TextView
android:id="@+id/hcef_support_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:textSize="32sp"
android:text="@string/HCEF_support_false"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/unlocker_work_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:textSize="32sp"
android:text="@string/Unlocker_work_false"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/hcef_support_text" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -2,10 +2,9 @@
<style name="Base.Theme.AICEmu" parent="Theme.Material3.DayNight.NoActionBar"> <style name="Base.Theme.AICEmu" parent="Theme.Material3.DayNight.NoActionBar">
<item name="titleTextColor">#E0E0E0</item> <item name="titleTextColor">#E0E0E0</item>
<item name="subtitleTextColor">#B0B0B0</item> <item name="subtitleTextColor">#B0B0B0</item>
<item name="colorPrimary">#e83948</item> <item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">#98030d</item> <item name="colorPrimaryDark">@color/colorPrimary</item>
<item name="colorSecondary">@color/colorSecondary</item> <item name="colorSecondary">@color/colorSecondary</item>
</style> </style>
</resources> </resources>

@ -1,7 +1,7 @@
<resources> <resources>
<string name="settings">设置</string> <string name="settings">设置</string>
<string name="dummy_card_name">AIC Card</string> <string name="dummy_card_name">AIC Card</string>
<string name="read_card_tip">请与AIC卡贴贴</string> <string name="read_card_tip">请与 AIC 卡贴贴!</string>
<string name="rename">改名</string> <string name="rename">改名</string>
<string name="delete">删除</string> <string name="delete">删除</string>
<string name="show_idm">展示卡号</string> <string name="show_idm">展示卡号</string>
@ -11,4 +11,10 @@
<string name="compatible_off">关闭兼容模式</string> <string name="compatible_off">关闭兼容模式</string>
<string name="nfc_not_on">NFC 没开...</string> <string name="nfc_not_on">NFC 没开...</string>
<string name="nfc_not_supported">设备不支持 NFC...</string> <string name="nfc_not_supported">设备不支持 NFC...</string>
<string name="title_activity_setting">设置</string>
<string name="HCEF_support_false">设备不支持 HCE-F...</string>
<string name="HCEF_support_true">设备支持 HCE-F</string>
<string name="Unlocker_work_true">Unlocker 运行中!</string>
<string name="Unlocker_work_false">Unlocker 没在工作...</string>
<string name="Unlocker_work_error">Unlocker 出错了!</string>
</resources> </resources>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="xposed_scope">
<item>com.android.nfc</item>
</string-array>
</resources>

@ -2,5 +2,7 @@
<resources> <resources>
<color name="black">#FF000000</color> <color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color> <color name="white">#FFFFFFFF</color>
<color name="colorPrimary">#e83948</color>
<color name="colorPrimaryDark">#98030d</color>
<color name="colorSecondary">#e86871</color> <color name="colorSecondary">#e86871</color>
</resources> </resources>

@ -17,4 +17,10 @@
<string name="desc_edit_card" translatable="false">edit card</string> <string name="desc_edit_card" translatable="false">edit card</string>
<string name="desc_close_popup" translatable="false">close</string> <string name="desc_close_popup" translatable="false">close</string>
<string name="desc_service" translatable="false">EmuCard</string> <string name="desc_service" translatable="false">EmuCard</string>
<string name="title_activity_setting">Setting</string>
<string name="HCEF_support_false">HCE-F not supported...</string>
<string name="HCEF_support_true">HCE-F is supported!</string>
<string name="Unlocker_work_true">Unlocker is working!</string>
<string name="Unlocker_work_false">Unlocker not working...</string>
<string name="Unlocker_work_error">Unlocker Error!</string>
</resources> </resources>

@ -2,11 +2,16 @@
<style name="Base.Theme.AICEmu" parent="Theme.Material3.DayNight.NoActionBar"> <style name="Base.Theme.AICEmu" parent="Theme.Material3.DayNight.NoActionBar">
<item name="titleTextColor">#202020</item> <item name="titleTextColor">#202020</item>
<item name="subtitleTextColor">#505050</item> <item name="subtitleTextColor">#505050</item>
<item name="colorPrimary">#e83948</item> <item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">#98030d</item> <item name="colorPrimaryDark">@color/colorPrimary</item>
<item name="colorSecondary">@color/colorSecondary</item> <item name="colorSecondary">@color/colorSecondary</item>
</style> </style>
<style name="Theme.AICEmuActionBar" parent="Theme.AppCompat.DayNight">
<item name="titleTextColor">@color/white</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimary</item>
</style>>
<style name="Theme.AICEmu" parent="Base.Theme.AICEmu" /> <style name="Theme.AICEmu" parent="Base.Theme.AICEmu" />
</resources> </resources>
Loading…
Cancel
Save