[nearby] Update encoding and decoding according to the spec

Test: w/ MainlineTestApp
Fix: 290294482
Ignore-AOSP-First: nearby_not_in_aosp_yet
(cherry picked from https://googleplex-android-review.googlesource.com/q/17a0803df0c82377ed4afda50c24d59b4a814002)
Merged-In: Ie50d3fae62af6f637583216e3dae5841c1214aa3
Change-Id: Ie50d3fae62af6f637583216e3dae5841c1214aa3
4 files changed