[英]Android device id doesn't match on Physical Device & Emulator
I found an application & they are using Device Identity as user login.我找到了一个应用程序,他们使用设备标识作为用户登录。 After uninstall & install its showing same DeviceID.
卸载并安装后显示相同的 DeviceID。 When I test this app on my android device.
当我在我的 android 设备上测试这个应用程序时。 The device identity doesn't match with this String.
设备标识与此字符串不匹配。
String android_id = Settings.Secure.getString(this.getContentResolver(),
Settings.Secure.ANDROID_ID);
But when I tried this on android emulator string matched with that app device ID.但是当我在与该应用程序设备 ID 匹配的 android 模拟器字符串上尝试此操作时。 But in my physical Device....
但是在我的物理设备中......
Showing on that app: 93edad60438f8004
在该应用程序上显示: 93edad60438f8004
Getting String Device ID: 5f1cf6393c37ae96
获取字符串设备 ID: 5f1cf6393c37ae96
How can I get device ID as that application?如何获取该应用程序的设备 ID?
As of Android 26, every app on the device gets told a different Android ID for privacy reasons.截至 Android 26,出于隐私原因,设备上的每个应用程序都会被告知不同的 Android ID。 This prevents companies from being able to share data on a user without his permission by just correlating the device id.
这可以防止公司仅通过关联设备 ID 就可以在未经用户许可的情况下共享用户数据。
Also, a device id should NEVER be used as login credentials.此外,设备 ID 永远不应用作登录凭据。 I can get a version of Android that allows me to claim whatever id I want on an emulator with a quick recompile of AOSP.
我可以获得一个版本 Android,它允许我通过快速重新编译 AOSP 在模拟器上声明我想要的任何 ID。 It can be spoofed way too easily.
它很容易被欺骗。 If you need to be able to log in a device, use a randomly generated key from your server and encrypt it with a key stored in the keystore.
如果您需要能够登录设备,请使用从您的服务器随机生成的密钥,并使用存储在密钥库中的密钥对其进行加密。 Do not count on an hardware identifier.
不要指望硬件标识符。 They can be spoofed, and just as importantly you can't revoke them without breaking the user's ability to use your app.
它们可以被欺骗,同样重要的是,您不能在不破坏用户使用您的应用程序的情况下撤销它们。 With a randomly generated token you can invalidate it server side and the user just has to log in again.
使用随机生成的令牌,您可以使其在服务器端无效,用户只需重新登录即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.