FW: Port HALO Mods (1/2)

* Untested at the moment if someone can provide me some feedback! Thanks

PS3: This also fix the issue encouterd by Bjork

PS2-4: blank. My error

PS5: Remove the Expanded Desktop dependencie for the awesome LongPress action

PS6: Remove whitespaces and tabs

PS7: As asked, restored original LongPress behavior

PS8: HALO tweaks:

-Draw status bubbles only when required (performance)
-Ninja level +1 (disappear if empty, only persistent or pinned apps are present)

Signed-off-by: iGio90 <giovanni.rocca.90@gmail.com>

Change-Id: I3591f60e3436c2ac205449d13044bf8c1b65f7a3
Hide GlowPadView warnings

Make message verbose and contingent on DEBUG. This has been spamming
my logs everytime I touch navbar or lockscreen targets.

Change-Id: Iea1a6db86055d4034405f0ee4e20282b6c493210
NPE in SearchManager.triggerSearch

mAssociatedPackage field is never initialized and cause NPE.

Change-Id: Ibf0d44b2170b7cbfe4a883008254a086e03579c5
set carrier label to gone instead of invisible

Change-Id: Ie1205802147b451aaff8d4a4def29d5c11aa2347
frameworks: squash of leak & race fixes

commit 5c837244a550308a6b8fadf95275d50f6bf3b202
Author: Daniel 2 Olofsson <daniel2.olofsson@sonymobile.com>
Date:   Mon Jun 10 14:49:14 2013 +0200

    Fixed race condition in Spinner.DialogPopup on null reference.

    NullPointerException is triggered when DialogPopup is
    dismissed due to object mPopup being null when not showing.
    Race condition is triggered when dialog is dismissed before
    touch event to dismiss dialog has been processed properly.

    Fixed by adding a null check prior to accessing mPopup object.

    Change-Id: I3c4fe9c279d92a7103fb4f68189d1d42beedc606

commit 4950d85c29bed35c0874858d094d5a0f628f1e54
Author: Pawel Augustyn <pawel.augustyn@sonymobile.com>
Date:   Mon Jul 16 11:23:54 2012 +0200

    Fix for native leaks in YuvToJpegEncoder.cpp

    Objects allocated by Get<object>ArrayElements function,
    should be released. Add a fix to release this objects
    in error cases.

    Change-Id: Idf834523d93bb2dfd6b872e3b2179b7f1bba38f3

commit 463ac945502552ab0c06ae00c987d3c400161fe3
Author: Michal Szynkaruk <michal.szynkaruk@sonymobile.com>
Date:   Wed Jun 26 11:28:36 2013 +0200

    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

commit 5167ab57b2a1dbee38a5303e4b490a04b9dff950
Author: Pavan Kumar S <pavan.kumar.s@intel.com>
Date:   Fri Aug 3 12:03:01 2012 +0530

    [BatteryStatsImpl] Avoid memory corruption due to Parcel Recycling

    While processing batterystatsfile, in present code there is a race where a parcel
    might be recycled while it is being written to disk in another thread.

    The write process is done in 2 steps:
    - write into a Parcel (memory block)
    - then write this Parcel to disk using Journaled API.
    The Journaled API ensures robustness against file-system issues due to power cut.
    The writing is done in batch using a thread running commitPendingDataToDisk().
    This function writes the parcel to disk but this parcel is a global variable
    initialized by writeLocked(). If the writing takes too long time and two write
    threads are launched, the parcel is freed by the second writeLocked() call;
    which could cause the memory corruption.

    Hence, change global Parcel variable by a Parcel parameter to commitPendingDataToDisk()
    and only this function will be allowed to recycle the parcel.

    Change-Id: Ie86ee0a66434b7107264c79f68411196c7505a34
    Signed-off-by: Pavan Kumar S <pavan.kumar.s@intel.com>
    Author: Pavan Kumar S <pavan.kumar.s@intel.com>
    Signed-off-by: Shuo Gao <shuo.gao@intel.com>
    Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
    Signed-off-by: Jack Ren <jack.ren@intel.com>
    Author-tracking-BZ: 47466 19426

commit ab625310c19573caf5cdcf4c6ef573bbfbc8a26b
Author: Vairavan Srinivasan <vairav@codeaurora.org>
Date:   Mon Jun 6 13:42:54 2011 -0700

    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

    Conflicts:
    	core/java/android/service/wallpaper/WallpaperService.java

Change-Id: Ib24d04673c5fff21533f7f00456df658cdbc6288
FW: Halo: Remove expanded desktop dependency to longpress action

* Always on is much better!

depends on: http://review.pac-rom.com/#/c/2456/

Signed-off-by: iGio90 <giovanni.rocca.90@gmail.com>
Change-Id: I777d65cc38b3d84212f04ce6405ceb5de8384903
Rework thumbnail handling

Since ids of media file are usually not continuous, the original file of thumbnail are
sparse. When there are big numbers files on ex\
ternal storage, the size of this file will be horrible.
Ex, when the id is 20000, then the .thumbnails/.thumbdata3-xx file will be 50000*10k = 488.28M.
Can refer http://stackoverflow.com/questions/12396715/android-huge-thumbdata4-file-in-dcim-folder
Because after 4.0, MediaProvider will scan any files, this will be a big problem. So I modify MiniThumbFile.java to avoid this.
According to the id, we now produce an index file. In this index file, one id will use BYTES_PER_MINTHUMB_INDEX(8) bytes in offset (i\
d+1)*BYTES_PER_MINTHUMB_INDEX. The data of these 8 bytes is the index of thumbnail file. The first BYTES_PER_MINTHUMB_INDEX bytes kee\
p next available index. And when you need insert a thumbnail, the index increase by 1. In this way, the block data in thumbnail file \
will be continuous. And thus unnecessary zero paddings will not be saved.

Change-Id: I66005dd69b0a5c8f4353bd7a8225d163a654fd2d
SystemUI: do not collapse panels if keyevent was canceled.

Change-Id: I9af82e9fa2305142521075938dfd05521adeb9f4
Fix up 'launch player on headset connection' option.

- don't crash system_server if no music player can be found
- use the active user's setting instead of the owner's setting

Change-Id: I38a07fe5c8c3d67ececd0768e1fcc01a6cf7fa5a
Fix Quick Settings tiles jerking down while animating to notifications view

Change-Id: Ic601d8808855dee667aea3bf368256fbadf9385d
Fix status bar brightness control when on secure lock screen

When the notifications panel is disabled no views are handling touch events
on the status bar, so we see nothing beyond each ACTION_DOWN. Intercept touch
events when needed specifically for brightness control.
Also recycle VelocityTracker when we're not using it, as per its documentation.

Change-Id: Ib96eb6a6fd16d086d318136155e16da10600c8fa
SystemUI/Added ADB over network QuickSettings Tile

Change-Id: I340846a171571a7b61d2c68f2a6875794be5d5b2
frameworks/base: FI translations

Change-Id: I86f3c0c440adec87d296dc2d9ffecc5a40e0a4fe
Freeze screen while changing expanded desktop mode.

Also animate from old to new state.

Change-Id: I2db8ec4d55f7b8b5e592cc1ef21b86ebdbd00eb0
PhoneWindowManager: Delay setting updates during window animation.

Change-Id: I90ee5d8f83176a38a32b5ff38c4b191f1b78532e
Statusbar: TabletUI: Hack to show statusbar icons while Halo is active

When halo is active the ticker window is created as before halo implementation, to avoid to show it we don't stop the methods but set the transition/delay to 0.
That's a kind of hack (awful) but works :)

Conflicts:
	packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletTicker.java

Change-Id: I909e8112ca6e31450201b75bc08546d2b585f8f5
Statusbar: TabletUI: Low the ticker delay to 3.5s that is enough (PhoneUI one is 3s, but TabletUI one is clickable and deserve a little bit more). Making right-navbar unaccessible for 5 sec is too much.

Change-Id: I9004b1e5be7612846390eaccf0f44fcac047a48b
Keep ToggleLockscreenTiles in sync between Quick Settings and Ribbon

Update the appearance of both tiles when one is toggled.
Only the KeyguardLock which disabled the lockscreen is able to
re-enable it, so have both tiles use a static KeyguardLock.

Change-Id: Idd8d41d3eda60f9a13bd4b6bc0fab12eb3d25f40
Merge branch 'AOSP/jb-mr2.0.0-release'

Change-Id: Ia16a1d1c4f5fb0c428449acbb6a633dfbc8d0f68
Fix Weathericon Size

Change-Id: If0bf90cf1da87adfe5a5bf4a23d8453ba95bbe18