パフォーマンス クラス

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

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

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

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

まず、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-beta02")
// Enable APIs to query Google Play Services for performance class.
implementation("androidx.core:core-performance-play-services:1.0.0-beta02")

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-beta02'
// Enable APIs to query Google Play Services for performance class.
implementation 'androidx.core:core-performance-play-services:1.0.0-beta02'

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 にアップグレードし、クラス 13 の要件を満たしていない場合は引き続きクラス 12 をサポートすることを報告できます。つまり、パフォーマンス クラスを使用すると、特定の Android バージョンに依存せずにデバイスをグループ化できます。

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

パフォーマンス クラス 14

パフォーマンス クラス 14 は、パフォーマンス クラス 13 で導入された要件をベースにしています。具体的なパフォーマンス クラスの要件は、Android CDD で公開されています。パフォーマンス クラス 13 の項目から要件が増えたことに加えて、CDD では以下の分野の要件が規定されています。

Media

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

カメラ

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

汎用

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

パフォーマンス クラス 13

パフォーマンス クラス 13 は、パフォーマンス クラス 12 で導入された要件をベースにしています。具体的なパフォーマンス クラスの要件は、Android CDD で公開されています。パフォーマンス クラス 12 の項目から要件が増えたことに加えて、CDD では以下の分野の要件が規定されています。

Media

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

カメラ

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

パフォーマンス クラス 12

パフォーマンス クラス 12 は、メディアのユースケースに焦点を当てています。具体的なパフォーマンス クラスの要件は、Android CDD で公開されています。CDD では、以下の分野の要件が規定されています。

Media

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

カメラ

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

汎用

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

パフォーマンス クラス 11

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