core/jni: Clean up and optimize build flags
Fix for native leaks in YuvToJpegEncoder.cpp

Objects allocated by Get<object>ArrayElements function,
should be released. Add a fix to release this objects
in error cases.

Change-Id: Idf834523d93bb2dfd6b872e3b2179b7f1bba38f3

Conflicts:
	core/jni/android/graphics/YuvToJpegEncoder.cpp
WallpaperManager: add NULL pointer check for getCropAndSetWallpaperIntent

Originally the api 'getCropAndSetWallpaperIntent' does not check
whether the parsed parameter is a NULL pointer, as leads to the
whole app crash if it call this api with a null parameter accidentally.
A null pointer check logic is added into its original parameter check
logic, so that this API will throw an IllegalArgumentException if it
is parsed with a null pointer

Change-Id: Ib7de40e571419d09e1a744edc969eb7162766b75
Implement FileUtils#contains.

Partial cherry-pick of changes 4ca728c0 and 21de56a9, which
can't be cherry-picked due to their large surface area.

Change-Id: Ife46e150d360cd5241dea93863141749233c1805
Support per-package lib dirs for bundled apps

Bundled apps can now use /system/lib/apkname or /system/lib64/apkname
in addition to the (globally shared) /system/lib and /system/lib64
directories.  Note that when an app is updated post hoc the update APK
will look to its normal library install directory in
/data/data/[packagename]/lib, so such updates must include *all*
needed libraries -- the private /system/lib/apkname dir will not be in
the path following such an update.

"apkname" here is the base name of the physical APK that holds the
package's code.  For example, if a 32-bit package is resident on disk
as /system/priv-app/SettingsProvider.apk then its app-specific lib
directory will be /system/lib/SettingsProvider

Bug 13170859

(cherry picked from commit addfbdc09ccf258395db8bfc510989a4c583f7ab)

Change-Id: Id82da78024a6325458b8b134d7d91ad0e5f0785e
Handle /oem and /vendor as well

Bug 13170859

(cherry-picked from commit 740888f62eae158d5775be716620f0d56d87f587)

Change-Id: I7b5e206697fcbec146cac6cd83fca5c583a8cbd7
Fix native-lib dir assignment & updating

The per-package /system/lib/* feature introduced bugs in the
native library path handling during app upgrade installs.  The
crux of the fix is that when recalulating the desired native
library directory, the basis for the calculation needs to be
the scanned APK's location rather than the extant package
settings entry -- because that entry refers to the pre-upgrade
state of the application, not the new state.

Bug 14233983

(cherry picked from commit 353e39a973dbbadce82fee2f83ad194e04a47449)

Change-Id: I26f17a596ca2cd7f963955c0642548c15138ae26
Fix OEM native library path bug.

Bug: 13340779

(cherry picked from commit 7d3328d14bbbee01a9de1ff5b13b0446c709d835)

Change-Id: I1b4c5d138cafe3651d475ca1e048f495ff6c5f10
Minor cleanup of UsageStatsService

Change-Id: Idea0e29f347d14e48e87aad38a261d0493bd5fd3