Add device name to About Phone page.

The device name is reflected in three places: A Settings.Global flag
which can be read by third party apps, the Bluetooth device name, and
the Wi-Fi tethering hotspot name.

The Bluetooth and Wi-Fi names can be changed independently of the device
name, but if the user sets the device name, they are all changed in
parallel.

Due to the naming restrictions of Bluetooth devices and SSIDs, the SSID
naming restrictions apply to the device name.

Bug: 63819909
Test: Robotest
Change-Id: I3a81535fc07d183557a6fa5d54baef3c7868499c
This commit is contained in:
Daniel Nishi
2018-01-17 18:05:13 -08:00
parent eb4dceea7f
commit a633b39cfa
10 changed files with 356 additions and 9 deletions

View File

@@ -0,0 +1,28 @@
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.bluetooth;
/**
* Filter to max the length of a Bluetotoh device name to 248 bytes, as defined by the spec.
*/
public class BluetoothLengthDeviceNameFilter extends Utf8ByteLengthFilter {
private static final int BLUETOOTH_NAME_MAX_LENGTH_BYTES = 248;
public BluetoothLengthDeviceNameFilter() {
super(BLUETOOTH_NAME_MAX_LENGTH_BYTES);
}
}

View File

@@ -43,8 +43,6 @@ import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
*/
abstract class BluetoothNameDialogFragment extends InstrumentedDialogFragment
implements TextWatcher {
private static final int BLUETOOTH_NAME_MAX_LENGTH_BYTES = 248;
private AlertDialog mAlertDialog;
private Button mOkButton;
@@ -109,7 +107,7 @@ abstract class BluetoothNameDialogFragment extends InstrumentedDialogFragment
View view = layoutInflater.inflate(R.layout.dialog_edittext, null);
mDeviceNameView = (EditText) view.findViewById(R.id.edittext);
mDeviceNameView.setFilters(new InputFilter[] {
new Utf8ByteLengthFilter(BLUETOOTH_NAME_MAX_LENGTH_BYTES)
new BluetoothLengthDeviceNameFilter()
});
mDeviceNameView.setText(deviceName); // set initial value before adding listener
if (!TextUtils.isEmpty(deviceName)) {

View File

@@ -37,7 +37,7 @@ import android.text.Spanned;
* pairs are encoded as 4 bytes, with the caveat that the maximum
* length will be constrained more conservatively than necessary.
*/
class Utf8ByteLengthFilter implements InputFilter {
public class Utf8ByteLengthFilter implements InputFilter {
private final int mMaxBytes;
Utf8ByteLengthFilter(int maxBytes) {