Revert GPS changes for now until issues are resolved.

Will do a refactoring to better isolate this code.

Revert "GPS fixes"

This reverts commit 84c6741f03118168aa61f2e028efae2ea4953a9f.

Revert "Squashed commit of GPS changes from CodeAurora"

This reverts commit 669786140ea7579dcbe05eb2d5199ebf161239a1.

Change-Id: Ib1a55d1be8dbc933c690b2f06af206ab5511903c

Conflicts:
	services/jni/com_android_server_location_GpsLocationProvider.cpp
Squash all 4.2.2 changes into one

Hide current soft input when a background user gains window focus.

Bug: 7507226
Change-Id: If58f68469e21eaaba8536c4b54b3aa8cf8c08eb5

DEFAULT_VIBRATE must always use the default vibe pattern

The logic here was backwards, causing the (softer) fallback vibe
pattern to be applied if the notification specified a sound
(or DEFAULT_SOUND) and also DEFAULT_VIBRATE. The fallback
vibe should only play if you have *no* vibration set.

Bug: 7588655
Change-Id: Iecdd362729bccedf779b51cc9b90a12014328aff

Fix IME down caret in keyguard nav bar bug.

The input method manager service now keeps track of whether or not
the ime was shown on the keyguard.  This prevents activities behind
the keyguard from incorrectly showing the down-caret in the keyguard.

Bug:7498792
Change-Id: I0de01ec29cb544e902305b0f9d9fb94a73835e7b

Switched to another method for launching apps.

Started using a separate thread which calls startActivityAndWait
for starting apps. Also increased the minimum and maximum lengths
of time to wait for apps to stabilize.

Change-Id: I49935a0ed1d1c230e58dc1629e5e4da6b3887903

Fix audio focus evaluation order for display update

Change 1f9196a8e5de9b004e61afabc70b18caf7cf9c7e introduced
 an issue when trying to ignore audio focus entries in the
 stack that don't use the music stream, or are for transient
 audio focus gain, for remote control display updates.
The bug was that the audio focus stack traversal was not
 starting from the top, as it should. It was using
 the iterator order, which, in the case of a stack, starts
 with the bottom-most entry.
The fix consists in traversing the stack from the top, i.e.
 from the last element of the vector used to hold the stack
 entries.

Bug 7311023

Change-Id: I0c1900dbf98599a621a420ab55531a3eee838fe5

Added app launch test.

The test will start each app and report the time it takes for
the app to start in milliseconds.

Change-Id: I974ac36f70f0d982aa01e46824fe138eb641d680

Copy missing state in DrawableContainer

The copy constructor of DrawableContainerState was not properly
copying all the state. This change adds the missing two fields
that should be copied over.

Change-Id: Ic92ba17ccf8fb3c8cbb5ead18690287da21c48a4

Cleanup: add PointF.toString()/equals()/hashcode()

PointF was missing these methods found in Point.

This change also properly implements equals() and hashcode() for
Point to match the PointF implementations.

Change-Id: Ic97280fb9f8c7011d8a13103c67d6e898adf00c0

Use correct alpha value when a color is not set on a GradientDrawable.

A previous fix ensured that color filters would have a default (black) color to
interact with if no color was set on the GradientDrawable object. However, that fix
assumed an opaque alpha value, which is not always the case. Specifically, calling
setImageAlpha() on an ImageView with a shape drawable source (as in the bug here)
caused the alpha to be set to a translucent value, which was then ignored in the fix
above.

The fix is to account for the current alpha value of the GradientDrawable object
when setting the color used by the paint object.

Issue #7592193 ImageView.setImageAlpha() broken when colorFilter is in use

Change-Id: Ie622ffca776fdd8731ced78ce1f683ca6a51dec8

Fix bug where icon animation is sometimes skipped

Bug: 7406230
Bug: 7406304

Change-Id: I9058acffa6587a5f8e757f1031750a8ba578c635

Ignore invalid combination of PowerManager flags.

ACQUIRE_CAUSES_WAKEUP is supposed to be ignored if combined with
PARTIAL_WAKE_LOCK. Instead it was being carried out for any values
of the WakeLock level.

This change reverts behavior to closely match
previous releases of the framework by only honoring
ACQUIRE_CAUSES_WAKEUP for screen wake lock levels. The only
difference being that in previous releases ACQUIRE_ could have been
combined with PROXIMITY_SCREEN_OFF_WAKE_LOCK (it never was) and
now such a combination will ignore the ACQUIRE_ flag.

Bug 7532258 fixed.

Change-Id: I46e848d8fd1b57e54c63141bf3d4f353986b5bdf

Fix reboot loop caused by keyguard appwidget cleanup

Bug: 7591092
Change-Id: I5e0cb835f0e6cc89a8c10cdaf1bacb37320ca45f

Fix a couple issues with page / outline alphas (issue 7488857)

-> Fix bug where page hints didn't disappear on boot
-> Fix bug where you see a weird rotated page under the
   lock affordance (usually after adding a widget)

Change-Id: I75b04ceadbc296d033cc9fb1cff32ab9d6e5ce9b

Update the content shell command's usage instructions.

The usage instructions of the content shell command were missing some
excape charecters which caused the examples not to work. As a result
of the incorrect instructions users are prone to constructing incorrect
commands.

bug:7526252

Change-Id: I2fcc4dd1fd05806fe951245651b97e40a4786d24

Removing the plus page when we reach the max number of allowable widgets. (Bug 7564782)

- Also adding feedback on the plus page (Bug 7500328)

Change-Id: Iddd09b7a3d5347a43bc040052114879cbaecccd9

Removing unecessary additional lock metadata from QuickSettings user tile.

Change-Id: I89ec94385eb3cdd46ad6942bf8989fb04d5c0370

Logging to help find the cause of widget crash in clock widget.

This will continue to crash as before, but will show some useful
information in the exception.

Bug: 7450247

Change-Id: Ib3160a5f64154517791d165973c12294ecd09901

Fix bug: swiped apps in Recents come back on rotate

Bug: 7409398

Fixing issue where you can still click on a widget on a side page. (Bug 7568412)

Change-Id: I7105bc6b06e850e6029d12b0fe36fad00b538e1a

Cannot move edit text cursor to first position using character granularity.

Navigating over text backwards by character does not allow the cursor to get
at the beginning of the text and it stops one position before the start. Now
the cursor can get to index zero which is before the first character.

bug:7307336

Change-Id: I109b579835cc080907b20b01e0cf07811e962c6c

clarify Geofence.createCircle() param ranges

This commit adds the valid ranges to the latitude/longitude
parameters in Geofence.createCircle()'s javadoc.

Bug: 7172696
Change-Id: Iff6e3c3723d3fd9b6393bbc827ec5755c0d034af

Improve debugging for issue #7586414: AlarmManager wakelocks held

In alarm manager, print a summary of the top 10 alarms by time
being executed.  Keep track of execution time (and wake count) of
each type of alarm for each application so this can be printed in
the summary (and used to compute the top 10 alarms).  Rework how
the alarm summary stats are tracked so that we don't need to hold
on to the full Intent for each stat and can get the Intent information
at the time the alarm is sent rather than waiting for whatever Intent
comes back in the result.

Also in the battery stats: sort the kernel wake locks by time, add
a new section showing all partial wake locks across all applications
sorted by time.

Finally a new LocalLog class that is used by AlarmManager to log
important warning messages, so these can also be later found in
its dumpsys output.

Change-Id: Icc07810053e60fb623a49937e696819cb8352b06

Remove overzealous mutate() sanity check in LayerDrawable

Child drawables of a LayerDrawable should be able to mutate() as a
no-op even if they !canConstantState.

Bug 7622311

Change-Id: I32c00961310f23aaf9ad868c419cbefb9d27a1d2

Retain configuration change info and sync access.

- If a window was hidden while the configuration changed and then
changed back WindowManagerService would not know that the change
had ever happened and wouldn't notify the window of this. Most
windows wouldn't care but because Keyguard inflates layouts while
it is hidden...

Bug 7094175 fixed?
Bug 7501099 fixed!

Change-Id: If27f5f1d333602dac7719dd39dbdf3fe7954aa06

Stop caching stream duration, it might change (increase) dynamically.

Change-Id: Ia829f47602e6961f24464da36a0162b8c1d7d6c8
related-to-bug: 6870049

New timings for default & fallback notification vibration.

Bug: 7599791
Change-Id: Ieae1cba864537b192be013e4f00131bcc59c6369

Quiet down a lot of logging.

Also fix a little problem where the USER_STARTED broadcasts
were not being sent as ordered broadcasts(!).

Change-Id: I3aa3e0a9b3900967cdd2d115ee103371b0a50c41

Clean up behavior of type arguments for MediaRouter#getSelectedRoute

MediaRouter's policy so far has been around a single selected route,
but when route types are entirely orthogonal this should not be the
case. However we still don't want to get into a situation where we
have multiple, very different routes selected for different types at
the same time, we still want to have more of an element of
predictability.

Behavior of getSelectedRoute is now:

* If the selected route matches at least one type with the requested
  type flags, it is still considered selected for that request.

* If the caller specifically requested the selected user route and the
  currently selected route is not a user route, return null.

* If the requested type flags do not match any types with the selected
  route, return the default system route.

Note that this is "any" behavior instead of "all" - this matches
existing usage of the method. We may consider adding an "all" variant
later on.

Bug 7588042

Change-Id: I3a79d8153ca6b882fd3ef6b9b1de8f538873dec2

Fix bug #7621927 Radio button/TextView drawable regression in 4.2

- as we remove the 9 patch padding trick, we need also to do the correct
positioning of the radio / checkbox / star during draw

Change-Id: I02b67bef9c0f2dc1c0c65361de14ab20ce9b881d

Use the same interrupt/resume logic for all functor calls

bug:7093396

The functor was able to change the renderer's blend mode without it
being restored in process mode. This single path of updating gl caches
reduces likelihood of this occurring in the future.

Change-Id: Ie367532f9c683299f02bc4f635d7cb31f96db39f

WFD: Fallback to PIN mode if PBC is not supported

Bug: 7627641
Change-Id: Ibba6114f907c67f1cb60c460d5b65479f2d1b148

Making sure keyguard and homescreen only display eligible widgets (issue 7550090)

Change-Id: I25acb7bde2e8e5ac3185a009f5c7151b81f0ae19

Secure a handful of framework broadcasts

At least one of these was getting spoofed in the wild.
We don't want to go too far this late in the game, but this is a good start.

bug:7622253
Change-Id: Id8ec2778b15fe001e6fd0d5a010181bb21c52ad8

Fix bug #7617883 RelativeLayout is not having the correct width when in RTL mode

- fix onMeasure() in RTL mode: need to compute width before computing layout params
that are used for layout
- fix getRelatedView() so that it uses the resolved rules
- add some extra "final" statements

Change-Id: I7c3bf841cd18c5f77b010a9be20fa78069e88d94

Cleaner initial boot.

This does some cleanup of the initial boot, especially when
booting in "no core apps" mode for encryption/decryption.

Change-Id: Ifb3949f580e52f54559e603c4b0b104f6bac2f6c

Fix time-related ScaleGestureDetector methods

Bug 7626515

Change-Id: Ie7abf9c166284a74b4e7bcf9de25520cf08e3b2d

Import assets from UX

Fixes issues with scaling/dithering artifacts in dialog/menu panel
assets.

Bug 7589786

Change-Id: I1285f9de5f8bcd0decfa7765c1463e444a56b335

Fix build.

Change-Id: Icc1f2913b4e889609066b0ff1dddcd9be0230897

timeout support for accept() and added check for signal size

bug 7592240

Change-Id: Ide1868da669c190cdfed90f7af3f739ec9da690b

Fix math errors causing black screen. DO NOT MERGE

Turning off animations in the Developer options creates a ValueAnimator
duration scale of 0. This is used as the denominator in RampAnimator
which, if the numerator is also 0, sets mAnimatedValue to NaN. Rounding
NaN to the nearest int produces 0 which is then assigned to
mScreenBrightness in DisplayPowerState.

A copy mistake which assigned mTransitionAnimationScale as the default
value for mAnimatorDurationScale in WindowManagerService is also
fixed here.

Bug 7515609 fixed.

Change-Id: I39f8d0a7abdd5a1fe70d757fe95fbddaf7a0ed51

Fix for navbar back/home appearing in keyguard (multiuser).

Clear remembered sysui visibility flags in PhoneWindowManager
when switching users. They might have been from another user.

Then reapply current window's flags to ensure contribution
makes it to the status bar.

Bug:7506446
Change-Id: I8249ba006934bdc22b952da7c16e9983d091c489

Flush the clock format when the locale changes.

Bug: 7569120
Change-Id: If85ff36c7fac8b07f10b7077afd23255a145db1c

Allow the NFC process to call Bluetooth APIs.

The NFC process used to be only running as user 0,
and it may be calling into Bluetooth. Most of the
handover code has now moved to a separate process
running as the current user.

Fix the existing checks to take into account the
correct NFC UID, whatever user it is running as.

Bug: 7309141
Change-Id: I953cfb263a28aef7fe1be5880b053425dc359a29

Fix multiuser bug in StatusBarManagerService.

First, do no harm.

Bug:7638210
Change-Id: I113b574a021d601b0c79d65a3b4b72eeb4c667ad

Fix issue #7585876: When changing the font settings, the movie...

...just keeps attempting to load and doesn't play on the TV

Change-Id: Ifcdc969a037a113224632f907d55f60a168dd05a

Add constant for Daydream settings.

Bug: 7480927
Change-Id: I383170c6c543b5ffe81568d273389585498d369b

trigger kernel blocked stack trace on system server watchdog

Bug b/7638530 may be caused by a kernel deadlock when killing
processes under low memory conditions.  Write to /proc/sysrq-trigger
to get a kernel log of blocked tasks before killing the system server.

Bug: 7638530
Change-Id: I60df324ad4affdadbf13650099dc4dfb38722420

Remove unused IExtendedNetworkService

It was used in the cupcake era for docomo.  Is not used anymore.

Bug 7633569

Change-Id: I2ec826fc9a70d261a340957a937ed4c9f8e67c5c

Saving and restoring current page when rotating in lockscreen. (Bug 7568412)

Change-Id: Ia80845d05df04dc2d31a834279096e5ed165a646

Disable adding keyguard widgets until setup is done

Bug: 7504154

Change-Id: I865f0139bb328e6b9b19493e0d8f9f086e2ebc38

Always report user switched after unfreezing screen.

Change-Id: I58172896892a07e72a3430e56e4d2944d388c7c9

 BluetoothManagerService call should allow SYSTEM_UID

bug 7561429

Change-Id: I1483bfe1361f71c7ae3529ea496b33504b95413e

Maybe fix issue #7596986: Frequent runtime restarts; IAE at...

...android.os.Parcel.nativeAppendFrom(Native Method)

The failing stack trace is:

11-20 20:29:04.365 19154 19170 E AndroidRuntime: java.lang.IllegalArgumentException
11-20 20:29:04.365 19154 19170 E AndroidRuntime:        at android.os.Parcel.nativeAppendFrom(Native Method)
11-20 20:29:04.365 19154 19170 E AndroidRuntime:        at android.os.Parcel.appendFrom(Parcel.java:428)
11-20 20:29:04.365 19154 19170 E AndroidRuntime:        at android.os.Bundle.writeToParcel(Bundle.java:1613)
11-20 20:29:04.365 19154 19170 E AndroidRuntime:        at android.os.Parcel.writeBundle(Parcel.java:605)
11-20 20:29:04.365 19154 19170 E AndroidRuntime:        at android.location.Location.writeToParcel(Location.java:903)
11-20 20:29:04.365 19154 19170 E AndroidRuntime:        at android.os.Parcel.writeParcelable(Parcel.java:1254)
11-20 20:29:04.365 19154 19170 E AndroidRuntime:        at android.os.Parcel.writeValue(Parcel.java:1173)
11-20 20:29:04.365 19154 19170 E AndroidRuntime:        at android.os.Parcel.writeMapInternal(Parcel.java:591)
11-20 20:29:04.365 19154 19170 E AndroidRuntime:        at android.os.Bundle.writeToParcel(Bundle.java:1619)
11-20 20:29:04.365 19154 19170 E AndroidRuntime:        at android.os.Parcel.writeBundle(Parcel.java:605)
11-20 20:29:04.365 19154 19170 E AndroidRuntime:        at android.location.Location.writeToParcel(Location.java:903)
11-20 20:29:04.365 19154 19170 E AndroidRuntime:        at android.os.Parcel.writeParcelable(Parcel.java:1254)
11-20 20:29:04.365 19154 19170 E AndroidRuntime:        at android.os.Parcel.writeValue(Parcel.java:1173)
11-20 20:29:04.365 19154 19170 E AndroidRuntime:        at android.os.Parcel.writeMapInternal(Parcel.java:591)
11-20 20:29:04.365 19154 19170 E AndroidRuntime:        at android.os.Bundle.writeToParcel(Bundle.java:1619)
11-20 20:29:04.365 19154 19170 E AndroidRuntime:        at android.os.Parcel.writeBundle(Parcel.java:605)
11-20 20:29:04.365 19154 19170 E AndroidRuntime:        at android.content.Intent.writeToParcel(Intent.java:6660)
11-20 20:29:04.365 19154 19170 E AndroidRuntime:        at android.app.ApplicationThreadProxy.scheduleReceiver(ApplicationThreadNative.java:763)
11-20 20:29:04.365 19154 19170 E AndroidRuntime:        at com.android.server.am.BroadcastQueue.processCurBroadcastLocked(BroadcastQueue.java:230)
11-20 20:29:04.365 19154 19170 E AndroidRuntime:        at com.android.server.am.BroadcastQueue.processNextBroadcast(BroadcastQueue.java:777)

This is odd because where we do Bundle.writeToParcel(), we are just writing the Parcel
we have with its current length.  There is no way this should be able to fail like this...
unless the Bundle is changed while we are running?

Hm.

It looks like the location manager is holding on to Location objects which have a
Bundle of extras.  It is that Bundle of extras that the crash is happening on.
And the bundle extras can be changed as it operates.  And there are places where
the raw Location object is returned from the location manager, which means the
caller can be olding on to a Location object whose extras can be changed at any
time by other threads in the location manager.

So that seem suspicious.

This change should take care of all these places in the location manager, by
making sure to copy the location object before it goes out of the location
manager.

In addition, add some code to the activity manager to not bring down the entire
system if there is a problem trying to send one of these broadcasts.  There is
no need, we can just skip the broadcast as bad.

Change-Id: I3043c1e06f9d2931a367f831b6a970d71b0d0621

AudioService: improve initial safe volume delay

AudioService relies on a valid mmc in order to enforce the headset
volume limitation or not. There is a timeout to enforce the limitation
if no mcc is configured after boot.
Until this timeout is reached or a valid SIM is detected the headset
volume is not limited.

This change makes that the last known volume limitation state (enforced or
not) is persisted so that next time we boot, last known state is applied until
a new mcc is configured if any. In most cases, the mcc does not change from one
boot to the next and we do the right thing. If teh mcc does change, the correct
policy will be enforced when the mcc is detected or after the timeout.

Also fix a bug where the volume panel was not displayed if the limitation mechanism
is triggered at the first press on VOL+ key.

Bug 7455275.

Change-Id: Id0f2996d893d38c6a14f4f9e4a0e9e3be17ef127

Don't apply transformation fudge when not rotating.

There is this stupid fudge factor applied to window transformations
when doing a screen rotation animation.  We need this when rotating,
but when not rotating it causes very visible artifacts.  Historically
the non-rotation case only happened due to configuration changes, so
wasn't that big a deal.  Now however that we use this when switching
users, it is more annoying.  So get rid of it for such cases.

Change-Id: I6b343866c1bad9b16984b4a629917c2f1bb37b9e

Clean up debug messages

bug 7626174

Change-Id: I65cdcaf2c48a78468b6cef0b8591289435068b24

Only show camera widget to setup users.

And remove misspelled and unused field in KeyguardHostView.

Bug:7645811
Change-Id: I3d6ceae8d25d0af7b504b4c22782611d25462a62

Reduce false swipe-closed gestures in status bar panels.

VelocityTracker is a powerful tool---too powerful, in this
case, because many devices (I'm looking at you, Nexus 7)
have touchscreens that report total garbage on takeoff and
landing.

PanelView now uses its own incredibly crude velocity tracker
called FlingTracker, which implements a short sliding window
of the last 8 motion events (7 intervals) over which touch
velocity is averaged. There's also a little bias toward more
recent touch events so that the overall velocity of small
circular gestures will tend to favor the exit tangent.

The end result is a primitive low-pass filter on touch
velocity that should help us avoid situations where one (or
even two!) stray MotionEvents at the end of a gesture won't
invalidate the overall thrust.

Bug: 7422342
Change-Id: Idae38d1957727e400493324af4eee357ba5baa27

Fix sample code issues

Correct min SDK.
Correct file extension on mandelbrot

Change-Id: I508c22c382f1a930b27d8c5f4414cac3a990a332

Fix rounding error when drawing panel handles.

Bug: 7649037
Change-Id: If8d9fa5f3852729207c31c95cfd68ef54ff47d7d

Fix some typos and missing @param in android.os.Bundle

getChar(String) and getChar(String, char) had wrong description in their
javadoc.
Also most of the get methods with default value were missing the corresponding
@param tag for the default value parameter.

Change-Id: I0f38b3caacf9cabd70e0c1ada36af3662f5566d0

Fix bug #7651552 resetRtlProperties() is called way too often

- remove unnecessary calls to resetRtlProperties().
- now reset of RTL properties will only be done when adding a View
(and no more when removing it)

Change-Id: I0d42128c9f7df6085fb92bb5af5c9bd4d1ba88a3

Add logging to try and track down bug 7643792

Fix whitespace & log message.

Change-Id: I9d241365503a6a9b02d3155dbb06ddb82065b375

Reorder tone mark and nikhahit in DroidSansThai.ttf

Fix for bug 6630331.

This is a workaround for a shortcoming in the Thai shaper in Harfbuzz.
De facto (but not documented) shaping rules dictate that a tone mark
followed by a SARA AM should be rendered with the NIKHAHIT below the
tone mark, rather than above it as would be indicated by a
straightforward interpretation of the GSUB and GPOS rules. This patch
adds an additional substitution of the form MAI THO + SARA AM ->
NIKHAHIT + MAI THO + SARA AA. The three tone marks affected are MAI EK,
MAI THO, and MAI CHATTAWA, based on an usage analysis of the Thai
dictioary included in ICU.

When we upgrade to harfbuzz-ng, we can revert this workaround.

Change-Id: I209ed094e7c89ea7f6fd6e983d37e396c6da1f64

Include child windows when looking for insertion point.

After finding a window in the window list we turn around and look in
the AppWindowToken.windows list for it. If it is a child of a window
in that list we should use the parent windows index as the search
result. Instead we gave up and ended up inserting the window at the
beginning of the windows list.

Bug 7357465 fixed.

Change-Id: If77f343b8597bfbb0b7fa41dedf7972d78d03020

Fix crosstalk between users for widgets hosted in lockscreen

This was initially about the Clock widget crashing repeatedly on some
devices with multiple users. Turned out that there were race conditions
when switching users that could result in remote views of one user calling
back to the RemoteViewsAdapter in keyguard that in turn sent an incorrect widget id
to a different user's widget, resulting in a crash.

Since KeyguardHostView is instantiated in the same process for different users,
it needs to carry a user identity to pass along to AppWidgetService so that
remote views services were bound to the correct user and callbacks were attached and
detached properly.

Added some aidl calls that take the userId to do the binding properly. A more
complete fix might be needed in the future so that all calls from Keyguard carry
the user id.

Also, there was a problem in comparing host uid for secondary users, since Settings
for a secondary user has a different uid than keyguard. Not an issue on single-user
systems. Changed the host.uid comparison to accomodate for the secondary user.

Bug: 7450247
Change-Id: Idbc36e3c60023cac74174f6cb7f2b2130dd3052c

Avoid null mobile interfaces.

Bug: 7634215
Change-Id: I6745f6a78c07ba11d98b4562a6b53386112ef652

app launch test fixes and improvements

* fixed NPE when specified app name does not exist
* force stop package before starting, because some names may
  resolve into the same package
* ensure app is launched in the order as sepcified in command
  line
* fixed time recording: it should have been 'thisTime' as
  reported by ActivityManager, to be consistent with previous
  harness

Change-Id: I411a568580feef21821dcbe6ec15884f697af6fd

Show alarm tile for the current user.

We were already refreshing the tile on user switch, but we
were only pulling the information (and observing changes)
for the owner.

Bug: 7596329
Change-Id: I33959af405bc79037b5b1321631d993bea65772f

BT is still on after enable flight mode, and reboot the DUT

bug 7275625
Change-Id: I4f8952a06152eb5f5775c1f616f6383e4f20e352

Fix remote views cache to avoid lockscreen widget crosstalk

Bug: 7660973

RemoteViewsAdapter will now store the userId as part of the cache key
when caching remote views to optimize for orientation changes.

Change-Id: I7c4e52b3995d4f56ebfa35aa9516327e182ad892

Fix issue #7649590: Background windows sometimes not being hidden for secondary users

There are two things going on here:

(1) In secondary users, some times theme information such as whether
the window is full screen opaque was not being retrieved, so the window
manager didn't know that it could hide the windows behind the app.
This would just be a performance problem, except that:

(2) There appear to be a number of applications that declare that they
are full screen opaque, when in fact they are not.  Instead they are
using window surfaces with an alpha channel, and setting some pixels
in their window to a non-opaque alpha level.  This will allow you to
see whatever is behind the app.  If the system happens to completely
remove the windows behind the app, and somebody is filling the frame
buffer with black, then you will see what the app intends -- those
parts of its UI blended with black.  If one of those cases doesn't
hold (and though we have never guaranteed they would, in practice this
is generally what happens), then you will see something else.

At any rate, if nothing else than for performance reasons, we need to
fix issue #1.

It turns out what is happening here is that the AttributeCache used
by the activity manager and window manager to retreive theme and other
information about applications has not yet been updated for multi-user.

One of the things we retrieve from this is the theme information telling
the window manager whether an application's window should be treated
as full screen opaque, allowing it to hide any windows behind it.  In
the current implementation, the AttributeCache always retrieves this
information about the application as the primary user (user 0).

So, if you have an application that is installed on a secondary user but
not installed on the primary user, when the AttributeCache tries to retrieve
the requested information for it, then from the perspective of the primary user
it considers the application not installed, and is not able to retrieve that
info.

The change here makes AttributeCache multi-user aware, keeping all of its
data separately per-user, and requiring that callers now provide the user
they want to retrieve information for.  Activity manager and window manager
are updated to be able to pass in the user when needed.  This required some
fiddling of the window manager to have that information available -- in
particular it needs to be associated with the AppWindowToken.

Change-Id: I4b50b4b3a41bab9d4689e61f3584778e451343c8

Fix ring volume issue by addressing focus regression in keyguard.

This fixes a regression where ring volume can be changed in keyguard.
Because KeyguardHostView is now being re-created in onScreenTurnedOff(),
it loses focus and the volume keys get handled by the fallback handler.

The fix is to ensure at least one child under KeyguardHostView has focus
whenever we re-create it.

Fixes bug 7546960

Change-Id: I34b7db402401a824f463d35d7546c05dc2979243

Fix an issue on installing 3rd-party IME by a non-primary user

Bug: 7573552

Currently IMMS doesn't receive install/uninstall messages. Accordingly enabled IMEs' list is not refreshed properly.

Change-Id: I25e9798a65f528dd270cd6bb1f14b1d887194787

Revised language for notification ringtone picker.

Bug: 7659273
Change-Id: I5cb94a24b8ebff96ab5b567efc39a780300ee7ee

Change getName and getAddress permission to BLUETOOTH

The permissions were set as BLUETOOTH_ADMIN by mistake. Correct them
bug 7665249

Change-Id: Ic1bdbeb25e8f55d886f9a8d38920cbb769dd38ca

Kill dreams that do not create a timely service connection.

Implement a timeout between when the dream binds and
when the dream creates the service connection.  If
the connection is not created within a certain amount of
time, stop the dream.

This fixes the current bug where a dream that crashes in
onCreate (or the ctor) can put the dream controller in a
bad state until the screen is turned off.

The timeout is equal to the service restart delay in
activity manager (ActiveServices) to avoid restarting
(and recrashing).

Bug:7596707
Change-Id: I3e11efc6af0b79ec4cb0fbc94e4e109c7602ddac

PRIORITY_MIN notifications should be truly ambient.

If your notification is set to MIN priority, it will never
attempt to interrupt the user, either by an icon (already
implemented), or (new in this patch) by LED, vibration, or
sound.

Bug: 7648785
Change-Id: Ia0f8e010e62029d8d8ef1955dd20b7c79fb68398

Fix for bug 7467609 Bad rendering of Telugu text

This change moves Telugu back before the fallback font. Previously it
had been moved to after it because it contained incorrect mappings of a
number of characters, including U+2212 and U+FFFD. These fonts have now
been fixed. When placed after the Droid Sans Fallback font, the glyph
count for complex script shaping exceeded the 2^16 limit, causing
incorrect rendering.

This patch depends on the fix for the Lohit-Telugu font.

Change-Id: Ib1bc665a246c4ad65a0dea1c261df5696b440344

Pin electron beam surface to natural orientation.

If a rotation occurred while the electron beam surface was showing,
the surface may have appeared in the wrong orientation.  We fix this
problem by adjusting the transformation matrix of the electron beam
surface according to the display orientation whenever a display
transaction occurs.

The rotation itself is allowed to proceed but it is not visible
to the user.  We must let this happen so that the lock screen
is correctly oriented when the screen is turned back on.

Note that the electron beam surface serves two purposes.

First, it is used to play the screen off animation.
When the animation is finished, the surface remains visible but is
solid black.  Then we turn the screen off.

Second, when we turn the screen back on we leave the electron beam
surface showing until the window manager is ready to show the
new content.  This prevents the user from seeing a flash of the
old content while the screen is being turned on.  When everything is
ready, we dismiss the electron beam.

It's important for the electron beam to remain visible for
the entire duration from just before the screen is turned off until
after the screen is turned on and is ready to be seen.  This is
why we cannot fix the bug by deferring rotation or otherwise
getting in the way of the window manager doing what it needs
to do to get the screen ready when the screen is turned on again.

Bug: 7479740
Change-Id: I2fcf35114ad9b2e00fdfc67793be6df62c8dc4c3

more app launch test tweaks

to get closer to the previous harness:
* sleep 750ms after launch then press HOME
* force close app after launch
* sleep 2s then move to next app

Change-Id: I70fefa7f3e87c637ed8b4cb2981c26d665c94319

DO NOT MERGE Notify provider when disposing last UpdateRecord

Cherry-pick of Id48151eb7de40164258cde7da220a4d6bb34b89a

Location providers were not being notified of the change in status
when the last UpdateRecord was removed due to numUpdates exhaustion
or request expiry. Oops! Enjoy some free battery life!

Bug: 7611837
Change-Id: I66303b355be4e4a56a81efb5406c9353b2588595

Defer process mode upon draw

Process mode functor execution can be expensive, and cause dropped frames if it
runs between two expensive frames (when there isn't cpu time to spare). Avoid
this by delaying the process mode by an additional 4 ms every time we hit a draw

bug:7670326
Change-Id: I27f42458d4a815183a4b24c7748e05bc361fb943

DO NOT MERGE Protect against NPE in FusionEngine.java.

Cherry-pick of Ic49a069eef47a62fb1e0c6f284a705a62c6ae232

Bug: 7629406
Change-Id: Ia04dba9496b02755678b43e12834e992f63ee45b

Make 3rd party lockscreen widgets work on secondary users

If you install a lockscreen widget app on a secondary user, lockscreen fails to find it.
There were several places where the correct context and userId were required under the
covers - AppWidgetHost, AppWidgetHostView and RemoteViewsAdapter.

Set the user id in the required places and use it to query the package information.

Bug: 7662835
Change-Id: Ife482c8ab2a2e601650b7cfe2660e88d3b8f2050

Fix baseline alignment of notification times.

Bug: 7668052
Change-Id: Ifc868ac5988e00c3d63aa1e1e91544d433c858a5

Fix bug #7649607 Hebrew text is cut off in Settings

- in RTL mode and wrap content, make RelativeLayout respect the width that can be  passed to him

Change-Id: I6029135dede1ee80e41ae1bc2a337bf52cf24445

Fix bug #7663550 ActionBar menu items should probably use android:textAlignment="viewStart"

- add "viewStart" for popup and list menu items

Change-Id: I3adf1a17080056e6d0e5fc8b9c9c95dcaafa90f6

Fix longstanding nonsense in javadocs.

Change-Id: Iea2c7b8e5dc7591a9586a628e891d71d215daec6

Fix NPE when showing Toast from system process.

The system process has no ApplicationContext and consequently was
returning null. Use the base Context in these cases.

Bug 7673699 fixed.

Change-Id: Ie2ab856bb0baefff44775a12bef7802320f72656

DO NOT MERGE Adjust update interval when expiring location requests.

Cherry-pick I88b419c92940b7e536d48b26e5fc0f72f3c9e73d

This is a more complete solution for this issue that disables
location providers when expiring their last request *and* adjusts
update intervals when expiring any request. This should help
further limit battery drain when a high-frequency-update app
exits, as it allows the system to throttle the update interval
back down to something appropriate for the remaining listeners.

Bug: 7611837
Change-Id: I7629a90f4c693be4bf96d662bd3a8b06dae0b089

Make it clear that non-optional MediaFormat keys are required

Also mark KEY_CHANNEL_MASK optional.

Change-Id: I569087f564dc60a89b15a3440a9b1c538927f610
related-to-bug: 7623602

Fix password field focus in keyguard

This fixes a bug introduced in Change-Id: I34b7db402401a824f463d35d7546c05dc2979243 where
the top-most view was allowed to capture focus in order to ensure the device handled volume
key events.

This resolves the issue by restoring previous behavior and ensures we still handle media keys,
regardless of focus.

Fixes bug 7676996

Change-Id: Id2d1200be81640e4b4b7b5e3a0af099d6fc2d259

Revert "Saving and restoring current page when rotating in lockscreen. (Bug 7568412)"

This reverts commit 6cbc2e81742039969e081a9eed02060fb8789e25.

Making sure to clear state related to views that are being recycled (issue 7650538)

Change-Id: I5161ac261f963789537d2066a472cd3036c218aa

Enable Turkish language encoding for Turkish SIM cards.

Enable Turkish language encoding for SMS messages. Adds an
MCC-specific config.xml override to enable the Turkish
language tables for Turkish SIM cards. Also modifies
GsmAlphabet.java to load the config.xml values before use,
so the SMSDispatcher will get the current values instead of
caching the boot-time values before the MCC is loaded.

Bug: 7422368
Change-Id: I57cd5fcc1d04a2d0cba3e8b9022078679cf5d4c1

Enforce camera shutter sound for Korea.

Bug 7680515.

Change-Id: Iafd0296aac36bd048e409f42f7e99eb0895d3d26

Call setSize to sync Surface to SurfaceFlinger. DO NOT MERGE

RecentsActivity screenshots are called for very quickly after
WindowStateAnimator prepareSurface(). Without enough delay the
Surface.setLayer call does not propagate to the SurfaceFlinger
and the screenshot is incorrect (black) because it stops sampling
the layers too early.

This fix calls Surface.setSize() for each sampled Surface in
screenshots. setSize forces the SurfaceFlinger to process all
transactions queued before returning from closeTransaction.

Bug 7552304 fixed.

Change-Id: I1911dfa0b09cab713c55f5ba0c612496337a77df

Conflicts:

	services/java/com/android/server/wm/WindowManagerService.java

Fallback to default dream if the current dream is removed.

To minimize fix size, return only valid dreams from the service api.

Settings will "just work" with no changes.

Bug:7699398
Change-Id: I3eb88237a8ccc421fdb68d1de19820614b13d7b8

Play a tone when wireless charging begins.

Only plays a tone if the battery level is below 95% which
is the same heuristic used when determining whether to turn
the screen on.

Use new low battery and wireless charging sounds on Mako.

Bug: 7371658
Change-Id: Ia4527ec398d024ee418a4287e1fcbf0ec83bcc24

If freeCache deletes APK, give out of space error

After DownloadManager has downloaded an application to cache to install
during low memory condition, we try to free cache to fit the new
application. The free cache function deletes older files first, but it
will also delete the downloaded application (since it's in cache) as a
last resort since installd has no context about it.

This just changes the error code returned in this case so that we'll
give something more meaningful to the user. A later fix should actually
make this more sane. For instance: know which file to avoid deleting,
not even trying to delete anything if it won't arrive at the desired
free space.

Bug: 7684538
Change-Id: Ide77320fc51a4f692ef8042cb0eafe17b5cd279d

Don't update global table when upgrading secondary users' database.

Bug: 7722149
Change-Id: I0c1373cba316b924701136579083274eb6c9b1da

Fix bug #7724071 ImageView drawable is not loaded correctly when changing Locale

aapt is not generating the correct CONFIG_LAYOUTDIR bit when a Drawable has a
LTR and RTL version. It was generating instead the wrong CONFIG_SCREEN_LAYOUT bit.

This was linked to the fact that the layout direction bits are contained into the
screen layout bit.

So now make sure that we are generating the correct CONFIG_LAYOUTDIR bit.

Change-Id: If17c84d31e6c128721ed97ee6711660b131bf941

Receive a user dictionary callback from Settings application

Bug: 7725834

The callback is sent when the user adds a word to the user dictionary.

Change-Id: Ieee9bfd50a9adbed1a769e3cd95d9cb2815c34b4

Fix NPE inside DreamManagerService.

Bug:7741911
Change-Id: Icfc39b2d89f57bba79866030df85b822e3f73ae2

Handle "CODE_ALREADY_PRESENT" message from Settings app

Bug: 7725834
Change-Id: I85c35e73978d606edf9687e2de76c6ffc3c3ee2b

change onEnd() to withEndAction() in javadocs

Change-Id: Ic9a04bf86d62249b47dc654052d58797dfc3990c

Fade recents thumbnail to transparent earlier.

Reduce the gpu load by fading the recents thumbnail to an alpha of
0.0 before the remaining animations are completed. When alpha hits
0 the gpu treats the layer as hidden and can merge the remaining
layers in time.

This is a partial fix for 7729214.

Change-Id: I9761bbd0554db6454c7eec0485be798b11672ff5

Fix a bug where disabled auxilialy IME is unexpectedly re-enabled

Bug: 7872918

This is a serious issue which the disabled system auxilialy IME is unexpectedly re-enabled by re-building internal IMI cache.

Change-Id: I0727cc973dfaea9823194021ce94af8665b98373

Add single crunch command to aapt. do not merge.

Previously the crunch command would work on a full res folder
and output a full res folder (with only the drawables). This
was only used in the SDK.

The incremental logic is moved to the SDK build system so we
change the crunch command (or rather add a new one) to only
crunch a single file.

(cherry picked from commit b1f6ad82dd8d1702617a757a88430604b3131fac)

Change-Id: I3653f67ee321eac37cb8a6d228b1ef6d104ff0be

Adding camera scene mode stress test.

Change-Id: I3f9afef4edc6ea1f659263bf2dbd8ca247039ce0

Refactoring the media recorder stress test.
Added test cases for:
- record & playback @ 1080p
- record & playback @ 720p
- record & playback @ 480p
- record & playback @ custom
Plus extending the record duration to a full minute.

Change-Id: I294714811606c1ae57907d6ef6a7052044b6247c

Make action bar title a valid touch target for up when relevant

arubin bug 7966136

Change-Id: Iea5b85852cc1664f1390a6f8b6179d63b50857e4

Merge from master: fix issue #7966357: Super lights out mode vs. volume dialog

The volume panel now forces us out of the UI modes while it
is up.

Change-Id: If39fa33b1c52579bf5d376ce4722408cee3ca951

Revert "Fix a bug where disabled auxilialy IME is unexpectedly re-enabled"

This reverts commit 32b812054cce27d1c70b53ba8ac729c7186b105e

Bug: 7976890

Change-Id: I75ab60734153719b199cf7281d23f5eb1ad2d1bc

Improve heuristics for detecting wireless chargers.

On some devices, we need to apply heuristics to determine whether
the device is docked on a wireless charger because the charging
circuits do not provide sufficient information to know whether
the device is on the charger unless it is actually receiving
power.

The previous heuristics only considered the battery level to
suppress spurious dock signals.

The new heuristics also take into account whether the device
appears to have moved from its previous position on the dock.

Bug: 7744185
Change-Id: I5ba885dac25b37840b6db46b8a0f30968a06776c

Fix image processing test to include all benchmark tests
-- each test case can be excuted separately
-- add a test case to run all benchmarks.

DO NOT MERGE

Change-Id: I3c61dfe50267a6db11bc1895a4f37ed618a9103b

Fix the single crunch command to return the right error code.

Casting from status_t to int doesn't work for return values
if the lower 8 bits are all 0.

Change-Id: I88e910dfe46cb72acd1595352e71da3c8eff4ca9

DO NOT MERGE Prevent OOM death for services under ServiceWatcher's care.

Change-Id: If87be5769b55368edaf4776189e8f6e51a21eb03

Conflicts:

	services/java/com/android/server/ServiceWatcher.java

Properly initialize recognition service if the recognizer component changed.

The getServiceInfo() call directly to IPackageManager does not throw an exception.
The return value needed to be checked for null.

Bug: 8031032
Change-Id: I701b9e8cf3b2406a3b35a486183330489b3d46f5

Prevent simultaneous interaction with action bar and content

Bug 8034744

Change-Id: I72cf4f5d2443e1cd6e40785b4d06d9bd363ab3e4

Touch action bar title text: you will go to space today!

Title/subtitle text in an action bar is now a full alias for home/up.

Add some prototype ActionBar functionality around titles for future
API consideration.

Bug 7966136

Change-Id: I14377121dcb976d0a5f1e1862f35c3d267eb5458

Fix Javadoc for View layoutDirection / textDirection / textAlignment - DO NOT MERGE

Change-Id: I19b7a53c1c7d805fb9b1611e8944db27c82fc986

Fix WiFi test:

 -- In environment where there are too many APs, sometimes, the AP will not show in the scan list.
    Part of the reason is due to the change that the scanning on each frequency is shortened to save power.
    to avoid that, change the test to connect without scanning.

 -- Increase the timer to wait for WiFi to be connected

Change-Id: If1a72607b3c7ad13dbbf788607665986eaf5b6b3

docs: delete orphaned images (the obvious ones)

Change-Id: Ib6219e65a05925a13a26c415c69431bc2fbbdc68

Fix regression in expanded action view up

A bug was introduced when these views were restructured. Make sure that the
Up button for expanded action views functions/focuses correctly.

Bug 8124825

Change-Id: I0a886e62fca21dbb9a173db87642bb79ce9245e7

Fix re-enabled state of up after action view collapse

A certain call ordering to the action bar could cause the record of
the pre-action view expanded home button enabled state to be
incorrect. Store this in all cases, not just when the action view is
initially expanded. (Except for when we actually disable it for the
expanded view.)

If an action view is already expanded when we get a call to change the
enabled state of the home/up button, don't modify the state of the up
container or other accessibility info, but record the new state if
requested.

Bug 8142097

Change-Id: I070c151aa9f2046d2114ee541d964bf68c6f0def

Suppress quick settings if setup has not been completed.

The button was already hidden, but there are lots of other
ways to get into QS that should check for USER_SETUP.

Bug: 7638795
Change-Id: Ib6c48fc02e833670768e7dc76e25c38097b88c18

Utility to format human-friendly durations.

Bug: 6777872
Change-Id: Ie7ebcb456306f4f88b4707030dd7beda3fc90368

Stop supplicant and dhcp before start

Bug: 7227463
Change-Id: Iaa0df7522edc38d25fae2bbda8d24490e997e733

Delete appWidgetId when removing lockscreen widgets

Change-Id: I06a01fd2255118fec8769034260f561dc7c640e1

Put back vibration control params

Who removed these?

Change-Id: Ie54fa4f9a66be40d00302ad1b30b0822cda2555d

Useful annotations for code documentation.

Bug: 6537978
Change-Id: I806c3c09e3255f8789455f13bf37c1dde2a93f1f

Fix Derp

Change-Id: I66704f0593d8d31c03bb604321d1b9c248c26654
Lockscreen Targets: Icon Revamp

Adjust the size of custom app icons and resize and round the corners
of gallery icons for a more uniform look.

Before http://imgur.com/cTOqdwX

After http://imgur.com/EKAeFiw

Change-Id: Ibcca275eb0ae946775773a8c8217b6508da10e5b
Frameworks: some fixes and rearrange of NotificationManagerService

cheers

Change-Id: Ifc09107b5f3189c4b722562fef7933f19ce2d2e8
bootanimation: performance/speedup enhancements (squashed from CM10)

bootanim: Don't cache textures if they're expected to use a lot of VRAM (rmcc)
https://github.com/CyanogenMod/android_frameworks_base/commit/14f9eecd3f543a25c4a2053d6155a9396a777a3a#cmds/bootanimation

bootanimation: performance enhancements (turl)
https://github.com/CyanogenMod/android_frameworks_base/commit/e6b54405aa70d7503a114d9c90ef7518abdd7133#cmds/bootanimation

bootanimation: fix usage of LOGW (intervigilium)
https://github.com/CyanogenMod/android_frameworks_base/commit/e45cf7d232490f44aecf8f2447220a8b5ace4c10#cmds/bootanimation

bootanimation: allow using RGB565 instead of ARGB8888 (tpruvot)
https://github.com/CyanogenMod/android_frameworks_base/commit/204282870a9c69b04ad5ddecd73fafbd7996cbc0#cmds/bootanimation

Change-Id: I203fa23f77d1349fb822a7662e2cd3998ba4c814

bootanim: Don't cache textures if they're expected to use a lot of VRAM

bootanimation cached all the textures generated until the animation
was completed.
For Hi-res animations with lots of frames (like the new CM9 anim on
xhdpi devices), this implied using large amounts of video RAM, more
than most devices actually have available, causing the animation to
stall (and in some cases, gralloc to lock up); so if an animation is
expected to use a lot of RAM (rough estimation based on frame size
and number of frames), disable cache entirely and generate the textures
on demand

Change-Id: I157e5cdde2aab1d82d980d77cbedd9f127c83a1d

Conflicts:

	cmds/bootanimation/BootAnimation.cpp

bootanimation: performance enhancements

This patch implements two simple performance enhancements, which
might benefit devices. They are completely opt-in by setting
the following variables.

  * TARGET_BOOTANIMATION_PRELOAD: will preload the bootanimation
    zip to memory; this is handy on devices where the storage
    might be slow. By preloading it, we get quick access to the
    zip file, and the animation doesn't stutter.

  * TARGET_BOOTANIMATION_TEXTURE_CACHE: allows maintainers to
    force texture cache on/off.

Also fixes the sign warnings related to int / size_t comparison

Change-Id: Ie92d1b0aa90b43ba39c368a2a33657a60c3a64b5

Conflicts:

	cmds/bootanimation/BootAnimation.cpp

bootanimation: fix usage of LOGW

Change-Id: I1d59df9f44f414d80058a532644cbbb40e22c701

bootanimation: allow using RGB565 instead of ARGB8888

RGB565 uses considerably less memory, and together with texture
cache, it allows us to offer a really smooth bootanimation on
not so powerful devices.

Change-Id: I9da8fd7e6a587b5895519dd0983ec9b8f676771b
Add method to PowerManager that allows querying the lowest possible
brightness.

Used by the auto-brightness adjustment to adjust the sliders.

Change-Id: Idb58fd86dee1a053fe858291be6c9b3169ac4247
Custom carrier text (2/2)
same as the other commit

Change-Id: I34e8de1921dce740454101020a1f259cb89f02e2
Fix HTC headset handling.

HTC's headset driver adds additional bits to the switch state, which
we're unable to deal with. Fix that by masking out those bits and
keeping only the valid ones.

Change-Id: I29f0de9520ebb56d61acbc9a6dfcfc73e1f297d8

Conflicts:

	services/java/com/android/server/WiredAccessoryManager.java