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:
@@ -20,6 +20,7 @@ import com.android.internal.telephony.PhoneStateIntentReceiver;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.database.ContentObserver;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.SystemProperties;
|
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) {
|
public AirplaneModeEnabler(Context context, CheckBoxPreference airplaneModeCheckBoxPreference) {
|
||||||
|
|
||||||
mContext = context;
|
mContext = context;
|
||||||
@@ -68,11 +76,15 @@ public class AirplaneModeEnabler implements Preference.OnPreferenceChangeListene
|
|||||||
|
|
||||||
mPhoneStateReceiver.registerIntent();
|
mPhoneStateReceiver.registerIntent();
|
||||||
mCheckBoxPref.setOnPreferenceChangeListener(this);
|
mCheckBoxPref.setOnPreferenceChangeListener(this);
|
||||||
|
mContext.getContentResolver().registerContentObserver(
|
||||||
|
Settings.System.getUriFor(Settings.System.AIRPLANE_MODE_ON), true,
|
||||||
|
mAirplaneModeObserver);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pause() {
|
public void pause() {
|
||||||
mPhoneStateReceiver.unregisterIntent();
|
mPhoneStateReceiver.unregisterIntent();
|
||||||
mCheckBoxPref.setOnPreferenceChangeListener(null);
|
mCheckBoxPref.setOnPreferenceChangeListener(null);
|
||||||
|
mContext.getContentResolver().unregisterContentObserver(mAirplaneModeObserver);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isAirplaneModeOn(Context context) {
|
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.
|
* - mobile does not send failure notification, fail on timeout.
|
||||||
*/
|
*/
|
||||||
private void onAirplaneModeChanged() {
|
private void onAirplaneModeChanged() {
|
||||||
ServiceState serviceState = mPhoneStateReceiver.getServiceState();
|
boolean airplaneModeEnabled = isAirplaneModeOn(mContext);
|
||||||
boolean airplaneModeEnabled = serviceState.getState() == ServiceState.STATE_POWER_OFF;
|
mCheckBoxPref.setChecked(isAirplaneModeOn(mContext));
|
||||||
mCheckBoxPref.setSummary(airplaneModeEnabled ? null :
|
mCheckBoxPref.setSummary(airplaneModeEnabled ? null :
|
||||||
mContext.getString(R.string.airplane_mode_summary));
|
mContext.getString(R.string.airplane_mode_summary));
|
||||||
}
|
}
|
||||||
|
@@ -111,8 +111,10 @@ class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
|
|||||||
" newProfileState " + newProfileState);
|
" newProfileState " + newProfileState);
|
||||||
}
|
}
|
||||||
|
|
||||||
int newState = LocalBluetoothProfileManager.getProfileManager(mLocalManager,
|
final LocalBluetoothProfileManager pm =
|
||||||
profile).convertState(newProfileState);
|
LocalBluetoothProfileManager.getProfileManager(mLocalManager, profile);
|
||||||
|
if (pm == null) return;
|
||||||
|
int newState = pm.convertState(newProfileState);
|
||||||
|
|
||||||
if (newState == SettingsBtStatus.CONNECTION_STATUS_CONNECTED) {
|
if (newState == SettingsBtStatus.CONNECTION_STATUS_CONNECTED) {
|
||||||
if (!mProfiles.contains(profile)) {
|
if (!mProfiles.contains(profile)) {
|
||||||
|
Reference in New Issue
Block a user