اعتبارًا من 27 آذار (مارس) 2025، ننصحك باستخدام android-latest-release
بدلاً من aosp-main
لإنشاء AOSP والمساهمة فيه. لمزيد من المعلومات، يُرجى الاطّلاع على التغييرات في AOSP.
تأمين الاتصال بالحقل القريب (NFC)
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
يتيح Android محاكاة البطاقات خارج الجهاز، ما يعني
محاكاة بطاقة NFC باستخدام عنصر آمن. لمزيد من المعلومات، يُرجى الاطّلاع على
نظرة عامة على محاكاة البطاقات المستندة إلى المضيف.
في بعض حالات الاستخدام، مثل استخدام FeliCa للتنقل، يُسمح بمحاكاة البطاقة خارج المضيف عندما تكون شاشة الجهاز مقفلة أو مُطفأة، أو
عندما يكون الجهاز مُطفأً.
تقنية "الاتصال القصير المدى (NFC) الآمنة" هي ميزة تم تقديمها في الإصدار 10 من نظام التشغيل Android، وهي تتيح تفعيل ميزة emulatiorبطاقة NFC التي تعمل خارج الجهاز فقط عندما تكون شاشة الجهاز غير مقفلة. من خلال تنفيذ
هذه الميزة، يمكن للمستخدمين تفعيل تقنية NFC الآمنة لتحسين الأمان.
التنفيذ
لتنفيذ ميزة "الربط الآمن عبر NFC"، يجب أن يكون الجهاز مزوّدًا بوحدة تحكّم في NFC تتوافق مع معيار NCI 2.0 وأن يستخدم إطار عمل NFC في "مشروع Android المفتوح المصدر" (AOSP). أضِف الجهاز (ro.boot.hardware.sku
) المتوافق مع
ميزة "الاتصال القصير المدى (NFC) الآمن" في ملف موارد تقنية
NFCXML
باستخدام السمة config_skuSupportsSecureNfc
.
واجهات برمجة التطبيقات لإطار العمل
لتنفيذ تقنية NFC الآمنة، عليك تنفيذ واجهات برمجة التطبيقات التالية للإطار الأساسي المتوفّرة في
مشروع Android Open Source Project:
واجهة مستخدم الإعدادات
في تطبيق "الإعدادات"، أضِف مفتاح تبديل للسماح للمستخدمين بتفعيل ميزة "التواصل الآمن عبر NFC"
وإيقافها. يمكنك تخصيص الإعداد التلقائي في
تطبيق "الإعدادات" لتفعيله أو إيقافه.
يعرض الشكل 1 مثالاً على مفتاح تبديل لتفعيل ميزة "الاتصال الآمن عبر NFC" وإيقافها
في تطبيق "الإعدادات" ضمن الإعدادات > الأجهزة المتصلة >
إعدادات الاتصال المفضّلة > الاتصال عبر NFC > يجب فتح قفل الجهاز لاستخدام تقنية الاتصال عبر NFC.
الشكل 1: مثال على مفتاح تبديل لتفعيل تقنية "الاتصال القصير المدى (NFC) الآمنة" وإيقافها
عندما تكون تقنية "الاتصال القصير المدى (NFC) الآمنة" مفعّلة ويضع المستخدم الجهاز على قارئ NFC،
يعرض Android الإشعار فتح القفل لاستخدام تقنية NFC على شاشة القفل
كما هو موضّح في الشكل 2.
الشكل 2: إشعار "افتح قفل الشاشة لاستخدام تقنية NFC" على شاشة القفل
التحقُّق
للتحقّق من صحة عملية التنفيذ، فعِّل ميزة "الاتصال الآمن عبر NFC" وتأكَّد من أنّه
تم إيقاف محاكاة بطاقة NFC عندما تكون شاشة الجهاز مُطفأة أو مقفلة، وكذلك
عندما يكون الجهاز غير مفعَّل.
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ Java وOpenJDK هما علامتان تجاريتان مسجَّلتان لشركة Oracle و/أو الشركات التابعة لها.
تاريخ التعديل الأخير: 2025-07-27 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","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 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],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."]]