Add a new Bluetooth device details page
Bug: 35877479 Test: make RunSettingsRoboTests The existing behavior is to bring up a dialog with Bluetooth device details with checkboxes for each supported profile. This adds a new page that serves the same purpose with a switch for each profile and a footer containing the MAC address. Whether to use the new page or old dialog is controlled by a flag accessible via BluetoothFeatureProvider. Change-Id: I026c363d4cd33932a84017a67cbef51c258bad10
This commit is contained in:
@@ -17,7 +17,6 @@
|
||||
package com.android.settings.bluetooth;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.bluetooth.BluetoothClass;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
@@ -27,7 +26,6 @@ import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceViewHolder;
|
||||
import android.text.Html;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
import android.util.TypedValue;
|
||||
import android.widget.ImageView;
|
||||
@@ -38,10 +36,6 @@ import com.android.settings.core.instrumentation.MetricsFeatureProvider;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.widget.GearPreference;
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||
import com.android.settingslib.bluetooth.HidProfile;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothProfile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static android.os.UserManager.DISALLOW_CONFIG_BLUETOOTH;
|
||||
|
||||
@@ -63,18 +57,11 @@ public final class BluetoothDevicePreference extends GearPreference implements
|
||||
private String contentDescription = null;
|
||||
|
||||
/* Talk-back descriptions for various BT icons */
|
||||
Resources r = getContext().getResources();
|
||||
public final String COMPUTER = r.getString(R.string.bluetooth_talkback_computer);
|
||||
public final String INPUT_PERIPHERAL = r.getString(
|
||||
R.string.bluetooth_talkback_input_peripheral);
|
||||
public final String HEADSET = r.getString(R.string.bluetooth_talkback_headset);
|
||||
public final String PHONE = r.getString(R.string.bluetooth_talkback_phone);
|
||||
public final String IMAGING = r.getString(R.string.bluetooth_talkback_imaging);
|
||||
public final String HEADPHONE = r.getString(R.string.bluetooth_talkback_headphone);
|
||||
public final String BLUETOOTH = r.getString(R.string.bluetooth_talkback_bluetooth);
|
||||
Resources mResources;
|
||||
|
||||
public BluetoothDevicePreference(Context context, CachedBluetoothDevice cachedDevice) {
|
||||
super(context, null);
|
||||
mResources = getContext().getResources();
|
||||
mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
||||
|
||||
if (sDimAlpha == Integer.MIN_VALUE) {
|
||||
@@ -139,7 +126,8 @@ public final class BluetoothDevicePreference extends GearPreference implements
|
||||
}
|
||||
|
||||
|
||||
Pair<Integer, String> pair = getBtClassDrawableWithDescription();
|
||||
Pair<Integer, String> pair = Utils.getBtClassDrawableWithDescription(mResources,
|
||||
mCachedDevice);
|
||||
if (pair.first != 0) {
|
||||
setIcon(pair.first);
|
||||
contentDescription = pair.second;
|
||||
@@ -246,45 +234,4 @@ public final class BluetoothDevicePreference extends GearPreference implements
|
||||
}
|
||||
}
|
||||
|
||||
private Pair<Integer, String> getBtClassDrawableWithDescription() {
|
||||
BluetoothClass btClass = mCachedDevice.getBtClass();
|
||||
if (btClass != null) {
|
||||
switch (btClass.getMajorDeviceClass()) {
|
||||
case BluetoothClass.Device.Major.COMPUTER:
|
||||
return new Pair<Integer, String>(R.drawable.ic_bt_laptop, COMPUTER);
|
||||
|
||||
case BluetoothClass.Device.Major.PHONE:
|
||||
return new Pair<Integer, String>(R.drawable.ic_bt_cellphone, PHONE);
|
||||
|
||||
case BluetoothClass.Device.Major.PERIPHERAL:
|
||||
return new Pair<Integer, String>(HidProfile.getHidClassDrawable(btClass),
|
||||
INPUT_PERIPHERAL);
|
||||
|
||||
case BluetoothClass.Device.Major.IMAGING:
|
||||
return new Pair<Integer, String>(R.drawable.ic_bt_imaging, IMAGING);
|
||||
|
||||
default:
|
||||
// unrecognized device class; continue
|
||||
}
|
||||
} else {
|
||||
Log.w(TAG, "mBtClass is null");
|
||||
}
|
||||
|
||||
List<LocalBluetoothProfile> profiles = mCachedDevice.getProfiles();
|
||||
for (LocalBluetoothProfile profile : profiles) {
|
||||
int resId = profile.getDrawableResource(btClass);
|
||||
if (resId != 0) {
|
||||
return new Pair<Integer, String>(resId, null);
|
||||
}
|
||||
}
|
||||
if (btClass != null) {
|
||||
if (btClass.doesClassMatch(BluetoothClass.PROFILE_HEADSET)) {
|
||||
return new Pair<Integer, String>(R.drawable.ic_bt_headset_hfp, HEADSET);
|
||||
}
|
||||
if (btClass.doesClassMatch(BluetoothClass.PROFILE_A2DP)) {
|
||||
return new Pair<Integer, String>(R.drawable.ic_bt_headphones_a2dp, HEADPHONE);
|
||||
}
|
||||
}
|
||||
return new Pair<Integer, String>(R.drawable.ic_settings_bluetooth, BLUETOOTH);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user