我们客户的应用程序主要功能是大量跟踪客户的设备,他们提供绑定到特定手机(而不是其所有者)的产品。使用设备imei可以做到这一点,但是随着Android 10中隐私权的更改,他们使其无法访问。(https://developer.android.com/about/versions/10/privacy/changes)。
Android上有关于在特定用户情况下使用什么标识符的文档,但与我们的情况不符,因为我们需要它唯一,恒定且绑定到设备(或至少难于更改)。https://developer.android.com/training/articles/user-data-ids。我正在考虑将Android ID用作可能的解决方案,或者使用知道它们不是100%可靠的mac地址。
有什么想法吗?建议?经验?在这一点上,任何选择都可以
在 Android O 上从本机获取序列号而不调用 Java 的正确方法是什么Build.getSerial()?
在 Android < 26 版本上,我们可以使用以下代码获取设备序列号:
string serial = read_property("ro.boot.serialno");
...
string read_property(const string& property_name) {
char propertyValue[PROP_VALUE_MAX];
int propertyLen = __system_property_get(property_name.c_str(), propertyValue);
...
}
Run Code Online (Sandbox Code Playgroud)
在 Android O 上,这会引发错误:
Access denied finding property "ro.boot.serialno"
Run Code Online (Sandbox Code Playgroud)
虽然READ_PHONE_STATE获得了许可。Build.SERIAL似乎与Android 26 中已弃用的内容有关。
我设法使用 获取此属性adb,因此该值不会被删除并且存在:
adb shell getprop ro.boot.serialno
Run Code Online (Sandbox Code Playgroud) 我知道我们可以通过使用类似的东西(在过去,在这里询问)来获取指定应用程序的网络使用情况(到目前为止,从某个特定时间到目前为止移动和Wifi的总带宽使用量):
private final static int[] NETWORKS_TYPES = new int[]{ConnectivityManager.TYPE_WIFI, ConnectivityManager.TYPE_MOBILE};
long rxBytes=0L, txBytes=0L;
final TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
final String subscriberId = telephonyManager.getSubscriberId();
final ApplicationInfo applicationInfo = context.getPackageManager().getApplicationInfo(packageName, 0);
final int uid = applicationInfo.uid;
for (int networkType : NETWORKS_TYPES) {
final NetworkStats networkStats = networkStatsManager.queryDetailsForUid(networkType, subscriberId, 0, System.currentTimeMillis(), uid);
final Bucket bucketOut = new Bucket();
while (true) {
networkStats.getNextBucket(bucketOut);
final long rxBytes = bucketOut.getRxBytes();
if (rxBytes >= 0)
totalRx += rxBytes;
final long txBytes = bucketOut.getTxBytes(); …Run Code Online (Sandbox Code Playgroud) 在 Android 10 之前,我使用TelephonyManagerAPI 来检索该信息,但它不再适用于 Android 10。
android ×4
imei ×2
android-10.0 ×1
api ×1
c++ ×1
identifier ×1
java ×1
native ×1
networking ×1