Android 10 では、ConfigStore HAL はビルドフラグを使用して vendor パーティション内に構成値を格納し、system パーティション内のサービスは HIDL を使用してそれらの値にアクセスします(この動作は Android 9 でも同様です)。ただし、メモリの消費量が多く、使用することが困難であるため、ConfigStore HAL は非推奨になりました。
ConfigStore HAL は、従来のベンダー パーティションをサポートするために AOSP に残されます。Android 10 以降を搭載したデバイスでは、surfaceflinger が最初にシステム プロパティを読み取ります。「SurfaceFlingerProperties.sysprop」の構成項目でシステム プロパティが定義されていない場合、「surfaceflinger」は ConfigStore HAL にフォールバックします。
Android 8.0 では、モノリシックだった Android OS が、汎用パーティション(system.img)とハードウェア固有のパーティション(vendor.img と odm.img)に分割されています。この変更により、システム パーティションにインストールされたモジュールから条件付きコンパイルを削除する必要があり、それらのモジュールは実行時にシステムの構成を決定する必要があります(構成に応じて挙動は異なります)。
ConfigStore HAL は、Android フレームワークの構成に使用する読み取り専用の構成アイテムにアクセスするための API セットを提供します。このページでは、ConfigStore HAL の設計(およびこの目的でシステム プロパティが使用されなかった理由)について説明します。このセクションの他のページでは、HAL インターフェース、サービスの実装、クライアント側の使用方法について詳しく説明しています。これらはすべて例として surfaceflinger を用いています。ConfigStore インターフェース クラスのヘルプについては、インターフェース クラスとアイテムの追加をご覧ください。
システム プロパティを使用しない理由
システム プロパティの使用を検討しましたが、次のようないくつかの根本的な問題が見つかりました。
値の長さの制限。システム プロパティには、値の長さに厳密な制限があります(92 バイト)。さらに、この制限は C マクロとして Android アプリに直接公開されているため、長さを長くすると下位互換性の問題が発生する可能性があります。
型のサポートがない。すべての値は基本的に文字列で、API は単に文字列を int または bool に解析します。他の複合データ型(配列や構造体など)は、クライアントがエンコードまたはデコードする必要があります(たとえば、"aaa,bbb,ccc" は 3 つの文字列の配列としてコード化できます)。
[[["わかりやすい","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-03-05 UTC。"],[],[],null,["# ConfigStore HAL\n\nIn Android 10, ConfigStore HAL uses build flags to store\nconfig values in the `vendor` partition, and a service in the `system`\npartition accesses those values using HIDL (this is also true in Android 9). However, due to high\nmemory consumption and difficult usage, the ConfigStore HAL has been deprecated.\n\n\nThe ConfigStore HAL remains in AOSP to support legacy vendor partitions. On\ndevices running Android 10 or later, `surfaceflinger`\nreads system properties first; if no system property is defined for a config\nitem in \\`SurfaceFlingerProperties.sysprop\\`, \\`surfaceflinger\\` falls back to the\nConfigStore HAL.\n| **Warning:** Android 10 deprecates the ConfigStore HAL and replaces the HAL with system properties. For details, refer to [Configuring](/docs/core/architecture/configuration).\n\nAndroid 8.0 splits the monolithic Android OS into generic\n(`system.img`) and hardware-specific (`vendor.img` and\n`odm.img`) partitions. As a result of this\nchange, conditional compilation must be removed from modules installed to the\nsystem partition and such modules must determine the configuration of the\nsystem at runtime (and behave differently depending on that configuration).\n\nThe ConfigStore HAL provides a set of APIs for accessing read-only\nconfiguration items used to configure the Android framework. This page describes\nthe design of ConfigStore HAL (and why system properties weren't used for this\npurpose); other pages in this section detail the\n[HAL interface](/docs/core/architecture/configstore/interface),\n[service\nimplementation](/docs/core/architecture/configstore/service), and\n[client-side usage](/docs/core/architecture/configstore/client),\nall using `surfaceflinger` as an example. For help with ConfigStore\ninterface classes, see\n[Adding Interface\nClasses and Items](/docs/core/architecture/configstore/add-class-item).\n\nWhy not use system properties?\n------------------------------\n\nWe considered using system properties but found several fundamental issues,\nincluding:\n\n- **Length limits on values.** System properties have tight limits on the length of their values (92 bytes). In addition, as these limits have been directly exposed to Android apps as C macros, increasing the length can cause backward-compatibility issues.\n- **No type support.** All values are essentially strings, and APIs simply parse the string into an `int` or `bool`. Other compound data types (for example, array and struct) should be encoded/decoded by the clients (for example, `\"aaa,bbb,ccc\"` can be coded as an array of three strings).\n- **Overwrites.** Because read-only system properties are implemented as write-once properties, vendors/ODMs that want to override AOSP-defined read-only values must import their own read-only values prior to AOSP-defined read-only values. This, in turn, results in vendor-defined rewritable values being overridden by AOSP-defined values.\n- **Address space requirements.** System properties take a relatively large amount of address space in each process. System properties are grouped in `prop_area` units with a fixed size of 128 KB, all of which is allocated to a process address space even if only a single system property in it is being accessed. This can cause problems on 32-bit devices where address space is precious.\n\nWe attempted to overcome these limitations without sacrificing compatibility,\nbut continued to be concerned that system properties weren't designed to\nsupport accessing read-only configuration items. Eventually we decided that\nsystem properties are better suited for sharing a few dynamically updated items\nacross all of Android in real time, and that a need existed for a new system\ndedicated to accessing read-only configuration items.\n\nConfigStore HAL design\n----------------------\n\nThe basic design is simple:\n\n**Figure 1.** ConfigStore HAL design\n\n- Describe build flags (currently used for conditionally compiling the framework) in HIDL.\n- Vendors and OEMs provide SoC and device-specific values for build flags by implementing the HAL service.\n- Modify the framework to use the HAL service to find the value of a configuration item at runtime.\n\nConfiguration items currently referenced by the framework are included in a\nversioned HIDL package (`android.hardware.configstore@1.0`).\nVendors/OEMs provide values to the configuration items by implementing\ninterfaces in this package, and the framework uses the interfaces when it needs\nto get a value for a configuration item.\n\nSecurity considerations\n-----------------------\n\nBuild flags defined in the same interface are affected by same SELinux\npolicy. If one or more build flags should have different SELinux policies,\n**they must be separated to another interface** . This can require\nmajor revision of `android.hardware.configstore package` as the\nseparated interfaces are no longer backward-compatible.\n| **Note:** For details on SELinux, see [SELinux Overview](/docs/security/features/selinux)."]]