MacAddress: address api review comments

1) toSafeString() is renamed to toOuiString()
2) toOuiString() returns a String that only contains the first 3 bytes
   of the mac address.

Bug: 70336442
Test: runtest frameworks-net
Change-Id: I798d8fec32dbff5687a682028e5d90eb941f81c1
This commit is contained in:
Hugo Benichi 2017-12-15 10:07:35 +09:00
commit 3f83b8ad4e

View file

@ -130,11 +130,12 @@ public final class MacAddress implements Parcelable {
}
/**
* @return a String representation of the OUI part of this MacAddres,
* with the lower 3 bytes constituting the NIC part replaced with 0.
* @return a String representation of the OUI part of this MacAddress made of 3 hexadecimal
* numbers in [0,ff] joined by ':' characters.
*/
public String toSafeString() {
return stringAddrFromLongAddr(mAddr & OUI_MASK);
public String toOuiString() {
return String.format(
"%02x:%02x:%02x", (mAddr >> 40) & 0xff, (mAddr >> 32) & 0xff, (mAddr >> 24) & 0xff);
}
@Override