On-The-Spot: Underp Safe-Headset one once for all and code cleanup:

After Gif support, context managing went derped resulting in the old NPE.
Valter's fix restored all the contexts that are used within system one that
we need just to read&write to system, but dialog's builder needs one created
by the ThemeEngine.

* Fix dialogs not being themed:
  Pass themed context only to dialog builder by crating one when needed.

* Cleanup implementation:
  Restore all normal system contexts and add an helper method to generate
  a theme context to be used by AlerDialog.Builder() for pulling themed resources.

PS3: Miscs
PS4: Code cleanup
PS5: Commit message cleanup

Signed-off-by: Carlo Savignano <stevewatersy@gmail.com>
Change-Id: I1e3f9dce7dd448306db0364ab6e1ff8a71160729
Merge remote-tracking branch 'aospa/kitkat' into aospal
Keyguard: Change SUB label to SIM

Change-Id: If3d92426e1c975870584f46d63c3ee0dfbfb3a52
msim: initialize sim icon to the known state

When system ui gets killed (for instance, during a theme change), MultiSimNetworkController may not receive the SIM_STATE_CHANGED for both sim cards. Instead of initializing the sim to "ready", query for the actual state at initialization.
Tethering: Enable NAT only when tether and upstream ifaces are different.

When enabling WIFI hostspot, chooseUpStreamInterface will choose WIFI
interface as it is still up. It will result in both tethered and upsteam
interfaces are same one. netd will reject this command and tethering
will fail this time.

This fix will not send NAT command to netd when it found these two
interfaces are same one. Later when the real upstream interface is
brought up by ConnetivityService, Tethering.java will continue the NAT
procedure.

CRs-Fixed: 692285
Change-Id: I1ecd700ad64748c3745fffc76b7ac0e7d7b9b96b

Telephony: Avoid Infinite loop problem in Tethering

1. Whenever data is enabled we will try to establish the tethered
call (USB tethering enabled case) for 5 fixed number of retries.
After reaching maximum number of retries we are turning off the
upstream connection. whenever the CONNECTIVTY_ACTION received
(because of USB cable disconnected and then connected case or
some changes), it can try to bring up the dun/hipri PDP again.

2. There is no retry in case of data disabled case.

Change-Id: I16af4d2983a8bf9ce0ce904877f86169bca549b4
CRs-Fixed: 401829
(cherry picked from commit 4c923c8537fdc49ef491b964adc1871c77bfd730)
(cherry picked from commit 3135e6a89ac14008df04fe6e068bd8dd95b4ee40)
(cherry picked from commit 137b7004f716a559c7249be20e25544fe10330b6)

Broadcast tethered client inteface along with upstream interface name

On change in tethering upstream interface for IPV4 of IPV6 address,
broadcast an intent with both tethered client interface as well as
upstream interface name, ip address type and update type.

Change-Id: I2f23e2b8ec125339bedd454446accb23e33cacae

base: Add P2P interface "p2p0" to tethering support list

Dnsmasq is running as singleton pattern, P2P GO start DHCP server fail
if dnsmasq has been started by USB tethering. Tethering management
feature in Tethering.java just support soft AP and USB tethering. Add
P2P interface "p2p0" to tethering support list.

CRs-Fixed: 719930
Change-Id: If3a07e6cac1678dfedf361abf99f52bc12a2f697

base: Fix for wifi tethering crash

Pass network info along with CMD_UPSTREAM_CHANGED
Added a NULL check for Network info in CMD_UPSTREAM_CHANGED

CRs-fixed: 562910
Change-Id: I98bd37205255d9d4025cfb95b0688c68bce3c9bd

Tether: fix the retry issue in Tethering

Since StartUsingNetworkFeature will always return success, it's
not a good place to set retry. With this modification, the retry
will work.

Change-Id: Ia2ea489ea57f99617004093bfedc8e7e6dba46ed
CRs-fixed: 667865
 MTU should be 1358 as per 3GPP standards, especially for LTE radio interfaces.

Change-Id: I5d3601b05a41d4c59cff3b39ddfb66d00cb23c45
Signed-off-by: Stacy Devino <swylie@oceusnetworks.com>
frameworks: fix setting default ringtone for multi sim

The defualt value for the ringtone expects a "_" between the setting and
the requested sim subscription. This was not being respected in the
mediascanner when it set the default ringtones, resulting in the setting
value being "ringtone2" instead of "ringtone_2".

Change-Id: I4a9147d579183229cc3300e71194e6f5ab74fbc6
Signed-off-by: Roman Birg <roman@cyngn.com>
linearlayout: fix measurement of childrens when parent and childrens have exactly the same pixels

When children measure exactly the same width/height than the parent, any child with
width/height == 0 and with weight > 0 must be reset. Otherwise, the view will retains
the same width/height between measurements calls (that is not valid if the view changed
its orientation).

This explain the bug in CYAN-5471 when in hpdi devices the spacer view has the same
width after rotate from landscape to portrait when language is german and date beewteen
September 10-30. Steps to repro in i9100 (hdpi):

1.- Set language to german and date to September, 10.
2.- First run, the expanded bar has the same width that its children (480px the current
screen size), but spacer has 0px (because it isn't being measured by linearlayout).
3.- Rotate to landscape, spacer gains space and all buttons are displayed correctly.
4.- Rotate to portrait, spacer has the same width that in step 3, because it isn't measured
again and delta == 0;

This patch forces this views to be re-measured to 0 to match the current delta (the views doesn't
need to be expanded or shrinked).

JIRA: CYAN-5471
https://jira.cyanogenmod.org/browse/CYAN-5471
Signed-off-by: Jorge Ruesga <jorge@ruesga.com>

Change-Id: Iab60337eca6ded7b2b4d57fdcc95863be461db34
WIFI: Fix wimax teardown when wifi connected

Due to patch:
https://github.com/CyanogenMod/android_frameworks_base/commit/f769f4cbc2aaac8d9d49f9ff79a6fe0affc4ff6e

Change-Id: I18e5ced62c8e4976f7a6835ba8c593930dac0586
Global Settings (MSIM): Add global settings for naming sim cards

Change-Id: Ibbd0d48042a92f82241a4ccaee12a81ca13ccdb4
SystemUI: Fix crash during notification/theme change

Fixes crashing that could occur when a notification is created
during a theme change. Entries were attempting to be added
to views which did not have a layout pass yet, causing it to fail.

When a theme change occurs, the fix is to halt the ticker and command queue
until a layout occurs.

BUGDUMP-151925

Change-Id: Ic19d26178df673a1d52981a8617415e6fbcb219d
Merge branch 'kitkat' of https://github.com/AOSPA-legacy/android_frameworks_base into HEAD