Skip to content

Commit 709c542

Browse files
Winson ChungAndroid (Google) Code Review
authored andcommitted
Merge "Fixing crash in emulator due to missing bluetooth." into jb-mr1-dev
2 parents 73e0d75 + 6072b00 commit 709c542

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

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

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,9 @@ private void startSettingsActivity(String action) {
167167
startSettingsActivity(intent);
168168
}
169169
private void startSettingsActivity(Intent intent) {
170-
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
170+
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
171171
mBar.collapseAllPanels(true);
172172
mContext.startActivity(intent);
173-
174173
}
175174

176175
private void addUserTiles(ViewGroup parent, LayoutInflater inflater) {
@@ -310,23 +309,25 @@ public void refreshView(QuickSettingsTileView view, State state) {
310309
parent.addView(airplaneTile);
311310

312311
// Bluetooth
313-
QuickSettingsTileView bluetoothTile = (QuickSettingsTileView)
314-
inflater.inflate(R.layout.quick_settings_tile, parent, false);
315-
bluetoothTile.setContent(R.layout.quick_settings_tile_bluetooth, inflater);
316-
bluetoothTile.setOnClickListener(new View.OnClickListener() {
317-
@Override
318-
public void onClick(View v) {
319-
startSettingsActivity(android.provider.Settings.ACTION_BLUETOOTH_SETTINGS);
320-
}
321-
});
322-
mModel.addBluetoothTile(bluetoothTile, new QuickSettingsModel.RefreshCallback() {
323-
@Override
324-
public void refreshView(QuickSettingsTileView view, State state) {
325-
TextView tv = (TextView) view.findViewById(R.id.bluetooth_textview);
326-
tv.setCompoundDrawablesRelativeWithIntrinsicBounds(0, state.iconId, 0, 0);
327-
}
328-
});
329-
parent.addView(bluetoothTile);
312+
if (mModel.deviceSupportsBluetooth()) {
313+
QuickSettingsTileView bluetoothTile = (QuickSettingsTileView)
314+
inflater.inflate(R.layout.quick_settings_tile, parent, false);
315+
bluetoothTile.setContent(R.layout.quick_settings_tile_bluetooth, inflater);
316+
bluetoothTile.setOnClickListener(new View.OnClickListener() {
317+
@Override
318+
public void onClick(View v) {
319+
startSettingsActivity(android.provider.Settings.ACTION_BLUETOOTH_SETTINGS);
320+
}
321+
});
322+
mModel.addBluetoothTile(bluetoothTile, new QuickSettingsModel.RefreshCallback() {
323+
@Override
324+
public void refreshView(QuickSettingsTileView view, State state) {
325+
TextView tv = (TextView) view.findViewById(R.id.bluetooth_textview);
326+
tv.setCompoundDrawablesRelativeWithIntrinsicBounds(0, state.iconId, 0, 0);
327+
}
328+
});
329+
parent.addView(bluetoothTile);
330+
}
330331

331332
// Brightness
332333
QuickSettingsTileView brightnessTile = (QuickSettingsTileView)

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,9 @@ void addBluetoothTile(QuickSettingsTileView view, RefreshCallback cb) {
258258
final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
259259
onBluetoothStateChange(adapter.isEnabled());
260260
}
261+
boolean deviceSupportsBluetooth() {
262+
return (BluetoothAdapter.getDefaultAdapter() != null);
263+
}
261264
// BluetoothController callback
262265
@Override
263266
public void onBluetoothStateChange(boolean on) {

0 commit comments

Comments
 (0)