2025 年 3 月 27 日より、AOSP のビルドとコントリビューションには aosp-main
ではなく android-latest-release
を使用することをおすすめします。詳細については、AOSP の変更をご覧ください。
不変のデバイス ID
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Android 6 以降、Wi-Fi サービス プロバイダとパケット アナライザは、ネットワーク リクエストの Wi-Fi スタックを介してデバイスの出荷時 MAC アドレスを取得できなくなっています。Android 10 以降には追加の制限が適用され、特権の権限レベルを付与されたアプリがデバイス ID にアクセスすることはできません。これにより、次のようなデバイス ID が保護されます。
- テレフォニー IMEI 番号、MEID 番号、ESN 番号、IMSI 番号。
- ビルド、SIM、USB のシリアル番号。
デバイス ID にアクセスできるユーザー
すべての Android 10 デバイスでは、ターゲットが Android 9 以前のアプリであっても、デバイス ID へのアクセスが制限されています。デバイス ID にアクセスできるアプリとユーザーは次のとおりです。
特権パッケージのアクセス
デバイス ID にアクセスするにはパッケージに権限が必要です。Manifest.permission
クラスの
READ_PRIVILEGED_PHONE_STATE
権限が付与され、privapp-permission.xml
ファイルで許可リストに登録されている必要があります。許可リストのプロセスの詳細については、特権の許可リストへの登録をご覧ください。
非特権パッケージの一意の ID を取得する方法については、一般的なユースケースと使用すべき識別子をご覧ください。
制限されたデバイス ID とランダム MAC アドレス
デバイス ID をさらに制限するために、Android 10 を搭載したすべてのデバイスは、プローブおよび関連付けられたリクエストの両方に対してデフォルトでランダム MAC アドレスを送信します。ランダム MAC アドレスは SSID ごとに異なる必要があります。クライアント モード、ソフトウェア アクセス ポイント(AP)、Wi-Fi Direct のユースケースでは、デバイスの出荷時 MAC アドレスを使用しないでください。特権アプリではない一般公開 API に対しては、非表示のままにする必要があります。出荷時の MAC アドレスを返される必要がある特権アプリには、LOCAL_MAC_ADDRESS
権限が必要です。
ユーザーは、各 SSID に割り当てられているデフォルトのランダム MAC アドレスを保持することもできます。
この項目は、[設定] > [ネットワークの詳細] の [プライバシー] で確認できます。ランダム MAC アドレスの取得について詳しくは、ランダム MAC アドレスをご覧ください。
図 1. [ネットワークの詳細] の [プライバシー] にランダム化された MAC アドレスが表示される。
デバイス ID API を呼び出すアプリ
デバイス ID API を呼び出すアプリは、Android 10 の要件を満たしている必要があります。要件を満たしていない場合、デバイス ID にアクセスしようとすると、次のような結果になります。
- Android 10 をターゲットとするアプリ
- Android 9 以前をターゲットとするアプリ
READ_PHONE_STATE
権限がある場合は、null
レスポンスまたはプレースホルダ データが返されます。
- この権限がない場合、デバイス ID API は
SecurityException
をスローして、呼び出されたメソッドの名前と、呼び出し元アプリがリクエスト対象の ID にアクセスするための要件を満たしていないことを示します。
不変のデバイス ID について詳しくは、再設定不可能なデバイス ID と一意の ID に関するおすすめの方法をご覧ください。
テスト
デバイスのシリアル番号、該当する場合は IMEI または MEID、SIM のシリアル番号、および登録者 ID にアプリがアクセスできないようにする必要があります。これらの ID にアクセスする権限を持つアプリは、デバイス ID にアクセスできるユーザーに記載された条件のいずれかを満たすことも必要です。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-07-27 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-07-27 UTC。"],[],[],null,["# Immutable device IDs\n\nIn Android 6 and higher, Wi-Fi service providers and packet analyzers have\nbeen restricted from retrieving a device's factory MAC address through the\nWi-Fi stack from network requests. Starting in Android 10, additional restrictions are in place that limit access to device\nidentifiers (IDs) to apps with the [privileged](/docs/core/permissions/perms-allowlist)[permission\nlevel](https://developer.android.com/reference/android/R.attr.html#protectionLevel). This protects device IDs such as\n\n- telephony IMEI, MEID, ESN, and IMSI numbers.\n- build, SIM, or USB serial numbers.\n\n### Who can access device IDs\n\nDevice IDs are restricted on all Android 10\ndevices, even if apps target Android 9 or lower. Device IDs can be accessed by:\n\n- The default SMS app.\n- Apps with both [READ_PRIVILEGED_PHONE_STATE](/docs/core/permissions/perms-allowlist#customizing-allowlists) permission in the `\n `[Manifest.permission](https://developer.android.com/reference/android/Manifest.permission) class, and allowlisting in the `privapp-permission.xml` file. These must also be loaded in the `priv-app` directory.\n- Apps with carrier privileges as defined in [UICC Carrier\n Privileges](/docs/core/connect/uicc).\n- A device owner or profile owner with [READ_PHONE_STATE](https://developer.android.com/reference/android/Manifest.permission.html#READ_PHONE_STATE) permission granted in the [Manifest.permission](https://developer.android.com/reference/android/Manifest.permission) class. (Allowlisting isn't required.)\n\n#### Privileged packages access\n\nA package must be privileged to access device IDs. It must have\n[READ_PRIVILEGED_PHONE_STATE](/docs/core/permissions/perms-allowlist#customizing-allowlists) permission in the\n`Manifest.permission` class, and be allowlisted in the\n`privapp-permission.xml` file. For information on the allowlist\nprocess, see [Privileged\nPermission Allowlisting](/docs/core/permissions/perms-allowlist).\n\nFor information on getting a unique ID for a *nonprivileged* package,\nrefer to [Common use cases and the appropriate identifier to use](https://developer.android.com/training/articles/user-data-ids#common-use-cases).\n\n#### Restricted device IDs and randomized MAC addresses\n\nTo further restrict device IDs, all devices on Android 10 transmit randomized MAC addresses by default for both\nprobe and associated requests, and must have a different randomized MAC address\nfor each SSID. Don't use the device factory MAC address in client mode, soft\naccess point (AP), or Wi-Fi Direct use cases. It must remain hidden from\npublicly accessible APIs that aren't privileged apps. Privileged apps that\nrequire the factory MAC address to be returned are required to have\n`LOCAL_MAC_ADDRESS` permission.\n\nUsers have the option to keep the *default randomized* MAC address that's assigned to each SSID.\nThe option is viewable under **Privacy** in\n**Settings** \\\u003e **Network details** . To learn about\nobtaining a randomized MAC address see [Randomized MAC addresses](https://developer.android.com/about/versions/10/privacy/changes#data-ids).\n\n**Figure 1.**MAC address shows as randomized under Privacy in Network details.\n\n#### Apps that invoke device ID APIs\n\nApps that invoke device ID APIs must meet the Android 10 requirements. Otherwise, when they try to access\ndevice IDs the following is returned:\n\n- Apps targeting Android 10\n - [SecurityException](https://developer.android.com/reference/java/lang/SecurityException) is thrown from the device ID APIs.\n- Apps targeting Android 9 or earlier\n - If they have the [READ_PHONE_STATE](https://developer.android.com/reference/android/Manifest.permission.html#READ_PHONE_STATE) permission, either a `null` response or placeholder data is returned.\n - If they don't, the device ID APIs throw [SecurityException](https://developer.android.com/reference/java/lang/SecurityException) that contains the name of the method called, and an indication that the calling app doesn't meet the requirements to access the requested ID.\n\nFor more on immutable device IDs see [Nonresettable\ndevice identifiers](https://developer.android.com/about/versions/10/privacy/changes#data-ids) and [best practices\nfor unique identifiers](https://developer.android.com/training/articles/user-data-ids).\n\n### Testing\n\nApps *must* be prevented from accessing the device serial number and,\nwhere applicable, IMEI or MEID, SIM serial number, and subscriber ID. Apps with\npermission to access these IDs must also meet one of the criteria listed under\n[Who can access device IDs](#who-access)."]]