[ActivityManager] Improve task order of getRunningTasks.

Symptom:
During switching task in same stack, the first result
of getRunningTasks will be the behind stack's top task.
e.g.
 App Task X is starting task Y, the first entry may be home.

Root Cause:
TaskRecord's lastActiveTime is updated when pausing
or resuming. When X task launch a new task Y, Y is
on the top of task history, before X complete pause,
Y's lastActiveTime will be 0 because it is a new task.
Then when comparing the front task with other stack,
other stack will be regarded as the newer one.

Solution:
If the stack is focused stack, give the top task with the last time.

Change-Id: I0adc07608e03d333e0120a0dbc52a0fbbbb12f34
Signed-off-by: Chet Kener <Cl3Kener@gmail.com>
Scale down the wallpaper image if it is larger than the surface frame

Let the wallpaper can fit the screen if the wallpaper is larger.

Change-Id: Ie4116dc0386c7b390a6a71608b09645cd08ffe78
Signed-off-by: Chet Kener <Cl3Kener@gmail.com>
Fix memory leak where we close the descriptor instead of the file.

(cherry pick of 5cb769d99952ef9fb4f576abba70423fe157342b.)

bug: 17541634
Change-Id: I9968f9df249e4cba24383239ce6130dd16fcd532
Signed-off-by: Chet Kener <Cl3Kener@gmail.com>
Remove the window whose client process has died or become zombie

Window Manager Service would fail to report window-resized to the
process which has become zombie. This would cause the window to
freeze screen continuously. In this case, we assume the process has
died and remove its window to recycle resources and to prevent it from
freezing the screen.

Change-Id: Ic7384731bf9a1fa8b9602d4f1dbee7492db126c5
Signed-off-by: Chet Kener <Cl3Kener@gmail.com>

Conflicts:
	services/java/com/android/server/wm/WindowManagerService.java

Signed-off-by: Chet Kener <Cl3Kener@gmail.com>
Prevent resource leak in YuvToJpegEncoder

SkWStream is never deleted before going out of scope

Change-Id: Ifdb75c18336d095b012e73b64281ec6c2fc5c3fe
Signed-off-by: Chet Kener <Cl3Kener@gmail.com>
Added adts as valid MediaFile extension

Change-Id: I835623a86f75aab9c7e0c7405218252c3fee784a
Symptom: Added adts as a valid media file extension, it is treated as aac.
Signed-off-by: Chet Kener <Cl3Kener@gmail.com>
Frameworks/base: Fix AssetManager JNI

Register the right method.

Change-Id: Ib5f5c531b4c5863eed04fe3b13f8c2662055fa5e
Signed-off-by: Chet Kener <Cl3Kener@gmail.com>
Fix ProgressBar isn't updating

Add a missing parameter for updating.

Change-Id: Ib40f1ccb43d3898bef6e33f2c392bded73c2e5ff
Signed-off-by: Chet Kener <Cl3Kener@gmail.com>
Prevent dead lock in AudioService.

Dead lock sequence:
 1. called onSetA2dpConnectionState()
  1-1. synchronized(mConnectedDevices)
 2. called onServiceDisconnected()
  2-1. synchronized(mA2DPAvrcpLock)
 3. waiting to lock(mConnectedDevices) in onServiceDisconnected()
 4. waiting to lock(mA2DPAvrcpLock) in onSetA2dpConnectionState()

========================================================================================
- watchdog issue
----- pid 3306 at 2014-10-14 16:15:12 -----
Cmd line: system_server

"main" prio=5 tid=1 MONITOR
  - waiting to lock <0x4343e9b0> (a java.util.HashMap) held by tid=46 (AudioService)
      at android.bluetooth.BluetoothA2dp$2.onServiceDisconnected(BluetoothA2dp.java:529)

"AudioService" prio=5 tid=46 MONITOR
  at android.media.AudioService.makeA2dpDeviceUnavailableNow(AudioService.java:~3836)
  - waiting to lock <0x42ab7a58> (a java.lang.Object) held by tid=1 (main)
  at android.media.AudioService.onSetA2dpConnectionState(AudioService.java:3906)
========================================================================================

Signed-off-by: Seunghwan Hong <seunghwan.hong@lge.com>

Change-Id: I99e061c07be01aabcd26786ef2ebb71f46717b93
Signed-off-by: Chet Kener <Cl3Kener@gmail.com>