Fix Photosphere/Camera FCs

Photosphere is setting a few parameters "blindly"
while the API says it should check the device capabilities first.

On TF101 (and probably other devices) the camera HAL doesn't handle
FLASH_MODE & SCENE_MODE and so it sends the required RuntimeException
for these, which makes Photosphere FC the Camera app.

=> Fix: check device capabilities & ignore these 2 parameters if the device doesn't support them.

Fix based on following Team EOS patch: https://review.teameos.org/#/c/1598/

Change-Id: Idd80299802e9213a3c40414ace3d516d39f47783
Remove unnecessary updateSurfaceScreenOn call.

This change stops updateSurfaceScreenOn() from being called one time
right after another. It's called at the end of stayAwake(boolean awake),
which is called right before updateSurfaceScreenOn() in release().
keyguard: enable magnetic target if no custom targets defined

When no custom target is defined (the "reset" button is pressed
in settings), the unlock target will always be at the right
regardless of the direction the user dragged to.

Change-Id: I0a2b1cd5dc7a2840c23d83a26593513cbc880c08
Fix potential deadlock between LockScreen and WindowManagerService

If LockScreen is enhanced using SurfaceView/GLSurfaceView,
deadlock problem between LockScreen and WindowManagerService
can occur because of IWindow.resized() callback.
And it must lead to watchdog and reset.

IWindow.resized() callback is one-way function so calling resized()
callback of a remote IWindow object is never blocked.
However, calling resized() callback of a local IWindow object
(LockScreen is running on the same system_server process)
is always blocked until resized() callback returns.
Because resized() callback of SurfaceView/GLSurfaceView can lead to
WindowManagerService.relayoutWindow() call, deadlock can occur
between relayoutWindow() and performLayoutAndPlaceSurfacesLockedInner().
(Both functions need locking mWindowMap)

So this patch simulate one-way call when calling resized() callback
of a local IWindow object.

Change-Id: I2a6a5c74ed22d8e6b7a3bea3424ff2879d227105
Signed-off-by: Sangkyu Lee <sk82.lee@lge.com>
Fix DateUtils.formatElapsedTime.

More reuse of StringBuilders, less broken home-grown formatting code.

Long-term, we should hand this over to icu4c, but they're not ready yet.

Bug: http://code.google.com/p/android/issues/detail?id=41401
Bug: 7736688
Change-Id: Ib3c1e1aad05827df646aa18645cce19dffb7551f
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
Correct executable bit for source files

Many media files and source code files were marked as executable in Git.
Remove those.

Also a shell script and python script were not marked as executable.

Change-Id: Ieb51bafb46c895a21d2e83696f5a901ba752b2c5
Signed-off-by: Chirayu Desai <cdesai@cyanogenmod.org>
Allow USB notification to show when primary SD allows UMS and MTP

Previously if primary SD is set to allowMassStorage="true" the USB
dialog would never show.  This checks if persist.sys.usb.config is
set to mtp,adb and then allows the USB notification to show. With
this you can then have the option to select from MTP, PTP and Mass
storage when clicking the pull down notification. When Mass Storage
is selected it activates the USB connected dialog to turn on USB
storage. When set back to MTP the USB connected notification disappears.

Change-Id: I2287075ec93cae75f19e8fb59965d9dddb234aca
QuickSettings: cleanup
Removed unnecessary references to QuickSettingsContainerView, LayoutInflater
Tile layout is set by constructor

Change-Id: Ied57bf6613594864db0201c2af514fbe4bb651ed

Conflicts:
	packages/SystemUI/src/com/android/systemui/quicksettings/DockBatteryTile.java
	packages/SystemUI/src/com/android/systemui/quicksettings/LteTile.java
	packages/SystemUI/src/com/android/systemui/quicksettings/QuickSettingsTile.java
	packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsController.java

Signed-off-by: travp624 <travp624@gmail.com>
QS/PW: Check for mobile data instead of telephony permissions (1/2)

For QuickSettings and Power Widget check if there is
ConnectivityManager.TYPE_MOBILE network avaialbe directly instead of relying
on a checking for the PackageManager.FEATURE_TELEPHONY permission.  Some
devices like tilapia (Nexus 7 GSM) has mobile data but does not set the
telephony permission.

Patchset 2:
   	- Use ConnectivityManager.isNetworkSupported() instead of checking for a null
	  value returned from ConnectivityManager.getNetworkInfo(). Thanks
	- Have MobileNetworkTile use the QSUtil deviceSupportsMobileData method

Change-Id: I71bd6217cbe08622f805de4ae30a87df11340f5f
Fixes: CYAN-803

Conflicts:
	core/java/com/android/internal/util/cm/QSUtils.java
	packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsController.java

Signed-off-by: travp624 <travp624@gmail.com>