Do not retry forever in DataConnection.

When we are initially to connect we limit the the number of
retries so as to go through the list of waiting apns. But if retry
forever is enabled, as it is with Verizon devices, we can burn the
battery down quickly because we're retrying with short initial
timeouts.

In this change I also increase the timeout between apn retries from
5 seconds to 20 seconds to further reduce battery drain when retrying.
And added a retry with a longer timeout if to keep the contract with
ConnectivityService that when enabled we will continue to retry.

Bug: 9240744
Change-Id: I45b9ec5300d602d838dbdeacdbd1fca0c4d65ee3
Fail on permanent errors in DcTracker.

This reverts the retry added when fixing bug 9240744:

  https://googleplex-android-review.git.corp.google.com/#/c/315817/2

Bug: 9373372
Change-Id: I15d8dcc2c04174d54dd33f8a34813fd72764fc77
Initialize RIL with the correct CDMA subscription mode setting

Users choice of CDMA Subscription Source is stored in CDMA_SUBSCRIPTION_MODE
setting in database.
If telephony restarts after a crash, PhoneFactory sets the
CDMA subscription source value from PREFERRED_CDMA_SUBSCRIPTION
setting and that causes the mismatch with the value in the settings
database chosen by the user. The change is to use the
CDMA_SUBSCRIPTION_MODE setting instead when creating the RIL object.

Also, remove the Setting PREFERRED_CDMA_SUBSCRIPTION from the database.
With this change the special treatment for LTE on CDMA will not be needed.
The correct value can be set in the database for CDMA_SUBSCRIPTION_MODE
and that will be taken on power-up by this code.

Change-Id: I11fff596a5fe721c64f192c889672326517dc43d

Conflicts:
	src/java/com/android/internal/telephony/PhoneFactory.java
Telephony: Add new apn.sim.operator_numeric property

Use new property to filter apns. We need this new property
because icc.operator_numeric property is also used in cdma
and ApnSetting UI might display wrong set of apns if the
peroperty value used was set by RuimRecords
CRs-Fixed: 362846

Change-Id: Iba3f5a21797b2a48cbc05cfb0e9b28c60de0c6dd
telephony: Ignore events on a destroyed phone

It is possible to receive responses from RIL after phone has released
it's references. Ignore events in such cases, since those events no
longer make sense, and some phone members have been de-initialized.

Make CallTrackers notify UI when ending calls in dispose, since
it has already unregistered, and won't receive the CALL_STATE_CHANGED

This is the combined CL for I5d8fd9ce3f74b9ae9b5b645565bd24d11be0aebc
and I34dbcea140629cd0c97c12c6ebd0ce2e08e53657
CRs-Fixed: 228731, 228005, 415801, 350739

Change-Id: I0419d8b8cbd221d12b426b35cf5b7298d2aa8d5c
Telephony: Optimizations on alarms used

* Use non wakeup alarms for data stall detection
* Stop data stall alarms during dormancy
CRs-Fixed: 334349

Change-Id: I74945648431245b9b4aaf4e8781855e1d4b76b20
Telephony: Handle RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE

Handle RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE as a way to exit from
Emergency Callback Mode

Change-Id: I78db53a47e1aeccb7e85e7383e1c56a10b687b26
telephony : Support for voicemail in TP-UDH of SMS

Added support for processing special message indication
for voice mail in TP user data header for SMS
Spec reference: 3GPP TS 23.040 V6.8.1

CPHS method does not use message count.
0xff is used to indicate unknown message count for CPHS
Ref[Adapt requirement CDR-MWI-120, TC: GSM-BTR-1-4700]

Change-Id: I893252d5cacd5c1c8680a8ca6c3a6dba95ef3e1f
Telephony: Multiparty Call related fix

Block multiple Call switch request to RIL

Sending a call switch request to RIL before receiving
a response for the previous request causes the lower
layers to not respond. Pending responses from RIL
block the call polling in telephony.
CRs-Fixed: 269330, 278014, 282061, 293727, 441309

Change-Id: I078945f7427fdc7b2b26d6563bc117a3dd4fc9c4
CatService: OPEN_CHANNEL p-cmd to send event confirmation and not T.R

Upon handling OPEN_CHANNEL command, send User confirmation instead of
terminal response as lower layers expect confirmation information.
CRs-Fixed: 390425

Change-Id: I5ff24405d095c2a51fde83abe99511cb08814456
Move ConnectTimeReal to base class Connection.java

Move ConnectTime Real from derived classes GsmConnection
and CdmaConnection to Connection base class.
This gives the flexibility
to access ConnectTimeReal from different derived classes
using base class object.
This is needed to transfer time from ImsConnection
to CS connection for SRVCC.

Change-Id: I4f2a834f9df27514373de22a1c71d3923b66dc14
CRs-Fixed: 412754
Conflicts:
	src/java/com/android/internal/telephony/cdma/CdmaConnection.java
	src/java/com/android/internal/telephony/gsm/GsmConnection.java
CatService: Alpha ID fix for OPEN_CHANNEL and other p-commands

p-cmds that support the below mentioned scenarios:
- SETUP CALL
- OPEN CHANNEL
- SEND DTMF
- SEND SMS
- SEND SS
- SEND USSD
- LAUNCH BROWSER
- PLAY TONE
- SELECT ITEM

Senarios handled :
- NO ALPHA ID : Introduce a new configurable sys prop
  "persist.atel.noalpha.usrcnf".
   --  Allow display of default UI confirmation if prop is set to true
   --  No UI confirmation to be show if prop is set to false
- NULL ALPHA ID (len = 0 ) :
   -- NO UI confirmation to be displayed

Change-Id: Ie211c9765a21c9c584ce8420b51cfe59476234cc
CRs-Fixed: 344570
Conflicts:
	src/java/com/android/internal/telephony/cat/CatService.java
Telephony: Specify file path when reading contacts from EF_ADN

Some cards, like RUIM and UICC with CSIM, have the same file ID for
multiple EFs. e.g. EF_ADN and EF_CSIM_LI. When trying to retrieve
the EF_ADN from such a card, the path gets mapped to that of
EF_CSIM_LI resulting in incorrect behavior.

To avoid this, specify the EF Id and the path to uniquely identify
EF_ADN, when reading contacts.
CRs-Fixed: 428259

Change-Id: I2dd94192d5db51b569c02ac1a46e8fcd71910a47
Telephony: Introduce DataProfile base class

DataProfile is a base class from which we derive ApnSetting.
This can be extended for other classes of DataProfiles.

Change-Id: I34f78ac22c82446bb74f538899d637656e0134ca
Telephony: Set digit_mode to 8 bit in case when ton set to 1

C.S0005 requires that digit_mode parameter in mobile originated
cdma sms address needs to be set to 8 bit when type_of_number
parameter is present.
CRs-Fixed: 295542

Change-Id: I3077d9a7b09933732bbff8119308ae3de6259821
Use EF_EXT5 as extension for EF_MSISDN on USIM

For USIM applications, use EF_EXT5 as the extension for EF_MSISDN
as per TS 31.102 Section 4.2.37

Change-Id: Ib3bd3d8160d73fcc02b80ef420d8c8f2ffb4992f
CRs-Fixed: 433379
Conflicts:
	src/java/com/android/internal/telephony/uicc/SIMRecords.java
Telephony: DataProfile priorities/arbitration

* Add flag to disable MPDN support
* Introduce priorities for different APN Types
* Create data calls in a prioritized order, tearing
  down lower priority calls if required.
Conflicts:
	src/java/com/android/internal/telephony/Phone.java
	src/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java
	src/java/com/android/internal/telephony/dataconnection/ApnContext.java
	src/java/com/android/internal/telephony/dataconnection/DcTracker.java
	src/java/com/android/internal/telephony/dataconnection/DcTrackerBase.java

Change-Id: I5f54eaa7a9af54c59c199c2f8e83d3435166e8c3
Telephony: Set RESULT tag properly when sending TR

While encoding terminal response, result tag is
encoded mistakenly as device identities tag, which
is rectified in current change.
CRs-fixed: 481803

Change-Id: Ia9a1334c9e1350e2e6cdaa66eb1e0673e5de9d46
opt/telephony: Handle ICC IO error

Following changes have been made as part of this:
-> At present in Android all ICC Card states other than ICC
   PRESENT are treated as ICC ABSENT. Adding functionality
   to handle ICC IO error card state.
->IccCardProxy broadcasts card error intent when application index
  received from UIM is invalid(i.e.mUiccAplication is null) during
  initialization of card for fraction of time. As a result of which
  "Invalid Card" is displayed on UI momentarily.

Change-Id: I6489e5be0b64073c70bd12db645a4ac25b34af39
  To fix this, When app index received from UIM is invalid broadcast
  "NOT_READY" intent.
CRs-Fixed: 184479 399597
Frameworks: Add ADN capabilities for CDMA phone

CDMA can support Abbreviated Dialing Numbers so add
CDMA in TelephonyCapabilities.

Change-Id: Ia33618d42664560f33bfa5b995b89cd030ee20de