除了IMEI,Android_ID,WLAN Mac和蓝牙地址之外的设备的完美unique_id [英] Perfect unique_id for device except IMEI,Android_ID,WLAN Mac and Bluetooth address

查看:29
本文介绍了除了IMEI,Android_ID,WLAN Mac和蓝牙地址之外的设备的完美unique_id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目标:

我正在寻找一种方法来为 android 设备找出 unique_id.

背景:

我将在登录请求负载中使用 Id,并且由于我的应用是基于许可的服务应用,因此 Id 在正常情况下不应更改.

现有方法:

在 iOS 中,有一些 iOS 的唯一 id 解决方案,例如 CFUUIDidentifierForVendor再加上钥匙串、广告标识符等,可以达到预期的效果.

但在 Android 中,我所知道的所有选项似乎都有漏洞.

IMEI:

TelephonyManager TelephonyMgr = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);String m_deviceId = TelephonyMgr.getDeviceId();

缺点

它依赖于sim卡所以

  • 如果没有sim卡那我们就完蛋了

  • 如果有双卡,那我们就完蛋了

Android_ID:

 String m_androidId = Secure.getString(getContentResolver(), Secure.ANDROID_ID);

缺点

  • 如果操作系统版本升级,则可能会发生变化
  • 如果设备被植根,它就会被改变
  • 不能保证 device_id 是唯一的,有报道称一些制造商有重复的 device_id

WLAN MAC 地址

WifiManager m_wm = (WifiManager)getSystemService(Context.WIFI_SERVICE);String m_wlanMacAdd = m_wm.getConnectionInfo().getMacAddress();

缺点

  • 如果没有 wifi 硬件,我们就完蛋了
  • 在一些新设备中,如果 wifi 关闭,我们就完蛋了.

蓝牙地址:

 BluetoothAdapter m_BluetoothAdapter = BluetoothAdapter.getDefaultAdapter();String m_bluetoothAdd = m_BluetoothAdapter.getAddress();

缺点:

  • 如果没有蓝牙硬件,我们就完蛋了.
  • 将来在某些新设备中,如果它关闭,我们可能无法读取它.

可能的解决方案:

我认为有两种方法可以解决这个问题

  • 我们通过使用我提到的唯一 id 散列时间戳来生成一个随机 id 并存储它,以便下次登录时我们将检查 key 的存储值是否为 null 如果是,那么我们将生成并存储它,否则我们将使用密钥的值.

    如果有与 iOS 的 keychain 等效的东西,那么我们很适合这种方法.

  • 找到一个全局标识符,例如 iOS 的 advertisingIdentifier,它对设备中的所有应用程序都相同.

感谢任何帮助!

解决方案

我选择使用 Android_ID 因为它不依赖于任何硬件.

Build.SERIAL 还取决于仅限 wifi 的设备电话的可用性,此 Build.SERIAL 将不起作用.>

我已经在问题本身中解释了其他方法如何依赖于硬件可用性.

Objective:

I am looking for a way to find out a unique_id for android device.

Background:

I will use the Id in login request payload and as my app is license based service app the Id should not change under normal circumstances.

Existing Approaches:

In iOS there are some unique id solutions for iOS such as CFUUID or identifierForVendor coupled with Keychain,Advertising Identifier etc.. that can do this job upto the expectation.

But in Android all the options that I know seems to have hole in it.

IMEI:

TelephonyManager TelephonyMgr = (TelephonyManager)getSystemService(TELEPHONY_SERVICE); 
String m_deviceId = TelephonyMgr.getDeviceId();

Drawbacks

It is sim card dependent so

  • If there is no sim card then we're doomed

  • If there is dual sim then we're dommed

Android_ID:

  String m_androidId = Secure.getString(getContentResolver(), Secure.ANDROID_ID);

Drawbacks

  • If OS version is upgraded then it may change
  • If device is rooted it gets changed
  • No guarantee that the device_id is unique there are some reports some manufacturers are having duplicate device_id

The WLAN MAC Address

WifiManager m_wm = (WifiManager)getSystemService(Context.WIFI_SERVICE); 
String m_wlanMacAdd = m_wm.getConnectionInfo().getMacAddress();

Drawbacks

  • If there is no wifi hardware then we're doomed
  • In some new devices If wifi is off then we're doomed.

Bluetooth Address:

   BluetoothAdapter m_BluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); 
   String m_bluetoothAdd = m_BluetoothAdapter.getAddress();

Drawbacks:

  • if there is no bluetooth hardware we're doomed.
  • In future in some new devices we mightn't able to read it if its off.

Possible solutions:

There are two approaches that I think to solve this problem

  • We generate a random id by hashing timestamp with unique ids that I have mentioned and store it so next time during login we’ll check if the the stored value of key is null if its so then we’ll generate and store it else we’ll use the value of the key.

    If there is something equivalent to keychain of iOS then we’re good with this approach.

  • Find a global identifier something like advertisingIdentifier of iOS which is same for all the apps in the device.

Any help is appreciated !

解决方案

I have chosen to use Android_ID since It's not dependent on any hardware.

Build.SERIAL also dependent on availability of telephony that is in wifi only devices this Build.SERIAL won't work.

I have explained how other approaches are dependent upon the hardware availability in the question itself.

这篇关于除了IMEI,Android_ID,WLAN Mac和蓝牙地址之外的设备的完美unique_id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆