パフォーマンス クラス

パフォーマンス クラスは、Android 12 で初めて導入された規格です。パフォーマンス クラスは、Android の基本要件を超えるデバイス機能のセットを定義します。

Android のバージョンごとに、対応する独自のパフォーマンス クラスがあります。これはそのバージョンの Android 互換性定義ドキュメント(CDD)で規定されています。Android 互換性テストスイート(CTS)で、CDD の要件を検証します。

各 Android 搭載デバイスは、サポート対象のパフォーマンス クラスを宣言します。デベロッパーは実行時にデバイスのパフォーマンス クラスを検出し、デバイスの機能を最大限に活用するアップグレード環境を提供できます。

デバイスのパフォーマンス クラス レベルを検出するには、Jetpack の Core Performance ライブラリを使用します。このライブラリは、ビルド バージョン情報での宣言、または Google Play 開発者サービスのデータに基づいて、デバイスのメディア パフォーマンス クラス(MPC)レベルをレポートします。

まず、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")

Groovy

// 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'

次に、ApplicationonCreate() ライフサイクル イベントで、PlayServicesDevicePerformance などの DevicePerformance 実装のインスタンスを作成します。これはアプリで 1 回だけ行う必要があります。

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.VANILLA_ICE_CREAM -> {
        // MPC level 35 and later.
        // Provide the most premium experience for the highest performing devices.
      }
      devicePerformance.mediaPerformanceClass == Build.VERSION_CODES.UPSIDE_DOWN_CAKE -> {
        // MPC level 34.
        // Provide a high quality experience.
      }
      else -> {
        // MPC level 33, 31, 30, 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.VANILLA_ICE_CREAM) {
      // MPC level 35 and later.
      // Provide the most premium experience for the highest performing devices.
    } else if (devicePerformance.getMediaPerformanceClass() == Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
      // MPC level 34.
      // Provide a high quality experience.
    } else {
      // MPC level 33, 31, 30, or undefined.
      // Remove extras to keep experience functional.
    }
  }
}

パフォーマンス クラスのレベルには上位互換性があります。デバイスは、パフォーマンス クラスを更新せずに、新しいプラットフォーム バージョンにアップグレードできます。たとえば、当初パフォーマンス クラス 33 をサポートしていたデバイスを Android 14 にアップグレードし、パフォーマンス クラス 34 の要件を満たしていない場合は引き続きパフォーマンス クラス 33 をサポートすることを報告できます。これにより、特定の Android バージョンに依存せずにデバイスをグループ化できます。

図 1. デバイスは Android バージョンをアップグレードし、元々サポートしていたクラスをサポートしているという報告を継続できます。

メディア パフォーマンス クラス 35

MPC 35 は Android 15 で導入され、MPC 34 で導入された要件に基づいています。具体的な MPC 35 の要件は、Android 15 CDD で公開されています。MPC 34 の項目から要件が増えたことに加えて、CDD では以下の分野の要件が規定されています。

メディア

  • デコードのフレーム落ち
  • HDR 編集
  • ダイナミック カラーの要素
  • 縦向きのアスペクト比

カメラ

  • JPEG_R
  • プレビューの手ぶれ補正

グラフィック

  • EGL 拡張機能
  • Vulkan 構造

メディア パフォーマンス クラス 34

MPC 34 は Android 14 で導入され、MPC 33 で導入された要件に基づいています。具体的な MPC 34 の要件は、Android 14 CDD で公開されています。MPC 33 の項目から要件が増えたことに加えて、CDD では以下の分野の要件が規定されています。

メディア

  • AV1 ハードウェア デコーダでのフィルム グレイン効果のサポート
  • AVIF ベースライン プロファイル
  • AV1 エンコーダのパフォーマンス
  • HDR 動画コーデック
  • RGBA_1010102 カラー形式
  • YUV テクスチャ サンプリング
  • 動画エンコードの品質
  • マルチチャンネル音声ミキシング

カメラ

  • 夜間モード拡張機能
  • HDR 対応メインカメラ
  • 顔検出撮影モード

General

  • ハードウェア オーバーレイ
  • HDR ディスプレイ

メディア パフォーマンス クラス 33

MPC 33 は Android 13 で導入され、MPC 31 で導入された要件に基づいています。具体的な MPC 33 の要件は、Android 13 CDD で公開されています。MPC 31 の項目から要件が増えたことに加えて、CDD では以下の分野の要件が規定されています。

メディア

  • AV1 ハードウェア デコーダ
  • セキュアなハードウェア デコーダ
  • デコーダの初期化レイテンシ
  • ラウンドトリップ オーディオ レイテンシ
  • 有線ヘッドセットと USB オーディオ デバイス
  • MIDI デバイス
  • ハードウェア格納型の高信頼実行環境

カメラ

  • プレビューの手ぶれ補正
  • スローモーション録画
  • ウルトラワイド カメラの最小ズーム倍率
  • 同時カメラ
  • 論理マルチカメラ
  • ストリームのユースケース

メディア パフォーマンス クラス 31

MPC 31 は Android 12 で導入されました。具体的な MPC 31 の要件は、Android 12 CDD で公開されています。CDD では、以下の分野の要件が規定されています。

メディア

  • 動画コーデック セッションの同時実行
  • エンコーダの初期化レイテンシ
  • デコーダのフレーム落ち
  • エンコードの品質

カメラ

  • 解像度とフレームレート
  • 起動とキャプチャのレイテンシ
  • FULL 以上のハードウェア レベル
  • リアルタイムのタイムスタンプ ソース
  • RAW 機能

General

  • メモリ
  • 読み取りと書き込みのパフォーマンス
  • 画面解像度
  • 画面密度

メディア パフォーマンス クラス 30

MPC 30 には、MPC 31 の要件のサブセットが含まれており、デベロッパーは、旧式ではあっても依然として性能の高いデバイスに合わせたエクスペリエンスを提供できます。具体的なパフォーマンス クラスの要件は、Android 11 CDD で公開されています。