SystemUI: Update cast tile when wifi display status changes

Cast tile in quick setting does not watch for wifi display status changes.
As a result, it will not update when wifi display status changes.

Register a broadcast to watch for wifi display status changes as settings
and update remote displays when wifi display status changes.

CRs-Fixed: 718032

Change-Id: Ib2ca4677be91817c007db941531849bbc7eff5d3
bootanimtion: fix no boot sound due to error file descriptor

-wrong file descriptor passed to setDataSource(fd, offset, length)
 API and causes no sound
-use the default setDataSource(httpService,url,header) to parse
 the file of boot sound

CRs-Fixed: 731547

Change-Id: I437e7d797cd13b7f8f8e0fbf81d5de99c55c27d1
Keyguard: Fix crash in widget pager

Systemui crashed during automatic test, due to NPE of currentPage.

Add null protect for currentPage view.

CRs-Fixed: 715102

Change-Id: Ia1ac67a28fc3aeca6395200adc3448923775164f
Add background app limit tunable.

Set MAX_CACHED_APPS based on a system property "ro.sys.fw.bg_apps_limit"
so that number of background apps can be tuned accordingly.

Conflicts:
        services/core/java/com/android/server/am/ProcessList.java

Change-Id: Ie21b0961dad10e1cd6da3cfe2a45eff45dc8756d
Mms: Fix mms Null Pointer exception when running monkey test

InsertionHandleView dismiss again after onDetached()

Dismiss only if PopupWindow is showing.

CRs-Fixed: 713460

Change-Id: Ic60443b9e557184031678516dc3665bf61b78bf7
Sensor: Enable the motion accelerometer for screen orientation change

The screen orientation can be detected by the motion accelerometer
instead of generic accelerometer to save power.

Change-Id: Iaeb3e5958d2ef7cc33080d7091ed8a5462695c67
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
base: App crash when select suggestion's length more than specified.

App crashed by catch IndexOutOfBoundsException which raised
by check span range when select suggested string.The root
cause is that the editor will truncate the suggested string
which length is more than it specified, but it also set span
use the suggestion's original length.

Update the suggestion's real length after editor replace the
original string to suggested.

Change-Id: I2d765701934a9e68be172cb87a104590f3cdeceb
CRs-Fixed: 532211
core: jni: fix memory leak in SoundTrigger JNI

jExtras object created in android_hardware_SoundTrigger
JNISoundTriggerCallback::onRecognitionEvent()
is not deleted causing a memory which depletes JNI
JNI local storage during back-to-back SoundTrigger
detections.
Delete jExtra after storing in return object.

Change-Id: Ib7048917b7538a27d4519504b30252879acc5447
CRs-fixed: 733969
Add looper to the thread to fix system_server crash

Toast message internally creates handler and we can't create
handler inside thread that has not called Looper.prepare().
Thus, we added looper to the thread to avoid system_server
carsh.

Change-Id: I09b9c4923c109f0b2707f8346e091efbd24b5089
CRs-Fixed: 669467
frameworks/base: add app launch timeline instrumentation

Displayed Activity is often being used to measure application
launch times. However Displayed Activity only accounts for a
subset of the app launch. This additional instrumentation will
allow for more accurate measurements of applications launch
times.

ActivityManager: Update timeline debug statements
Update the timeline debug messages so that
'ActivityManager' is not used as the tag in log
messages as it interferes with some CTS tests.
CRs-fixed: 628703

This commit combines the changes from KK gerrit 668250 & 543988

Change-Id: I0af42520dc30d89a910e60aebdddf0c4fdd32b3e
Block application install from unknown sources through adb

adb install command  doesn't check source of an application.

This change enforces that adb install command only works if user has
download/install from unknown sources selected in settings app.

Change-Id: Id0d328d1dad36089802d6bec2f5d2f940e045c25
LocationServiceManager: Handle MODE_ASK in location service.

AppOps CheckOp can return MODE_ASK.
Fix location manager service to handle this new mode.

Change-Id: I085f01e992f60456ad24921bf4ce508ece54e8a6
base: Fix the problems for runtime overlay.

 - There is no need to make the string blocking when adding the asset path,
   as it will be made by the resources.
 - After adding the overlay path, it also needs to update the string blocks.
 - Scan all the sub folders for framework overlay res.

Change-Id: Iaad019111ae364c319e58dce57dbf4647b38d4c3
IndexOutOfBoundsException observed in ProcessStats

Sometime, IndexOutOfBoundsException is observed in ProcessStats
while allocating longs array. This could be due to synchronization.
This fix will return if array index is >= size.

Change-Id: I1302e6b88a3e94249f811fe682f1b0944b5d4e8a
Add a null check in exifParser to avoid crash while setting Wallpaper.

For some images, while setting as Wallpaper, the src array in
System.arraycopy was null in exifParser, which leads to crash.
This change adds null check to the array used in System.arraycopy.
Also, a safe check is made to ensure start index is not negative.

Change-Id: I46a16b6943aaeeb2395e335bf3926988b881be7a
Ensure to add Persistent Apps to LruProcess List on app restart

This change will ensure to add Persistent Apps to mLruProcesses
if not already present while restarting.Previously, on some
occasions, the process was not getting added to the list
resulting in SecurityException as this process was not found
in the mLruProcesses.

Change-Id: I26813a794e01aae316dffd3cf2bb38ab66ac69a9
Fix for framework reboot on format of SD card

MountService is not aware of /storage/emulated/legacy path which is
causing the issue on ExternalStorageFormatter service. We are getting
the a list of non-emulated SD cards and format the first one

Conflicts:
	core/java/android/os/storage/StorageManager.java
	core/res/res/values/symbols.xml

Change-Id: Iba1a9f6e40499f7f6fb095a5ee4e711b02bed439
CRs-fixed: 489037

Conflicts:
	core/res/res/values/symbols.xml
frameworks/base: move the traces file to avoid data loss.

If an ANR comes just after the framework reboot, the traces for
the framework reboot will get over-written with the ANR traces.
So, We are missing the traces for the framework reboot which
makes debugging the framework reboot difficult.

This patch will rename and will append a unique timestamp
this trace file name for the framework reboot once the
ActivityManager collects the traces. In case of multiple
Watchdog Kills the trace file generated will have diffrent
timestamp so that it does not get overwritten on multiple
Watchdog kills.

Change-Id: I90cb400d06aa909c1560328de4751aa02dbb6858
MMS: Fix Messaging will force close after tap one item in suggestion list

The span end is larger than string's length, it caused IndexOutOfBounds
exception.

Check the span end to avoid the IndexOutOfBounds exception.

CRs-Fixed: 555378

Change-Id: Iaf1cbe8db8704b3112afb6207982750b650fe5c5