Avoid possible memory leaks by ensuring stream closures

Stream close() methods should always be called in finally block
to ensure we don't accidentally leak a stream.

Time to fix some old sloppy code.

Patch Set 2:
 + ensure closure of some other streams
Patch Set 3:
 + missing import java.io.IOException
Patch Set 4:
 + missing import
Patch Set 5:
 + missing ';'
 + whitespace cleanup
Patch Set 6:
 - Reverted changes to MemoryUsage (final requirement
     prevents my implentation)
 + fixed Object allocation in Root.java
Patch Set 7:
 + fixed curly bracket style violations
Patch Set 8:
 x fixed my own sloppy code :/

Change-Id: I3460b558ed5b4489296388c9a52fbb773cefd31f

Conflicts:
	packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
[2/2] Frameworks: Halo Color

Change-Id: I6b8a3e8b1057e466b947da63e5faf67560781837
Signed-off-by: anerikg <anerikgames@gmail.com>

Conflicts:
	core/java/android/provider/Settings.java
Correct typo in doc comment

Changed "will" to "with"
(will null Options -> with null Options)

Change-Id: I3bbfb953d8e783ca6335247463007cbee722a28e
Signed-off-by: Shuhrat Dehkanov <k@efir.uz>
Fix a bug in KeyStore.getInstance().

Sometimes keystore process may die unexpectedly, so client cannot connect it.

Let KeyStore.getInstance() return null when it cannot get KeyStore
service, so that caller can get informed to prevent NullPointerExcepion.

Change-Id: I7aafc959dee9a77fda80ab6eb5c82f9a3f56f959
Signed-off-by: hanpengx <pengfeix.han@intel.com>
Signed-off-by: Guobin Zhang <guobin.zhang@intel.com>
frameworks/base: Fix aliasing violations

Fix violations of strict aliasing rules

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
Use default visibility for Snapshot::getLocalClip.

The method is in libhwui.so but used by libandroid_runtime.so
(via android_view_GLES20Canvas.cpp). If the compiler decides not to
inline this method, the linker won't be able to resolve the dependency
when it has hidden visibility.

The problem is found when testing GCC 4.9.

Change-Id: I3b4d096c7767f0bef0796886dfb2c5ba2ecff48c
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
hwui: Apply hwui qcom fixes to all adreno-bearing hardware

Even if the device doesn't fully use the qcom stack, changes to
libhwui are generally workarounds for adreno-specific issues and
apply across the board without other dependencies

Change-Id: I10455ebf09c1d00762b06e3c092398604bb39796
hwui: Fix build in ISO C++11 mode

Make sure log calls can't be confused with C++11 string literals

Change-Id: I1d458e92e690f6f2b922a05494db8c01da54e460
Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
Fix confusion about whether or not output() should be const

It probably should be const, but it isn't on master - let's try to
be closer to next upstream

Change-Id: Id26bf19d94a36d83b57488e8bd8d86fa21e784b2
Signed-off-by: Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org>
Remove opaque check in preparing dirty region

Since preserve swap is enabled, we need to clear the color buffer
when the scissor rect is prepared for a new process. This prevents
garbage being present from the previous process in the color buffer.

CRs-Fixed: 549755

Change-Id: Icd12ae388077b8c9ed329c37314e896500078543
(cherry picked from commit 48b6a9767317e08a24e189c9cbee21043543682a)
(cherry picked from commit 777610a5ddf19cebcad30b7e9a481e9dfe38b74c)
Update the layer's alpha value upon composition of the layer

Fixes: This patch makes sure that the layer's alpha value is
up-to-date and does not reflect the previous view's alpha value.
It fixes the square block on marquee fading edge when text view
is applied transparency.

CRs-Fixed: 562000

Change-Id: I397308b739f5f4fe4b630cf594825f401c97e0e3

Conflicts:
	libs/hwui/OpenGLRenderer.cpp
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
Correct stride for drawing to cached glyph bitmap

fixes the glyph cachebuffer index to account for pixelbuffer
format size.

issue: in launcher home screen create icon group and rename the
group to some text string with emo-icons (smilies). without this
change the drop shadows for emo-icons will look bad.

Change-Id: I525a9219d35f4541363fd64e7fc5fd1053269725
Signed-off-by: Digish Pandya <digishp@codeaurora.org>
Use alpha channel instead of red in drawCachedGlyphBitmap

the correct value to copy in bitmap is alpha component from
the cachebuffer. currently it is offset to red channel if format is
RGBA which is wrong.

this is followup fix for https://android-review.googlesource.com/#/c/93943/

Change-Id: I96b5ba35df5ccaef44caf2542d35d6585ba1df80
Signed-off-by: Digish Pandya <digishp@codeaurora.org>
Signed-off-by: houst0nn <houstonn@gmail.com>
Missing break in switch statement

Change-Id: I1b7e7a94df8d39e162050911e31e510d2ce5447e
mediaeditor: Fix c++11 narrowing

Summary: Depends on D309 D310

Test Plan: verified

Reviewers: randall.rushing, jriordan001

Reviewed By: randall.rushing

Differential Revision: http://review.codefirex.com/D312

Change-Id: I34a0e0e0fc9879e6c4a12a1dd8375dd409042878
Signed-off-by: DHOMD <DHO@dho.im>
[2/3] mediaeditor: Allow custom DOMX source instead of Google DOMX default

Part 2 of 3 patches: To allow omap4 devices to use custom "domx" source
via a new BoardConfig.mk item:
TI_CUSTOM_DOMX_PATH := device/<manufacturer>/<device-name>/domx

This setting provides for 3 changes during the build:
1. In hardware/ti/omap4xxx this settings stops standard Google domx
source from being built and changes the domx reference for tiutils.
2. In frameworks/base it changes the default openmax references for
frameworks/base/media/jni/mediaeditor/Android.mk to the new location
3. In frameworks/av changes the openmax references in 5 places, and adds
new includes in ACodec.cpp, CameraSource.cpp and OMXCodec.cpp

This commit is based on cherry-pick from omapzoom (with a more descriptive
BoardConfig setting name):
http://www.omapzoom.org/?p=platform/frameworks/base.git;a=commit;h=f7f929ff477955333bf7e7413a81a66d683d1f3f

Change-Id: I7ba8052a6144597bf961b78723186c58b7e12e48
libaudioeffect_jni GREF leak fix

- excessive jni reference in AudioEffects
- global references created during native setup are not deleted
- global references are dleted in setup failure and during native releases

Changeset 2:
    -fixed whitespace, and rebased on jb42

Modifications, 1 tab == 4 spaces

Change-Id: I3ff54cc3b0c5394e978421dad3a7a257551f776e
Signed-off-by: Alexander Martinz <eviscerationls@gmail.com>
[3/3] AudioFX: Add center frequency param to bassboost

Change-Id: I49da8e5ab24502d0de5c09b7fc9f4b8a51bead60