Skip to content

Commit

Permalink
update UI
Browse files Browse the repository at this point in the history
  • Loading branch information
cinit committed Dec 29, 2021
1 parent 9cc111f commit be22cb5
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,15 @@ public boolean attachToHalService() throws IOException {
if (daemon != null) {
if (!daemon.isHwServiceConnected()) {
INciHostDaemon.DaemonStatus status = daemon.getDaemonStatus();
if (status.halServiceArch > 0) {
File patchFile = NativeInterface.getNfcHalServicePatchFile(
NativeInterface.NfcHalServicePatch.NXP_PATCH,
status.halServiceArch);
return daemon.initHwServiceConnection(patchFile.getAbsolutePath());
if (status.nfcHalServiceStatus.halServiceArch > 0 && status.esePmServiceStatus.halServiceArch > 0) {
File nxpNfcPatchFile = NativeInterface.getNfcHalServicePatchFile(
NativeInterface.NfcHalServicePatch.NXP_NFC_HAL_PATCH,
status.nfcHalServiceStatus.halServiceArch);
File qtiEsePatchFile = NativeInterface.getNfcHalServicePatchFile(
NativeInterface.NfcHalServicePatch.QTI_ESE_PM_PATCH,
status.esePmServiceStatus.halServiceArch);
return daemon.initHwServiceConnection(new String[]{nxpNfcPatchFile.getAbsolutePath(),
qtiEsePatchFile.getAbsolutePath()});
} else {
throw new IOException("Device is not running NFC HAL service, or device is not supported");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package cc.ioctl.nfcdevicehost.activity;

import android.annotation.SuppressLint;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Path;
Expand Down Expand Up @@ -35,7 +36,7 @@ protected boolean doOnCreate(@Nullable Bundle savedInstanceState) {

public void onGenBtnClick(View view) throws IOException, NoSuchFieldException, IllegalAccessException {
AdaptiveIconDrawable iconDrawable = (AdaptiveIconDrawable) getDrawable(R.mipmap.ic_launcher);
Field fMaks = AdaptiveIconDrawable.class.getDeclaredField("sMask");
@SuppressLint("SoonBlockedPrivateApi") Field fMaks = AdaptiveIconDrawable.class.getDeclaredField("sMask");
fMaks.setAccessible(true);
Path path = new Path();
path.addRoundRect(0, 0, 100, 100, 18, 18, Path.Direction.CW);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ protected boolean shouldRetainActivitySavedInstanceState() {
@Override
@Deprecated
protected void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {
super.onRestoreInstanceState(shouldRetainActivitySavedInstanceState() ? savedInstanceState : null);
if (!shouldRetainActivitySavedInstanceState()) {
return;
}
if (!this.mIsInitializing) {
doOnRestoreInstanceState(savedInstanceState);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ class HomeFragment : Fragment() {
mBinding.homeLinearLayoutOperationC.visibility = View.GONE
} else {
// daemon is running
if (status.isHalServiceAttached) {
if (status.nfcHalServiceStatus.isHalServiceAttached
&& status.esePmServiceStatus.isHalServiceAttached
) {
// HAL attached
mBinding.homeMainStatusTitle.text = getString(R.string.status_general_running_ok)
mBinding.homeMainStatusDesc.text = getString(R.string.status_hal_service_attached)
Expand All @@ -147,10 +149,16 @@ class HomeFragment : Fragment() {
R.drawable.bg_green_solid,
null
)
mBinding.homeDetailInfoDesc.text = "HAL Service: ${status.halServicePid}" +
" | Daemon: ${status.processId}"
mBinding.homeDetailInfoDesc.text =
"NFC HAL: ${status.nfcHalServiceStatus?.halServicePid}" +
" | eSE PM: ${status.esePmServiceStatus?.halServicePid}" +
" | Daemon: ${status.processId}"
mBinding.homeDetailInfoDetailMsg.text =
status.halServiceExePath?.substringAfterLast("/") ?: "<unknown>"
(status.nfcHalServiceStatus?.halServiceExePath?.substringAfterLast("/")
?: "<unknown>") +
"\n" +
(status.esePmServiceStatus?.halServiceExePath?.substringAfterLast("/")
?: "<unknown>")
mBinding.homeOperationsHints.text = getString(R.string.ui_home_no_operation_needed)
mBinding.homeOperationsHintDetails.text =
getString(R.string.ui_home_restart_hal_service_if_needed)
Expand All @@ -174,16 +182,28 @@ class HomeFragment : Fragment() {
R.drawable.bg_yellow_solid,
null
)
if (status.halServicePid > 0) {
if (status.nfcHalServiceStatus.halServicePid > 0 || status.esePmServiceStatus.halServicePid > 0) {
// found HAL service
mBinding.homeDetailInfoDesc.text = String.format(
Locale.ROOT,
"HAL service PID: %d, %s",
status.halServicePid,
NativeUtils.archIntToAndroidLibArch(status.halServiceArch)
"NFC HAL: %d, %s | eSE PM: %d, %s",
status.nfcHalServiceStatus?.halServicePid,
if ((status.nfcHalServiceStatus?.halServicePid ?: -1) > 0)
status.nfcHalServiceStatus?.halServiceArch?.let {
NativeUtils.archIntToAndroidLibArch(it)
} else "N/A",
status.esePmServiceStatus?.halServicePid,
if ((status.esePmServiceStatus?.halServicePid ?: -1) > 0)
status.esePmServiceStatus?.halServiceArch?.let {
NativeUtils.archIntToAndroidLibArch(it)
} else "N/A"
)
mBinding.homeDetailInfoDetailMsg.text =
status.halServiceExePath.toString().substringAfterLast("/")
status.nfcHalServiceStatus?.halServiceExePath.toString()
.substringAfterLast("/") +
"\n" +
status.esePmServiceStatus?.halServiceExePath.toString()
.substringAfterLast("/")
} else {
// unable to find HAL service
mBinding.homeDetailInfoDesc.text =
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="nav_header_desc">侧滑道航</string>
<string name="initializing">正在初始化…</string>
<string name="text_warn_app_risk">NCI Host 使用 root 权限直接与您的 NFC 驱动程序进行通信,如果使用不当,可能会损坏您的系统以及 NFC 硬件。\
NCI Host 的开发人员不对使用此应用程序造成的任何损失负责。如果您不完全了解此应用程序的工作原理,那么您可能不应该使用此应用程序,直到您完全了解风险。\
Expand Down Expand Up @@ -55,14 +56,14 @@ NCI Host 的开发人员不对使用此应用程序造成的任何损失负责
<string name="ui_dialog_error_title">错误</string>
<string name="ui_toast_no_data_to_save">无数据…</string>
<string name="ui_toast_data_saved">已保存</string>
<string name="ui_toast_operation_canceled">Canceled.</string>
<string name="ui_toast_operation_canceled">已取消</string>
<string name="intent_label_view_hal_dump">查看 HAL 转储</string>
<string name="ui_dialog_unable_to_open_file_v0s">无法打开文件: %s</string>
<string name="ui_title_main_dump">HAL Dump</string>
<string name="ui_title_main_dump">HAL 转储</string>
<string name="action_view_dump_file">浏览转储文件</string>
<string name="ui_dialog_title_requesting_root">请求 root 权限</string>
<string name="ui_dialog_msg_body_requesting_root">正在请求 root 权限,请授予本应用 root 权限</string>
<string name="label_nav_main_dump_file">HAL Dump File</string>
<string name="label_nav_main_dump_file">HAL 转储</string>
<string name="action_close">关闭</string>
<string name="action_submit">提交</string>
<string name="ui_toast_operation_success_v0d">操作成功: %d</string>
Expand Down
10 changes: 8 additions & 2 deletions app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
<item>SN100/SN110(JCOP5.1)</item>
<item>NQ330/NQ310</item>
<item>NQ220/NQ210</item>
<item>PN71xx(none)</item>
<item>PN80T/PN81T</item>
<item>PN66T/PN54xC2</item>
<item>PN553/PN557</item>
<item>PN71xx(none)</item>
<item>PN53x(none)</item>
<item>Proxmark3 SERIAL OTG</item>
<item>Proxmark3 HID OTG</item>
<item>PN532 SERIAL OTG</item>
<item>Other NCI device</item>
<item>Other non-NCI device</item>
</string-array>
Expand All @@ -18,11 +21,14 @@
<item>sn1xx</item>
<item>nq3xx</item>
<item>nq2xx</item>
<item>pn71xx</item>
<item>pn80t</item>
<item>pn66t</item>
<item>pn55x</item>
<item>pn71xx</item>
<item>pn53x</item>
<item>proxmark3_otg_serial</item>
<item>proxmark3_otg_hid</item>
<item>pn532_otg_serial</item>
<item>generic_nci</item>
<item>unknown</item>
</string-array>
Expand Down
15 changes: 5 additions & 10 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
<resources>
<string name="app_name" translatable="false">NCI Host</string>
<string name="title_activity_dashboard">DashboardActivity</string>
<string name="navigation_drawer_open">Open navigation drawer</string>
<string name="navigation_drawer_close">Close navigation drawer</string>
<string name="nav_header_title">NFC Device Host</string>
<string name="nav_header_subtitle">Freedom of 13.56MHz</string>
<string name="nav_header_title" translatable="false">NFC Device Host</string>
<string name="nav_header_subtitle" translatable="false">Freedom of 13.56MHz</string>
<string name="nav_header_desc">Navigation header</string>
<string name="action_settings">Settings</string>

<string name="menu_fragment_home">Home</string>
<string name="menu_fragment_dump">NCI Dump</string>
<string name="menu_fragment_cards">Cards</string>
<string name="title_activity_settings">SettingsActivity</string>
<string name="menu_fragment_home" translatable="false">Home</string>
<string name="menu_fragment_dump" translatable="false">HAL Dump</string>
<string name="menu_fragment_cards" translatable="false">Cards</string>
<string name="initializing">Initializing…</string>
<string name="title_warning">Warning</string>
<string name="btn_continue">Continue</string>
Expand Down

0 comments on commit be22cb5

Please sign in to comment.