Skip to content

Commit e3b7a2d

Browse files
committed
Fix initial Bluetooth icon state.
Bug: 5206026 Change-Id: I17cd7ec00fefc0598673b885331c03ebbdf1bc39
1 parent 0f167d7 commit e3b7a2d

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public class PhoneStatusBarPolicy {
8282
private boolean mVolumeVisible;
8383

8484
// bluetooth device status
85-
private boolean mBluetoothEnabled;
85+
private boolean mBluetoothEnabled = false;
8686

8787
// wifi
8888
private static final int[][] sWifiSignalImages = {
@@ -139,6 +139,18 @@ public PhoneStatusBarPolicy(Context context) {
139139
mContext = context;
140140
mService = (StatusBarManager)context.getSystemService(Context.STATUS_BAR_SERVICE);
141141

142+
// listen for broadcasts
143+
IntentFilter filter = new IntentFilter();
144+
filter.addAction(Intent.ACTION_ALARM_CHANGED);
145+
filter.addAction(Intent.ACTION_SYNC_STATE_CHANGED);
146+
filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
147+
filter.addAction(AudioManager.VIBRATE_SETTING_CHANGED_ACTION);
148+
filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
149+
filter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED);
150+
filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
151+
filter.addAction(TtyIntent.TTY_ENABLED_CHANGE_ACTION);
152+
mContext.registerReceiver(mIntentReceiver, filter, null, mHandler);
153+
142154
// storage
143155
mStorageManager = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE);
144156
mStorageManager.registerListener(
@@ -153,13 +165,15 @@ public PhoneStatusBarPolicy(Context context) {
153165
mService.setIconVisibility("cdma_eri", false);
154166

155167
// bluetooth status
156-
mService.setIcon("bluetooth", R.drawable.stat_sys_data_bluetooth, 0, null);
157168
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
169+
int bluetoothIcon = R.drawable.stat_sys_data_bluetooth;
158170
if (adapter != null) {
159-
mBluetoothEnabled = adapter.isEnabled();
160-
} else {
161-
mBluetoothEnabled = false;
171+
mBluetoothEnabled = (adapter.getState() == BluetoothAdapter.STATE_ON);
172+
if (adapter.getConnectionState() == BluetoothAdapter.STATE_CONNECTED) {
173+
bluetoothIcon = R.drawable.stat_sys_data_bluetooth_connected;
174+
}
162175
}
176+
mService.setIcon("bluetooth", bluetoothIcon, 0, null);
163177
mService.setIconVisibility("bluetooth", mBluetoothEnabled);
164178

165179
// Alarm clock
@@ -176,19 +190,6 @@ public PhoneStatusBarPolicy(Context context) {
176190
mService.setIcon("volume", R.drawable.stat_sys_ringer_silent, 0, null);
177191
mService.setIconVisibility("volume", false);
178192
updateVolume();
179-
180-
IntentFilter filter = new IntentFilter();
181-
182-
// Register for Intent broadcasts for...
183-
filter.addAction(Intent.ACTION_ALARM_CHANGED);
184-
filter.addAction(Intent.ACTION_SYNC_STATE_CHANGED);
185-
filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
186-
filter.addAction(AudioManager.VIBRATE_SETTING_CHANGED_ACTION);
187-
filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
188-
filter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED);
189-
filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
190-
filter.addAction(TtyIntent.TTY_ENABLED_CHANGE_ACTION);
191-
mContext.registerReceiver(mIntentReceiver, filter, null, mHandler);
192193
}
193194

194195
private final void updateAlarm(Intent intent) {

0 commit comments

Comments
 (0)