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,20 +17,28 @@
|
||||
package com.android.settings.bluetooth;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.bluetooth.BluetoothClass;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.bluetooth.BluetoothProfile;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.res.Resources;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.util.Pair;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||
import com.android.settingslib.bluetooth.HidProfile;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothManager.BluetoothManagerCallback;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothProfile;
|
||||
import com.android.settingslib.bluetooth.Utils.ErrorListener;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Utils is a helper class that contains constants for various
|
||||
* Android resource IDs, debug logging flags, and static methods
|
||||
@@ -141,4 +149,52 @@ public final class Utils {
|
||||
com.android.settingslib.bluetooth.Utils.setErrorListener(mErrorListener);
|
||||
}
|
||||
};
|
||||
|
||||
static Pair<Integer, String> getBtClassDrawableWithDescription(Resources r,
|
||||
CachedBluetoothDevice cachedDevice) {
|
||||
BluetoothClass btClass = cachedDevice.getBtClass();
|
||||
if (btClass != null) {
|
||||
switch (btClass.getMajorDeviceClass()) {
|
||||
case BluetoothClass.Device.Major.COMPUTER:
|
||||
return new Pair<Integer, String>(R.drawable.ic_bt_laptop,
|
||||
r.getString(R.string.bluetooth_talkback_computer));
|
||||
|
||||
case BluetoothClass.Device.Major.PHONE:
|
||||
return new Pair<Integer, String>(R.drawable.ic_bt_cellphone,
|
||||
r.getString(R.string.bluetooth_talkback_phone));
|
||||
|
||||
case BluetoothClass.Device.Major.PERIPHERAL:
|
||||
return new Pair<Integer, String>(HidProfile.getHidClassDrawable(btClass),
|
||||
r.getString(
|
||||
R.string.bluetooth_talkback_input_peripheral));
|
||||
|
||||
case BluetoothClass.Device.Major.IMAGING:
|
||||
return new Pair<Integer, String>(R.drawable.ic_bt_imaging,
|
||||
r.getString(R.string.bluetooth_talkback_imaging));
|
||||
|
||||
default:
|
||||
// unrecognized device class; continue
|
||||
}
|
||||
}
|
||||
|
||||
List<LocalBluetoothProfile> profiles = cachedDevice.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,
|
||||
r.getString(R.string.bluetooth_talkback_headset));
|
||||
}
|
||||
if (btClass.doesClassMatch(BluetoothClass.PROFILE_A2DP)) {
|
||||
return new Pair<Integer, String>(R.drawable.ic_bt_headphones_a2dp,
|
||||
r.getString(R.string.bluetooth_talkback_headphone));
|
||||
}
|
||||
}
|
||||
return new Pair<Integer, String>(R.drawable.ic_settings_bluetooth,
|
||||
r.getString(R.string.bluetooth_talkback_bluetooth));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user