Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0a3d73ca authored by Erik Ljungberg's avatar Erik Ljungberg Committed by Steve Kondik
Browse files

Limit bluetooth device name to safe length to avoid crashes

Bluetooth device name can become too long when unicode characters are
used. For device name the max length is 248 bytes but since a unicode
character can be up to 4 bytes the safe length is only 62.

Change-Id: I4a345125f82863e13b8faffece4b2e4718bbd129
parent 87b9b7dd
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -40,8 +40,9 @@ import android.widget.EditText;
 */
public class BluetoothNamePreference extends EditTextPreference implements TextWatcher {
    private static final String TAG = "BluetoothNamePreference";
    // TODO(): Investigate bluetoothd/dbus crash when length is set to 248, limit as per spec.
    private static final int BLUETOOTH_NAME_MAX_LENGTH = 200;
    // Bluetooth spec says length is limited to 248 bytes. Since utf-8 encoding can be 4 bytes
    // per character it is only safe with max length of 62.
    private static final int BLUETOOTH_NAME_MAX_LENGTH = 62;

    private LocalBluetoothManager mLocalManager;