summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
Diffstat (limited to 'services')
-rw-r--r--services/java/com/android/server/WifiService.java124
-rw-r--r--services/java/com/android/server/WindowManagerService.java2
-rw-r--r--services/java/com/android/server/WiredAccessoryObserver.java25
3 files changed, 62 insertions, 89 deletions
diff --git a/services/java/com/android/server/WifiService.java b/services/java/com/android/server/WifiService.java
index 2008215..9687aa7 100644
--- a/services/java/com/android/server/WifiService.java
+++ b/services/java/com/android/server/WifiService.java
@@ -134,12 +134,6 @@ public class WifiService extends IWifiManager.Stub {
*/
private static final long DEFAULT_SCAN_INTERVAL_MS = 60 * 1000; /* 1 minute */
- /**
- * Number of allowed radio frequency channels in various regulatory domains.
- * This list is sufficient for 802.11b/g networks (2.4GHz range).
- */
- private static int[] sValidRegulatoryChannelCounts = new int[] {11, 13, 14};
-
private static final String ACTION_DEVICE_IDLE =
"com.android.server.WifiManager.action.DEVICE_IDLE";
@@ -423,7 +417,12 @@ public class WifiService extends IWifiManager.Stub {
*/
public boolean pingSupplicant() {
enforceAccessPermission();
- return mWifiStateMachine.syncPingSupplicant();
+ if (mChannel != null) {
+ return mWifiStateMachine.syncPingSupplicant(mChannel);
+ } else {
+ Slog.e(TAG, "mChannel is not initialized");
+ return false;
+ }
}
/**
@@ -634,7 +633,12 @@ public class WifiService extends IWifiManager.Stub {
*/
public int addOrUpdateNetwork(WifiConfiguration config) {
enforceChangePermission();
- return mWifiStateMachine.syncAddOrUpdateNetwork(config);
+ if (mChannel != null) {
+ return mWifiStateMachine.syncAddOrUpdateNetwork(mChannel, config);
+ } else {
+ Slog.e(TAG, "mChannel is not initialized");
+ return -1;
+ }
}
/**
@@ -662,7 +666,12 @@ public class WifiService extends IWifiManager.Stub {
*/
public boolean enableNetwork(int netId, boolean disableOthers) {
enforceChangePermission();
- return mWifiStateMachine.syncEnableNetwork(netId, disableOthers);
+ if (mChannel != null) {
+ return mWifiStateMachine.syncEnableNetwork(mChannel, netId, disableOthers);
+ } else {
+ Slog.e(TAG, "mChannel is not initialized");
+ return false;
+ }
}
/**
@@ -673,7 +682,12 @@ public class WifiService extends IWifiManager.Stub {
*/
public boolean disableNetwork(int netId) {
enforceChangePermission();
- return mWifiStateMachine.syncDisableNetwork(netId);
+ if (mChannel != null) {
+ return mWifiStateMachine.syncDisableNetwork(mChannel, netId);
+ } else {
+ Slog.e(TAG, "mChannel is not initialized");
+ return false;
+ }
}
/**
@@ -708,86 +722,28 @@ public class WifiService extends IWifiManager.Stub {
public boolean saveConfiguration() {
boolean result = true;
enforceChangePermission();
- return mWifiStateMachine.syncSaveConfig();
- }
-
- /**
- * Set the number of radio frequency channels that are allowed to be used
- * in the current regulatory domain. This method should be used only
- * if the correct number of channels cannot be determined automatically
- * for some reason. If the operation is successful, the new value may be
- * persisted as a Secure setting.
- * @param numChannels the number of allowed channels. Must be greater than 0
- * and less than or equal to 16.
- * @param persist {@code true} if the setting should be remembered.
- * @return {@code true} if the operation succeeds, {@code false} otherwise, e.g.,
- * {@code numChannels} is outside the valid range.
- */
- public synchronized boolean setNumAllowedChannels(int numChannels, boolean persist) {
- Slog.i(TAG, "WifiService trying to setNumAllowed to "+numChannels+
- " with persist set to "+persist);
- enforceChangePermission();
-
- /*
- * Validate the argument. We'd like to let the Wi-Fi driver do this,
- * but if Wi-Fi isn't currently enabled, that's not possible, and
- * we want to persist the setting anyway,so that it will take
- * effect when Wi-Fi does become enabled.
- */
- boolean found = false;
- for (int validChan : sValidRegulatoryChannelCounts) {
- if (validChan == numChannels) {
- found = true;
- break;
- }
- }
- if (!found) {
+ if (mChannel != null) {
+ return mWifiStateMachine.syncSaveConfig(mChannel);
+ } else {
+ Slog.e(TAG, "mChannel is not initialized");
return false;
}
-
- if (persist) {
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.WIFI_NUM_ALLOWED_CHANNELS,
- numChannels);
- }
-
- mWifiStateMachine.setNumAllowedChannels(numChannels);
-
- return true;
- }
-
- /**
- * Return the number of frequency channels that are allowed
- * to be used in the current regulatory domain.
- * @return the number of allowed channels, or {@code -1} if an error occurs
- */
- public int getNumAllowedChannels() {
- int numChannels;
-
- enforceAccessPermission();
-
- /*
- * If we can't get the value from the driver (e.g., because
- * Wi-Fi is not currently enabled), get the value from
- * Settings.
- */
- numChannels = mWifiStateMachine.getNumAllowedChannels();
- if (numChannels < 0) {
- numChannels = Settings.Secure.getInt(mContext.getContentResolver(),
- Settings.Secure.WIFI_NUM_ALLOWED_CHANNELS,
- -1);
- }
- return numChannels;
}
/**
- * Return the list of valid values for the number of allowed radio channels
- * for various regulatory domains.
- * @return the list of channel counts
+ * Set the country code
+ * @param countryCode ISO 3166 country code.
+ * @param persist {@code true} if the setting should be remembered.
+ *
+ * The persist behavior exists so that wifi can fall back to the last
+ * persisted country code on a restart, when the locale information is
+ * not available from telephony.
*/
- public int[] getValidChannelCounts() {
- enforceAccessPermission();
- return sValidRegulatoryChannelCounts;
+ public void setCountryCode(String countryCode, boolean persist) {
+ Slog.i(TAG, "WifiService trying to set country code to " + countryCode +
+ " with persist set to " + persist);
+ enforceChangePermission();
+ mWifiStateMachine.setCountryCode(countryCode, persist);
}
/**
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index 55ebded..1cbc8324 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -687,7 +687,7 @@ public class WindowManagerService extends IWindowManager.Stub
}
}
if (touchedWin != null) {
- if (DEBUG_DRAG) {
+ if (false && DEBUG_DRAG) {
Slog.d(TAG, "sending DRAG_LOCATION to " + touchedWin);
}
DragEvent evt = DragEvent.obtain(DragEvent.ACTION_DRAG_LOCATION,
diff --git a/services/java/com/android/server/WiredAccessoryObserver.java b/services/java/com/android/server/WiredAccessoryObserver.java
index ab92fdf..2046473 100644
--- a/services/java/com/android/server/WiredAccessoryObserver.java
+++ b/services/java/com/android/server/WiredAccessoryObserver.java
@@ -37,20 +37,25 @@ import java.io.FileNotFoundException;
class WiredAccessoryObserver extends UEventObserver {
private static final String TAG = WiredAccessoryObserver.class.getSimpleName();
private static final boolean LOG = true;
- private static final int MAX_AUDIO_PORTS = 2; /* h2w & USB Audio */
+ private static final int MAX_AUDIO_PORTS = 3; /* h2w, USB Audio & hdmi */
private static final String uEventInfo[][] = { {"DEVPATH=/devices/virtual/switch/h2w",
"/sys/class/switch/h2w/state",
"/sys/class/switch/h2w/name"},
{"DEVPATH=/devices/virtual/switch/usb_audio",
"/sys/class/switch/usb_audio/state",
- "/sys/class/switch/usb_audio/name"} };
+ "/sys/class/switch/usb_audio/name"},
+ {"DEVPATH=/devices/virtual/switch/hdmi",
+ "/sys/class/switch/hdmi/state",
+ "/sys/class/switch/hdmi/name"} };
private static final int BIT_HEADSET = (1 << 0);
private static final int BIT_HEADSET_NO_MIC = (1 << 1);
private static final int BIT_USB_HEADSET_ANLG = (1 << 2);
private static final int BIT_USB_HEADSET_DGTL = (1 << 3);
+ private static final int BIT_HDMI_AUDIO = (1 << 4);
private static final int SUPPORTED_HEADSETS = (BIT_HEADSET|BIT_HEADSET_NO_MIC|
- BIT_USB_HEADSET_ANLG|BIT_USB_HEADSET_DGTL);
+ BIT_USB_HEADSET_ANLG|BIT_USB_HEADSET_DGTL|
+ BIT_HDMI_AUDIO);
private static final int HEADSETS_WITH_MIC = BIT_HEADSET;
private int mHeadsetState;
@@ -93,6 +98,11 @@ class WiredAccessoryObserver extends UEventObserver {
}
else switchState = (mHeadsetState & (BIT_HEADSET|BIT_HEADSET_NO_MIC));
}
+ else if ((event.get("SWITCH_NAME")).equals("hdmi")) {
+ switchState = ((mHeadsetState & (BIT_HEADSET|BIT_HEADSET_NO_MIC|
+ BIT_USB_HEADSET_DGTL|BIT_USB_HEADSET_ANLG)) |
+ (Integer.parseInt(event.get("SWITCH_STATE")) << 4));
+ }
else {
switchState = ((mHeadsetState & (BIT_USB_HEADSET_ANLG|BIT_USB_HEADSET_DGTL)) |
(Integer.parseInt(event.get("SWITCH_STATE"))));
@@ -204,7 +214,8 @@ class WiredAccessoryObserver extends UEventObserver {
if ((headsetState & headset) != 0) {
state = 1;
}
- if((headset == BIT_USB_HEADSET_ANLG) || (headset == BIT_USB_HEADSET_DGTL)) {
+ if((headset == BIT_USB_HEADSET_ANLG) || (headset == BIT_USB_HEADSET_DGTL) ||
+ (headset == BIT_HDMI_AUDIO)) {
Intent intent;
// Pack up the values and broadcast them to everyone
@@ -220,6 +231,12 @@ class WiredAccessoryObserver extends UEventObserver {
intent.putExtra("state", state);
intent.putExtra("name", headsetName);
ActivityManagerNative.broadcastStickyIntent(intent, null);
+ } else if (headset == BIT_HDMI_AUDIO) {
+ intent = new Intent(Intent.ACTION_HDMI_AUDIO_PLUG);
+ intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
+ intent.putExtra("state", state);
+ intent.putExtra("name", headsetName);
+ ActivityManagerNative.broadcastStickyIntent(intent, null);
}
if (LOG) Slog.v(TAG, "Intent.ACTION_USB_HEADSET_PLUG: state: "+state+" name: "+headsetName);