ตั้งแต่วันที่ 27 มีนาคม 2025 เป็นต้นไป เราขอแนะนำให้ใช้ android-latest-release
แทน aosp-main
เพื่อสร้างและมีส่วนร่วมใน AOSP โปรดดูข้อมูลเพิ่มเติมที่หัวข้อการเปลี่ยนแปลงใน AOSP
รักษาความปลอดภัยของ NFC
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
Android รองรับการจําลองบัตรนอกโฮสต์ ซึ่งหมายถึงการจําลองบัตร NFC ที่มีองค์ประกอบที่ปลอดภัย ดูข้อมูลเพิ่มเติมได้ที่ภาพรวมโปรแกรมจำลองการ์ดแบบโฮสต์
ในบางกรณีการใช้งาน เช่น การใช้ FeliCa สำหรับขนส่งสาธารณะ ระบบจะอนุญาตให้จําลองบัตรแบบออฟโฮสต์เมื่อหน้าจอของอุปกรณ์ล็อกอยู่หรือปิดอยู่ หรือเมื่อปิดอุปกรณ์
NFC ที่ปลอดภัยเป็นฟีเจอร์ที่เปิดตัวใน Android 10 ซึ่งเปิดใช้การจําลองบัตร NFC นอกโฮสต์ได้เฉพาะเมื่อหน้าจอของอุปกรณ์ไม่ได้ล็อกเท่านั้น การใช้ฟีเจอร์นี้จะช่วยให้ผู้ใช้มีตัวเลือกในการเปิดใช้ NFC ที่ปลอดภัยเพื่อความปลอดภัยที่ดียิ่งขึ้น
การใช้งาน
หากต้องการใช้ฟีเจอร์ NFC ที่ปลอดภัย อุปกรณ์ต้องมีตัวควบคุม NFC ที่รองรับมาตรฐาน NCI 2.0 และต้องใช้เฟรมเวิร์ก NFC ของโปรเจ็กต์โอเพนซอร์ส Android (AOSP) เพิ่มฮาร์ดแวร์ (ro.boot.hardware.sku
) ที่รองรับฟีเจอร์ NFC ที่ปลอดภัยใน ไฟล์ XML ของทรัพยากร NFC ด้วยแอตทริบิวต์ config_skuSupportsSecureNfc
Framework API
หากต้องการใช้ NFC ที่ปลอดภัย ให้ใช้ API เฟรมเวิร์กต่อไปนี้ซึ่งอยู่ในโครงการโอเพนซอร์ส Android
UI การตั้งค่า
ในแอปพลิเคชันการตั้งค่า ให้เพิ่มปุ่มสลับเพื่ออนุญาตให้ผู้ใช้เปิดและปิดใช้ฟีเจอร์ NFC ที่ปลอดภัย คุณสามารถปรับแต่งการตั้งค่าเริ่มต้นในแอปพลิเคชันการตั้งค่าให้เปิดหรือปิดใช้ก็ได้
รูปที่ 1 แสดงตัวอย่างสวิตช์เปิด/ปิดเพื่อเปิดและปิดใช้ NFC ที่ปลอดภัยในแอปการตั้งค่าในส่วนการตั้งค่า > อุปกรณ์ที่เชื่อมต่อ >
ค่ากำหนดการเชื่อมต่อ > NFC > ต้องปลดล็อกอุปกรณ์เพื่อใช้งาน NFC
รูปที่ 1 ตัวอย่างสวิตช์เปิด/ปิดเพื่อเปิดและปิดใช้ NFC ที่ปลอดภัย
เมื่อเปิดใช้ NFC ที่ปลอดภัยและผู้ใช้วางอุปกรณ์บนเครื่องอ่าน NFC
Android จะแสดงการแจ้งเตือนปลดล็อกเพื่อใช้ NFC บนหน้าจอล็อก
ดังที่แสดงในรูปที่ 2
รูปที่ 2 ปลดล็อกเพื่อใช้การแจ้งเตือน NFC ในหน้าจอล็อก
การตรวจสอบความถูกต้อง
หากต้องการตรวจสอบการติดตั้งใช้งาน ให้เปิดใช้ฟีเจอร์ NFC ที่ปลอดภัยและยืนยันว่าการจําลองบัตร NFC ถูกปิดใช้เมื่อหน้าจอของอุปกรณ์ปิดอยู่หรือล็อกอยู่ และเมื่ออุปกรณ์ปิดอยู่
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-27 UTC
[[["เข้าใจง่าย","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-27 UTC"],[],[],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."]]