Enhance db dump performance

BufferedOutputStream can enhance db dump performance.
Especially, if the data for dump is bigger
and the dump is being processed in the main thread,
it could cause ANR for slow performance.

Change-Id: Ia9c8f0ca22e0b829ee983a3cb78e9757654b9a35
Signed-off-by: jangwon.lee <jangwon.lee@lge.com>
ActivityManager: memoize for performance

isHighEndGfx and isLargeRam are frequently called upon.. isLargeRam very
frequently within the ActivityStack. these aren't going to change after
they're calculated the first time so subject them to a basic memoization.
FTW.

Change-Id: I176089f99ac6c6e4074cb2fde502c729986ea701
Fix DataInputStream leaks

Fix fixes
-In viewstateserializer, try to close before throwing or returning, and throw early if inputstream is null
-other stuff

Change-Id: I7f3b16057582566b82a85841829ff6ed11cd570e
frameworks/base: Fix for the race in Wallpaperservice

Wallpaperservice has a race among message handler of
DO_DETACH and service's onDestroy. In certain cases,
the engine kept track in mActiveEngines is removed by
message handler of DO_DETACH and service's onDestroy
doesn't get a entry in mActivieEngines and isn't able
to invoke detach. This keeps the broadcast receiver,
mReceiver active and is unregistered by the framework
and a corresponding leak is reported.

  Later, the message handler of DO_DETACH continues
and invokes detach on mEngine, which attempts to
unregister mReceiver and framework throws an exception
"Receiver not registered: android.service.wallpaper.
WallpaperService$Engine$1@40874580" and causes the
framework to reboot.

  In case of system_server, WindownManagerPolicy and
android.server.ServerThread contest for access of
shared members, mActiveEngines and mEgine. Fix is to
protect the critical section via synchronized block.

Change-Id: Ice79cb8344fb54bcc6e9f76f4b143daac2608d7b
Composing text is not cleared if you write too fast

In some scenarios when you write very fast, onUpdateSelection
is called with delay. This can lead to a incorrect state in
the input methods.
Current change notifies InputMethod as soon as a cursor position has
been changed.

Change-Id: I5064d52f576225f79544e06e3de2d2acef30c597