Solve three memory leaks related to PatchCache

A Patch can be fairly large, holding bitmap data, but
is also frequently leaked which adds to the severity.
The feature is used in many important processes such
as Home, SystemUI and Chrome.

The following leaks are solved:

1. The Patch itself was not always freed.
PatchCache::removeDeferred() can mark patches to be
cared for by PatchCache::clearGarbage(). But
mCache.remove() would only destroy the container
and the pointer, not the Patch object itself.

2. The vertices stored in the Patch at Patch::createMesh()
would always leak. The empty/default destructor in Patch
would not properly destroy "vertices" since it's just a
pointer.

3. A BufferBlock that's added to the mFreeBlocks
in PatchCache could leak. The leak happened when a
patch later needed the entire free block, because the
object was removed from the list but never deleted
in PatchCache::setupMesh().

Change-Id: I41e60824479230b67426fc546d3dbff294c8891f
Signed-off-by: houst0nn <houstonn@gmail.com>
Do not launch floating window when on default launcher

We only do this when user is on the default launcher 
because if the user was on a non-default launcher,
he/she must have been there for some purpose and we 
do not want to throw him/her back to the default 
launcher incase he/she exits the app with HOME button.
Fix thumbnail bug

When there was no thumbnail for a given image, the getThumbNail() convenience
method could return a previously-returned thumbnail instead of null.

b/15771860
https://code.google.com/p/android/issues/detail?id=40714

Change-Id: Ibd18e048145bf347469f800afdf436247ea6b693
Signed-off-by: houst0nn <houstonn@gmail.com>
Fixed VM memory leak in AudioSystem JNI interface

The function android_media_AudioSystem_error_callback from AudioSystem
JNI interface is using FindClass function but does not delete the
reference created by VM in this function.
By doing this call, VM will add a local reference in IndirectRefTable
and it's the caller's job to delete this reference.
By not doing this, everytime this callback is called, a new reference is
added and never deleted.
The effect is crashing the VM running system_server:

E/dalvikvm( 3071): JNI ERROR (app bug): local reference table overflow (max=512)
W/dalvikvm( 3071): JNI local reference table (0x732da288) dump:
W/dalvikvm( 3071):   Last 10 entries (of 512):
W/dalvikvm( 3071):       511: 0x42a90008 java.lang.Class<android.os.Parcel>
W/dalvikvm( 3071):       510: 0x4381fd90 android.view.KeyEvent
W/dalvikvm( 3071):       509: 0x439b9808 android.view.KeyEvent
W/dalvikvm( 3071):       508: 0x42d2fe18 java.lang.Class<com.android.server.input.InputManagerService>
W/dalvikvm( 3071):       507: 0x42ad4298 java.lang.Class<android.media.AudioSystem>
W/dalvikvm( 3071):       506: 0x42ad4298 java.lang.Class<android.media.AudioSystem>
W/dalvikvm( 3071):       505: 0x42ad4298 java.lang.Class<android.media.AudioSystem>
W/dalvikvm( 3071):       504: 0x42ad4298 java.lang.Class<android.media.AudioSystem>
W/dalvikvm( 3071):       503: 0x42ad4298 java.lang.Class<android.media.AudioSystem>
W/dalvikvm( 3071):       502: 0x42ad4298 java.lang.Class<android.media.AudioSystem>
W/dalvikvm( 3071):   Summary:
W/dalvikvm( 3071):       510 of java.lang.Class (3 unique instances)
W/dalvikvm( 3071):         2 of android.view.KeyEvent (2 unique instances)
E/dalvikvm( 3071): Failed adding to JNI local ref table (has 512 entries)
...
E/dalvikvm( 3071): VM aborting

In this case, PID 3071 is system server.

Change-Id: I0c113eb72256984854d59a3ccef11a8d23f96e79
Signed-off-by: Robert Chiras <robert.chiras@intel.com>
Signed-off-by: houst0nn <houstonn@gmail.com>
Themes: Use default_wallpaper for HOLO lockscreen wp

Change-Id: I9c7fd29c99d13e811993eb9b3b045010431ccad0
Revert "Implement DocumentsProvider.createDocument and deleteDocument"

The original commit breaks the public API and causes crashes when
deleting certain items in DocumentsUI

This reverts commit f6bfaee6ad7ccd4491609d5df606558a4ae30f72.

Change-Id: I5a433148548e7a1a997ee50e5938f7a4cb4c5ade
SettingConfirmationHelper: Unbreak public api

Missing @hide for javadoc breaks public api.

Change-Id: I29c5e8b5b2ae5a998fdf84895808f79d1e7ae500
Signed-off-by: Evan Anderson <evan@thelinuxman.us>
Automatic Translation Import

Change-Id: I1a255c84ce5c94069735b48bb4345f0508a45be4
Merge "Themes: Use default_wallpaper for HOLO lockscreen wp" into kitkat
ExpandHelper: Performance improvement during expanding

- Reflects on Hover mainly
- Add an helper to get natural height

Thanks to Kiril Mikos @mik9 http://review.cyanogenmod.org/#/c/66676/

Signed-off-by: Carlo Savignano <stevewatersy@gmail.com>
Merge "ExpandHelper: Performance improvement during expanding" into kitkat
HOVER: Respect screen limits when adding view

As for what @Decad3nce reported here http://review.cyanogenmod.org/#/c/66654/
we shouldn't keep FLAG_LAYOUT_NO_LIMITS so view doesn't exceed the screen limits.

Thank you Adnan :)

Signed-off-by: Carlo Savignano <stevewatersy@gmail.com>
Change-Id: Ifcbc4a1143362e1b7dd40e710126060688c894b9
BatteryMeter: Isolate QS resources too, specify label as for status bar

- This way we can theme PA separately, will not reflect with CM
  so we don't end theming both CM statusbar and QS indicators while
  we want to do just QS and testing base is PA.

PS2: Use status bar color in style, is about the status bar icon so no need to keep using qs one.
PS3: Fix new array name

Signed-off-by: Carlo Savignano <stevewatersy@gmail.com>
Change-Id: I104f4b435470745e8b4bcb7fb2413148b24766c9
Merge "BatteryMeter: Isolate QS resources too, specify label as for status bar" into kitkat
Themes: add ability to theme quick settings battery tiles

This is to make the battery tiles more uniform to the rest
of quick settings and also allow the background to be themed

http://i.imgur.com/AA5bkMK.png

PA Changes: adapt for PA quick settings thanks to @linuxman94

Change-Id: Iec03572a0fa3619d2652f30b6c260a278ed0c86b
Signed-off-by: Evan Anderson <evan@thelinuxman.us>
Merge "Themes: add ability to theme quick settings battery tiles" into kitkat
PackageManager: Add option for single threaded dexopt

* Execute all dexopt invocations on the main thread instead of using the
  ExecutorService when persist.sys.dalvik.multithread is set to false.

Change-Id: I3b8499d5af5091ad7abcddf006f8f2837943903b
Merge "PackageManager: Add option for single threaded dexopt" into kitkat
HOVER: Don't treat touch outside event as true if is animating

- It needs to wait animation to be finished to start listen for touch outside
  and runs hide timer.

Signed-off-by: Carlo Savignano <stevewatersy@gmail.com>
Themes: Update LoadedApk resources.

Instead of creating a new LoadedApk when resources are not up to
date, we use the existing LoadedApk but recreate mResources.

Change-Id: Ic1ad810863d03c2cedc751c9e84dd7c954daf3d7