Cursor leakage due to cancellation signal

If a query call was cancelled, the cursor adaptor might leak. The
adaptor is now closed if any exception is thrown during query.

Change-Id: Ic4c2edeaf2fcef56b4ef59484a36d3233aa12dbc
Fix error checking in MemoryFile.

mmap returns MAP_FAILED on failures, not 0 (NULL).
Also, convert some C style casts to C++ since they
make intent clearer.

Change-Id: I367993c73e9ee576f11ebe76e530d2c2f27c662d

Conflicts:
	core/jni/android_os_MemoryFile.cpp
Only send storage intents after boot complete

It is not possible to send a broadcast before the system
boot is completed. If you do it anyway you will get an
IllegalStateException: Cannot broadcast before boot completed.

If a memory card is inserted or removed while the phone is
booting up, there is a risk that the MountService will try to
broadcast a storage intent too early, and cause the device
to crash.

Use FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT to avoid
problems with too early broadcasts.

Change-Id: Ied36a13d235df37c9788e45a35de40d919ae0cd0
Fix in MediaMuxer's JNI code

android_media_MediaMuxer_native_setup should return jlong. It was
incorrectly returning jint.

Change-Id: I31a475af0818f4d5dcbb39380b42612188cf3853
Signed-off-by: Ashok Bhat <ashok.bhat@arm.com>
Improve Parcel's handling of non-primitive arrays

Treat arrays other than actual Object arrays (i.e. those whose component type
is actually Object) and the primitive arrays already handled specially by
Parcel as Serializable's.

Issue: 64583
Change-Id: I3ff797f3262e77e4de27f35709bceee5410d1ed4
Miscellaneous small documentation fixes.

Most of these I noticed on my own. The change to docs/html/tools/testing/testing_ui.jd is mentioned in a bug report:
https://code.google.com/p/android/issues/detail?id=56324

Signed-off-by: Mark Doliner <markdoliner@google.com>
Fix documentation for Parcel.readException().

The old documentation was kind of useless and not clear, so this is an
improvement.

In addition to this change, I think this method should probably be private
instead of public, especially since the values for code are private. But it's
too late to change that now. Also the method name is pretty poor, since it's
not actually reading anything. Something like "throwException" would be more
appropriate.

I'm open to suggestions on how to improve this situation. Maybe mark the
method as deprecated with a comment that it will be made private in the
future?

Change-Id: I830f2bcf606714bd130d8c953aa33974b33c9a83
Fixed typo errors in documentation

Fixed some type errors in developer documentation.

Change-Id: I92629a4350508fb96fda1842741c5ced64171464
Signed-off-by: Taeho Kim <jyte82@gmail.com>
Open display settings by long-pressing the brightness tile

Change-Id: I379d09280ed796918fe504665b6303e82dfb7134
frameworks/base: Fix SystemUI crash on Recent Apps list

Issue: SystemUI crash is observed when Context MenuItem "App info"
       is selected on the recent apps activity
       1. Open the rencet apps list
       2. Long press on any one/more recent app(s)
       3. Lock the screen using power key
       4. Unlock the screen using power key
       5. select menu item "App info"
       6. SystemUI process will get crashed.

Fix: Changed the code to make sure that only one context
     menu is active at a time and also dismissed the
     context menu on pause of the RecentsActivity

Change-Id: Ia50bed7bfad6fde7beeaec37fa6402177eee1d40
Race condition in Toast.

1. mTN.mNextView is set in toast.show() but can be invalidated by posted
runnable mTN.mHide. If application call toast.cancel() right before
toast.show(), this race condition can occur.

2. Removes superfluous TN.hide() if toast.cancel() is called.

Change-Id: I554c5d44c59e18f5066f6175faec3e256b4e40d6

Conflicts:
	core/java/android/widget/Toast.java
Change the way to calculate the native heap size

Previously the native heap size returned by android.os.Debug's
getNativeHeapSize() is mallinfo.usmblks, which is the maximum
total allocated space. But this value is greater than current
total if trimming has occurred. In the output of 'dumpsys meminfo',
as a result, the native heap size dose not equal to the sum of
the allocated native heap size and the free native heap size.

I think this is misleading because actual and current footprint
of the native heap is usually smaller than the max footprint,
a peak number of bytes allocated to the heap.

This commit makes the native heap size returned by
getNativeHeapSize() to be the current footprint, which is the sum
of the allocated and free native heap size.

Change-Id: Ie5eec4ac43b82c8f8d7dcf9c6d7785fd9b4526eb
Signed-off-by: Kyungmin Lee <snailee@gmail.com>
fix null pointer exception in enqueuing

Change-Id: I6f9b104d06fc18b8465117436279a8e34d1622c2
Improve notification shade auto-collapse code.

- When the user dismisses a notification by swiping, also collapse
  notification shade if there are persistent notifications remaining.
  Only skip collapsing if there are still non-persistent notifications
  pending
- When the notification is removed by the app, wait a bit until
  collapsing the shade so the removal doesn't come as a surprise to the
  user
- Centralize the collapse trigger at one place

Change-Id: I4e5114f66e799a7c80e18b38abce5678da460846
Increase available volume levels

Increase media volume levels from 15 to 30 to have more precise
volume control instead of having only 15 levels from 0-100%

For example, when listening to music it is often the case that one
volume level is too quiet and the next one higher is too loud (especially with Headsets).

Signed-off-by: Michael Bestas <mikeioannina@gmail.com>

Change-Id: I7a8750c901967ce3c818fb9c33b082af6b86b8d6
Fix for MemoryLeak in InputMethodService

Problem: when onConfigrationChanged is called many times,
mInsetsComputer is added many times to the list.
Solution: check before if specific listener is already
in the arraylist.

Change-Id: Ic730395120d6dc8585628c142b2e161c42317f30
UI not updated correctly in expanded statusbar

Sometimes when getting status changes in expanded statusbar the
text disappear. Both NetworkController and PhoneStatusBar handles
UI updates and they are not in sync. This fix allows PhoneStatusBar
to update UI when NetworkController is updating the UI.

Change-Id: I46b8a24ecc732e441f836692c6584a78d8108dff

Conflicts:
	packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
Avoid duplicate call to onLoadFinished()

When a loader is initialized in Fragment#onActivityCreated(Bundle), then
LoadersCallback#onLoadFinished() was called twice on device orientation
change:
 - once during fragment start();
 - once during loader finishRetain().

Reported as bug 63179:
https://code.google.com/p/android/issues/detail?id=63179

This commit prevents to call onLoadFinished() when the data has already
been delivered.

Change-Id: I893013049f819dd5543a8079ce9d8025a5fdb2f1
GREF leaks in AudioEffect and Visualizer.

When playing songs with MusicPlayer global references are leaked.
Added call to DeleteGlobalRef in the destructors for both classes.

Change-Id: I35b311b2accb8be7ca1eefa2ecdf5a37e0fb2027
Fixes documentation bug in SQLiteDatabase

The documentation incorrectly states that, "[insertWithOnConflict
returns] the primary key of the existing row if the input param
'conflictAlgorithm' = CONFLICT_IGNORE". Unfortunately, SQLite does
not provide such functionality.

Closes: https://code.google.com/p/android/issues/detail?id=13045

Change-Id: Ife919c4dcf7bf703b692d338d1fb5844a532dd39
Signed-off-by: Steve Pomeroy <steve@staticfree.info>