2025 年 3 月 27 日より、AOSP のビルドとコントリビューションには aosp-main
ではなく android-latest-release
を使用することをおすすめします。詳細については、AOSP の変更をご覧ください。
アプリごとのネットワーク選択(PANS)
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
自動車では、OEM と車両所有者の両方から要求されるユースケースの増加に伴い、接続性への依存度が高まっており、その結果、データの使用量とそれに関連するコストが増加しています。OEM がコストを支払っているネットワークに特定のアプリのトラフィックをルーティングするには、PANS(per-application network selection)機能を使用します。
PANS を使用すると、データの使用量と費用を管理し、同時に堅牢かつ安全なコネクテッド カー エクスペリエンスを実現できます。PANS には次のような特長があります。
ConnectivityManager
に追加された、自動車デバイスでのみ使用可能な新しい API で構成されています。
- PANS ネットワーク機能の動的な変更をサポートするための最新の Wi-Fi suggestion API(インターネット接続のための Wi-Fi suggestion API を参照)を提供します。
- 補助的な指標を収集します。
- リファレンス アプリを提供します。
PANS を使用する理由
PANS では以下のことができます。
- アプリとネットワークの間のマッピングを動的に更新する
- アプリに変更を加えることなく、アプリレベルのルーティングを管理する
- OEM が許可するアプリのみが、マッピングされた OEM ネットワークにアクセスできるようにする
- アプリ デベロッパーは、この機能を実装するために変更を加える必要はありません。
- ユーザー向けの指標により、OEM が管理するネットワークにおけるアプリとネットワークの間のデータ使用量を追跡する
- 安全なネットワーク アクセスを実現し、意図しないユースケースや不正なアプリによって悪用されないようにする
- PANS のアプリとネットワークの間のマッピングが変更された場合、それをユーザーに通知する
- すべてのユーザーに同じネットワーク設定を適用する
主な利点
PANS には、OEM にとって次のような重要な利点があります。
- OEM は、ユーザーの代わりにネットワーク トラフィックの料金を支払うことができます。
- システム アップデートを無料でユーザーに提供できます。
- ユーザーが指定したアプリでネットワークを無料で使用できるようになります。
- ユーザーが、テレメトリーやその他の分析を無料で管理できます。
- OEM は、ユーザーが有料のデータプランに加入していなくても、重要アプリが接続された状態を維持できます。たとえば、地図、アシスタント(ハンズフリー運転)、システム アップデートなどの安全上重要な機能は、ユーザーがデータプランに加入していなくても引き続き機能します。
- PANS では、Android でのネットワーク トラフィック ルーティングに固有の制御をさらに細かく行うことができます。たとえば、OEM はアプリレベルのトラフィックのルーティングに対して論理ネットワーク トポロジを適切に定義できます。

図 1. PANS フレームワーク
PANS を実装する
PANS を実装するために、新しい ConnectivityManager
API(setOemNetworkPreference
)が提供されています。この新しい API は、アプリを OemNetworkPreference
にマッピングします。
この API は自動車デバイスでのみ使用可能で、新しい signature
権限を持つ @SystemApi
としてアノテーションが付けられます。

図 2. PANS を実装する
OemNetworkPreference
OemNetworkPreference
は、アプリをパッケージ名でネットワーク設定にマッピングする OEM_PAID
と OEM_PRIVATE
NetworkCapabilities
を要約したものです。ネットワーク設定により、ネットワーク階層を作成できます。
たとえば、アプリを OEM_NETWORK_PREFERENCE_OEM_PAID
設定にマッピングすると、アプリに割り当てられるデフォルト ネットワークの優先順位が決定されます。まず UNMETERED
ネットワークが使用され、UNMETERED
が使用できない場合は OEM_PAID
ネットワークが使用され、OEM_PAID
も使用できない場合はシステムのデフォルト ネットワークが使用されます。
OEM_PAID
: OEM ネットワークと非 OEM ネットワークの両方にルーティングされるアプリに主に使用します。
OEM_PRIVATE
: 主に、OEM アプリが OEM 専用のネットワークにアクセスできるようにするために使用します。
/**
* If an unmetered network is available, use it.
* Otherwise, if a network with the OEM_PAID capability is available, use it.
* Otherwise, use the general default network.
*/
public static final int OEM_NETWORK_PREFERENCE_OEM_PAID = 1;
/**
* If an unmetered network is available, use it.
* Otherwise, if a network with the OEM_PAID capability is available, use it.
* Otherwise, the app doesn't get a default network.
*/
public static final int OEM_NETWORK_PREFERENCE_OEM_PAID_NO_FALLBACK = 2;
/**
* Use only NET_CAPABILITY_OEM_PAID networks.
*/
public static final int OEM_NETWORK_PREFERENCE_OEM_PAID_ONLY = 3;
/**
* Use only NET_CAPABILITY_OEM_PRIVATE networks.
*/
public static final int OEM_NETWORK_PREFERENCE_OEM_PRIVATE_ONLY = 4;
PANS API の呼び出し
PANS API を使用するには:
OemNetworkPreferences
を使用して、アプリをネットワーク設定にマッピングします。
OemNetworkPreferences
オブジェクトで setOemNetworkPreference
を呼び出します。
Runnable
インターフェースを使用して、API の完了をリッスンします。
例:
// Mapping three packages to two network preferences
// Packages have a 1:1 mapping to network preferences
OemNetworkPreferences pref = new OemNetworkPreferences.Builder()
.addNetworkPreference("first.package.name", OEM_NETWORK_PREFERENCE_OEM_PAID)
.addNetworkPreference("second.package.name", OEM_NETWORK_PREFERENCE_OEM_PAID)
.addNetworkPreference("third.package.name", OEM_NETWORK_PREFERENCE_OEM_PRIVATE_ONLY)
.build();
myConnectivityManager.setOemNetworkPreference(pref, myExecutor, myListener);
留意事項
PANS を実装する場合は、次の点に注意してください。
- ネットワーク設定は再起動後には維持されないため、起動ごとに再適用する必要があります。
- アプリの設定を作成する際、そのアプリがインストールされている必要はありません。したがって、インストールされていないアプリでもネットワーク設定を事前に設定できます。
- どの時点であっても、1 つのネットワーク設定にマッピングできるのは 1 つのアプリのみです。
- ネットワーク設定は、アプリのデフォルト ネットワークの設定に使用されます。このネットワークはアプリが専用 API のいずれかを介して使用するネットワークを指定していない場合に使用されます。接続ニーズの大部分をカバーするだけでなく、既存のアプリのユースケースに悪影響が及ばないように、
NetworkRequest
API などの専用 API の使用を継続することもできます。たとえば、アプリが定額制ネットワークのみを経由してオペレーションを行う場合、PANS は別のネットワークの使用を強制しません。
OEM_PAID
または OEM_PRIVATE
機能のいずれかを使用するネットワーク設定を使用する場合、それぞれに対応する機能を備えたネットワークを使用できなければなりません。Android は、イーサネット ネットワークと Wi-Fi ネットワークの機能の設定をサポートしています。イーサネット ネットワークの場合は、リソース オーバーレイ config_ethernet_interfaces
を使用できます。これはコンパイル時に設定されます。
Wi-Fi の場合は、Android 12 の新しい API(setOemPaid(Boolean)
と setOemPrivate(Boolean)
)とあわせて WifiNetworkSuggestion
API を使用できます。これはランタイム時に変更できます。
次のような例を想定します。
config_ethernet_interfaces
という名前のリソース オーバーレイで、次の情報が指定されています。
- 設定するインターフェースの名前。
NetworkCapabilities
の目的の値。<!-- 11 NET_CAPABILITY_NOT_METERED
12 NET_CAPABILITY_INTERNET
14 NET_CAPABILITY_TRUSTED
15 NET_CAPABILITY_NOT_VPN
22 NET_CAPABILITY_OEM_PAID || 26 NET_CAPABILITY_OEM_PRIVATE -->
<string-array translatable="false" name="config_ethernet_interfaces">
<item>eth0;11,12,14,15,22;;</item></string-array>
- この
WiFiNetworkSuggestion
は動的に変更できます。
ArrayList<WifiNetworkSuggestion> list = new ArrayList<>();
list.add(new WifiNetworkSuggestion.Builder()
.setSsid(WifiInfo.sanitizeSsid(ssid))
.setOemPrivate(true)
.build());
mWifiManager.addNetworkSuggestions(list);
PANS ネットワークへのアクセス制限
OEM_PAID
または OEM_PRIVATE
のいずれかの機能をネットワークにタグ付けすると、そのネットワークは制限付きネットワークとしてマークされます。制限付きネットワークは、OEM が制御する CONNECTIVITY_USE_RESTRICTED_NETWORKS
権限を持つアプリのみが使用できます。
この権限を持つアプリは、制限付きネットワークの使用を明示的にリクエストしている場合にのみ、制限付きネットワークを使用できます。ただし、デフォルトでは、これらのアプリは制限付きネットワークを使用することはできません。PANS によりマッピングされたアプリでは、制限付き OEM ネットワークをデフォルトとして設定でき、制限付きネットワークの使用権限がなくてもこれらのネットワークを使用できます。そのようなアプリは、PANS によってデフォルト ネットワークとして OEM ネットワークが割り当てられている場合、アプリが OEM ネットワークを選択するのであれば、明示的に OEM ネットワークをリクエストできます。
リファレンス アプリを確認する
NetworkPreferenceApp
という名前のリファレンス アプリ(コードを含む)は、ユーザー デバッグ用の自動車用ビルドで提供されています。このリファレンス アプリでは、以下を行う方法を確認できます。
- PANS 指標を使用する。
- PANS ポリシーを設定する。
- デバイスのデフォルトのポリシーを設定する。
- ポリシーを消去する。
- 起動時にポリシーを適用する。
- Driver Distraction API を使用する(ドライバーの注意散漫に関するガイドラインをご覧ください)。
OEM_PAID
と OEM_PRIVATE
を使用して Wi-Fi を動的に更新する。

図 3. リファレンス アプリ
指標
データ使用量の透明性を高めるために、OEM_PAID
と OEM_PRIVATE
のネットワーク マッピング経由で送信されるデータの量に関する指標が収集され、提供されます。
トラブルシューティング
トラブルシューティングの多くは、アプリが間違ったネットワークを使用している(ネットワーク接続がない)か、データ通信の容量がオーバーすることで発生します。迅速に解決できるようにするには:
- Connectivity
dumpsys
には、アプリごとのアクティブなデフォルト ネットワークと、それに関連付けられているアプリ(PANS からマッピング)のリストが含まれています。
- Netd
dumpsys
には、UID IP とファイアウォール ルールが含まれています。
- Netstats
dumpsys
には、アプリごとの PANS 指標が含まれています(どのアプリがどの OEM ネットワークを使用したかなど)。
Android バグレポートを作成すると、すべての dumpsys
データが使用可能になります。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-06-12 UTC。
[[["わかりやすい","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-06-12 UTC。"],[],[],null,["# Per-application network selection (PANS)\n\nVehicles increasingly rely on connectivity to manage the growing list of\nuse cases requested by both OEMs and vehicle owners, resulting in an increased\ndata footprint and associated costs. Use the *per-application network selection\n(PANS)* feature to route the traffic of specified apps on networks paid for\nby the OEM.\n\nWith PANS, you can manage the volume and cost of data usage while simultaneously\nproviding a robust, secure, and connected car experience. PANS:\n\n- Consists of a new API added to `ConnectivityManager` available only to automotive devices.\n- Provides an updated Wi-Fi suggestion API (see [Wi-Fi suggestion API for internet connectivity](https://developer.android.com/guide/topics/connectivity/wifi-suggest)) to include support for dynamically changing PANS network capabilities.\n- Collects supporting metrics.\n- Provides a reference app.\n\nWhy PANS?\n---------\n\nPANS can:\n\n- Dynamically update app-to-network mappings.\n- Manage app-level routing without making changes to apps.\n- Only OEM-allowed apps can access the mapped OEM networks.\n- App developers needn't make any changes to implement this feature.\n- User-facing metrics track app-to-network data usage for OEM managed networks.\n- Network access is secure and can't be abused through unintended use cases or unauthorized apps.\n- Changes to PANS app-to-network mappings are communicated to users.\n- The same network configuration is applied across all users.\n\n### Core advantages\n\nPANS provides OEMS with these core advantages:\n\n1. OEMs can pay for network traffic instead of users:\n - System updates can be provided at no cost to the user.\n - Network usage of specified apps can be provided at no cost to the user.\n - Telemetry and other analytics can be managed at no cost to the user.\n2. OEMs can ensure critical apps remain connected even without a user-paid data plan. For example, safety-critical features such as maps, assistant (hands-free driving), and system updates continue to function even when a user has no data plan.\n3. PANS provides additional granularity of control specific to network traffic routing in Android. For example, OEMs can optimally define a logical network topology for the routing of app-level traffic.\n\n**Figure 1**. PANS framework\n\nImplement PANS\n--------------\n\nTo implement PANS, a new `ConnectivityManager` API,\n`setOemNetworkPreference`, is provided.\nThis new API maps apps to an `OemNetworkPreference`.\nThis API is available only to automotive devices and is annotated as a\n`@SystemApi` with a new `signature` permission.\n\n**Figure 2.** Implement PANS\n\n### OemNetworkPreference\n\n`OemNetworkPreference` is an abstraction over `OEM_PAID` and\n`OEM_PRIVATE` `NetworkCapabilities` mapping apps by package name\nto a *network preference* . Network preferences allow for network hierarchies.\nFor example, mapping an app to the `OEM_NETWORK_PREFERENCE_OEM_PAID` preference\nresults in the following priority of default networks assigned to an app: use an\n`UNMETERED` network first, if `UNMETERED` is not available use an\n`OEM_PAID` network, and if `OEM_PAID` is not available, use the system\ndefault network.\n\n- `OEM_PAID` Used primarily for apps that can be routed on both OEM and non-OEM networks.\n- `OEM_PRIVATE` Used primarily for OEM apps to gain access to a network dedicated to them.\n\n```scilab\n/**\n* If an unmetered network is available, use it.\n* Otherwise, if a network with the OEM_PAID capability is available, use it.\n* Otherwise, use the general default network.\n*/\npublic static final int OEM_NETWORK_PREFERENCE_OEM_PAID = 1;\n\n/**\n* If an unmetered network is available, use it.\n* Otherwise, if a network with the OEM_PAID capability is available, use it.\n* Otherwise, the app doesn't get a default network.\n*/\npublic static final int OEM_NETWORK_PREFERENCE_OEM_PAID_NO_FALLBACK = 2;\n\n/**\n* Use only NET_CAPABILITY_OEM_PAID networks.\n*/\npublic static final int OEM_NETWORK_PREFERENCE_OEM_PAID_ONLY = 3;\n\n/**\n* Use only NET_CAPABILITY_OEM_PRIVATE networks.\n*/\npublic static final int OEM_NETWORK_PREFERENCE_OEM_PRIVATE_ONLY = 4;\n```\n\n### Call PANS APIs\n\nTo use PANS APIs:\n\n1. Use `OemNetworkPreferences` to map an app to a network preference.\n2. Call `setOemNetworkPreference` with the `OemNetworkPreferences` object.\n3. Use the `Runnable` interface to listen for API completion.\n\nFor example: \n\n```carbon\n// Mapping three packages to two network preferences\n// Packages have a 1:1 mapping to network preferences\nOemNetworkPreferences pref = new OemNetworkPreferences.Builder()\n .addNetworkPreference(\"first.package.name\", OEM_NETWORK_PREFERENCE_OEM_PAID)\n .addNetworkPreference(\"second.package.name\", OEM_NETWORK_PREFERENCE_OEM_PAID)\n .addNetworkPreference(\"third.package.name\", OEM_NETWORK_PREFERENCE_OEM_PRIVATE_ONLY)\n .build();\n\nmyConnectivityManager.setOemNetworkPreference(pref, myExecutor, myListener);\n```\n\n### Considerations\n\nAs you implement PANS, keep the following points in mind:\n\n- Network preferences aren't persisted across boots and needs to be reapplied on each boot.\n- To create a preference for an app, it needn't be installed. Therefore, network preferences for uninstalled apps can be set proactively.\n- At any given time, an app can only be mapped to a single network preference.\n- Network preferences are used to set the default network of an app. This is the network used when an app hasn't specified what network(s) it wants to use through one of the specialized APIs. Not only does this cover the vast majority of connectivity needs, it also allows continued usage of specialized APIs such as the `NetworkRequest` API so as to not break existing app use-cases. For example, when an app only wants to do an operation over an unmetered network, PANS won't force it to use another network.\n\nConfigure a network\n-------------------\n\nA network with either the `OEM_PAID` or `OEM_PRIVATE`\ncapabilities must be available when using a corresponding network preference. Android\nprovides support for the configuration of capabilities for Ethernet and Wi-Fi networks. For\nEthernet networks, you can use a resource overlay, `config_ethernet_interfaces`.\nThis is set at compile time.\n\nFor Wi-Fi, the `WifiNetworkSuggestion` API can be used with the new\nAndroid 12 APIs, `setOemPaid(Boolean)` and\n`setOemPrivate(Boolean)`. This can be changed at runtime.\n\nConsider these examples:\n\n1. A resource overlay named `config_ethernet_interfaces` specifies:\n - The name of the interface to configure.\n - The desired `NetworkCapabilities` values. \n\n ```scdoc\n \u003c!-- 11 NET_CAPABILITY_NOT_METERED\n 12 NET_CAPABILITY_INTERNET\n 14 NET_CAPABILITY_TRUSTED\n 15 NET_CAPABILITY_NOT_VPN\n 22 NET_CAPABILITY_OEM_PAID || 26 NET_CAPABILITY_OEM_PRIVATE --\u003e\n \u003cstring-array translatable=\"false\" name=\"config_ethernet_interfaces\"\u003e\n \u003citem\u003eeth0;11,12,14,15,22;;\u003c/item\u003e\u003c/string-array\u003e\n ```\n2. This `WiFiNetworkSuggestion` can be changed dynamically: \n\n ```text\n ArrayList\u003cWifiNetworkSuggestion\u003e list = new ArrayList\u003c\u003e();\n list.add(new WifiNetworkSuggestion.Builder()\n .setSsid(WifiInfo.sanitizeSsid(ssid))\n .setOemPrivate(true)\n .build());\n mWifiManager.addNetworkSuggestions(list);\n ```\n\nRestrict access to PANS networks\n--------------------------------\n\nTagging a network with either the `OEM_PAID` or `OEM_PRIVATE`\ncapabilities marks that network as a *restricted network* . Restricted networks\ncan *only* be used by apps that have the\n`CONNECTIVITY_USE_RESTRICTED_NETWORKS` permission, which is controlled by OEMs.\n\nApps with this permission can use restricted networks *provided the apps explicitly request\nthem*. However, these apps won't get restricted networks as their default. Apps\nmapped through PANS can have restricted OEM networks set as their default and won't need\nthe restricted network permission to use them. When such an app has a restricted\nOEM network assigned as its default network by PANS, it also has the ability to\nexplicitly request said OEM network if the app chooses to do so.\n\nReview the reference app\n------------------------\n\nA reference app (including code) named `NetworkPreferenceApp` is provided\nin user-debug automotive builds and demonstrates how to:\n\n- Consume PANS metrics.\n- Set PANS policy.\n- Set a default policy for the device.\n- Clear a policy.\n- Apply a policy on boot.\n- Use the Driver Distraction API (see [Driver Distraction Guidelines](/docs/automotive/driver_distraction/guidelines)).\n- Dynamically update Wi-Fi with `OEM_PAID` and `OEM_PRIVATE`.\n\n**Figure 3.** Reference app\n\nMetrics\n-------\n\nTo facilitate transparency around data usage, metrics are collected and made\navailable regarding the amount of data transmitted over the\n`OEM_PAID` and `OEM_PRIVATE` network mappings.\n\nTroubleshooting\n---------------\n\nMost troubleshooting conditions arise from either an app using the wrong network\n(no network connectivity) or data overages. To enable quick resolutions:\n\n- Connectivity `dumpsys` includes a list of active per-app default networks and their associated apps (mapped from PANS).\n- Netd `dumpsys` includes UID IP and firewall rules.\n- Netstats `dumpsys` includes PANS per-app metrics. For example, which apps used which OEM network.\n\nAll `dumpsys` data is available by creating an Android bugreport."]]