Merge commit '47cc8112c3f77637ef408ef18e48d146e8250a27' into eclair-mr2-plus-aosp * commit '47cc8112c3f77637ef408ef18e48d146e8250a27': Fix updating Bluetooth icon on status bar and for Wifi.
This commit is contained in:
@@ -25,6 +25,7 @@ import static android.net.wifi.WifiManager.WIFI_STATE_UNKNOWN;
|
|||||||
import android.app.AlarmManager;
|
import android.app.AlarmManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.bluetooth.BluetoothA2dp;
|
import android.bluetooth.BluetoothA2dp;
|
||||||
|
import android.bluetooth.BluetoothDevice;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -62,6 +63,7 @@ import java.util.HashMap;
|
|||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.io.FileDescriptor;
|
import java.io.FileDescriptor;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
@@ -109,7 +111,7 @@ public class WifiService extends IWifiManager.Stub {
|
|||||||
private int mMulticastDisabled;
|
private int mMulticastDisabled;
|
||||||
|
|
||||||
private final IBatteryStats mBatteryStats;
|
private final IBatteryStats mBatteryStats;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See {@link Settings.Gservices#WIFI_IDLE_MS}. This is the default value if a
|
* See {@link Settings.Gservices#WIFI_IDLE_MS}. This is the default value if a
|
||||||
* Settings.Gservices value is not present. This timeout value is chosen as
|
* Settings.Gservices value is not present. This timeout value is chosen as
|
||||||
@@ -162,7 +164,7 @@ public class WifiService extends IWifiManager.Stub {
|
|||||||
* Last UID that asked to enable WIFI.
|
* Last UID that asked to enable WIFI.
|
||||||
*/
|
*/
|
||||||
private int mLastEnableUid = Process.myUid();
|
private int mLastEnableUid = Process.myUid();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Number of allowed radio frequency channels in various regulatory domains.
|
* Number of allowed radio frequency channels in various regulatory domains.
|
||||||
* This list is sufficient for 802.11b/g networks (2.4GHz range).
|
* This list is sufficient for 802.11b/g networks (2.4GHz range).
|
||||||
@@ -177,7 +179,7 @@ public class WifiService extends IWifiManager.Stub {
|
|||||||
mWifiStateTracker = tracker;
|
mWifiStateTracker = tracker;
|
||||||
mWifiStateTracker.enableRssiPolling(true);
|
mWifiStateTracker.enableRssiPolling(true);
|
||||||
mBatteryStats = BatteryStatsService.getService();
|
mBatteryStats = BatteryStatsService.getService();
|
||||||
|
|
||||||
mScanResultCache = new LinkedHashMap<String, ScanResult>(
|
mScanResultCache = new LinkedHashMap<String, ScanResult>(
|
||||||
SCAN_RESULT_CACHE_SIZE, 0.75f, true) {
|
SCAN_RESULT_CACHE_SIZE, 0.75f, true) {
|
||||||
/*
|
/*
|
||||||
@@ -396,7 +398,7 @@ public class WifiService extends IWifiManager.Stub {
|
|||||||
} finally {
|
} finally {
|
||||||
Binder.restoreCallingIdentity(ident);
|
Binder.restoreCallingIdentity(ident);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update state
|
// Update state
|
||||||
mWifiState = wifiState;
|
mWifiState = wifiState;
|
||||||
|
|
||||||
@@ -1380,11 +1382,16 @@ public class WifiService extends IWifiManager.Stub {
|
|||||||
}
|
}
|
||||||
mPluggedType = pluggedType;
|
mPluggedType = pluggedType;
|
||||||
} else if (action.equals(BluetoothA2dp.ACTION_SINK_STATE_CHANGED)) {
|
} else if (action.equals(BluetoothA2dp.ACTION_SINK_STATE_CHANGED)) {
|
||||||
boolean isBluetoothPlaying =
|
BluetoothA2dp a2dp = new BluetoothA2dp(mContext);
|
||||||
intent.getIntExtra(
|
Set<BluetoothDevice> sinks = a2dp.getConnectedSinks();
|
||||||
BluetoothA2dp.EXTRA_SINK_STATE,
|
boolean isBluetoothPlaying = false;
|
||||||
BluetoothA2dp.STATE_DISCONNECTED) == BluetoothA2dp.STATE_PLAYING;
|
for (BluetoothDevice sink : sinks) {
|
||||||
|
if (a2dp.getSinkState(sink) == BluetoothA2dp.STATE_PLAYING) {
|
||||||
|
isBluetoothPlaying = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
mWifiStateTracker.setBluetoothScanMode(isBluetoothPlaying);
|
mWifiStateTracker.setBluetoothScanMode(isBluetoothPlaying);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1396,7 +1403,7 @@ public class WifiService extends IWifiManager.Stub {
|
|||||||
* Determines whether the Wi-Fi chipset should stay awake or be put to
|
* Determines whether the Wi-Fi chipset should stay awake or be put to
|
||||||
* sleep. Looks at the setting for the sleep policy and the current
|
* sleep. Looks at the setting for the sleep policy and the current
|
||||||
* conditions.
|
* conditions.
|
||||||
*
|
*
|
||||||
* @see #shouldDeviceStayAwake(int, int)
|
* @see #shouldDeviceStayAwake(int, int)
|
||||||
*/
|
*/
|
||||||
private boolean shouldWifiStayAwake(int stayAwakeConditions, int pluggedType) {
|
private boolean shouldWifiStayAwake(int stayAwakeConditions, int pluggedType) {
|
||||||
@@ -1415,7 +1422,7 @@ public class WifiService extends IWifiManager.Stub {
|
|||||||
return shouldDeviceStayAwake(stayAwakeConditions, pluggedType);
|
return shouldDeviceStayAwake(stayAwakeConditions, pluggedType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine whether the bit value corresponding to {@code pluggedType} is set in
|
* Determine whether the bit value corresponding to {@code pluggedType} is set in
|
||||||
* the bit string {@code stayAwakeConditions}. Because a {@code pluggedType} value
|
* the bit string {@code stayAwakeConditions}. Because a {@code pluggedType} value
|
||||||
@@ -1509,7 +1516,7 @@ public class WifiService extends IWifiManager.Stub {
|
|||||||
intentFilter.addAction(BluetoothA2dp.ACTION_SINK_STATE_CHANGED);
|
intentFilter.addAction(BluetoothA2dp.ACTION_SINK_STATE_CHANGED);
|
||||||
mContext.registerReceiver(mReceiver, intentFilter);
|
mContext.registerReceiver(mReceiver, intentFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isAirplaneSensitive() {
|
private boolean isAirplaneSensitive() {
|
||||||
String airplaneModeRadios = Settings.System.getString(mContext.getContentResolver(),
|
String airplaneModeRadios = Settings.System.getString(mContext.getContentResolver(),
|
||||||
Settings.System.AIRPLANE_MODE_RADIOS);
|
Settings.System.AIRPLANE_MODE_RADIOS);
|
||||||
|
|||||||
@@ -283,7 +283,7 @@ public class StatusBarPolicy {
|
|||||||
private IBinder mBluetoothIcon;
|
private IBinder mBluetoothIcon;
|
||||||
private IconData mBluetoothData;
|
private IconData mBluetoothData;
|
||||||
private int mBluetoothHeadsetState;
|
private int mBluetoothHeadsetState;
|
||||||
private int mBluetoothA2dpState;
|
private boolean mBluetoothA2dpConnected;
|
||||||
private int mBluetoothPbapState;
|
private int mBluetoothPbapState;
|
||||||
private boolean mBluetoothEnabled;
|
private boolean mBluetoothEnabled;
|
||||||
|
|
||||||
@@ -455,7 +455,7 @@ public class StatusBarPolicy {
|
|||||||
} else {
|
} else {
|
||||||
mBluetoothEnabled = false;
|
mBluetoothEnabled = false;
|
||||||
}
|
}
|
||||||
mBluetoothA2dpState = BluetoothA2dp.STATE_DISCONNECTED;
|
mBluetoothA2dpConnected = false;
|
||||||
mBluetoothHeadsetState = BluetoothHeadset.STATE_DISCONNECTED;
|
mBluetoothHeadsetState = BluetoothHeadset.STATE_DISCONNECTED;
|
||||||
mBluetoothPbapState = BluetoothPbap.STATE_DISCONNECTED;
|
mBluetoothPbapState = BluetoothPbap.STATE_DISCONNECTED;
|
||||||
mService.setIconVisibility(mBluetoothIcon, mBluetoothEnabled);
|
mService.setIconVisibility(mBluetoothIcon, mBluetoothEnabled);
|
||||||
@@ -636,12 +636,12 @@ public class StatusBarPolicy {
|
|||||||
int flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
|
int flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
|
||||||
| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
|
| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
|
||||||
| WindowManager.LayoutParams.FLAG_DIM_BEHIND;
|
| WindowManager.LayoutParams.FLAG_DIM_BEHIND;
|
||||||
|
|
||||||
if (!mContext.getResources().getBoolean(
|
if (!mContext.getResources().getBoolean(
|
||||||
com.android.internal.R.bool.config_sf_slowBlur)) {
|
com.android.internal.R.bool.config_sf_slowBlur)) {
|
||||||
flags |= WindowManager.LayoutParams.FLAG_BLUR_BEHIND;
|
flags |= WindowManager.LayoutParams.FLAG_BLUR_BEHIND;
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
|
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||||
@@ -1083,7 +1083,6 @@ public class StatusBarPolicy {
|
|||||||
|
|
||||||
private final void updateBluetooth(Intent intent) {
|
private final void updateBluetooth(Intent intent) {
|
||||||
int iconId = com.android.internal.R.drawable.stat_sys_data_bluetooth;
|
int iconId = com.android.internal.R.drawable.stat_sys_data_bluetooth;
|
||||||
|
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
|
if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
|
||||||
int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR);
|
int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR);
|
||||||
@@ -1092,8 +1091,12 @@ public class StatusBarPolicy {
|
|||||||
mBluetoothHeadsetState = intent.getIntExtra(BluetoothHeadset.EXTRA_STATE,
|
mBluetoothHeadsetState = intent.getIntExtra(BluetoothHeadset.EXTRA_STATE,
|
||||||
BluetoothHeadset.STATE_ERROR);
|
BluetoothHeadset.STATE_ERROR);
|
||||||
} else if (action.equals(BluetoothA2dp.ACTION_SINK_STATE_CHANGED)) {
|
} else if (action.equals(BluetoothA2dp.ACTION_SINK_STATE_CHANGED)) {
|
||||||
mBluetoothA2dpState = intent.getIntExtra(BluetoothA2dp.EXTRA_SINK_STATE,
|
BluetoothA2dp a2dp = new BluetoothA2dp(mContext);
|
||||||
BluetoothA2dp.STATE_DISCONNECTED);
|
if (a2dp.getConnectedSinks().size() != 0) {
|
||||||
|
mBluetoothA2dpConnected = true;
|
||||||
|
} else {
|
||||||
|
mBluetoothA2dpConnected = false;
|
||||||
|
}
|
||||||
} else if (action.equals(BluetoothPbap.PBAP_STATE_CHANGED_ACTION)) {
|
} else if (action.equals(BluetoothPbap.PBAP_STATE_CHANGED_ACTION)) {
|
||||||
mBluetoothPbapState = intent.getIntExtra(BluetoothPbap.PBAP_STATE,
|
mBluetoothPbapState = intent.getIntExtra(BluetoothPbap.PBAP_STATE,
|
||||||
BluetoothPbap.STATE_DISCONNECTED);
|
BluetoothPbap.STATE_DISCONNECTED);
|
||||||
@@ -1101,9 +1104,7 @@ public class StatusBarPolicy {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mBluetoothHeadsetState == BluetoothHeadset.STATE_CONNECTED ||
|
if (mBluetoothHeadsetState == BluetoothHeadset.STATE_CONNECTED || mBluetoothA2dpConnected ||
|
||||||
mBluetoothA2dpState == BluetoothA2dp.STATE_CONNECTED ||
|
|
||||||
mBluetoothA2dpState == BluetoothA2dp.STATE_PLAYING ||
|
|
||||||
mBluetoothPbapState == BluetoothPbap.STATE_CONNECTED) {
|
mBluetoothPbapState == BluetoothPbap.STATE_CONNECTED) {
|
||||||
iconId = com.android.internal.R.drawable.stat_sys_data_bluetooth_connected;
|
iconId = com.android.internal.R.drawable.stat_sys_data_bluetooth_connected;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user