RIL: Make RIL subclassable

Change-Id: I9144ef279ca9c8cb9e657a28342f0f4cb3e7debd

Conflicts:
	src/java/com/android/internal/telephony/RIL.java
telephony: Use reflection to create command interface (RIL class)

Change-Id: Icdc02eaa74b89dbde4ddfb989cc62481d6423312
telephony: Reintroduce the old ICS RadioStates

All the previous SIM/RUIM states are now equivalent to "RADIO_ON".
Tested with a fully ICS-compliant set of radio libraries, and appears
to work fully.

Change-Id: Id34320c59a316e2b6747bd3a48077b863ab772d6

Conflicts:
	src/java/com/android/internal/telephony/RIL.java
telephony: add SamsungExynos4RIL class

Forward ported from CM10 including contributions from:
Andrew Dodd<atd7@cornell.edu>
Daniel Bateman <jetison.24@gmail.com>
Daniel Hillenbrand <codeworkx@cyanogenmod.org>
Ethan Chen <intervigil@gmail.com>
Lee Chu <lee.lc.chu@gmail.com>
Mike Kasick <mike@kasick.org>

Change-Id: Ibc33a866a02a88b346ae30aa6f09a398edfc79c1

Conflicts:
	src/java/com/android/internal/telephony/RIL.java
RIL: squashed support for old RIL

	commit 6536e023ed1523b6184da5d5704570fb3e24f01a
	Author: Emilio López <turl@tuxfamily.org>
	Date:   Fri Oct 12 16:45:29 2012 +0000

	    telephony: let us write just the aid on getIMSIForApp

	    This implements a new RIL compatibility feature, "writeaidonly", that
	    lets us write just the aid, without the preceding 1. This is needed to
	    be able to read the IMSI correctly on some Motorola RILs

	    Change-Id: I48e9d76db6730571c01d59313fc7a5e79845f922

	commit e470d722cc6fc5705d6e407a90f34692f019129f
	Author: Hashcode <hashcode0f@gmail.com>
	Date:   Mon Sep 24 11:29:48 2012 -0700

	    ril: avoid sending null aid string in getIMSI

	    A change to how getIMSI works in JB causes null aid strings
	    to be sent.  The result for RILs older than v7 is a corrupt
	    ril response in SIMRecords::fetchSimRecords.  This corruption
	    ends up setting mImsi to null (in SIMRecords) and that causes
	    havoc w/ 3g/4g data connections.

	    This patch avoids sending null aid strings and has fixed
	    data connection issues on several Motorola devices.

	    This new patch is implemented as an opt-in old ril feature

	    Change-Id: I6682ea10c8b216e2adc5abffbcc50f3cb6c9d7b8

	commit 16cd02ad6f9679ed5895d53e9d07fef3ee9d3240
	Author: Robert Burns <burnsra@gmail.com>
	Date:   Tue Sep 25 09:33:24 2012 -0400

	    Revert "ril: avoid sending null aid string in getIMSI"

	    This reverts commit 4b785569b338d150dccdb5bb6d3a290b068e603c.

	    This change has been verified as breaking network for toro/toroplus.

	    Change-Id: I74e43acd10d4b38e149acf55e08537430f871139

	commit 814e909c879621101640128fe0a0c9f0ad2ef504
	Author: codeworkx <codeworkx@cyanogenmod.com>
	Date:   Tue Sep 25 13:06:15 2012 +0200

	    ril: dedup mRilVer

	    Change-Id: I665b5c1c502d3cc49d2b3343a2e9eafc8b8e5a77

	commit 69292881c8c120c90852d306a5c312a07dd19c10
	Author: codeworkx <codeworkx@cyanogenmod.com>
	Date:   Tue Sep 25 02:51:18 2012 +0200

	    fix build: add missing instance variable mRilVer

	    Fixes commit 4b785569b338d150dccdb5bb6d3a290b068e603c

	    Change-Id: Id239285aff6997eaa42521b695b6812029f580c1

	commit 4b785569b338d150dccdb5bb6d3a290b068e603c
	Author: Hashcode <hashcode0f@gmail.com>
	Date:   Mon Sep 24 11:29:48 2012 -0700

	    ril: avoid sending null aid string in getIMSI

	    A change to how getIMSI works in JB causes null aid strings
	    to be sent.  The result for RILs older than v7 is a corrupt
	    ril response in SIMRecords::fetchSimRecords.  This corruption
	    ends up setting mImsi to null (in SIMRecords) and that causes
	    havoc w/ 3g/4g data connections.

	    This patch avoids sending null aid strings and has fixed
	    data connection issues on several Motorola devices.

	    Change-Id: Ic1fc363e35d79793c48d19080a2e028e428b888f

	commit 154221766ac6bcb1c0af549377e65a8c8ec5d0a0
	Author: Ethan Chen <intervigil@gmail.com>
	Date:   Mon Sep 3 01:21:04 2012 -0700

	    RIL: make data call APN a selectable RIL feature

	    Disabling this for all RIL versions above 3 can cause issues with some
	    device RILs and establishing a data connection.

	    Change-Id: I7be41b120663b0839beec95c22d0615f5e79c582

	commit d76a3247a3547e7c7a95a13db7cfa1ec2a061f3d
	Author: Mike Kasick <mike@kasick.org>
	Date:   Thu Aug 30 13:42:27 2012 -0400

	    RILs: Eliminate repeated overrides of responseOperatorInfos.

	    - Add mQANElements field, default to 4 in RIL, use in responseOperatorInfos.
	      This may be set to 5 in subclassed RIL constructors.

	    - Remove repeated overrides of responseOperatorInfos by subclassed RILs, as
	      there's no logic change, just a disagreement as to whether the
	      QUERY_AVAILABLE_NETWORKS response is an array with 4 or 5 per-network
	      elements.

	    - Size OperatorInfo ArrayList appropriately in SemcRIL and SonyQualcommRIL.

	    Change-Id: I1254a670d8611f76aad13a6f197c67012c7d4c47

	commit b40a14246e50429d91e603a64d6baac7813699d1
	Author: Janne Grunau <j@jannau.net>
	Date:   Tue Aug 14 22:32:08 2012 +0200

	    RIL: fix protocol mismatch for DataConnectionState_v4

	    The apn got dropped in DataConnectionState v4.

	    Avoids UnknownHostExceptions in DataCallState.setLinkProperties().

	    Change-Id: Icd0a1ba1c77cead13b15b3749965edead5f59135

	commit 431c19a5ef39003383de3fc44c636f8d03e74a17
	Author: isimobile <isimobile@ismaakit.com>
	Date:   Wed Jan 11 21:34:47 2012 +0200

	    telephony: Added support for use of Honeycomb Radio (Modem).

	    -squashed (RIL: reference ICS and GB):
	    https://github.com/isimobile/android_frameworks_base/commit/7507127287aa8cf84b5e811977d95400b029f95b
	    https://github.com/isimobile/android_frameworks_base/commit/af2b84d1860b38952784ae116172e00a4b445a1d
	    https://github.com/isimobile/android_frameworks_base/commit/872156a81fb4185217e7642d10ec33da4893a2b3
	    https://github.com/isimobile/android_frameworks_base/commit/400bbc4e3ce8e9e0219b31bb985e6628c50d0f07
	    https://github.com/isimobile/android_frameworks_base/commit/7cb289d9e59ac69350dd2377eff63940641df603

	    -cleaned up some whitespace

	    Change-Id: I3a3474245bb336bc3f275605648f5f94f3f9b6e7

	    Conflicts:

	    	telephony/java/com/android/internal/telephony/DataConnection.java

	commit 87ee134d8a0a09ff5c824450969207fa66531f2f
	Author: Emilio López <turl@tuxfamily.org>
	Date:   Thu Dec 1 21:35:21 2011 +0000

	    RIL: skip broken RIL_UNSOL_DATA_CALL_LIST_CHANGED

	    Some old RILs might produce events with type 'IP' containing the remote IP
	    address, normally 10.64.64.64. These events mismatch with the previously
	    generated ones and cause the system to take the connection down, even if
	    it was up and working correctly.

	    Add skipbrokendatacall to ro.telephony.ril.v3 to enable the workaround.

	    Change-Id: I3bc3c84735201a797011aafba2718638a826f31d

	commit b2cfc6f82f75fe47e5ca66ac7ee5bab1740f4a45
	Author: Tom Giordano <tomgiordano83@gmail.com>
	Date:   Mon Nov 28 02:51:53 2011 +1100

	    v3 RIL: another getDataCallState fix

	    Change-Id: Ie4e69e231956f46bc1b82550fdf4863c1367efaf

	commit 16330ce5c921792115bc796a3229057491524915
	Author: Pawit Pornkitprasan <p.pawit@gmail.com>
	Date:   Sun Nov 27 09:17:19 2011 +0700

	    v3 RIL: Fix getDataCallState and PIN setting

	    Change-Id: Icf5cee33aeec58cffb23430f0f7b06b9971a71ad

	commit 3f730cc1055739dc4cbf53b44acf9c254c43a52b
	Author: Koushik Dutta <koushd@gmail.com>
	Date:   Fri Nov 25 17:23:58 2011 -0800

	    Break the legacy ril shims into specific features. The ICC feature breaks crespo, but crepso needs the signal strength feature.

	commit 6b09342ad9131754eeaa733364c2f4474a10bde7
	Author: Emilio López <turl@tuxfamily.org>
	Date:   Sun Nov 20 22:12:28 2011 +0000

	    RIL: handle the lack of version gracefully on older RILs

	    Change-Id: I8227c55968f502112c5b6ac334eee505c29924c2

	commit 913255a820cfcb99a6d89ca036eba53c110adea2
	Author: Kolja Dummann <k.dummann@gmail.com>
	Date:   Mon Nov 21 22:27:45 2011 +0100

	    RIL: fix pin unlock for old ril

	    Change-Id: I27eb348233d41618875473ca9bdb93d339c359f9

	commit 27b873d14816282bab22db8a5920ca01466d36d0
	Author: Ricardo Cerqueira <github@cerqueira.org>
	Date:   Thu Nov 17 11:16:23 2011 +0000

	    RIL: Support signal strength format from v3 vendor RILs

	    Enable by setting property ro.telephony.ril.v3=1

Change-Id: I2eb23ab5d17d15ed71e5777dcd368d47c87e29ef

Conflicts:
	src/java/com/android/internal/telephony/CommandsInterface.java
	src/java/com/android/internal/telephony/RIL.java
	src/java/com/android/internal/telephony/sip/SipCommandInterface.java
	src/java/com/android/internal/telephony/test/SimulatedCommands.java
telephony: add SamsungExynos3RIL

forward ported from CM10 SamsungRIL

	commit 9cfdf50438f603196cd3c75b92ae5346968c2b6d
	Author: Pawit Pornkitprasan <p.pawit@gmail.com>
	Date:   Thu Aug 2 20:24:38 2012 +0700

	    SamsungRIL: Fix data connection after pin unlock

	    If the user has PIN-locked his phone, data connectivity will not
	    work because the RIL sends APPSTATE_UNKNOWN and does not update
	    it to APPSTATE_READY. We inject the state update if there's a
	    signal change.

	    Change-Id: Id64e95ebcadd1d7ff181f8d9c2ee4f18e6ae48f1

	commit 7e06e52d2c23443a28c8ad756fe7ac9b883e6ba9
	Author: Pawit Pornkitprasan <p.pawit@gmail.com>
	Date:   Tue Jul 24 22:43:02 2012 +0700

	    SamsungRIL: Update HSDPA checking for jellybean

	    Jellybean no longer publish network type id to prop, don't check for it

	    Change-Id: I689aa448853677a8719af963bf3370abaefdaf23

	commit caa215a26a958962b3e24b0f193698547ac7e317
	Author: Pawit Pornkitprasan <p.pawit@gmail.com>
	Date:   Wed Jul 18 10:54:08 2012 +0700

	    SamsungRIL: cleanup

	    Removed unneeded states and forward them to RIL. In ics, this had
	    the side-effect of allowing STK to work due to the Samsung STK
	    implementation already in place

	    cherry-picked from ics

	    stk functionality for SamsungRIL

	    * Implemented SMS based SIM application functionality
	    * PatchSet 3: Added fix so unknown unsolicited response are sent to super class
	    * PatchSet 4: Removed "import android.content.resources" - not needed any more
	    * PatchSet 5: processUnsolicited cleanup, using super class standard states where possible
	    * Patchset 6: Rebased

	    Change-Id: I9bf844da1480fe442f851fb20d99b530b96cfa4c

	commit 3f876005b1c6c39a62c4eee3d5e54a3bc36e7faa
	Author: Daniel Bateman <jetison.24@gmail.com>
	Date:   Sat Jul 14 11:27:07 2012 +0200

	    samsung ril: add UNSOL_AM implementation

	    * The Samsung RIL will sometimes send up an UNSOL_AM
	    request which is to be handled by the "am" service.
	    (For example when the RIL resets)

	    Change-Id: Ifc8ead91f2dbc39456c4a502b9623c608c796224

	commit acdff5c2f175127fd2fdfc6ef4ae511b0f4bc329
	Author: sbrissen <sbrissen@Hotmail.com>
	Date:   Fri May 25 09:27:31 2012 -0400

	    Fix for Signal bars on Samsung devices

	    Sometimes the CDMA ecio value is sent as a negative integer where we would expect a positive.
	    This causes SignalStrength.java to mark ecio as -160 (Unknown_Signal_Strength) and making signal bar
	    s clear out.
	    This "fix" checks the ecio value and takes it absolute value if it is negative.

	    Confirmed working on SCH-I500 and SPH-D710

	    Change-Id: Ic515dd6c92193cd5db75adf5bef93ecd617a5c6a

	commit 6308cb5329de73292665d8c8d538b09b4fe97fb3
	Author: Daniel Bateman <jetison.24@gmail.com>
	Date:   Mon Apr 23 22:24:01 2012 -0500

	    telephony: SamsungRIL cleanup

	    == RIL ==
	    * remove unused "found" boolean in processSolicited
	    * make requestToString/repsonseToString append the request
	      ID on unknown requests.

	    == Samsung RIL ==
	    * add CM copyright header to file
	    * SAMSUNG_UNKNOWN_MAGIC_REQUEST_3 is actually UNSOL_AM
	    * add DIAL_EMERGENCY to a SamsungRIL::requestToString
	    * add DIAL_EMERGENCY response to processSolicited
	    * move emergency dialing into dialEmergencyCall()
	    * dialEmergencyCall() also ditches UUS info like on stock.
	    * cleanup and improve readibility of responseCallList()
	    * move isVideo before isVoicePrivacy, as it is in stock:
	        ref "stock" code: http://pastebin.com/WePMyXDi
	        ref "stock" order: isMpty then isMT then als then isVoice then isVideo
	                           then isVoicePrivacy
	        ref cm code: http://pastebin.com/UU105gNr
	        ref cm order: isMpty then isMT then als then isVoice then
	                      isVoicePrivacy then "videoMagic"
	    * general cleanup

	    Change-Id: Ic4ada0a3d6ac1bf580b3930a2599a91e822540ef

	    Conflicts:

	    	telephony/java/com/android/internal/telephony/RIL.java

	commit e96b94500359b13fbbc186bf8b03418d82449f09
	Author: Daniel Bateman <jetison.24@gmail.com>
	Date:   Tue Apr 17 03:01:20 2012 -0500

	    SamsungRIL: clean up and re-organization

	    Clean up some messy code in the Samsung RIL.

	    Change-Id: If8bc9c0e4264de5919be1b6a858896076c879708

	commit 7a3d8a991067e957ccd6b0159951f4b98d6d98f5
	Author: Mike Kasick <mike@kasick.org>
	Date:   Sat Mar 3 13:16:42 2012 -0500

	    SamsungRIL: Fixes for CDMA data reconnection failures due to stale pppd

	    Occasionally the CDMA data connection fails to reconnect after various
	    radio events, which is fixed neither by toggling mobile data nor airplane
	    mode, but only by a reboot.  One known cause of this problem is that the
	    pppd_cdma service is occasionally left running after the radio event, which
	    causes all subsequent "setup data call" operations to fail.  These two
	    fixes address the stale pppd_cdma service issue:

	    - Move the pppd_cdma service shutdown (set ril.cdma.data_state=0) from the
	      "deactivate data call" response to its request.  This avoids the issue
	      where the response never comes (radio crash?), and thus, the service is
	      never stopped.

	    - Force pppd_cdma service shutdown on a "setup data call" failure.  This
	      allows subsequent setup attempts to succeed in the event that the
	      "deactivate" request was never made (unexpected radio poweroff).

	commit 3f647c94c54e8861cfe1b75120903c303a423ddb
	Author: Mike Kasick <mike@kasick.org>
	Date:   Fri Feb 3 16:23:03 2012 -0500

	    Add more CDMA SamsungRIL fixes.

	    Adds a collection of CDMA device fixes to SamsungRIL.  They include:

	    - Overriding ERROR_UNSPECIFIED fail cause with NORMAL_CLEARING, to prevent
	      far-end hangups from displaying the "Call Lost" dialog.

	    - Adding, and ignoring the RIL_UNSOL_GPS_NOTI request, which is also
	      ignored in the TW RIL, to keep the radio log clean of exceptions when the
	      GPS is active.

	    - Workaround for Samsung CDMA "ring of death" bug.  See source comments for
	      details on this problem.

	    Change-Id: Ida4797718ad3463d073a6fc27246cc916526d487

	commit 65d22c288fec6a82d3350c68da0a76163bade668
	Author: Mike Kasick <mike@kasick.org>
	Date:   Sun Jan 29 17:32:13 2012 -0500

	    Fix support for CDMA devices in SamsungRIL.

	    These fixes are ported from jt1134's fascinatemtd patches and CM7.  For
	    CM9, the fixes are applied to SamsungRIL directly instead of elsewhere in
	    the telephony framework.  They include:

	    - Signal strength reporting: pass raw integer values.
	    - Voice registration: convert base station values from hex to dec.
	    - Data call setup/deactivate: start/stop pppd_cdma service and pull network
	      parameters from pppd ip-up script.
	    - CDMA subscription: add missing PRL version from system properties.

	    Changes from CM7:

	    Note use of "ril.cdma.data_state" property instead of
	    "ril.cdma.data_ready".  This property has three states:

	    - Disconnect(ed): ril.cdma.data_state=0: stop pppd_cdma service.
	    - Connecting:     ril.cdma.data_state=1: (re)start pppd_cdma.
	    - Connected:      ril.cdma.data_state=2: pppd_cdma has responded.

	    The disconnect (0) and connecting (1) states are set by SamsungRIL on the
	    deactivation and setup, respectively, of a data call.  Prior to setting the
	    connecting (1) state, SamsungRIL sets the "net.cdma.datalinkinterface" for
	    pppd_runner's use.

	    After setting to the connecting (1) state, SamsungRIL waits for pppd_cdma
	    to respond by (itself) setting the connected (2) state.  This should be
	    done at the end of a /system/etc/ppp/ip-up script, after that script sets
	    the following interface values, which SamsungRIL uses to complete the data
	    call state:

	    - net.cdma.ppp.interface: $IFNAME (typically "ppp0")
	    - net.$IFNAME.local-ip:   pppd's local IPv4 address
	    - net.$IFNAME.remote-ip:  pppd's remote IPv4 address
	    - net.$IFNAME.dns1:       pppd's primary DNS address
	    - net.$IFNAME.dns2:       pppd's secondary DNS address

	commit 0b4354118b72c23d5ce003b065b42a1d9e3c5155
	Author: Pawit Pornkitprasan <p.pawit@gmail.com>
	Date:   Sat Jan 14 13:47:19 2012 +0700

	    telephony: Add SamsungRIL

	    Patch Set 2: Fix Emergency calling for Samsung CDMA

	    Patch Set 3: Do not extraneously send RIL poll requests due to extraneous HSDPA update

	    Patch Set 4: Remove extraneous import accidentally added in Patch Set 3

	    commit 91cb0a82f785539986ee4f6ef95ccd8c789121d5
	    Author: Pawit Pornkitprasan <p.pawit@gmail.com>
	    Date:   Mon Dec 19 17:53:40 2011 +0700

	        SamsungRIL: ignore setCurrentPreferredNetworkType

	        Change-Id: Ifa87949da3d807803db932e31c6c2dd053040c9c

	    commit b578cdb7bf0222a05af65cb09cdfc53aa7457328
	    Author: Daniel Hillenbrand <info@codeworkx.de>
	    Date:   Mon Dec 12 18:32:35 2011 +0100

	        SamsungRIL: added unknown unsol request 11010

	    commit 259ccc34d53a0067c730c616814c0ec5fc788d95
	    Author: Pawit Pornkitprasan <p.pawit@gmail.com>
	    Date:   Sun Nov 27 12:06:34 2011 +0700

	        SamsungRIL: Always use v3 signal strength

	        Our signal processing wouldn't make sense without it anyway.

	        Change-Id: Ie101d6b220b00383aa18a9ac2c66e2ef786b7467

	    commit 1f5730d26e7e0dece905192b4dab6340336a8a21
	    Author: Pawit Pornkitprasan <p.pawit@gmail.com>
	    Date:   Fri Nov 18 21:15:34 2011 +0700

	        SamsungRIL: Fix datacall

	    commit 1838b577a899a1f5259327361d95fe64f706c8e8
	    Author: Pawit Pornkitprasan <p.pawit@gmail.com>
	    Date:   Fri Nov 18 13:50:39 2011 +0700

	        SamsungRIL: Fix signal strength

	    commit 1e23a1d363e7514b32703f604bdc96411cc35330
	    Author: Pawit Pornkitprasan <p.pawit@gmail.com>
	    Date:   Thu Nov 17 17:40:56 2011 +0700

	        Brings back SamsungRIL

	    Change-Id: Ice09e25c8657aad0ddb345d240829789f28d18fb

Change-Id: I06ee05b590e603413106a9a20ab85d65d4eb33cf
Allow a device to include its own RIL subclass

For cases where a single device needs a subclass, there's no need to
pollute the common core with it: just stick it in the device's own
repository, and add something like
"BOARD_RIL_CLASS := ../../../device/manuf/model/ril/" to the BoardConfig

Change-Id: I9d01ceb6e5587382eb216341e2e373ec0c52848f

Conflicts:
	Android.mk
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
RIL: Underp DataCall

Something went wrong with the old-stuff merge, these lines mess
up the parcel

Change-Id: I74191746fe8baec1a86efdd2e9fee7ffa47fc3e3

Conflicts:
	src/java/com/android/internal/telephony/RIL.java