Reduce EntropyMixer seed size from 4096 to 512 bytes.

The suggested seed size from Linux drivers/char/random.c is 512 bytes
rather than the 4096 bytes currently used.

Change-Id: I3dd55105f0a95ce9cda34b4cf08987b8a28c4ac9
power: Add CPU boosting interface

 * Boosts CPU using Power HAL for the given duration.
 * Duration is given in microseconds.
 * Power HAL must implement POWER_HINT_CPU_BOOST.

Change-Id: Ic79baf7e3d0f75483c2fe8a242b4c3d93368b68b

Conflicts:
	services/jni/com_android_server_power_PowerManagerService.cpp
NPE in SearchManager.triggerSearch

mAssociatedPackage field is never initialized and cause NPE.

Change-Id: Ibf0d44b2170b7cbfe4a883008254a086e03579c5
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

Conflicts:
	core/java/android/service/wallpaper/WallpaperService.java
Fix SSLCertificateSocketFactory.getDefaultCipherSuites.

The method was returning all supported cipher suites instead of the
default ones only. The default list of cipher suites actually used by
sockets created by this factory is not affected by this issue.

PS2: Rebased

Change-Id: I2e4d7c6547fcb29ff7a0943bc8791706cc8d22bc
FileUtils: add method to get UUID of a volume

Change-Id: I41b76c5e01c82a2f8e67b33133a76947877a2814
Replace SEAndroid with SELinux.

Change-Id: Ibbe544a9f025d71ad416bc01cee2145b62d7b2d4
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
fix cursor leaks in F_B

my previous commit was submitted before i was finished.  Here is an updated version.

PS2: missing bracket

Change-Id: I9d8048e49695cdac7ded086cd49ee6eb99e518cc
Facebook Sync Dirty Hack (Credit RomanB)
Remove dead code.

This hasn't been used since at least 2011, and we're no longer
shipping the data supporting it either.

Change-Id: Ibe42057650b49794c65d6f0d54ed7a492f3b594b
Ensure running mTouchModeReset when AbsListView is detached

mTouchModeReset should be executed when AbsListView is detached from window.
If not, when the AbsListView is re-attaced to window,
the child can retain a pressed state.

You can see this problem easily when you double-touch an item of
option menu very quickly.

Change-Id: I5aaa1fd5b95847efb2f5f1b5ec7cabe8eb85b237
Signed-off-by: Sangkyu Lee <sk82.lee@lge.com>
Fix ListView is not scrolled properly with arrows

According to ListView's layoutChildren logic, it detaches all children
and rebuilds its children based on visible area which might omit
invisible elements in the adapter.

In this case, arrowScroll methods only tries to find next scroll
candidates from its children so user is unable to scroll more with
D-pad.

This fixes the issue by look forward next child among the adapter as
well as children.

Bug: 7346868
Change-Id: I01ab19ad899b5bcb5ab420ddf08c9ffd136933d1

Conflicts:
	core/java/android/widget/ListView.java
Scroll: modified velocitytracker

Velocitytracker and overscroll are called on every touch event to
calculate if there is a scrolling/fling. Move this and the recycling
to static voids so they are pre-optimized at compile time rather than
after evoking the method call during runtime (JIT) to increase responsiveness.

-Vanir

Change-Id: Ic7351da58f29281ca2b6a788386b95b68b552390
frameworks/base: Fix to avoid crash when the tab is not set from app

As the current tab is not set from application, getChildTabViewAt
returns Null value. Added a condition which checks whether mSelectTab
is set to first Tab.

(cherry picked from commit 9be6755efb149b22c36aa3eb7cc4ffe7e765e08a)

Change-Id: I11c77ca96333e2663d28db1b5fdb46602bd9e745
CRs-Fixed: 321176
Selectively restore non-stupid parts of stuff we had
before a patented nuclear decrapificating

Change-Id: I679f5748365bb50451abc71398dcf35002282330

Conflicts:
	core/java/android/webkit/CallbackProxy.java
	core/java/android/widget/ProgressBar.java
	core/java/android/widget/Toast.java

Conflicts:
	core/java/android/webkit/BrowserFrame.java
	core/java/android/webkit/CallbackProxy.java
	core/java/android/widget/Toast.java
Fix for ambiguous and broken disk formatting dialog

This patch ensures that the path-string from StorageNotification is converted
to the appropriate StorageVolume so that it can be correctly passed to the
formatting class. It also displays this path to the user so that it is clear
what will be deleted.

While trying to use a USB flash drive over OTG, the drive's FS somehow got
corrupted, so Android gave me a notification to re-format it. Okay, so then
a dialog pops up that doesn't specify what volume/device it will format, and
I incorrectly assumed it would be the USb drive. However this activity defaults
to the main internal memory for some reason, and wiped my data. Thank God for
them internets... (Dropbox)

Change-Id: I5621dff3cfd12a173b0d793398cf729333f97263
DefaultContainerService: implement additional methods

For usage in Settings->Storage

Change-Id: I2d45198cc6ea3b84af1547873380eae2c04c0b93
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

Conflicts:
	core/java/android/webkit/ViewStateSerializer.java
Avoid possible memory leaks by ensuring stream closures

Stream close() methods should always be called in finally block
to ensure we don't accidentally leak a stream.

Time to fix some old sloppy code.

Patch Set 2:
 + ensure closure of some other streams
Patch Set 3:
 + missing import java.io.IOException
Patch Set 4:
 + missing import
Patch Set 5:
 + missing ';'
 + whitespace cleanup
Patch Set 6:
 - Reverted changes to MemoryUsage (final requirement
     prevents my implentation)
 + fixed Object allocation in Root.java
Patch Set 7:
 + fixed curly bracket style violations
Patch Set 8:
 x fixed my own sloppy code :/

Change-Id: I3460b558ed5b4489296388c9a52fbb773cefd31f

Conflicts:
	packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
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