Enable native tracking for RS contexts to improve GC behavior.

This should prevent apps from leaking RS contexts as easily.

bug 18579193

Change-Id: I2d943ce4443ce7cb90ebdd3dd37d338eda6df3a2
(cherry picked from commit 534fc294437bae845b130858de1ca4f6ba32a10b)
Fix bugs regarding delay the dispatching of non-wakeup alarms

checkAllowNonWakeupDelayLocked() method determines that delay the dispatching of non-wakeup alarms.
(there are no wakeup alarms and the screen is off, it can delay until the future.)

if there is any pending non-wakeup alarms, non-wakeup alarm delivery time is bigger than nowELAPSED.
but, checkAllowNonWakeupDelayLocked() returns false and non-wakeup alarm is not delay until future.

i think it is necessary to reverse the inequality symbol on "mNextNonWakeupDeliveryTime > nowELAPSED"
if it isn't, Could you let me know when we get ¡°stuck in a loop¡± in the comment of checkAllowNonWakeupDelayLocked () method?

Change-Id: I7e972064547f4d0a9b4175dbd4cf735b4837abfd
Signed-off-by: Minho Choo <minho.choo@lge.com>
(cherry picked from commit d0c3fe52173c22d70da687c26adbc84a556663fb)
[ActivityManager] Fix NPE when start activity

Symptom:
NPE occurs in line 1184 (resultStack.sendActivityResultLocked)
because resultStack is null.

Root cause:
When starting activity with FLAG_ACTIVITY_FORWARD_RESULT flag,
the resultRecord could be updated, but the resultStack is not
updated as well. In that case, the resultStack is still be
null. The exception will occurs if the activity is not
granted to launch due to permission denied.

Solution:
Update resultStack when resultRecord updates.

Change-Id: I91634e4f713c2e8dbd1a71f358a8fd9beed83ec7
(cherry picked from commit 6ca5bbe5b2147db3478899d13cb9d6289a1dee8d)
Frameworks: Slim heads up customizations for LP (1/2)

Basically it follows the same idea like we had on SlimKat....see here
https://github.com/SlimRoms/frameworks_base/commit/323ed77c5e5bd6d421beae1f8118eb580be5ecf1

That said there are some differences in this more or less completely recoded feature.

- Moved it into the app policy files
- Enable/Disable on every app (no system apps)  either longpress a notification and an button appears / or in notification app settings
- For now only snooze and heads up timeout configurable....other stuff will follow later.
- fix up some AOSP code for it as well fix some UX inconsitence.
- left swipe dismiss, right swipe put into background, swipe down opens notification drawer and moves the notification into it
  (aosp default behaviour is a big UX disaster....swipe up dismisses it completely and swipe down open notification drawer but heads up stays....first
   happened to me 10000 times accidentally which is really bad and second does not make sense. Hence this change of the default behaviour)

Well and a lot smaller things as usual.

Last PS
- fixed some minor stuff
- reset snooze timer when screen goes off
- do not show headups if notification drawer is visible

PS
making snooze button functional - we may need to move it a bit down.

PS
give snooze button a bit animation love

PS
icons

PS
add accessibility descriptions etc

PS
hedasupcandidate package fix
move snooze timout into config
smaller fixes
out off WIP and ready to merge
added commit description

Still ToDo:
Settings

Change-Id: Ic8977feb4bb0700f1093ce7d62c22d4c63c69bad

Conflicts:
	core/java/android/app/NotificationGroup.aidl
	core/java/android/provider/Settings.java
	packages/SystemUI/res/layout/notification_guts.xml
	packages/SystemUI/res/values/config.xml
	packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
	services/core/java/com/android/server/am/ActivityStackSupervisor.java

(cherry picked from commit 3be276a207f95d4791cdbee1689ac688f53161b7)
CommandQueue: showCustomIntentAfterKeyguard ensure that it gets syncronized

Change-Id: I86be91a09277bfa8b1522fb0088541ac865eb23b
(cherry picked from commit c10070417d818174d84f4ef9cd6f7cf42f815e80)
Frameworks: Only set package name on user heads ups

Let us not influence the default aosp behaviour which could conflict if an app
is strange coded

Change-Id: If69e40ce932ce7e77886d250879346a9a43920a2
(cherry picked from commit 939e37e08314e9ad724326a4d8d1c8716d5550f3)
Fix Smart Pulldown

Currently if No dismissible or persistent is chosen, quick setting still appears when persistant notifications are present.  This fixes that.

Change-Id: Id8907a4f888e48ed511dd11b484508eca93fa0b3
(cherry picked from commit a57efb015789fd8fd9128cc3bda918dc21163c3b)
Framworks: Possibly construct ticker views if user changed settings.

Otherwise it leads into a FC

Change-Id: I3f96e162fb9d221cca5d376f38c3a313c8746d48

Conflicts:
	packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java

(cherry picked from commit 2707dfc3404aa3dfcec59853dba8aa3c0220e2fd)
StopSwitchDelay - Remove 5s Delay To Open Apps After Pressing Home Button

Conflicts:
	services/java/com/android/server/am/ActivityManagerService.java

Change-Id: I86b882244dc5e240a2e94d651fa5366c43919dee
(cherry picked from commit 6b51aa63f416cf5d1269055be010fee912824501)
Fix blacklist unknown number mode query string.

The same was string was being used to query the database for both private and
unknown numbers, with the effect that enabling private number blocking also
blocked unknown numbers.

Change-Id: I5a77566fde3187ff6044415c64e74ce4e10cd4dc
(cherry picked from commit df77a7036ce15d9b912881a57f01728b0d0a6880)
(cherry picked from commit aa5b3890844770758d2e9118f059982576185d84)
Fix a ticker feature derp!

(cherry picked from commit 0746e34bef4df262fe5331e14e4a6f47ab4fb36a)
Frameworks: add ability to change the color in battery saver mode (1/2)

User complain about the ugly orange....give the user the ability to change the
color in status and navigation bar if battery saver mode is activated.

Especially for you Tylog :D

PS
- move it into the observer...method is called to often to call every time
  the settings value for it.

Change-Id: I48ed2e85c462a2e94770b2bc1ad75b1ca40f2304

Conflicts:
	core/java/android/provider/Settings.java

(cherry picked from commit 4313f6f13ed0fa15fcc66cf759cbb815bacd4c16)
Frameworks: Be sure heads up view is attached before removing it

We did not have it in our tests but some user ran into it. Thing is if the
system is disabling notifications for whatever reason and till this time the
view was never attached and the system tries to detach the view on windowmanager
we run into an illegal argument exception.

Fix it with simply checking if the view was attached before removing it.

Change-Id: I0800beed3553815cc529087052138345773b32e4
(cherry picked from commit a02757fe3035fae726e5c8d7577cf7bd7a7d66a2)
Allow 3 AT (mnc05) to roam on T-Mobile in Austria

Change-Id: Ie1a62db9a48cfaf594ddda7b413299a9b587ddd4

Conflicts:
	core/res/res/values-mcc232-mnc05/config.xml

(cherry picked from commit 657c89b75e156f59b5ee3530b7ecd3d5930c21ee)
Tele2 considered non-roaming on T-Mo

Change-Id: Ibb05f277b701861b8716168b54e96f63127e686d

Conflicts:
	core/res/res/values-mcc204-mnc02/config.xml

(cherry picked from commit ccf30a79bb18b95c0e0457606fc30e7ddd6fb23a)
Vectone UK (MNC01) considered non-roaming on T-Mobile (MNC30)

Change-Id: Id74c854f958be721be12451a124cfd2f8b150255
(cherry picked from commit 5ac2a66b5463c43b48301d48c3d78075a3979275)
SystemUI: redraw navbar icons, add custom navbar icons back

Patchset: add sw600dp versions

Patchset: finish up the rest of the custom icons

Change-Id: I0925fe7a348a8914757caaca6c97d85fb7337f7b
(cherry picked from commit f2164f98294f9cc7f2d24abb388b7a62e2318742)
Add option for screenshot in powermenu

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

Conflicts:

	core/res/res/values/strings.xml
	core/res/res/values/symbols.xml

(cherry picked from commit a58fd19f426077776a6b017890b836f532ab14d2)
Fix ANDROID_LOOP=true for ArgoNavis and Perseus ringtones

Change-Id: I2fd05e73d68758867a17d2c3369cfeefc203ac9a
Signed-off-by: Chet Kener <Cl3Kener@gmail.com>
(cherry picked from commit bf967d98e98d6c1d8cfda9672dfa80a8a20df0ab)
Fix: Don't disable rotation lock tile

Rotation tile was hiding if the user disabled Auto-rotate
option from display settings.Enable auto rotate tile as always visible

Signed-off-by: Chet Kener <Cl3Kener@gmail.com>
(cherry picked from commit 592011d9ffc763288e5aee1dbf73cddc8baf8652)