Loading src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java +40 −26 Original line number Diff line number Diff line Loading @@ -274,11 +274,14 @@ public class AdvancedBluetoothDetailsHeaderController extends BasePreferenceCont showBatteryPredictionIfNecessary(linearLayout, deviceId, batteryLevel); } final TextView batterySummaryView = linearLayout.findViewById(R.id.bt_battery_summary); if (isUntetheredHeadset(bluetoothDevice)) { if (batteryLevel != BluetoothUtils.META_INT_ERROR) { linearLayout.setVisibility(View.VISIBLE); batterySummaryView.setText(com.android.settings.Utils.formatPercentage(batteryLevel)); batterySummaryView.setText( com.android.settings.Utils.formatPercentage(batteryLevel)); batterySummaryView.setVisibility(View.VISIBLE); int lowBatteryLevel = BluetoothUtils.getIntMetaData(bluetoothDevice, lowBatteryMetaKey); int lowBatteryLevel = BluetoothUtils.getIntMetaData(bluetoothDevice, lowBatteryMetaKey); if (lowBatteryLevel == BluetoothUtils.META_INT_ERROR) { if (batteryMetaKey == BluetoothDevice.METADATA_UNTETHERED_CASE_BATTERY) { lowBatteryLevel = CASE_LOW_BATTERY_LEVEL; Loading @@ -294,7 +297,8 @@ public class AdvancedBluetoothDetailsHeaderController extends BasePreferenceCont int level = bluetoothDevice.getBatteryLevel(); if (level != BluetoothDevice.BATTERY_LEVEL_UNKNOWN && level != BluetoothDevice.BATTERY_LEVEL_BLUETOOTH_OFF) { batterySummaryView.setText(com.android.settings.Utils.formatPercentage(level)); batterySummaryView.setText( com.android.settings.Utils.formatPercentage(level)); batterySummaryView.setVisibility(View.VISIBLE); } else { batterySummaryView.setVisibility(View.GONE); Loading @@ -304,7 +308,9 @@ public class AdvancedBluetoothDetailsHeaderController extends BasePreferenceCont linearLayout.setVisibility(View.GONE); } } } else { batterySummaryView.setVisibility(View.GONE); } final TextView textView = linearLayout.findViewById(R.id.header_title); if (deviceId == MAIN_DEVICE_ID) { textView.setVisibility(View.GONE); Loading @@ -314,6 +320,14 @@ public class AdvancedBluetoothDetailsHeaderController extends BasePreferenceCont } } private boolean isUntetheredHeadset(BluetoothDevice bluetoothDevice) { return BluetoothUtils.getBooleanMetaData(bluetoothDevice, BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET) || TextUtils.equals(BluetoothUtils.getStringMetaData(bluetoothDevice, BluetoothDevice.METADATA_DEVICE_TYPE), BluetoothDevice.DEVICE_TYPE_UNTETHERED_HEADSET); } private void showBatteryPredictionIfNecessary(LinearLayout linearLayout, int batteryId, int batteryLevel) { ThreadUtils.postOnBackgroundThread(() -> { Loading Loading
src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java +40 −26 Original line number Diff line number Diff line Loading @@ -274,11 +274,14 @@ public class AdvancedBluetoothDetailsHeaderController extends BasePreferenceCont showBatteryPredictionIfNecessary(linearLayout, deviceId, batteryLevel); } final TextView batterySummaryView = linearLayout.findViewById(R.id.bt_battery_summary); if (isUntetheredHeadset(bluetoothDevice)) { if (batteryLevel != BluetoothUtils.META_INT_ERROR) { linearLayout.setVisibility(View.VISIBLE); batterySummaryView.setText(com.android.settings.Utils.formatPercentage(batteryLevel)); batterySummaryView.setText( com.android.settings.Utils.formatPercentage(batteryLevel)); batterySummaryView.setVisibility(View.VISIBLE); int lowBatteryLevel = BluetoothUtils.getIntMetaData(bluetoothDevice, lowBatteryMetaKey); int lowBatteryLevel = BluetoothUtils.getIntMetaData(bluetoothDevice, lowBatteryMetaKey); if (lowBatteryLevel == BluetoothUtils.META_INT_ERROR) { if (batteryMetaKey == BluetoothDevice.METADATA_UNTETHERED_CASE_BATTERY) { lowBatteryLevel = CASE_LOW_BATTERY_LEVEL; Loading @@ -294,7 +297,8 @@ public class AdvancedBluetoothDetailsHeaderController extends BasePreferenceCont int level = bluetoothDevice.getBatteryLevel(); if (level != BluetoothDevice.BATTERY_LEVEL_UNKNOWN && level != BluetoothDevice.BATTERY_LEVEL_BLUETOOTH_OFF) { batterySummaryView.setText(com.android.settings.Utils.formatPercentage(level)); batterySummaryView.setText( com.android.settings.Utils.formatPercentage(level)); batterySummaryView.setVisibility(View.VISIBLE); } else { batterySummaryView.setVisibility(View.GONE); Loading @@ -304,7 +308,9 @@ public class AdvancedBluetoothDetailsHeaderController extends BasePreferenceCont linearLayout.setVisibility(View.GONE); } } } else { batterySummaryView.setVisibility(View.GONE); } final TextView textView = linearLayout.findViewById(R.id.header_title); if (deviceId == MAIN_DEVICE_ID) { textView.setVisibility(View.GONE); Loading @@ -314,6 +320,14 @@ public class AdvancedBluetoothDetailsHeaderController extends BasePreferenceCont } } private boolean isUntetheredHeadset(BluetoothDevice bluetoothDevice) { return BluetoothUtils.getBooleanMetaData(bluetoothDevice, BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET) || TextUtils.equals(BluetoothUtils.getStringMetaData(bluetoothDevice, BluetoothDevice.METADATA_DEVICE_TYPE), BluetoothDevice.DEVICE_TYPE_UNTETHERED_HEADSET); } private void showBatteryPredictionIfNecessary(LinearLayout linearLayout, int batteryId, int batteryLevel) { ThreadUtils.postOnBackgroundThread(() -> { Loading