am 23bb90c1: am ae71d89a: Merge "Update airplane mode checkbox when toggled from system bar." into honeycomb

* commit '23bb90c1a73254400024566ec989de7d5047907c':
  Update airplane mode checkbox when toggled from system bar.
This commit is contained in:
Amith Yamasani
2011-01-26 13:20:00 -08:00
committed by Android Git Automerger
2 changed files with 20 additions and 6 deletions

View File

@@ -20,6 +20,7 @@ import com.android.internal.telephony.PhoneStateIntentReceiver;
import android.content.Context;
import android.content.Intent;
import android.database.ContentObserver;
import android.os.Handler;
import android.os.Message;
import android.os.SystemProperties;
@@ -51,6 +52,13 @@ public class AirplaneModeEnabler implements Preference.OnPreferenceChangeListene
}
};
private ContentObserver mAirplaneModeObserver = new ContentObserver(new Handler()) {
@Override
public void onChange(boolean selfChange) {
onAirplaneModeChanged();
}
};
public AirplaneModeEnabler(Context context, CheckBoxPreference airplaneModeCheckBoxPreference) {
mContext = context;
@@ -68,11 +76,15 @@ public class AirplaneModeEnabler implements Preference.OnPreferenceChangeListene
mPhoneStateReceiver.registerIntent();
mCheckBoxPref.setOnPreferenceChangeListener(this);
mContext.getContentResolver().registerContentObserver(
Settings.System.getUriFor(Settings.System.AIRPLANE_MODE_ON), true,
mAirplaneModeObserver);
}
public void pause() {
mPhoneStateReceiver.unregisterIntent();
mCheckBoxPref.setOnPreferenceChangeListener(null);
mContext.getContentResolver().unregisterContentObserver(mAirplaneModeObserver);
}
public static boolean isAirplaneModeOn(Context context) {
@@ -106,8 +118,8 @@ public class AirplaneModeEnabler implements Preference.OnPreferenceChangeListene
* - mobile does not send failure notification, fail on timeout.
*/
private void onAirplaneModeChanged() {
ServiceState serviceState = mPhoneStateReceiver.getServiceState();
boolean airplaneModeEnabled = serviceState.getState() == ServiceState.STATE_POWER_OFF;
boolean airplaneModeEnabled = isAirplaneModeOn(mContext);
mCheckBoxPref.setChecked(isAirplaneModeOn(mContext));
mCheckBoxPref.setSummary(airplaneModeEnabled ? null :
mContext.getString(R.string.airplane_mode_summary));
}

View File

@@ -111,8 +111,10 @@ class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
" newProfileState " + newProfileState);
}
int newState = LocalBluetoothProfileManager.getProfileManager(mLocalManager,
profile).convertState(newProfileState);
final LocalBluetoothProfileManager pm =
LocalBluetoothProfileManager.getProfileManager(mLocalManager, profile);
if (pm == null) return;
int newState = pm.convertState(newProfileState);
if (newState == SettingsBtStatus.CONNECTION_STATUS_CONNECTED) {
if (!mProfiles.contains(profile)) {