Reorganize code to handle class 2 SMS.

If SIM card is having more than one USIM application the
registering mechanism in SIMRecords.java to the
CommandsInterface is not as expected. The CommandsInterface
will hold only the last registered application registrant
due to for every application the it is overwritten. So
whenever telephony received SMS_ON_SIM it will come to only
last USIM application created not the desired application
which is used by actual phone object.
Move registering mechanism for SMS_ON_SIM to SMSDispatcher
where we can get the proper application.

Change-Id: I02616e7a2e0f0250cc27780e53a061ef49f72fd6
CRs-fixed: 432656
Stk: Ensure that APDU input length does NOT exceed 255 Bytes.

- Depending on the encoding , the number of characters that
can be stored in 255 bytes varies. See details below.
- detect the current encoding used and enforce max length

Details:
As per TS 102.223 Annex C, Structure of CAT communications,
the APDU length can be max 255 bytes. This leaves only 239 bytes for
user input string. CMD details TLV + Device IDs TLV + Result TLV + Other
details of TextString TLV not including user input take 16 bytes.

If UCS2 encoding is used, maximum 118 UCS2 chars can be encoded in 238
bytes.Each UCS2 char takes 2 bytes. Byte Order Mask(BOM), 0xFEFF takes
2 bytes.

If GSM 7 bit default(use 8 bits to represent a 7 bit char) format is
used,maximum 239 chars can be encoded in 239 bytes since each char takes
1 byte.

No issues for GSM 7 bit packed format encoding.

Change-Id: I6a12b9a9c8f8b6b44c0164fc4e038c92c05284ce
Add getOperatorNumeric method in RuimRecords.

Add getOperatorNumeric in RuimRecords in order to
override base class method in IccRecords.

Change-Id: Ia22dd161c6250c34b2408d367ec6565e0439232d
CRs-Fixed: 522455
Do not update External state until we receive card status.

When updateExternalState is called before card state is received
from RIL, unwanted ABSENT state is getting broadcasted to
external apps incase of property apm_sim_not_pwdn is  set to 1.

So do not broadcast card state to external apps until we
receive card status from RIL atlease once.

Change-Id: I8803360dd57055ca3534b6dc7bade63ff629c730
CRs-Fixed: 520485
Do not send terminal response incase of 'SET_UP_CALL' user timeout.

Currently for SET_UP_CALL proactive command, a redundant terminal
response is sent on user timeout.

Add a condition in CatService, to prevent terminal response
for 'SET_UP_CALL' user timeout response.

Change-Id: I794a3ead971485bda920f722ad7bfa8b7ff74383
CRs-Fixed: 633521
Change to return proper MNC in case of CSIM

As per spec C.S0065 section 5.2.2 MNC length in case of CSIM
IMSI is 2. So modify the code to return the MNC of proper length.

Change-Id: Id046b9ff3173c038fb2196e18625f077b1897beb
CRs-Fixed: 656508
Initialize AdnCache for ISIM app type.

In case of ISIM app type initialize adncache, so that
it can be used in ICC records for generic purposes.

Change-Id: I82ab6bb85387a96f546bd0e5e90311023eb00f1c
CRs-Fixed: 564267
SIM Phone Book : Modify update operation

Add empty number check during update operation to comply
with the 3GPP 51.101 sections
10.5.1 EFADN (Abbreviated dialling numbers) and
10.5.2 EFFDN (Fixed dialling numbers)

Change-Id: I22584704ac961ea0bd7648cd6e9fa5ae33f655ee
CRs-Fixed: 539346
Add Dual Transfer Mode support.

In GsmServiceStateTracker, decode the "concurrent services support
indicator" field from RIL_REQUEST_VOICE_REGISTRATION_STATE
request and based on the value of this CSSI field allow concurrent
CS and PS services to applications.

Notify data connection changed on CSS indicator update.

When the phone moves from a DTM cell to a non DTM cell while in
active voice call, data connection is not suspended.
To fix this, consider CSS indicator change also for notifying
data connection.

CRs-Fixed:  564063, 641116
Change-Id: I57c445ee28be4e1c0f2934cb136a70d39447511c
Fixes to active app, quietmode handling and radio on event.

1) Don't assume 3GPP as active app on CDMA with LTE device

IccCardProxy assumes, that on a CDMA+LTE device, the active app
is the SIM/USIM and not the RUIM/CSIM. However, for voice RUIM/CSIM
is the active app on such a device. All services, like FDN,etc. should
be tied to the active voice app.
CRs-Fixed: 428304, 506938

2) Uicc: Do not be in QuietMode if the device is LTE capable

The voice radio tech can be set either due to a VOICE_RADIO_TECH_CHANGED
unsol or due to a change in the radio technology in the
VOICE_REGISTRATION_STATE response. Ideally when the preferred network
mode on the UI changes, the radioTech update received from both the
messages should belong to the same radio tech family (3GPP or 3GPP2).
But if they do not, (for example, the system reports different radioTechs
in both the messages for a few seconds due to a delay in updating the
system state), an incorrect radioTech which may not be supported on
the current network mode will be set by IccCardProxy. Hence
incorrect value of the quietmode will be set leading to broadcasting
incorrect sim state changes. For example, in a LTE only network mode,
if a radioTech from 3GPP2 family is reported, QuietMode would be set to
true and hence sim state changes will not be broadcasted.

If the device is LTE capable, always be out of QuietMode
and therefore broadcast any sim state changes. For this,
introduce a new config item which indicates if the device is LTE
capable or not (true value indicating that the device is LTE capable).
CRs-Fixed: 628506

3) Uicc: Update icc card state when radio is turned on.

When the radio is off, if the icc card status changes,
the icc card state will be updated. At a later point when
the radio turns on, if the icc card status change event is not
received, ,the card state will not be restored and an incorrect
card state may be present in IccCardProxy.

Always update the icc card state (externalState) when the
radio turns on.
CRS-Fixed: 646808

Change-Id: I70894a1aab0a812a50f1cbab986161bb3b708b85
Parsing of CDMA MMS notification carried by SMS

Decode operator specific WDP header.

Change-Id: I4ac1a66dba8590c496fd4375c8dfb9c49272617e
Add TD-SCDMA support

Add network mode TD-SCDMA to the list
of supported network modes.

Change-Id: Iad1f0ad424a8cc2b57df28caa3cea1c3c4c2f134
CRs-Fixed: 479310
Define EF MSPL/MLPL/PRL value and path

FR22494: UI will get MSPL/MLPL/PRL version by SIM_IO, This change
just define EF MSPL/MLPL/PRL value and path.

CRs-Fixed: 695024

Change-Id: Ib1f50dbfb2751448a6ee41b58e245aa1a6b34e4f
Telephony: Add support for copy SMS to RUIM card

RIL received PDU data is wrong.

Rearrange the PDU data make it can be RIL parse correctly.

Change-Id: I8045484fabe46262835f2cdc241911cbb3cb57e8
CRs-Fixed: 543087
Add Radio Tech Support in manual PLMN

Add radio technology interface when search available
PLMNs and manually select PLMN

Change-Id: I825a0159f7125cce0ea6fc3738a838392fbe8d3a
Fix permission check for deleting SMS on UICC.

When accessing SMS stored on UICC via TelephonyProvider, we need to
use the com.android.phone UID for the call to IccSmsInterfaceManager
to avoid a UID mismatch failure in the app ops check. Change the
permission check method call from enforceCallingPermission() to
enforceCallingOrSelfPermission() so the check doesn't fail.

Change-Id: Ie5fbf2b0d9c18ed4822775c3cf4af9ba671e5d4a
CRs-Fixed: 562711
Do not inform user when the alpha identifier is a null data.

Add a condition to distinguish between alpha identifier with
null data and no alpha identifier.

Ref spec: 3GPP TS 11.14, 6.4.5. Play Tone.

Change-Id: Ibfe211653c34206e4326d4b4f234c9dd1e9778f2
CRs-Fixed: 631723
Telephony: Managed Roaming feature re-design.

Add support to broadcast Managed Roaming intent.
When device is in manual network mode, if network rejects the
manual registration request with cause code "Persistent
location update reject", telephony broadcast this intent.

Change-Id: Ibddfb4a2007ab6e486a55b43bba95ec0c36080fc
Clear adn records during cleanup in IccPhoneBookInterfaceManager

Sim contacts are cached on every query. These cached contacts
are returned when queried after sim card is deactivated.
Clear the cached adn records when the adncache is reset so
that sim contacts don't appear after card is deactivated.

Change-Id: Ib42354f3d42ef4b9f50cde7d3e13240fdcd64aaf
CRs-Fixed: 638838
Telephony: Add priority support in MMS database

Add SMS priority support for 3GPP2 SMS.
Add "priority" column into message database.

Change-Id: I28d0986918d095fb302f3e01276ae394da61ccd4
Conflicts:
src/java/android/provider/Telephony.java