Improving pie control's user interaction

User feedback showed that it is sometimes difficult to interact
with pie controls. This commit adds some tweaks to how pie
controls react on user touch events.

This changes:
* Pie trigger on LEFT and RIGHT are now more forgiving in the
  initial phase of a swipe. (This should reduce problems when
  trying to activate the pie with a thumb.)
* Pie items are now more sloppy when it comes to focus.

Patch Set #2:
* Removed sloppy focus.
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
use Calendar in DateUtils format method

The DatePickerDialog is using DateUtils to format the dialog's title
and the DateUtils class does not work with dates outside to the
specified range.
For example, if user selects 2038-03-07, DatePickerDialog shows
1902-01-30 on Title.
The reason for the DateUtils class not being able to format dates
outside the range of 1902 and 2036 is because internally it is using
the Time class which does not support such dates.
To fix it, use Calendar class in DataUilts format method.

Steps to reproduce:
1. Settings -> Date & time
2. uncheck Automatic date & time
3. Set Date
4. choose any date before 1902 or after 2037
5. update wrong date on Title

Bug: https://code.google.com/p/android/issues/detail?id=13050
Change-Id: I003266765751b5c340426af84daef271f39f771e
Multi pane preference settings
Quick launch shortcuts: update search panel on userSwitch to recreate targets.
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.
Adapt navigation bar's long press behaviour for pie controls

This commit brings the navigation bar long press behaviour to
pie controls.

Two things will be considered for long press:
* Long press on HOME will open Google Now.
* Long press on BACK will kill an application if enabled within
  the debug options.
SystemUI: fix memory leaks

ContentObservers are being registered without being unregistered,
causing old objects not to be garbage collected. This causes memory
leak if the classes are destroyed and recreated throughout the
device's uptime.

SearchPanelView is recreated every time the screen is turned on.

Different from original CM commit since StatusBarIconView has not been edited
PowerMenu : Improve keyguard filtered actions

Replaces the check for visibility of lockscreen with the state
of the keyguard instead. This avoids the situation where actions
returning false from showDuringKeyguard, are still shown if user enters
emergency call screen.
Don't start keyguard in an attempt to exit it.

exitKeyguardSecurely() will open the keyguard if it's currently disabled
by an app. As this is unwanted here (the user has either already
bypassed the keyguard or the keyguard isn't secure; otherwise he
couldn't click on a notification entry) and as the lockscreen already is
dismissed a few lines above, don't call exitKeyguardSecurely here.
KeyEvent: update comment

Change-Id: I1ea491e7e23670bf0ea83392710010b557803178
Option to wake up the device when plugged/unplugged
Power connect/disconnect notification support
Make Safe headset volume user configurable
AudioService: Restore volumes after boot and when a headset is plugged

The correct volume levels for <device>_speaker and <device>_headset are not
restored after booting and when a headset device is plugged in or out.

This fixes a glitch where the first volume change event causes the volume to
be reset to the last stored value instead of increasing/decreasting it by
one step.
Can not mark the same content of browser page after copy

Marking a text on the web page and then press copy works,
but trying to mark the same text again does not work.
The reason for this is that the selection never gets
cleared in webkit.
The fix, calling cleaSelection in the onDestroyActionMode.
Also added clearSelection when getting an
onConfigurationChange.
Allow creating custom dialogs in DialogPreference.

This allows creating non-AlertDialogs while still using the click and
state handling of DialogPreference.
Email force close when pressing back key after selecting characters

Email and Browser will be forced closed after selecting a text
and then press the back key, tilting the screen or trying to
share or copy the text. This is because a previouse fix
is using a part of the code that Google has removed.
Fix: clearSelection will now use its own EventHub id,
CLEAR_SELECT_TEXT.

This part describes the previous fix.
Marking a text on the web page and then press copy works,
but trying to mark the same text again does not work.
The reason for this is that the selection never gets
cleared in webkit.
The fix, calling cleaSelection in the onDestroyActionMode.
Also added clearSelection when getting an
onConfigurationChange.

FIX=DMS01503793
Fix Watchdog HeartbeatHandler to run on correct thread

The HeartbeatHandler for the System Server Watchdog has been running
on the wrong thread due to a race condition in initialization.  It's
designed to run on ServerThread, so that it can catch lockups in the
main looper of the System Server.  It has been running on
ActivityManagerThread instead, so it does not detect lockups on the
ServerThread as it should.

ActivityManagerService is calling Watchdog.getInstance() before
ServerThread calls Watchdog.getInstance().init(), so the handler is
being bound to the ActivityManagerThread instead of the ServerThread.

Explicitly bind HeartbeatHandler to ServerThread, so that the Watchdog
catches lockups on this critical thread.

Change-Id: Iccb184ac3adb817feb86ed4ee0e50e443bf74636