Ported: Bluetooth Message Access Profile (MAP) from CM9

This was added to CM10 to restore message exchange capabilities with automotive systems.

Change-Id: Ib872bebc5c292b1f84c903b068e59b7eeca6d76f
Bluetooth MAP (Message Access Profile) Upstream Changes (3/3)

PORTED FROM CM10: http://review.cyanogenmod.org/#/c/26419/

Incorporates updates to the Bluetooth MAP profile from Code Aurora's
Android Enablement Project since we initially pulled in from their
gingerbread to CM7 last year. This patch addresses bugs with the
current MAP profile, adds a UI request for message access approval
when pairing, and adds additional error checking and logging.
Confirmed to fix date and "Download" function of Ford SYNC Gen1.
Pulled in from the codeaurora jb branch.

Change-Id: I5c7e7396e0e97760bba9bdf4bf848b6bfa58e62c
wifi: Allow Settings to retrieve country code

This makes getCountryCode behave like getFrequencyBand

This allows Settings to get/set country code like
it can for frequency band.

Change-Id: Id9f00d3a678642c6c142fd1511af820d729507a7
Wi-Fi: Ping the driver for wifi-only devices

Wifi-only devices are not capable to find APs with hidden SSID unless a DRIVER COUNTRY command
will send to wifi driver. This change has:

- Send DRIVER COUNTRY command to ping the driver (to correct the seek of hiddens SSIDs)
- Save mCountryCode as uppercase because the wifi_countrycode_values array is in uppercase.
  Otherwise the preference will not be found.

Patchset 7: Rebase
            Do not set mCountryCode if country is null

Change-Id: Ie0f838aef07eaf683b713f7f0e46ff3c751523ab
Wi-Fi: Pass default country code to driver

This patch reverts partially the change http://review.cyanogenmod.org/#/c/28918/8, and
passing the default country code ("GB") to the driver instead of null.

Change-Id: I7d7115155a0a52261931ffaddaf35f316d095800
Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
Wifi: Enable Ad-Hoc (IBSS) network configuration

This adds two public but hidden variables to WifiConfiguration: isIBSS and
frequency. These are used for configuring IBSS mode.

WifiConfigStore is exended to get and set these variables to wpa_supplicant
(via WifiNative).

Change-Id: Iab02c3d738c05c2de036350ea77b78789213e357
Wifi: Add IBSS supported method

Add method isIbssSupported() to WifiManager and related classes to query wether
the driver supports IBSS mode. The query is answered by wpa_supplicants new
command "get_capability modes".

It will only return a correct result after WIFI_STATE_ENABLED has been
reached.

Change-Id: I93aa2fdff94cd897c91ec3beb7e58940d1de7b72
Wifi: Get the list of supported channels

Get the list of supported channels/frequencies from wpa_supplicant and provide
them thru WifiManager.getSupportedChannels();

One channel is represented thru the class WifiChannel which includes channel
number, frequency in MHz and a flag if IBSS mode is allowed on this channel.

Like isIbssSupported() we can only expect a result after WIFI_STATE_ENABLED has
been reached.

Change-Id: I9fc34642b9a0047f6871b180a3a7a69d47b7e2ff
wifi: Fix StringIndexOutOfBoundsException for incorrectly encoded SSIDs

If the last character of a SSID is a unescaped backslash then WifiSsid
convertToBytes() will throw a StringIndexOutOfBoundsException and takes the
whole ROM down.

The issue was reported by andreip in the HTC One X XDA thread. His SSID was
set to "/ Andrew \".

04-10 21:33:54.265 E/AndroidRuntime(10479): *** FATAL EXCEPTION IN SYSTEM PROCESS: WifiStateMachine
04-10 21:33:54.265 E/AndroidRuntime(10479): java.lang.StringIndexOutOfBoundsException: length=10; index=10
04-10 21:33:54.265 E/AndroidRuntime(10479):     at android.net.wifi.WifiSsid.convertToBytes(WifiSsid.java:89)
04-10 21:33:54.265 E/AndroidRuntime(10479):     at android.net.wifi.WifiSsid.createFromAsciiEncoded(WifiSsid.java:54)
04-10 21:33:54.265 E/AndroidRuntime(10479):     at android.net.wifi.WifiStateMachine.setScanResults(WifiStateMachine.java:1522)
04-10 21:33:54.265 E/AndroidRuntime(10479):     at android.net.wifi.WifiStateMachine.access$7100(WifiStateMachine.java:103)
04-10 21:33:54.265 E/AndroidRuntime(10479):     at android.net.wifi.WifiStateMachine$SupplicantStartedState.processMessage(WifiStateMachine.java:2511)
04-10 21:33:54.265 E/AndroidRuntime(10479):     at com.android.internal.util.StateMachine$SmHandler.processMsg(StateMachine.java:905)
04-10 21:33:54.265 E/AndroidRuntime(10479):     at com.android.internal.util.StateMachine$SmHandler.handleMessage(StateMachine.java:760)
04-10 21:33:54.265 E/AndroidRuntime(10479):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-10 21:33:54.265 E/AndroidRuntime(10479):     at android.os.Looper.loop(Looper.java:137)
04-10 21:33:54.265 E/AndroidRuntime(10479):     at android.os.HandlerThread.run(HandlerThread.java:60)

Change-Id: I8273decacfffea4e4cae3bb957c925833dab09e2