On-The-Spot: Underp Safe-Headset one once for all and code cleanup:

After Gif support, context managing went derped resulting in the old NPE.
Valter's fix restored all the contexts that are used within system one that
we need just to read&write to system, but dialog's builder needs one created
by the ThemeEngine.

* Fix dialogs not being themed:
  Pass themed context only to dialog builder by crating one when needed.

* Cleanup implementation:
  Restore all normal system contexts and add an helper method to generate
  a theme context to be used by AlerDialog.Builder() for pulling themed resources.

PS3: Miscs
PS4: Code cleanup
PS5: Commit message cleanup

Signed-off-by: Carlo Savignano <stevewatersy@gmail.com>
Change-Id: I1e3f9dce7dd448306db0364ab6e1ff8a71160729
extmediaplayer: miscellaneous fix

Fix for issue 20936 reported by KW.

Change-Id: I512657696d99bbe64edfffa0ad7c687651a31acc
Fix memory leak in nativeDecodeFileDescriptor

Fix memory leak in nativeDecodeFileDescriptor:
SkFILEStream::kCallerRetains_Ownership is used to keep
life cycle of file in Java,so fclose is not called when
destruct SkFILEStream because ownership not belong to
native here, while when file is closed in Java, close
is called instead of fclose,that means buffer allocated
by malloc in fseek, when create SkFrontBufferedStream
with this filestream, will not be freed, because this
buffer will only be freedin fclose.
To fix this issue: duplicate this fd, and use
SkFILEStream::kCallerPasses_Ownership for SkFILEStream,
means Java and native manage file life cycle separately.
CRs-Fixed: 718738

Change-Id: I1c664551ab8d381db2e1f948a2207bc6fb7a11f9
AudioService: Fix monitorRotation for landscape applications

Current implmntation only sends rotation updates on orientation
changes, so does not handle direct 0<->180 or 90<->270 transitions.

Update rotation based on an OrientationEventListener instead of
Intent.ACTION_CONFIGURATION_CHANGED

Bug 17606902

Change-Id: I01dfcd1c587f5b2e8a96365c2389782ad77936ef

Conflicts:
	media/java/android/media/AudioService.java
lowmemorykiller: Overwrite LMK parameters for low-tier devices

LMK parameters calculated by default algorithm were not optimal for
low-tier devices. Values mentioned here were well tested and
evaluated w.r.t memory and performance for such setups.

Change-Id: I40ed92d204aae6e758028ea1e9bd4ec7226dbe2b

lowmemorykiller: fine-tune LMK parameters for low-tier devices

LMK parameters for low-tier devices are fine-tuned for better
concurrency. Values mentioned here were well tested and
evaluated w.r.t memory and performance for such setups.

Change-Id: I0d547f1ec84863bbaedb68d9aba1ff7aef057e42
Support full size application screenshots

Add optional width and height parameters for
ease of capturing entire application screenshots

Change-Id: I6d154f6b33bfb8ec90e3757a40382c1dc6feaad3
Revert "Systemui: ignore bartransitions if we are not on highend gfx"

This reverts commit 8cee5e7df73efac25cb08d34bcab76770303bcb3.

Change-Id: Idcc944333139a84fd6215529591ca0b03a9b7e31
Merge remote-tracking branch 'aospa/kitkat' into aospal