Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
516 views
in Technique[技术] by (71.8m points)

android - Get Static NFC Tag Id with HCE mode

I'm new in NFC thing, so I tested several phones with calling getTagId() method in HCE mode, and this is the result:

device       | UID
LG G2        | random
LG G3        | static
S4           | random
HTC One Mini | static
Xiaomi mi3   | static

My questions:

  1. Why do some phones have static UID and some do not? Is this chipset related?
  2. Is it possible to get a fixed UID? I need it to authenticate the device.
  3. On other side, I'm using Kitkat CyanogenMod 11 on Xperia M, but I did not manage to use it for HCE, why?

Any documents that can explain/support the answer?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Why do some phones have static UID and some do not? Is this chipset related?

That depends on the chipset and the implementation of the NFC stack. As far as I'm aware of, there are three different scenarios used by various Android NFC devices:

  • The device has a secure element and uses the static UID of that secure element.
  • The device generates a new random UID whenever it is turned on.
  • The device generates a new random UID on every activation by an external reader device. I.e. whenever an external HF field is applied to the NFC antenna of the Android device.
  • The device has no secure element but still uses a static UID (typically not unique), e.g. 0x01020304. [Thanks to ErikM for pointing this out.]

Is it possible to get a fixed UID?

Typically, you can't influence this. Specifically without modifying the Android device firmware (changes to the NFC stack) it's definitely not possible. See this answer for a method to set the UID value on Broadcom chipsets through modifying the libnfc-nci library.

I need it to authenticate the device.

Don't do this! See this answer for more information on that.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...