Fix crash while installing themes rapidly

A theme can be installed on a PM or theme service thread.
If multiple themes are being installed at once and one of
those themes happens to be part of the boot config, then
two themes will try to be installed at the same time. This
causes problems with files like the temp AndroidManfiest.xml
which are not designed to be multi-thread safe.

This patch fixes the issue by making sure a theme is
never installed in a PM thread except during boot.

Change-Id: Ic9a0ffe43d0199a2a893579f3d2dbb6d9340e7b4
Sanity-check paths of files to be restored

(cherry picked from commit 7d51cc701a6735cf455af8479f56c9c0b2109e02)
Bug: 16298491
Change-Id: I0c2d6523c9d152dad4d27d06d3853afd432e5af7
ThemeManager: Synchronize access to listeners

If the Set of listeners is modified while iterating we will get
a ConcurentModificationException so we need to synchronize access
to avoid this.

Change-Id: Ib521ad86a665316d707463200c16c1bcdcfac362
SystemUI: fix msim signal cluster text label spacing

When WiFi is on and mobile data is active with msim device, the first
mobile text label (e.g. 1) was too close to the WiFi icon. Show the
spacer as necessary.

Change-Id: I2fc4c77f448647d79d81cfa02373da477556c6b0
Signed-off-by: Roman Birg <roman@cyngn.com>
SystemUI: hide msim no-sim icons

Simply hide the SIM mobile indicator group when a no SIM icon is
requested.

Change-Id: I074b8e486ab35f57daa1f1eaee7e5b696835b3b8
Signed-off-by: Roman Birg <roman@cyngn.com>
Revert "Themes: Build icon cache when applying icons"

This reverts commit 7bb802a478faaac295ccd8b98a3573701edd9b1e.

This is not thread safe.  It is possible for an icon to be in the
middle of being composed when another process requests it.  That
process would not be able to load the image.  In Trebuchet, the
icon would be displayed as the standard "android" icon since it
would not be able to load the icon.

Change-Id: Id9bc38296cc02c376f9ea66565babc00e8dbf634
Protect windowNoTitle and windowActionBar attributes

This patch creates a new method to define "protected" attributes. These
are attributes like windowActionBar which should not be modified by
a theme.

Some apps (eg gmail) use the appcompat library which
has its own Actionbar classes. When an app uses its own
Actionbar it must not include the default actionbar which is
achieved through the windowActionBar attribute.

Some themes may try to change these attributes, which can will cause
the app to crash.

Change-Id: Ie3bb7285eed09f3f13facf9d142ea9eb83796eec
Themes: Handle processing themes in separate thread

If themes are being processed and the user attempts to apply a theme
they will be forced to wait for themes to finish processing before
the theme is applied.  This patch moves processing of theme resources
into a separate handler/thread.

Change-Id: Ib30a1be75915364c2867df04d63700be63c9f2c5
core: Fix SMS capitalization

Change-Id: Iab3d935b9980bb802baaf1ebe255ec5cdfa5cee7
frameworks: add alwaysRequestAudioFocusForCalls overlay

Change-Id: I0e3e5dd0741d295cdb6cbb0867f19a83c3363dc5
Signed-off-by: Roman Birg <roman@cyngn.com>
Installer: Use nanoTime instead of currentTimeMillis

It is possible for the Installer to timeout even though the elapsed
time of 100,000 ms has not elapsed.  This can happen if the system
clock changes while we are running something from the Installer.

The documentation says not to use currentTimeMillis for determining
timeouts and recommends using nanoTime() instead.

Change-Id: I376d5b0fad8eefcdeabbb7ed89ebd3d1d3c96ba0
Change permission guard on bindBackupAgent()

Bug: 15829193
Change-Id: I6c1c39923b7b1a9f528f97da10913cb7f2d7e8f9
Fix issue #16794553: Duplicate ArrayMap entries in Bundle...

...can lead to launching of un-exported activities

We now validate the array map after unparcelling to make sure there
are no duplicate keys.

And to make up for the performance overhead this introduces, I switched
the parcelling/unparcelling code to write keys as explicit string
objects rather than generic values.  There was no reason to use generic
values since the write method itself only accepts an array map with
String keys.

Change-Id: I57bda9eb79ceaaa9c1b94ad49d9e462b52102149
Do not persist and restore the media button event receiver

Do not persist the media button event receiver.
Do not restore the media button event receiver on behalf of the
  application that registered. Prevents reported vulnerability.

Bug 15428797

Change-Id: I7ca3e7fccb165c55b23f471c00e0ed77436f7dc1
lights: fix notification and attention lights

- Turn off attention light in pulse rather than
  just turning flashing off.  This was causing
  the LED to be left on for any HAL that obeys
  the concept of LIGHT_FLASH_NONE.  Most HALs
  will either treat this as OFF, or have special
  handling for the attention LED case where
  it was getting left on.
- Remove some unnecessary code in Light

Change-Id: I36292ae0d57e0454d7c9f1d3c909a87affeaf7d2