Add support for SIM availability in Flight Mode.

Add support for accessing SIM related activities such as
activation/deactivation of SUB in  Airplane Mode.

Get SIM Status in RADIO_OFF state.

Change-Id: I3cc84ca691ef2ea03fc68b94d4e7043b399350ab
CRs-Fixed: 614186
Update subscription preferences when card is removed.

On card removal, the subscription status is deactivated but
subscription preferences are not updated. Due to this DDS switch
is not happening.
Update subscription preferences while handling card removed event,
so that DDS switch is triggered.

Change-Id: I3ba82520da2e282239fd400f331130ac10d33f59
CRs-Fixed: 616444
Get File handler from first available valid app.

Make changes to get File handler from first available
valid app instead of getting file handler everytime
from first app.

Change-Id: I7372abc837b783815fbf01474cb3e79784c0d67a
CRs-Fixed: 611780
Add FLAG_RECEIVER_FOREGROUND to CatService broadcast intents.

Stk app can receive broadcast intents from CatService before
BOOT_COMPLETE, when Intent flag FLAG_RECEIVER_FOREGROUND is added
to the intents. Without this flag, broadcast intents sent before
BOOT_COMPLETE are queued up by android framework.

Change-Id: I523332f0450195974fe41a2409831cc0c59775f8
CRs-Fixed: 620457
Correctly handle card absent event during phone shutdown.

When card absent event is received during phone shutdown, it is wrongly
handled as card removal. This results in subscription preferences to be
updated based on remaining available cards.
To fix this, check for shut down in progress condition and avoid updating
subscription preferences during shutdown.

Change-Id: I3be0926da04ea8c07f59f3e5071bc1c78bf4c705
CRs-Fixed: 639536
Fix the Subscription copy from method.

While copying the subscription data, app id is not updated
if it is null for the source subscription.

This results in saving global app subscription data with
CSIM app id, when subscription is changed from CSIM to global.

Fix the copy from function in Subscription to update app Id,
app Label, app Type and icc id even when those values are null.

Change-Id: I932a2e56489c0593726624e2074197ee632dfac6
CRs-Fixed: 642188
Avoid DDS switch when changing sub selection between two apps in same slot.

Check for any pending avtivation requests on the deactivated subscription
before updating subscription preferences.
This prevents subscription preferences from moving to the other sub
while changing the subscription app in the same slot.

Change-Id: I33d9cd197ed792d68aedf56c2ae479a8e26b14b0
CRs-Fixed: 643765
Fix for unable to read SIM contacts in APM mode.

Do not reset subscription data to null, when deactivate event is
received in MSimCDMALTEPhone and MSimGSMPhone.

Avoid handling messages in MSimCDMALTEPhone and MSimGSMPhone after
phone disposal.

Set the card to null in MSimCDMALTEPhone and MSimGSMPhone, if
subscription status is deactivated.

Change-Id: Id69771ff58c0f967a6f50f4968e883307426ed65
CRs-Fixed: 638838
Avoid automatic DDS switch during airplane mode toggle.

Sim card is powered down in APM when persist.radio.apm_sim_not_pwdn = 0.
Due to this card subscriptions are de activated and activated when APM is
toggled. Based on the timing of the sub activation events, sometimes DDS
switches to other sub automatically.
To fix this, check for airplane mode sim power down condition before
updating sub preferences. Also remove mAllCardsStatusAvailable check from
isAllCardsInfoAvailable() since it is redundant and gives wrong result in
APM toggle case.

Change-Id: Idb75a5bac0bd702b9319479e5e2c1486923893b6
CRs-Fixed: 648737
fix app index mismatch when setting global subscription

In global type, getGlobalAppsIndex returns global app indexes, then
SetUiccSubsParams sets the first app index as 3gppId and second app
to index as 3gpp2Id. But in fact getGlobalAppsIndex may get 3gpp2 app
as first app index, 3gpp app as second app index, which will result
in appindex mismatching.

Modify getGlobalAppsIndex to ensure return that first app index is 3gpp,
second app index is 3gpp2Id.

CRs-Fixed: 646936

Change-Id: I2b3c608893b82d76ce4ab623290a4a19e2224861