Android ID 作为设备 ID 的替代

Android ID as an alternative to Device ID

我的应用程序一直使用 DeviceId 作为唯一标识符,这当然需要 READ_PHONE_STATE 作为权限。这在过去没问题,但现在我已经迁移到 Marshmellow 23,在那里请求此权限会在 运行 时显示一个非常可怕的对话框说...

"Allow {my app} to make and manage phone calls?"

对于只想获取 deviceId 的应用程序来说,这是一条非常可怕的消息。

我正在考虑切换到 Android ID,因为它不需要任何许可。

String androidId = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID);

谷歌搜索我发现使用 android ID 时出现了一些问题,但这些都是旧东西。在 Froyo 时代,有一家 phone 供应商为他们所有的 phone 生产了相同的 ID,但这就是我所看到的全部。

有人知道使用 Android ID 有什么问题吗? 谢谢, 院长

您选择使用什么唯一标识符在很大程度上取决于您需要标识符的具体用例。 Best Practices for Unique Identifiers training 经历了许多常见的用例以及要使用的标识符。他们确实有许多使用 Android 标识符的原则:

1: Avoid using hardware identifiers. Hardware identifiers such as SSAID (Android ID) and IMEI can be avoided in most use-cases without limiting required functionality.

2: Only use Advertising ID for user profiling or ads use-cases. When using an Advertising ID, always respect the Limit Ad Tracking flag, ensure the identifier cannot be connected to personally identifiable information (PII) and avoid bridging Advertising ID resets.

3: Use an Instance ID or a privately stored GUID whenever possible for all other use-cases except payment fraud prevention and telephony. For the vast majority of non-ads use-cases, an instance ID or GUID should be sufficient.

4: Use APIs that are appropriate to your use-case to minimize privacy risk. Use the DRM API API for high value content protection and the SafetyNet API for abuse prevention. The Safetynet API is the easiest way to determine whether a device is genuine without incurring privacy risk.

在绝大多数情况下,Android ID 仍然不是正确的选择。