frameworks/base: Fix to avoid UI freeze issue.

Due to some race condition in WindowManagerService, Screenshot
layer remains as topmost and buffers are not flipped hence
no updates seen on the screen. So, trying to destroy persistent
layer explicitly if freeze timeout expires 6sec.

Change-Id: Ibe295550a7431a4f633a57e7dfab0cbda102ab87

(cherry picked from commit f8146d56eab71245cf6b86d0c5a4725c528d8a0b)

(cherry picked from commit c6789fe6da4e6855e9409851a6469d20561cbe49)
MediaMuxer: handle expection for add track

Native addTrack call throws IllegalArgumentException on failure.
Catch this exception in MediaMuxer and throw IllegalArgumentException
that calling function can trap.

Change-Id: I97239ee2272c754ef6d7d54c5a27d1889ac01b80

(cherry picked from commit 1dd6f42412fb6a15c64acb71028798432ff06ba9)

(cherry picked from commit 7fc3e90b3f4aece035cfedb2790d35ef3938d7a6)
SystemUI: Remove unnecessary mobile data activity icon update

The unnecessary mobile data activity icon update causes activity
icon is 0 when mobile data is not actually used. As a result, data
icon will not show even if data connected.

As mobile data activity icon has updated in updateDataIcon, do not
update it again in refreshViews. Remove unnecessary mobile activity
indicator icon update.

Change-Id: Ib39c55a39a0623cc9a2d14508d487f86e3a0f82f
CRs-Fixed: 745386

(cherry picked from commit b30569b021d81a0598dbc5f131ef5f1de31f2d0d)

(cherry picked from commit 46a0e182b4f833c7ff771679958a1cacb43d0d57)
SystemUI: Set zen mode to no interruptions if silent mode is set

When setting ringer mode to silent and current zen mode is off, zen
mode will become priority interruptions mode. As a result, ringer mode
is set to normal mode in updateZenMode.

Set zen mode to no interruptions when ringer mode is set to silent.

CRs-Fixed: 744813

Change-Id: Id104e5473d0e8d624b06dfc9e5dbd8d9f7627b6e

(cherry picked from commit 18d823cb53b13fae2a9a17d6fae4a466c311529e)

(cherry picked from commit ace02afe713b6d3e715dfcac10608055fdb27ef2)
SystemUI: Fix task manager title not change with language issue

When system language changes, task manager title and kill all button
name do not update.

Set task manager title and kill all button name when refresh task manager
view to ensure they change with system language. Rename task manager tile
to meet multi language requirement.

CRs-Fixed: 741079

Change-Id: Ic247c2a70cd63ccb87fd2f3bea05196e28060857

(cherry picked from commit 5e0f5527a8f025b3939e73a8bee42ceaa864efc2)

(cherry picked from commit db9bfe55cdc158d5815c22cf7a967ef7e0c4e30f)
SystemUI: Fix sim pin lock message displaying incorrectly issue

When verify password successfully and no sim card is pin locked,
getSimPinLockSubId returning invalid sub id causes slot name
displays incorrectly.

Do not update sub info if sub id is invalid, remove inappropriate
security message update to avoid displaying incorrectly.

CRs-Fixed: 737973

Change-Id: Ic4c4aca09456008c72677aedd9caa6af9e84da8f

(cherry picked from commit 2c364790e9bf971738bb5fcc5524221528ef3ca3)

(cherry picked from commit e55ad3de48892df8d20ba1d376e7867271e79c35)
VideoView: Check state before calling suspend

Only call suspend under certain states. There is a possibility
that when activity is finished, pause gets called before destroy
calling suspend and stop on mediaplayer respectively. This will
result in stop failure as it has already been suspended.

CRs-Fixed: 750459
Change-Id: I34c24d6abe3726b163f9a582d73b31dfd4094e44

(cherry picked from commit a17b9b9fb312624d181e238fb317644666f0743e)

(cherry picked from commit 54b4a123b2b1aeef8dc67e5a753d4bfc0e209591)
Allow override of DUN settings

Allow override of system DUN settings by setting
persist.sys.dun.override
to one of the following values:
2 = not set, 0 = DUN not required, 1 = DUN required
If the prop is not set or is set to an invalid value the system setting
will be used.

Conflicts:
	services/java/com/android/server/connectivity/Tethering.java

Change-Id: I296f303a23351e4ab29898895abfcd313c747db9

(cherry picked from commit efe7da1bd9d95e38e69557ce3494a60983705dfe)

(cherry picked from commit 99265de817dbe0773849daecf401c53f8a319ae5)
Sounds: Cleanup duplicate ringtones/alarms

Removes duplicates from AllAudio makefile and fixes title tag of
Promethium (from Platinum).

Change-Id: I767a846dbc5575ec9f86b1326e0b9f7aa015086b

(cherry picked from commit 0f195e0204665437d331606a4335cd4ca54a8119)

(cherry picked from commit bef866a2ee4395c50fe5c661d6fbdeded2907a28)
immersive mode: don't unconfirm a package, that's just dumb

* This is very annoying for specialized apps
* See here for a great explanation http://stackoverflow.com/a/20309721
* The fact that it doesn't even notify the user until the NEXT time they
  run it makes it completely pointless in my opinion anyway.

Change-Id: I423611efc07d467e1d81c66d58adcff331be8b38

(cherry picked from commit 06f2cac348465bc44ef436a563c1ea8ed3e121d6)
frameworks/base: Add support for fully transparent layers

Allow apps to specify a window to be fully transparent. This hint
can be used later by the compositor to drop the layer.

Change-Id: Ib58f1026e74ca39e7160d2adcb34ebf50ec28a9a

(cherry picked from commit 5387341d7a0cc3cfc24cec98f0f0c4c3bab45349)

(cherry picked from commit e08abe81163442cb68dcd633e59cae56c3c6021c)
Optimize drawBitmapMesh using TRIANGLE_STRIP

Draw BitmapMesh using STRIP instead of TRIANGLES.
Depending on where the bottleneck is located in the pipeline,
there is a potential for saving two-thirds of the time spent rendering.
The speedup is due to avoiding redundant operations,
i.e., mapping each vertex four times to texture and color attribute,
sending each vertex twice to the GPU, vertex processing of GPU ...

In this patch:
1. Refactoring mesh using Strip.
2. Batch triangles by adding degenerate triangles.
3. Optimize computing positions of texture and color attribute.

Benchmark: Drawing Bitmap(1152x768 px) with 200x200 meshes
Performance is doubled (from 26.4 fps to 53 fps, Nexus10).
Memory footprint: only 17% of original method.
(from 240000 to 40401 vertices with xy, uv, rgba data.)

Change-Id: I08c5c20d981d88528ce7b02012feefae468d6ec4
Signed-off-by: kui.zheng <kui.zheng@arm.com>

(cherry picked from commit ccec048da3a86d67b4d487101fff15711c833f47)

(cherry picked from commit 14d1e55dbbc96ef161b6a3bbe5fed082dd2dba45)
Factor out preference-in-storage check to overridable method.

Change-Id: I2fff3192802f8a180330fda66388eda394334a5a
appops: Fix an off-by-one error that causes the location icon to stay on

Commit bdfde4fc820fad768dbc596b17507e4cdc84b850 added Bluetooth AppOps
capabilities, but it contained a subtle bug where the string representation
was added in the wrong place, offseting every operation after it by 1. This
broke the toString functionality but didn't have any consequence since this
was used for logging purposes only.

Commit b01b08928a42a626f5f1c6c18a20d786fb873d75 changed AppOps so that
operations are persisted by name instead of by index, this caused the string
representation offset to affect functionality and, among other things, one
of the consequences was that coarse location requests were being interpreted
by AppOps as high-energy location requests.

Change-Id: I319f1ac1c5910098689b4cb8645eb92c0e3538cb

(cherry picked from commit 82bb89b95b2695af832e50f7988e7651615a331e)
media: Scan FLV files, because why not?

Change-Id: Ia517d3057d843d7306f567cdbdddddd63c472a2b

(cherry picked from commit 3440a671ea6e4a69014d4acd425779138599ea96)
Update the ADB status bar icon

Change-Id: I35a52f9a438013d37e1f6739dc8fcc2527203ecf

(cherry picked from commit 4daf28faee922853c91385356bfbc2c53ac5c6cf)
Turn off carrier provisioning by default to allow tethering

Whether or not to use carrier provisioning is a setting hidden to the
end user that is currently not set. Unfortunately, on some carriers that
may result in it being set to yes, or effectively set to yes, without
other accompanying changes that must occur, such as setting a tethering
apn and possibly having a carrier provisioning app, resulting in hitting
a paywall when a tethering plan exists, or, worse having nothing happen
at all when you try to tether since the data doesn't have an apn set.

Change-Id: I3b5b3cc86e3325302411f46e3fd5f7a7c1b9f57e

(cherry picked from commit 5980a9e74ea28173ab0763e19914c5d61af3bc93)

(cherry picked from commit 1b6b79c1a11bbb1ffb8fd27c3141076a88ed302f)

(cherry picked from commit 77adb28edb982e2653c305c8ceb113c503cd0773)

(cherry picked from commit b84a3ef36724a9326e307635846d1d484725fb2b)

(cherry picked from commit d6864609a1b8225be044376a3cf4f5f511e9f20b)
Missing break in switch statement

Change-Id: I462c0c5fec96a850032266b04419ec409ad02174

(cherry picked from commit 4dba87d529632cb99e6014c640f3bb3b26d37393)

(cherry picked from commit bc90a5a14bd0319698d36121c7d0730de6734c3f)
framework:Thread synchronization for UI update

Issue : Framework reboot was observed due to out of sync between
        two threads which inturn causes Null pointer exception
        while updating airplanemode.
Fix : Handled Null pointer exception and the crash is not observed.
CRs-Fixed: 570122

Change-Id: I2e969f6e7726ffcf8648b366ebb54cb2b0afc292

(cherry picked from commit 1bc2a7b68ca71dab0bd58f3b7bcad16120a1900d)

(cherry picked from commit 5467446be034f9e6a272ae51cb1a0117c4e48a4b)

(cherry picked from commit 2a80377816e88bcb8bde846bab780e55f9f4ec9e)

(cherry picked from commit 726f6d41c268ea8a3b77086246ec621944a56070)

(cherry picked from commit efe250d78a2914032cd83d208117bbd383fe262a)
Change SQL to improve performance.

To know the number of images, use "COUNT(*)" instead of "_id" in SQL.
Using "_id" gets all result set. and when getCount() is called, CursorWindow is filled.
But using "COUNT(*)" gets just 1by1 data.
So using "COUNT(*)" is more faster than now.
And this SQL is called everytime per a file during a file transfer in MTP
The better way is by using "EXIST".
But if using "EXIST", modify MediaProvider.call() method.
So i applied just a "COUNT(*)"

Change-Id: Ic5882af0fad2304f836b7b7043a4746359391609
Signed-off-by: muzbit.kim <muzbit.kim@lge.com>

(cherry picked from commit 5e2edb4ce62b261aabf9ed11cc7120f812d56df6)

(cherry picked from commit 26fe45a5c03371b2527e417e10a67bf68e0f1772)

(cherry picked from commit ff7d148ed2ea8fa2a76d7370d5b4fd4603a1520a)

(cherry picked from commit 3cf6a5a0a702553e066cceb9ba7dbac2c2b343c4)

(cherry picked from commit ef49f3e0242d58b80e155313915eb4c5ebb9d451)