اعتبارًا من 27 آذار (مارس) 2025، ننصحك باستخدام android-latest-release
بدلاً من aosp-main
لإنشاء AOSP والمساهمة فيه. لمزيد من المعلومات، يُرجى الاطّلاع على التغييرات في AOSP.
استخدام Trade Federation مع Scripting Layer لنظام التشغيل Android
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
Scripting Layer for Android (SL4A) هي مجموعة من
أدوات التشغيل الآلي لاستدعاء واجهات برمجة تطبيقات Android بطريقة لا تعتمد على المنصة.
وهو يتيح التشغيل الآلي عن بُعد من خلال adb
وتنفيذ النصوص البرمجية
من الجهاز من خلال سلسلة من طبقات الترجمة الخفيفة.
يمكن العثور على المشروع على platform/external/sl4a.
استخدام
يمكنك اتّباع ملف README الخاص بـ SL4A
لإنشاء حزمة SL4A وتثبيتها يدويًا. وعند استخدام Tradefed،
يمكنك الاستفادة من بعض أدوات حِزم التطبيقات لتسهيل الاستخدام.
التنزيل والتثبيت
يمكنك البدء بمراجعةملف BT-discovery-sl4a.xml، وهو مثال على إعداد Tradefed يستخدم جهازَين. يتوفّر SL4A.apk
في معظم إصدارات الأجهزة ضمن مجلد tests
.
يعرض مثال Tradefed أعلاه عملية جلب الإصدارات تلقائيًا وفلاش كلا
الجهازَين وتثبيت SL4A.apk
على كلا الجهازَين. يمكنك تنفيذه على النحو التالي:
source build/envsetup.sh
lunch
make sl4a
tradefed.sh run google/example/BT-discovery-sl4a
أو بعد إنشاء النموذج:
./tradefed.sh run google/example/BT-discovery-sl4a
كتابة اختبار في Tradefed باستخدام SL4A
يمكنك اتّباع نموذج الاختبار الموضّح أعلاه:
Sl4aBluetoothDiscovery.java.
يقدّم هذا مثالاً جيدًا على عملية استخدام SL4A في اختبار Tradefed.
مستندات واجهة برمجة التطبيقات SL4A
يمكن إنشاء القائمة الكاملة لطلبات إعادة الاتصال المتاحة من خلال SL4A. من
دليل مصدر SL4A، platform/external/sl4a/
، نفِّذ هذا الأمر:
python Docs/generate_api_reference_md.py
في دليل "المستندات"، سيتوفّر ملف ApiReference.md
يحتوي على دوال RPC المتاحة في SL4A، بالإضافة إلى مستندات حول دوال RPC.
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ 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,["# Use Trade Federation with Scripting Layer for Android\n\nScripting Layer for Android, SL4A, is an\nautomation toolset for calling Android APIs in a platform-independent manner.\nIt supports both remote automation via `adb` and execution of scripts\nfrom on-device via a series of lightweight translation layers.\n\nThe project is located at [platform/external/sl4a](https://android.googlesource.com/platform/external/sl4a/).\n\nUse\n---\n\nYou can follow the [SL4A README](https://android.googlesource.com/platform/external/sl4a/+/refs/heads/android16-release/README.md)\nto build and install it manually. And when running through Tradefed, you\ncan take advantage of some of the harness utilities to make use easier.\n\n### Download and install\n\nYou can start by reviewing\n[BT-discovery-sl4a.xml](https://android.googlesource.com/platform/tools/tradefederation/contrib/+/refs/heads/android16-release/res/config/google/example/BT-discovery-sl4a.xml),\nan example Tradefed configuration that uses two devices. The `SL4A.apk` is\navailable in most device builds within their `tests` folder.\n\nThe Tradefed example above automatically fetches the builds, flashes both\ndevices and installs `SL4A.apk` on both devices. You can run it like so: \n\n source build/envsetup.sh\n lunch\n make sl4a\n tradefed.sh run google/example/BT-discovery-sl4a\n\nOr once built: \n\n ./tradefed.sh run google/example/BT-discovery-sl4a\n\n### Write a test in Tradefed using SL4A\n\nYou can follow the test sample describe above:\n[Sl4aBluetoothDiscovery.java](https://android.googlesource.com/platform/tools/tradefederation/contrib/+/refs/heads/android16-release/src/com/android/tradefed/Sl4aBluetoothDiscovery.java).\nThis gives a good example of the flow to use SL4A within a Tradefed test.\n\n### SL4A API documentation\n\nThe complete list of callbacks available through SL4A can be generated. From the\nSL4A source directory, `platform/external/sl4a/`, run this command: \n\n python Docs/generate_api_reference_md.py\n\nIn the Docs directory there will be an `ApiReference.md` file that contains\nthe RPC functions available in SL4A, as well as documentation for the RPC\nfunctions."]]