ระดับประสิทธิภาพ

ระดับประสิทธิภาพเป็นมาตรฐานที่เปิดตัวครั้งแรกใน Android 12 ประสิทธิภาพ คลาสจะกำหนดชุดความสามารถของอุปกรณ์ที่มากกว่าเกณฑ์พื้นฐานของ Android

Android แต่ละเวอร์ชันมีคลาสประสิทธิภาพของตนเอง ซึ่งก็คือ ที่กำหนดไว้ในเอกสารข้อกำหนดความเข้ากันได้กับ Android ของเวอร์ชันนั้น (CDD) ความเข้ากันได้กับ Android Test Suite (CTS) ยืนยันความถูกต้องของ ข้อกำหนดของ CDD

อุปกรณ์ที่ใช้ระบบ Android แต่ละเครื่องจะประกาศระดับประสิทธิภาพที่รองรับ นักพัฒนาแอปสามารถดูคลาสประสิทธิภาพของอุปกรณ์ได้ที่รันไทม์และมอบ ประสบการณ์ที่อัปเกรดซึ่งใช้ประโยชน์จากความสามารถของอุปกรณ์อย่างเต็มที่

หากต้องการค้นหาระดับคลาสประสิทธิภาพของอุปกรณ์ ให้ใช้ Jetpack Core ประสิทธิภาพ ไลบรารี ไลบรารีนี้รายงานคลาสประสิทธิภาพของสื่อของอุปกรณ์ตามที่ประกาศไว้ ในเวอร์ชันบิลด์ ข้อมูล หรือ อิงตามข้อมูลจากบริการ Google Play

เริ่มด้วยการเพิ่มทรัพยากร Dependency สำหรับโมดูลที่เกี่ยวข้องในไฟล์ Gradle

Kotlin

// Implementation of Jetpack Core library.
implementation("androidx.core:core-ktx:1.12.0")
// Enable APIs to query for device-reported performance class.
implementation("androidx.core:core-performance:1.0.0")
// Enable APIs to query Google Play Services for performance class.
implementation("androidx.core:core-performance-play-services:1.0.0")

ดึงดูด

// Implementation of Jetpack Core library.
implementation 'androidx.core:core-ktx:1.12.0'
// Enable APIs to query for device-reported performance class.
implementation 'androidx.core:core-performance:1.0.0'
// Enable APIs to query Google Play Services for performance class.
implementation 'androidx.core:core-performance-play-services:1.0.0'

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 เวอร์ชันใดเวอร์ชันหนึ่ง

รูปที่ 1 อุปกรณ์จะอัปเกรดเวอร์ชัน Android และ รายงานต่อว่าตนสนับสนุนชั้นเรียนเดิม การสนับสนุน

ระดับประสิทธิภาพ 14

ระดับประสิทธิภาพ 14 สร้างขึ้นจากข้อกำหนดที่เริ่มใช้ในระดับประสิทธิภาพ 13 ข้อกำหนดเฉพาะเกี่ยวกับระดับประสิทธิภาพได้เผยแพร่ใน Android CDD นอกจากข้อกำหนดที่เพิ่มขึ้นสำหรับรายการจากระดับประสิทธิภาพ 13 แล้ว CDD จะระบุข้อกำหนดในด้านต่อไปนี้

สื่อ

  • รองรับเอฟเฟกต์เนื้อฟิล์มในตัวถอดรหัสฮาร์ดแวร์ AV1
  • โปรไฟล์พื้นฐานของ AVIF
  • ประสิทธิภาพของโปรแกรมเปลี่ยนไฟล์ AV1
  • ตัวแปลงรหัสวิดีโอ HDR
  • รูปแบบสี RGBA_1010102
  • การสุ่มตัวอย่างพื้นผิว YUV
  • คุณภาพการเข้ารหัสวิดีโอ
  • การมิกซ์เสียงแบบหลายช่อง

กล้อง

  • ส่วนขยายโหมดกลางคืน
  • กล้องหลักที่รองรับ HDR
  • โหมดฉากการตรวจจับใบหน้า

Generic

  • การวางซ้อนฮาร์ดแวร์
  • จอแสดงผล HDR

ระดับประสิทธิภาพ 13

ระดับประสิทธิภาพ 13 สร้างขึ้นจากข้อกำหนดที่เริ่มใช้ในระดับประสิทธิภาพ 12 ข้อกำหนดเฉพาะเกี่ยวกับระดับประสิทธิภาพได้เผยแพร่ใน Android CDD นอกจากข้อกำหนดที่เพิ่มขึ้นสำหรับรายการจากระดับประสิทธิภาพ 12 แล้ว CDD จะระบุข้อกำหนดในด้านต่อไปนี้

สื่อ

  • ตัวถอดรหัสฮาร์ดแวร์ AV1
  • ตัวถอดรหัสฮาร์ดแวร์ที่ปลอดภัย
  • เวลาในการตอบสนองการเริ่มต้นตัวถอดรหัส
  • เวลาในการตอบสนองของเสียงไป-กลับ
  • ชุดหูฟังแบบมีสายและอุปกรณ์เสียง USB
  • อุปกรณ์ MIDI
  • สภาพแวดล้อมการดำเนินการที่เชื่อถือได้ซึ่งได้รับการสนับสนุนจากฮาร์ดแวร์

กล้อง

  • ระบบกันภาพสั่นตัวอย่าง
  • การบันทึกแบบสโลว์โมชัน
  • อัตราส่วนการซูมขั้นต่ำสำหรับกล้องภาพมุมกว้างพิเศษ
  • กล้องที่ใช้พร้อมกัน
  • กล้องหลายตัวแบบตรรกะ
  • กรณีการใช้งานของสตรีม

ระดับประสิทธิภาพ 12

ประสิทธิภาพคลาส 12 มุ่งเน้นที่ Use Case สื่อ ระดับประสิทธิภาพที่เฉพาะเจาะจง มีการเผยแพร่ใน CDD CDD จะระบุข้อกำหนดในด้านต่อไปนี้

สื่อ

  • เซสชันตัวแปลงรหัสวิดีโอพร้อมกัน
  • เวลาในการตอบสนองของการเริ่มต้นโปรแกรมเปลี่ยนไฟล์
  • การลดลงของเฟรมตัวถอดรหัส
  • คุณภาพการเข้ารหัส

กล้อง

  • ความละเอียดและอัตราเฟรม
  • เริ่มต้นใช้งานและบันทึกเวลาในการตอบสนอง
  • FULL หรือระดับฮาร์ดแวร์ที่ดีกว่า
  • แหล่งที่มาของการประทับเวลาเป็นแบบเรียลไทม์
  • ความสามารถของไฟล์ข้อมูล RAW

Generic

  • หน่วยความจำ
  • ประสิทธิภาพในการอ่านและเขียน
  • ความละเอียดของหน้าจอ
  • ความหนาแน่นของหน้าจอ

ระดับประสิทธิภาพ 11

ระดับประสิทธิภาพ 11 มีชุดย่อยของข้อกำหนดสำหรับระดับประสิทธิภาพ 12. ให้นักพัฒนาซอฟต์แวร์สามารถนำเสนอประสบการณ์ที่ปรับแต่งก่อนหน้านี้และ อุปกรณ์ที่สนับสนุนการทำงาน ข้อกำหนดระดับประสิทธิภาพที่เจาะจงมีการเผยแพร่ใน Android CDD