Fix EventLog string class problem in onOptionMenuSelected

EventLog function can handle string,integer class and long class. (in android_util_EventLog.cpp)
If menu title string are used bold tag(like <b>test</b>), it'll be android.text.SpannedString.
In onOptionMenuSelected, it is using item.getTitleCondensed() function for writing event log.
therefore any android activity using tag menu string(like <b></b>) can be crashed by IllegalArgumentException.

I found this crash on GMS Application.
change locale chinese -> launch Google+ -> hangout -> menu key -> Invite(expressed chinese) click -> Google+ crash

Change-Id: I0437be81699925e29bf4510eb615ef2424432763
Fix NullpointException problem in onMenuItemSelected

If both title and condensed title is null,
item.getTitleCondensed() could be return null value
in onMenuItemSelected. therefore need to check
whether retun value is null or not.

Change-Id: Ib08f52b949a794aa7bd6cc25414041e820f62969
Handle nested folder case

Change-Id: Id6d6a5899e8255d18192adbc766d8d9a0e6825d0
Signed-off-by: Roger Chen <cxr514033970@gmail.com>
GlobalActions: Add null checks to onServiceStateChanged

can potentially cause a fatal NPE.

  Patch Set 7: Remove unnecessary dependency.

Signed-off-by: bmc08gt <bmc08gt.teamb00sted@gmail.com>
Change-Id: I7943c2db663157296cf69e524a15fd71bf017496
Fix ViewRootImpl to find missing focus using D-pad.

By using D-pad, no-focus in non touch mode is rare but legal in a case like below.

1. The first request to get focus for a new activity is handled in the first
   performTraversals() call when activity is not ready for a complete view hierarchy.
   So there might be no focusable yet.
2. If the activity has some menus, ActionMenuView can be attached to the view hierarchy
   in the PhoneWindow.preparePanel() soon.
   So there can be focusables but still not focused.

Fixed ViewRootImpl.deliverKeyEventPostIme() to handle this case to resurrect a focus
if there are focusables.

How to reproduce:
(1) Open "API Demos" application -> Views -> Search View
(2) Select "Action Bar" item using the D-pad
(3) Try to focus the Search View, using the D-pad.

Change-Id: Ic379774f0307f168f0ed775d0f6a9078ac5c9713
Make implementation of isEmpty consistent with implementation of getCount in HeaderListViewAdapter

Fix for Issue ID 18316. Make isEmpty() return false when getCount() returns a non-zero value. So that the list cannot be considered empty when a header or footer is present.

https://code.google.com/p/android/issues/detail?id=18316

Change-Id: Ib69201e9d5ef3efcbb68ea298b8cc8ca6e027246
Signed-off-by: Emma Sajic <esajic@effectivelateralsolutions.co.uk>
Ensure running mTouchModeReset when AbsListView is detached

mTouchModeReset should be executed when AbsListView is detached from window.
If not, when the AbsListView is re-attaced to window,
the child can retain a pressed state.

You can see this problem easily when you double-touch an item of
option menu very quickly.

Change-Id: I5aaa1fd5b95847efb2f5f1b5ec7cabe8eb85b237
Signed-off-by: Sangkyu Lee <sk82.lee@lge.com>
Make transactGetSockaddr locale safe

Explicitly use Locale.US transactGetSockaddr to avoid
unexpected results in some locales.

Change-Id: If8316e543e21e133dc0c821cc390a2b55fe6fcdf
Sensors could be disabled by any application

In the SensorManager API unregisterListener any application could
unregister any sensor. This lets any application disable a sensor
which another application is using.
This fix restricts the applications to only be able to unregister
a sensor it has previously registered to.

Change-Id: Ief926dd29f480dd97626160810dff87a8d3ac8dc
Decrease lag generated by autorotation on

There are different issues from what I understand:

1) Discarding of events too close to each others is broken
as mAccelerationTimestampNanos is conditionned by isAccelerating()
on TF101 no events are discarded anymore, and so it creates an update every ~50ms
filing up the android notification message queue quite a bit for nothing and so generating lag.
2) isAccelerating seems incorrect to me too, the code means more that it's accelerating "out of range" and should be discarded in that case.

=> Discard the sample if outOfRange and don't condition the update of mAccelerationTimestampNanos that way next time we come back "too soon"
the sample will be properly discarded.

3) with events being discarded properly on the WindowOrientationListener
the SensorManager can now update every 20ms instead of 50ms
but that is definitely overkill.
=> add SystemProperty sensor.loop.minms with a default value of 50ms to throttle the notifications.
That way the thread sleeps properly instead of sending events as fast as it can.

(increasing up to 100ms can be ok depending if you want faster response or not.)
This can be positionned on a per device prop too.

4) Add 2 SystemProperties:
one on the SystemSensor side: sensor.magnitude.threshold with a default 0 value(doesn't change the behavior)
one on the WindowOrientationListener: orientation.magnitude.threshold with a 200 (0.2G) default value
These allows to discard the sample if it is too close to STANDARD_GRAVITY (ie not accelerating much)
These can be set on a per device or use the default values.
On the TF101 200 works most of the time. But weirdly when docked the reported gravity seems to have an additionnal offsert of -0.2
maybe some magnetic interference from the dock...

For the moment the 0.2G threshold is positionned on the Orientation code.
Once the cpp sensor poll crazy loop is solved it could be better to use the sensor.magnitude.threshold instead.

That should take care of most of the lag generated by autorotation.

Change-Id: I093227f539050a6bad8e6e8d9f533eff7bddd0d6

Conflicts:
	core/java/android/hardware/SystemSensorManager.java
show SELECT ALL icon with text in landscape mode

Though set config_allowActionMenuItemTextWithIcon as true,
icon for the "SELECT ALL" menu on ActionBar is not shown as staring
in landscape mode.
To fix it, use "SELECT ALL" icon in onCreateActionMode() to show the
icon and text together.

To show or hide text is decided by updateTextButtonVisibility() of
core/java/com/android/internal/view/menu/ActionMenuItemView.java

STEPS TO REPRODUCE: (please be specific)
1. launch Browser/Chrome and go to google.com
2. rotate to landscape mode
3. long press on URL address

Bug: 8073761
Change-Id: Ie0e0aa45f0dff609ed8c03e4423b163bad5452ed
Fix for truncated sentence in "Find on Page" field

When typing a text in find on page, then deleting it again the
default text in the field "Find on Page" is truncated by
an invisible view.

This commit fixes the problem by setting the visibility of
mMatches view changes to View.GONE instead of View.INVISIBLE.

Change-Id: I9889f22a254cdabb0cbaba72bff4b14158e5c9ff