Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java +1 −9 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import android.app.AlarmManager; import android.app.AlarmManager.AlarmClockInfo; import android.app.IActivityManager; import android.app.SynchronousUserSwitchObserver; import android.bluetooth.BluetoothDevice; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; Loading @@ -43,7 +42,6 @@ import android.view.View; import androidx.lifecycle.Observer; import com.android.settingslib.bluetooth.CachedBluetoothDevice; import com.android.systemui.R; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.dagger.qualifiers.DisplayId; Loading Loading @@ -231,7 +229,6 @@ public class PhoneStatusBarPolicy filter.addAction(AudioManager.ACTION_HEADSET_PLUG); filter.addAction(Intent.ACTION_SIM_STATE_CHANGED); filter.addAction(BluetoothDevice.ACTION_BATTERY_LEVEL_CHANGED); filter.addAction(TelecomManager.ACTION_CURRENT_TTY_MODE_CHANGED); filter.addAction(Intent.ACTION_MANAGED_PROFILE_AVAILABLE); filter.addAction(Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE); Loading Loading @@ -443,9 +440,7 @@ public class PhoneStatusBarPolicy if (mBluetooth.isBluetoothConnected() && (mBluetooth.isBluetoothAudioActive() || !mBluetooth.isBluetoothAudioProfileOnly())) { List<CachedBluetoothDevice> connectedDevices = mBluetooth.getConnectedDevices(); int batteryLevel = connectedDevices.isEmpty() ? -1 : connectedDevices.get(0).getBatteryLevel(); int batteryLevel = mBluetooth.getBatteryLevel(); if (batteryLevel == 100) { iconId = R.drawable.stat_sys_data_bluetooth_connected_battery_9; } else if (batteryLevel >= 90) { Loading Loading @@ -742,9 +737,6 @@ public class PhoneStatusBarPolicy case AudioManager.ACTION_HEADSET_PLUG: updateHeadsetPlug(intent); break; case BluetoothDevice.ACTION_BATTERY_LEVEL_CHANGED: updateBluetooth(); break; } } }; Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothController.java +2 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,8 @@ public interface BluetoothController extends CallbackController<Callback>, Dumpa int getBondState(CachedBluetoothDevice device); List<CachedBluetoothDevice> getConnectedDevices(); int getBatteryLevel(); public interface Callback { void onBluetoothStateChange(boolean enabled); void onBluetoothDevicesChanged(); Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothControllerImpl.java +19 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,7 @@ public class BluetoothControllerImpl implements BluetoothController, BluetoothCa private int mConnectionState = BluetoothAdapter.STATE_DISCONNECTED; private boolean mAudioProfileOnly; private boolean mIsActive; private int mBatteryLevel; private final H mHandler; private int mState; Loading Loading @@ -107,6 +108,7 @@ public class BluetoothControllerImpl implements BluetoothController, BluetoothCa pw.print(" mEnabled="); pw.println(mEnabled); pw.print(" mConnectionState="); pw.println(stateToString(mConnectionState)); pw.print(" mAudioProfileOnly="); pw.println(mAudioProfileOnly); pw.print(" mBatteryLevel="); pw.println(mBatteryLevel); pw.print(" mIsActive="); pw.println(mIsActive); pw.print(" mConnectedDevices="); pw.println(mConnectedDevices); pw.print(" mCallbacks.size="); pw.println(mHandler.mCallbacks.size()); Loading Loading @@ -255,6 +257,7 @@ public class BluetoothControllerImpl implements BluetoothController, BluetoothCa mHandler.sendEmptyMessage(H.MSG_STATE_CHANGED); } updateAudioProfile(); updateBattery(); } private void updateActive() { Loading Loading @@ -298,6 +301,22 @@ public class BluetoothControllerImpl implements BluetoothController, BluetoothCa } @Override public int getBatteryLevel() { if (!mConnectedDevices.isEmpty()) { return mConnectedDevices.get(0).getBatteryLevel(); } return -1; } private void updateBattery() { int batteryLevel = getBatteryLevel(); if (batteryLevel != mBatteryLevel) { mBatteryLevel = batteryLevel; mHandler.sendEmptyMessage(H.MSG_STATE_CHANGED); } } @Override public void onBluetoothStateChanged(int bluetoothState) { if (DEBUG) Log.d(TAG, "BluetoothStateChanged=" + stateToString(bluetoothState)); Loading packages/SystemUI/tests/src/com/android/systemui/utils/leaks/FakeBluetoothController.java +5 −0 Original line number Diff line number Diff line Loading @@ -110,4 +110,9 @@ public class FakeBluetoothController extends BaseLeakChecker<Callback> implement public List<CachedBluetoothDevice> getConnectedDevices() { return Collections.emptyList(); } @Override public int getBatteryLevel() { return 0; } } Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java +1 −9 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import android.app.AlarmManager; import android.app.AlarmManager.AlarmClockInfo; import android.app.IActivityManager; import android.app.SynchronousUserSwitchObserver; import android.bluetooth.BluetoothDevice; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; Loading @@ -43,7 +42,6 @@ import android.view.View; import androidx.lifecycle.Observer; import com.android.settingslib.bluetooth.CachedBluetoothDevice; import com.android.systemui.R; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.dagger.qualifiers.DisplayId; Loading Loading @@ -231,7 +229,6 @@ public class PhoneStatusBarPolicy filter.addAction(AudioManager.ACTION_HEADSET_PLUG); filter.addAction(Intent.ACTION_SIM_STATE_CHANGED); filter.addAction(BluetoothDevice.ACTION_BATTERY_LEVEL_CHANGED); filter.addAction(TelecomManager.ACTION_CURRENT_TTY_MODE_CHANGED); filter.addAction(Intent.ACTION_MANAGED_PROFILE_AVAILABLE); filter.addAction(Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE); Loading Loading @@ -443,9 +440,7 @@ public class PhoneStatusBarPolicy if (mBluetooth.isBluetoothConnected() && (mBluetooth.isBluetoothAudioActive() || !mBluetooth.isBluetoothAudioProfileOnly())) { List<CachedBluetoothDevice> connectedDevices = mBluetooth.getConnectedDevices(); int batteryLevel = connectedDevices.isEmpty() ? -1 : connectedDevices.get(0).getBatteryLevel(); int batteryLevel = mBluetooth.getBatteryLevel(); if (batteryLevel == 100) { iconId = R.drawable.stat_sys_data_bluetooth_connected_battery_9; } else if (batteryLevel >= 90) { Loading Loading @@ -742,9 +737,6 @@ public class PhoneStatusBarPolicy case AudioManager.ACTION_HEADSET_PLUG: updateHeadsetPlug(intent); break; case BluetoothDevice.ACTION_BATTERY_LEVEL_CHANGED: updateBluetooth(); break; } } }; Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothController.java +2 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,8 @@ public interface BluetoothController extends CallbackController<Callback>, Dumpa int getBondState(CachedBluetoothDevice device); List<CachedBluetoothDevice> getConnectedDevices(); int getBatteryLevel(); public interface Callback { void onBluetoothStateChange(boolean enabled); void onBluetoothDevicesChanged(); Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothControllerImpl.java +19 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,7 @@ public class BluetoothControllerImpl implements BluetoothController, BluetoothCa private int mConnectionState = BluetoothAdapter.STATE_DISCONNECTED; private boolean mAudioProfileOnly; private boolean mIsActive; private int mBatteryLevel; private final H mHandler; private int mState; Loading Loading @@ -107,6 +108,7 @@ public class BluetoothControllerImpl implements BluetoothController, BluetoothCa pw.print(" mEnabled="); pw.println(mEnabled); pw.print(" mConnectionState="); pw.println(stateToString(mConnectionState)); pw.print(" mAudioProfileOnly="); pw.println(mAudioProfileOnly); pw.print(" mBatteryLevel="); pw.println(mBatteryLevel); pw.print(" mIsActive="); pw.println(mIsActive); pw.print(" mConnectedDevices="); pw.println(mConnectedDevices); pw.print(" mCallbacks.size="); pw.println(mHandler.mCallbacks.size()); Loading Loading @@ -255,6 +257,7 @@ public class BluetoothControllerImpl implements BluetoothController, BluetoothCa mHandler.sendEmptyMessage(H.MSG_STATE_CHANGED); } updateAudioProfile(); updateBattery(); } private void updateActive() { Loading Loading @@ -298,6 +301,22 @@ public class BluetoothControllerImpl implements BluetoothController, BluetoothCa } @Override public int getBatteryLevel() { if (!mConnectedDevices.isEmpty()) { return mConnectedDevices.get(0).getBatteryLevel(); } return -1; } private void updateBattery() { int batteryLevel = getBatteryLevel(); if (batteryLevel != mBatteryLevel) { mBatteryLevel = batteryLevel; mHandler.sendEmptyMessage(H.MSG_STATE_CHANGED); } } @Override public void onBluetoothStateChanged(int bluetoothState) { if (DEBUG) Log.d(TAG, "BluetoothStateChanged=" + stateToString(bluetoothState)); Loading
packages/SystemUI/tests/src/com/android/systemui/utils/leaks/FakeBluetoothController.java +5 −0 Original line number Diff line number Diff line Loading @@ -110,4 +110,9 @@ public class FakeBluetoothController extends BaseLeakChecker<Callback> implement public List<CachedBluetoothDevice> getConnectedDevices() { return Collections.emptyList(); } @Override public int getBatteryLevel() { return 0; } }