Add explicit close of Scanner input

The UsbDeviceManager is using a Scanner to identify
the ALSA card/device numbers to use for USB Gadget
audio, with a FileInputStream as its input.

Since FileInputStream implements the Closeable interface
it provides a close() method that should be explictly
called in order to close the stream source and release
any system resources that it might hold.

Change-Id: Ia0ff86d1f3cdf8916becec9c8603915dcbf4d2c8
Fix a JNI local reference leak in MediaDrm

A reference leak was found in the subtitle usecase that also
applies to android_media_MediaDrm.cpp
(Code taken from the similar fix in android_media_MediaPlayer.cpp)

Change-Id: Icc4b25e4adc9a600ff4ac99a7a8478bb55a6e348
onAccountsUpdated shouldn't be called back after listener unregistered

There is a problem of AccountManager that onAccountsUpdated() is
called back even after the OnAccountsUpdatedListener is unregistered.
It may cause application crash.

For example, when rotating a tablet 180 degree with Settings apk
running, com.android.settings.Settings is re-launched 2 times
successively. (Destroy->Create->Destroy->Create)
It repeats adding&removing OnAccountUpdatedListener.

When dialog was being opened in the following cases,
NullPointerException at BackStackRecord.getBreadCrumbTitle()
was happened on 10 inch tablet which has 2 panes on Settings.
* Settings > Language&input > Language
* Settings > Language & input > Text-to-speech output > Speech rate
* Settings > Wi-Fi > Menu > Advanced > Keep Wi-Fi on during sleep
* Settings > Wi-Fi > Menu > Wi-Fi Direct > Rename device

This fix prevents the undesirable callback.

Change-Id: I081f69c90539cca821cf686b4587495135f375e4
Fix preference puts with "null" values.

Null values were being written out as <null /> elements in the
XML prefs file (as expected). This allowed the getFoo() functions
to work correctly because they treated null values as missing mappings
but containsKey would fail.

bug: https://code.google.com/p/android/issues/detail?id=64563
Change-Id: I1f466d01db96bf26e208d4fed3a6f257228bea5d
MountService listeners can not be unregistered

When unregistering MountService listeners, their Binder proxy
objects were compared to registered listeners instead of their
backing objects.

Change-Id: Ie98a686b1d17544f1eda59fb3eb0dc02d836c1b2
Add NULL check in updateProxyConfig

If the exclusionList was null in updateProxyConfig the VM would
crash when converting it to a UTF8 string. Avoid this by adding a
null check.

Change-Id: I0d8106fd54385bd9ae9c652a6c67d459a119cf2b
Before requerying a cursor, check if it is closed.

Before updating a cursor,
it needs to be checked if it is valid.
Currently a defence code only checks
if it is not null.
But in case of "Cursor", it is not valid,
if it is closed.
So just like in CursorAdapter.onContentChanged(),
add the additional defence code to check validation.

Change-Id: I1302f1b6d009897815d4bdb2f20f625688cf9901
p2p: Display P2P peer MAC address if device name is empty.

Display MAC address of a P2P peer in an invitation prompt
message on receiving invitation request from the P2P peer
with empty device name.

Change-Id: Icabeb91d666437746eb5a733ec582849eb7295a5
CRs-Fixed: 506109
Use highp precision for scaled coordination

If scaled coordination is closer to zero than what
the medium precision can store, distance becomes
zero and it causes divided by zero.

Change-Id: I8ee921dd1f57564a442e685266b12d95fc08e165
NetworkPolicy: Validate policy templates before updating

Ensure all the policies to be added are validated, otherwise
this service will throw IllegalArgumentException and cause
system crash when updating network template after receiving
ACTION_NETWORK_STATS_UPDATED.

Change-Id: I3faef0ac2a2fcea64ba5dde9c9256f6714280e2e
CRs-Fixed: 561490
 Frameworks: speed up statubar/notification drawer

a lot user complain about slow statusbar pull down introduced
with jb 4.2....this speed it up

thanks to IceColdJelly