packages/apps/Settings
リビジョン | 9372484065993cfdb9a48ddecc52d2ed911e8ce1 (tree) |
---|---|
日時 | 2012-02-29 02:58:45 |
作者 | Amith Yamasani <yamasani@goog...> |
コミッター | Xavier Ducrohet |
Don't crash if there's no bluetooth functionality (such as in an emulator) do not merge.
Bug: 6079494
(cherry picked from commit 5fb53f36cb77c3d924b3fe5c305ce7d082ecdfb8)
Change-Id: Ia0d3a638f93c7c7923ce6e85f3555af0aeda96f9
@@ -138,21 +138,26 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment { | ||
138 | 138 | public void onResume() { |
139 | 139 | // resume BluetoothEnabler before calling super.onResume() so we don't get |
140 | 140 | // any onDeviceAdded() callbacks before setting up view in updateContent() |
141 | - mBluetoothEnabler.resume(); | |
141 | + if (mBluetoothEnabler != null) { | |
142 | + mBluetoothEnabler.resume(); | |
143 | + } | |
142 | 144 | super.onResume(); |
143 | 145 | |
144 | 146 | if (mDiscoverableEnabler != null) { |
145 | 147 | mDiscoverableEnabler.resume(); |
146 | 148 | } |
147 | 149 | getActivity().registerReceiver(mReceiver, mIntentFilter); |
148 | - | |
149 | - updateContent(mLocalAdapter.getBluetoothState(), mActivityStarted); | |
150 | + if (mLocalAdapter != null) { | |
151 | + updateContent(mLocalAdapter.getBluetoothState(), mActivityStarted); | |
152 | + } | |
150 | 153 | } |
151 | 154 | |
152 | 155 | @Override |
153 | 156 | public void onPause() { |
154 | 157 | super.onPause(); |
155 | - mBluetoothEnabler.pause(); | |
158 | + if (mBluetoothEnabler != null) { | |
159 | + mBluetoothEnabler.pause(); | |
160 | + } | |
156 | 161 | getActivity().unregisterReceiver(mReceiver); |
157 | 162 | if (mDiscoverableEnabler != null) { |
158 | 163 | mDiscoverableEnabler.pause(); |
@@ -161,6 +166,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment { | ||
161 | 166 | |
162 | 167 | @Override |
163 | 168 | public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { |
169 | + if (mLocalAdapter == null) return; | |
164 | 170 | boolean bluetoothIsEnabled = mLocalAdapter.getBluetoothState() == BluetoothAdapter.STATE_ON; |
165 | 171 | boolean isDiscovering = mLocalAdapter.isDiscovering(); |
166 | 172 | int textId = isDiscovering ? R.string.bluetooth_searching_for_devices : |
@@ -96,6 +96,7 @@ public abstract class DeviceListPreferenceFragment extends | ||
96 | 96 | @Override |
97 | 97 | public void onResume() { |
98 | 98 | super.onResume(); |
99 | + if (mLocalManager == null) return; | |
99 | 100 | |
100 | 101 | mLocalManager.setForegroundActivity(getActivity()); |
101 | 102 | mLocalManager.getEventManager().registerCallback(this); |
@@ -106,6 +107,8 @@ public abstract class DeviceListPreferenceFragment extends | ||
106 | 107 | @Override |
107 | 108 | public void onPause() { |
108 | 109 | super.onPause(); |
110 | + if (mLocalManager == null) return; | |
111 | + | |
109 | 112 | removeAllDevices(); |
110 | 113 | mLocalManager.setForegroundActivity(null); |
111 | 114 | mLocalManager.getEventManager().unregisterCallback(this); |