Fix for positioning of glyphs within a bitmap

For positioning of glyphs within a bitmap, roundf(int + float) is used,
where the float is the glyph position and the int is the text position.
When the text position is varied, this may lead to the sum being rounded
in different directions, due to floating point rounding, caused by that
floating point numbers have different precision in different ranges.

This may therefore lead to slightly different positioning for glyphs and
therefore slightly different widths and heights for text strings,
depending on the position they are rendered at.

The solution in this patch is to use int + (int) roundf(float), which
has consistent rounding, and also enables us to use the full range of
ints.

Change-Id: Id1143cdfcbdfa9915ced878ae04df589a3e03cee
Release locked buffer when it fails to acquire graphics buffer

The JNI buffer in ImageReader_imageSetup is not released when
it fails to acquire graphics buffer. After all JNI buffers are
exhausted, ACQUIRE_MAX_IMAGES will be returned and leads to
error. The JNI buffer should be released when it fails to acquire
graphics buffer.

Change-Id: I3319a58ac44e36c8593b404672a685c4b589a735
Fixed upgrading from forward-lock application to system application

Fixes the case when the app on system is newer than the
currently installed. Something that can happen e.g. after
a FOTA update.

Change-Id: I102e9cdd5693d5e66667c0c8989dc2643c72dd16
Fix graphics corruption caused by HWUI caches

Some caches(PatchCache, TextureCache, PathCache) for HWUI
uses deferred removal for their cache entries even though
actual resource objects are immediately freed by
ResourceCache.
For this reason, the uniqueness of a resource address in
the caches is not guaranteed in specific cases.
(Because malloc() can return the same address when malloc()
and free() called very frequently.)

So it can be possible the cache have two cache entries for
two different resources but the same memory address.
(Of course one of the resources is already freed.)
It also can be possible mGarbage vector in PatchCache has
duplicated addresses and this can lead to duplicated free
blocks in the free block list and graphics corruption.
(Deferred removal was implmeneted based on an assumption of
unique resource addresses.)

So this patch makes sure resource objects are freed after
the resources are removed from the caches to guarantee
the uniqueness of a resource address and prevent graphics
corruption.

Change-Id: I040f033a4fc783d2c4bc04b113589657c36fb15b
Signed-off-by: Sangkyu Lee <sk82.lee@lge.com>

Fix AOSP build - DO NOT MERGE

Change-Id: I42b420c2ce89ce364a2809b28b827964e6923fa1
[2/2] Frameworks: HALO

Forward port from jb.
PS1:  Initial port
      Fix conficts with notification LED
      Fix derp
      Major derp
      HALO Mods
      Rebase
      Fix blackist, code clean and added some TODOs
PS2:  Fix build
PS3:  Fix bubble sometimes doesn't respond on new notification
PS4:  Align halo icon
PS5:  Keep floating app in recents and disable transparent layer temporarily
PS6:  Fix conflict after recent merges
PS7:  Cosmetic fixes:
      Fix buttons layout in status bar.
      Status bar button holders show halo + qs switch on notification and qs edit mode + notification switch on qs.
      Update new margins size.
PS8:  Rebase
      Clean white spaces
      Toggle on/off from notification shade icon (remove red X)
      Standardize behavior (remove option to reverse tap/double tap)
PS9:  Remove references to LayerActivity
PS14: Rebase
PS15: update halo strings to prevent conflict with latest changes
PS16: Wrap all things!
      Modify halo behavior
PS17: Get the correct activity stack: this makes all windows in the same stack to get the floating mode
PS18: Stop pop-out on rotation
      Catch "silent" notifications
PS19: Rebase
PS20: Rebase, fix conflicts with recent merges
PS21: Fix missing commit messages from previous undefined patchset (19) and other conflicts

Change-Id: I3e79945433d61da090ca263f4e2989be9987f11d
Conflicts:
	packages/SystemUI/res/values/pa_strings.xml
	packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
	services/java/com/android/server/am/ActivityStack.java