فئة الأداء هي فئة قياسية تم طرحها لأول مرة في نظام التشغيل Android 12. تُعرّف فئة الأداء مجموعة من إمكانيات الجهاز التي تتجاوز متطلبات Android الأساسية.
لكل إصدار من إصدارات Android فئة الأداء المقابلة الخاصة به، والتي يتم تحديدها في مستند تعريف التوافق مع Android (CDD) لهذا الإصدار. تتحقّق مجموعة اختبار التوافق مع Android (CTS) من متطلبات CDD.
يحدّد كل جهاز يعمل بنظام التشغيل Android فئة الأداء المتوافقة معه. ويمكن للمطوّرين العثور على فئة أداء الجهاز في وقت التشغيل وتقديم تجارب تمت ترقيتها تستفيد إلى أقصى حد من إمكانات الجهاز.
للعثور على مستوى فئة أداء الجهاز، استخدِم مكتبة الأداء الأساسي في Jetpack. تُبلِغ هذه المكتبة عن فئة أداء الوسائط في الجهاز وفقًا لما هو منصوص عليه في معلومات إصدار الإصدار أو استنادًا إلى بيانات من خدمات Google Play.
ابدأ بإضافة تبعية للوحدات ذات الصلة في ملف Gradle الخاص بك:
Kotlin
// Implementation of Jetpack Core library. implementation("androidx.core:core-ktx:1.10.1") // Enable APIs to query for device-reported performance class. implementation("androidx.core:core-performance:1.0.0-beta01") // Enable APIs to query Google Play Services for performance class. implementation("androidx.core:core-performance-play-services:1.0.0-beta01")
رائع
// Implementation of Jetpack Core library. implementation 'androidx.core:core-ktx:1.10.1' // Enable APIs to query for device-reported performance class. implementation 'androidx.core:core-performance:1.0.0-beta01' // Enable APIs to query Google Play Services for performance class. implementation 'androidx.core:core-performance-play-services:1.0.0-beta01'
Then, create an instance of a
DevicePerformance
implementation, such as
PlayServicesDevicePerformance
,
in the onCreate()
lifecycle event of your Application
. This should only be
done once in your app.
Kotlin
import androidx.core.performance.play.services.PlayServicesDevicePerformance class MyApplication : Application() { lateinit var devicePerformance: DevicePerformance override fun onCreate() { // Use a class derived from the DevicePerformance interface devicePerformance = PlayServicesDevicePerformance(applicationContext) } }
لغة Java
import androidx.core.performance.play.services.PlayServicesDevicePerformance; class MyApplication extends Application { DevicePerformance devicePerformance; @Override public void onCreate() { // Use a class derived from the DevicePerformance interface devicePerformance = new PlayServicesDevicePerformance(applicationContext); } }
يمكنك بعد ذلك استرداد سمة mediaPerformanceClass
لتخصيص تجربة تطبيقك بناءً على إمكانات الجهاز:
Kotlin
class MyActivity : Activity() { private lateinit var devicePerformance: DevicePerformance override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) // Note: Good app architecture is to use a dependency framework. See // https://developer.android.com/training/dependency-injection for more // information. devicePerformance = (application as MyApplication).devicePerformance } override fun onResume() { super.onResume() when { devicePerformance.mediaPerformanceClass >= Build.VERSION_CODES.TIRAMISU -> { // Performance class level 13 and later. // Provide the most premium experience for the highest performing devices. } devicePerformance.mediaPerformanceClass == Build.VERSION_CODES.S -> { // Performance class level 12. // Provide a high quality experience. } else -> { // Performance class level 11 or undefined. // Remove extras to keep experience functional. } } } }
لغة Java
class MyActivity extends Activity { private DevicePerformance devicePerformance; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Note: Good app architecture is to use a dependency framework. See // https://developer.android.com/training/dependency-injection for more // information. devicePerformance = ((MyApplication) getApplication()).devicePerformance; } @Override public void onResume() { super.onResume(); if (devicePerformance.getMediaPerformanceClass() >= Build.VERSION_CODES.TIRAMISU) { // Performance class level 13 and later. // Provide the most premium experience for the highest performing devices. } else if (devicePerformance.getMediaPerformanceClass() == Build.VERSION_CODES.S) { // Performance class level 12. // Provide a high quality experience. } else { // Performance class level 11 or undefined. // Remove extras to keep experience functional. } } }
فئات الأداء متوافقة مع إعادة التوجيه. يمكن لأي جهاز الترقية إلى إصدار أحدث من النظام الأساسي دون تحديث فئة أدائه. على سبيل المثال، يمكن للجهاز الذي يتوافق في البداية مع الفئة 12 الترقية إلى Android 13 ويستمر في الإبلاغ عن أنه يتوافق مع الفئة 12 إذا لم يستوفِ متطلبات الفئة 13. وهذا يعني أن فئة الأداء توفر طريقة لتجميع الأجهزة معًا بدون الاعتماد على إصدار معيّن من Android.
فئة الأداء 13
تعتمد فئة الأداء 13 على المتطلبات التي تم تقديمها في فئة الأداء 12. يتم نشر المتطلبات المحدّدة لفئة الأداء في Android CDD. بالإضافة إلى المتطلبات المتزايدة لعناصر من الفئة 12 للأداء، يحدد CDD المتطلبات في المجالات التالية:
الوسائط
- برنامج فك ترميز أجهزة AV1
- برامج فك ترميز الأجهزة الآمنة
- وقت استجابة إعداد برنامج فك الترميز
- وقت استجابة الصوت ذهابًا وإيابًا
- سماعات الرأس السلكية وأجهزة الصوت عبر USB
- أجهزة MIDI
- بيئة تنفيذ موثوقة مستندة إلى الأجهزة
الكاميرا
- معاينة التثبيت
- التسجيل بالتصوير البطيء
- الحد الأدنى لنسبة التكبير أو التصغير للكاميرات الفائقة العرض
- كاميرا متزامنة
- كاميرات متعدّدة منطقية
- حالة استخدام مجموعة البث
فئة الأداء 12
تركّز فئة الأداء 12 على حالات استخدام الوسائط. يتم نشر متطلبات فئة الأداء المحددة في CDD لنظام التشغيل Android. ويحدد مستند CDD المتطلبات في المجالات التالية:
الوسائط
- جلسات ترميز الفيديو المتزامنة
- وقت استجابة إعداد برنامج الترميز
- مرات الانخفاض في إطار برنامج فك الترميز
- جودة الترميز
الكاميرا
- درجة الدقة وعدد اللقطات في الثانية
- بدء التشغيل وتسجيل أوقات الاستجابة
FULL
أو على مستوى أجهزة أفضل- مصدر الطابع الزمني في الوقت الفعلي
- إمكانات RAW
Generic
- الذاكرة
- قراءة وكتابة الأداء
- درجة دقة الشاشة
- كثافة الشاشة
فئة الأداء 11
تشمل فئة الأداء 11 مجموعة فرعية من متطلّبات الفئة 12 لأداء الأجهزة، ما يتيح للمطوّرين تقديم تجربة مخصّصة على الأجهزة السابقة ذات الكفاءة العالية. ويتم نشر المتطلبات المحدّدة لفئة الأداء في Android CDD.
محتوى مُقترَح لك
- ملاحظة: يتم عرض نص الرابط عند إيقاف JavaScript.
- وقت بدء تشغيل التطبيق