Fix Bluetooth device name max length checking.

The Bluetooth device name has a maximum length of 248 bytes in UTF-8
encoding. The settings app previously limited the Bluetooth device
name entered by the user based on the number of characters, which is
incorrect when the name includes non-ASCII characters.

Created a new Utf8ByteLengthFilter class for BluetoothNamePreference
which counts UTF-8 bytes instead of Unicode characters, along with
unit tests.

We can move Utf8ByteLengthFilter into the framework in the future
if it would be useful elsewhere in the system or for applications.

Change-Id: I9debface09659f09d750f3bfe8ad6ddfd34c75c5
4 files changed