از 27 مارس 2025، توصیه می کنیم از android-latest-release
به جای aosp-main
برای ساختن و کمک به AOSP استفاده کنید. برای اطلاعات بیشتر، به تغییرات AOSP مراجعه کنید.
NFC ایمن
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
اندروید از شبیه سازی کارت خارج از میزبان پشتیبانی می کند که به معنای شبیه سازی کارت NFC با یک عنصر امن است. برای اطلاعات بیشتر، نمای کلی شبیهسازی کارت مبتنی بر میزبان را ببینید.
در موارد استفاده خاص مانند استفاده از FeliCa برای حمل و نقل، شبیهسازی کارت خارج از میزبان زمانی که صفحه دستگاه قفل یا خاموش است، یا زمانی که دستگاهی خاموش است مجاز است.
Secure NFC ویژگی معرفی شده در اندروید 10 است که به شبیه سازی کارت NFC خارج از میزبان اجازه می دهد تنها زمانی که صفحه نمایش دستگاه باز است فعال شود. اجرای این ویژگی به کاربران امکان فعال کردن Secure NFC را برای بهبود امنیت می دهد.
پیاده سازی
برای پیاده سازی ویژگی Secure NFC، دستگاه باید دارای یک کنترلر NFC باشد که از استاندارد NCI 2.0 پشتیبانی می کند و باید از چارچوب NFC پروژه منبع باز Android (AOSP) استفاده کند. سخت افزار ( ro.boot.hardware.sku
) را که از ویژگی Secure NFC پشتیبانی می کند در فایل XML منبع NFC با ویژگی config_skuSupportsSecureNfc
اضافه کنید.
APIهای چارچوب
برای پیادهسازی Secure NFC، APIهای چارچوب زیر را که در پروژه منبع باز Android یافت میشوند، پیادهسازی کنید:
تنظیمات UI
در برنامه تنظیمات، یک سوئیچ جابجایی اضافه کنید تا به کاربران اجازه دهید قابلیت Secure NFC را فعال و غیرفعال کنند. می توانید تنظیمات پیش فرض را در برنامه تنظیمات سفارشی کنید تا فعال یا غیرفعال شود.
شکل 1 نمونه ای از سوئیچ جابجایی را برای فعال و غیرفعال کردن Secure NFC در برنامه تنظیمات در تنظیمات > دستگاه های متصل > تنظیمات برگزیده اتصال > NFC > نیاز به باز کردن قفل دستگاه برای NFC نشان می دهد.

شکل 1. نمونه سوئیچ برای فعال و غیرفعال کردن Secure NFC
هنگامی که Secure NFC فعال است و کاربر دستگاه را روی یک خواننده NFC قرار می دهد، Android همانگونه که در شکل 2 نشان داده شده است ، باز کردن قفل را برای استفاده از اعلان NFC در صفحه قفل نمایش می دهد.

شکل 2. برای استفاده از اعلان NFC در صفحه قفل، قفل را باز کنید
اعتبار سنجی
برای تأیید اعتبار پیاده سازی خود، ویژگی Secure NFC را فعال کنید و بررسی کنید که شبیه سازی کارت NFC زمانی که صفحه دستگاه خاموش یا قفل است و هنگامی که دستگاه خاموش است غیرفعال باشد.
محتوا و نمونه کدها در این صفحه مشمول پروانههای توصیفشده در پروانه محتوا هستند. جاوا و OpenJDK علامتهای تجاری یا علامتهای تجاری ثبتشده Oracle و/یا وابستههای آن هستند.
تاریخ آخرین بهروزرسانی 2025-07-29 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","easyToUnderstand","thumb-up"],["مشکلم را برطرف کرد","solvedMyProblem","thumb-up"],["غیره","otherUp","thumb-up"]],[["اطلاعاتی که نیاز دارم وجود ندارد","missingTheInformationINeed","thumb-down"],["بیشازحد پیچیده/ مراحل بسیار زیاد","tooComplicatedTooManySteps","thumb-down"],["قدیمی","outOfDate","thumb-down"],["مشکل ترجمه","translationIssue","thumb-down"],["مشکل کد / نمونهها","samplesCodeIssue","thumb-down"],["غیره","otherDown","thumb-down"]],["تاریخ آخرین بهروزرسانی 2025-07-29 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# Secure NFC\n\nAndroid supports off-host card emulation, which means\nNFC card emulation with a secure element. For more information, see\n[Host-based card emulation overview](https://developer.android.com/guide/topics/connectivity/nfc/hce).\n\nIn certain use cases such as using\n[FeliCa](https://en.wikipedia.org/wiki/FeliCa)\nfor transit, off-host card\nemulation is permitted when a device's screen is locked or turned off, or\nwhen a device is turned off.\n\nSecure NFC is a feature introduced in Android 10\nthat allows off-host NFC card\nemulation to be enabled only when the device's screen is unlocked. Implementing\nthis feature gives users the option to enable Secure NFC for\nimproved security.\n\nImplementation\n--------------\n\nTo implement the Secure NFC feature, the device must have an NFC controller that\nsupports the NCI 2.0 standard and must use the Android Open Source Project\n(AOSP) NFC framework. Add the hardware (`ro.boot.hardware.sku`) that supports\nthe Secure NFC feature in the NFC\n[resource XML file](https://android.googlesource.com/platform/packages/apps/Nfc/+/refs/heads/android16-release/res/values/config.xml)\nwith the `config_skuSupportsSecureNfc` attribute.\n\n### Framework APIs\n\nTo implement Secure NFC, implement the following framework APIs found in the\nAndroid Open Source Project:\n\n- [`isSecureNfcSupported()`](https://developer.android.com/reference/android/nfc/NfcAdapter#isSecureNfcSupported()): Checks if the device supports the Secure NFC feature.\n- [`isSecureNfcEnabled()`](https://developer.android.com/reference/android/nfc/NfcAdapter#isSecureNfcEnabled()): Checks if the Secure NFC feature is enabled.\n- [`enableSecureNfc(boolean enable)`](https://android.googlesource.com/platform/frameworks/base/+/refs/heads/android16-release/core/java/android/nfc/NfcAdapter.java#1722): Enables the Secure NFC feature.\n\n### Settings UI\n\nIn the Settings application, add a toggle switch to allow users to enable and\ndisable the Secure NFC feature. You can customize the default setting in the\nSettings application to be either enabled or disabled.\n\nFigure 1 shows an example of a toggle switch to enable and disable Secure NFC\nin the Settings app in **Settings \\\u003e Connected devices \\\u003e\nConnection preferences \\\u003e NFC \\\u003e Require device unlock for NFC**.\n\n**Figure 1.** Example toggle switch to enable and disable Secure NFC\n\nWhen Secure NFC is enabled and a user places the device on an NFC reader,\nAndroid displays the **Unlock to use NFC** notification on the lock screen\nas shown in Figure 2.\n\n**Figure 2.** Unlock to use NFC notification on the lock screen\n\nValidation\n----------\n\nTo validate your implementation, enable the Secure NFC feature and verify that\nNFC card emulation is disabled when the device's screen is off or locked, and\nwhen the device is turned off."]]