AudioService: Fix absolute volume for AVRCP

Avrcp.java uses max volume obtained by getStreamMaxVolume() when
converting to AVRCP levels and it returns non-scaled volume index.
For this reason volume index needs to be dispatched to Avrcp before
scaling as otherwise Avrcp will convert volume level incorrectly,
i.e. max volume index for music stream is 15 and any volume index
>1 (>10 after scaling) will result in setting *MAXIMUM* volume level
on headset which is not safe for listener.

Change-Id: Ia799eec578ed2326ec18b69f2ee4f2a60c664514
Volumes in Settings/Sound is slow to start

There is a delay after pressing volume menu item
there is a delay until the Volume popup is shown.

The reason for this is that the initialization of
the different seekbars is slow and run in the main
thread. More specifically the call to get the
ringtone from the RingtoneManager is causing this
delay.

Moving the call to the ringtone manager to the
handler thread used to play ringtones to make
the launch of the volume dialog a bit snappier.

Change-Id: I76da0226592468debd542d67164b37b2b59897c7
Parallel shutdown

Decrease shutdown time by doing some shutdown tasks in parallel.

There are two threads executing during the shut down: the ShutdownThread
and a separate thread for the radio shutdown. However, the execution is
done in serial, as the ShutdownThread immediately joins on the radio
thread.

This commit will move the shutdown of the radio to the beginning of
shutdown and execute it in parallel to the shutdown of the rest of the
system.

The flow of the two threads during shutdown is now:

Radio Thread
  * Start shutdown of the radio
  * Wait for radio off or time out
  * Notify that the radio is done
ShutdownThread
  * Broadcast ACTION_SHUTDOWN as a parallel broadcast. (The receivers
    will get as much time to handle onReceive as it takes execute the
    rest of the tasks in the shut down flow. If they are not done in
    that time, we don't care.)
  * Shutdown ActivityManager
  * Shutdown MountService
  * Wait for MountService and radio to notify done
  * Vibrate
  * Low level shutdown

Change-Id: Ifdd8a9c75337fd9d00148a0d2b9917e10fa60634
Fix setSurfaceTexture to handle surface caching

Changed the TextureView.setSurfaceTexture to apply the
existing listener to the surface provided in the method.
This is done to allow surface caching to work.
Whenever a new SurfaceTexture gets created, its listener is
created as well, so when the setSurfaceTexture is called
we should be attaching the listener to the new surface.

Change-Id: I4c1a704c587e977ab7a6b1fe3a7d3e0d20d00218
CRs-Fixed: 639136
update zh-rCN translation

Change-Id: Ibf7276adf35687d736746298e464a10d7532b1fc
Bluetooth: pause music player on A2dp service disconnect

When A2dp service disconnects as part of SSR, it marks a2dp state
as unavailable in Audio module but does not pause music player, as
a result when bluedroid stack restarts as part of sub system restart,
media player does not pause and music continues to play on device
speaker.
This change helps to pause the media player, in addition to marking
a2dp as unavailable, so that media player pauses when a2dp service
forcibly disconnects as part of sub system restart with A2dp in
connected state.

CRs-Fixed: 590462
Change-Id: I05ee5bcc808eb438156b64181d54e8ccabe1e186
Bluetooth: Add Total track number.

Add support to add total number of tracks in
Meta-data

Change-Id: I5b1287f791615adcd4f920fe5c7cae0c7c7b04ea
CRs-Fixed: 627869
Base: use another Method to Kill app (NavRing Target)

sometimes SystemUi got Killed if enable NavRing Kill app
or using long press back button

this code fix that

taken from SlimRoms
https://github.com/SlimRoms/frameworks_base/commit/bbbb6f6fb2b1db59825b6a32ae136c72cac52bfa

Change-Id: If60b04105e77977df42ef32a91aeb7e5ea393531

Conflicts:
	packages/SystemUI/src/com/android/systemui/cm/ActionTarget.java
	policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
Keyguard: We need to ensure that keyguard is showing as well to set the token

Google fix

https://github.com/SlimRoms/frameworks_base/commit/021806ec33f5f59567f3bb3af135b2a1d88c0951

fixes what it is meant to fix.

But still we need to ensure if the keyguard eg is disabled by 3rd party
apps or the keyguard is not showing due of other reasons to inform PhoneWindowManager over the token
not to wait to draw for the Keyguard and go ahead.

Fix:
Just check for isShowing in addition to the check if KeyGuard is disabled

Change-Id: I5f017a6ccebf12dc717fb6d44802a1c1fee15abc
Fix fc in NavRing Target Settings
When greenify or tasker is installed and their accessibility-service active, Navring Target Settings failed because of an out of Index Exception, this commit fixes this
couple fixes for msim dual sim

Change-Id: I2bd9ebdd6fa147c67e397d4cc2db1f8bfc2f5666
Signed-off-by: houst0nn <houstonn@gmail.com>
MSIM: Rework statusbar, order signal clusters to match settings

Settings have SIM 1 on left, then SIM 2, etc. Do the same in the
statusbar. Also show the sim slot number in front of each signal
cluster.

Change-Id: I6ce16870af6374958b09a8a9d7d6d510f4561e13

Conflicts:
	packages/SystemUI/res/layout/msim_signal_cluster_view.xml
	packages/SystemUI/res/values/cm_strings.xml
	packages/SystemUI/res/values/styles.xml
SystemUI: Don't try to translate SIM slot numbers

Change-Id: I9cbf8a04e04e363e11465516da7c7f1336c5c10a
MSimNetworkController: Set debug to false.

Change-Id: I292d6d4fd94ed4f86d6c39c230912e12c6124037
MSIM: Expanded StatusBar: Show SIM slot number

Change-Id: I5c9ba33bfd564ba5301072ba1ef8c33640943710
[1/2] Add to support pause/resume download

We add pause and resume API here so that application can
pause and resume downloads manually by DownloadManager.
This contains two points:
1. add pause and resume download APIs.
2. add another paused reason for this download status.

PS2/3:
* Fix code.

Signed-off-by: Carlo Savignano <stevewatersy@gmail.com>
Change-Id: I606b48ca20f43bcc6c119683818c2ab6ff03bfe5
SignalStrength: Hotfix TD-SCDMA

These checks need to be reviewed, they're making unwarranted assumptions
about signal value formats and possible tech combos.
This appears to work for all possible scenarios I was able to test,
but the "LTE checks" shouln't be necessary at all.

Change-Id: I889e17e79ca2b1b5fcaa393741e19bef9d3f4229
WallpaperCropper: Fix crash when set .gif as wallpaper

It returns an equivalent scaled cropBounds as true
crop bounds, then it set the rounded rect by rounding
"out" the true crop rect, this make the rounded crop
rect may out range of the original bitmap, then an error
will happen.

We change to check the rounded crop rect, if it is out
the range of original bitmap, we set the original bitmap
bounds as rounded crop bounds.

CRs-Fixed: 622582

Change-Id: I215ef2a0165adaaadb05c62dee741a8ea6926144
Media process is crashing with NullPointer exception

Sometime, while creating thumnails list of media files in
compose MMS->attach file,  filepath may be null due to
synchronization issue.
Adding NULL check to avoid NUllPointer exception.

Change-Id: Id6cf5612a959b3ae15b44bc60dbbcbe40c624f09
CRs-Fixed: 636494
wallpapercropper: OOM issue while opening *.bmp image

This change manages setting of large images as
wallpapers without encountering OOM.

CRs-fixed: 619815
Change-Id: I3a32ec4b42050b146076f0adf6b6e65afd6fae4e