[WIP]telephony: RIL: import and fix SAMSUNG RIL

This is a squashed commit of the following commits plus some fixes made by me:
-Some functions used in the imported files have changed their types
-Some constants changed their names
-Some functions need to be changed from private to protected -> I've used
https://github.com/omnirom/android_frameworks_opt_telephony/commit/ca385b311c763964ae28d9643e76bbdfa1f0549a as a reference (cherrypicking this caused lots of merging
problems so I remodified the needed parts)

This needs https://gerrit.omnirom.org/10594 to compile

PS2: Just tried it compiles fine now but RIL isn't fixed (on n8000)
PS3: Fix a writing to a null pointer array
PS4: As Jason Voorhees suggested I've imported https://github.com/CyanogenMod/android_device_samsung_d2-common/commit/761ee9bf817c6ae82e8b0c974a21de8d974bebee and fixed
the build with this
PS5: Added here https://gerrit.omnirom.org/#/c/10600/ and https://gerrit.omnirom.org/#/c/3865/

Squashed commits:

telephony: Use reflection to create command interface (RIL class)

I needed to change a bit this commit from android-4.4 tree to make it compile and support new android changes (multisim support)

original commit:

Author: Pawit Pornkitprasan <p.pawit@gmail.com>
Date: Thu Nov 22 19:01:13 2012 +0100

Use reflection to create command interface (RIL class)

Change-Id: Icdc02eaa74b89dbde4ddfb989cc62481d6423312

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

fw_opt_telephony: Fix RIL for all Samsung devices

By SferaDev and jakew02

Add Samsung RIL files from CM

Fix dependencies and errors at RIL.java

Create Operators.java

RIL: Add compatibility with qcom's DSDS:
Devices with radio libraries built against a DSDS-enabled qualcomm
BSP (anything in the last 4 or 5 months, apparently) have a slight
incompatibility in the RIL protocol: it expects the first 4 bytes
of the datastream to be the slot's identification (even if the
device isn't dual-SIM). Absence of those 4 bytes will make the
connection hang.

Change-Id: Ie5894e4cf639b57b0e44bf63d6abb414448e9da0

Conflicts:
	src/java/com/android/internal/telephony/CommandsInterface.java
	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

Change-Id: Ie84aa61964f8af35673536efba7b433f273fd248

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

PhoneFactory: fall back to default RIL if custom RIL Class fails

If the ro.telephony.ril_class property is set to an invalid class it will cause
Phone to repeatedly FC and make the device unuseable. This allows it to handle the
exceptions gracefully and fall back on the default RIL.

Change-Id: Ic9c309aff173de5267aa7ef633bfff87243f24fd

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

Change-Id: Ie74c12392c40e0c996240505e066978f37dbf5c6

Conflicts:
	src/java/com/android/internal/telephony/PhoneFactory.java
	src/java/com/android/internal/telephony/RIL.java
	src/java/com/android/internal/telephony/imsphone/ImsPhoneCommandInterface.java
Fix mismerge

Conflicts:
	src/java/com/android/internal/telephony/RIL.java
Rename some constants
UiccController: Query GET_SIM_STATUS when radio state is ON

mCi.registerForAvailable resulted in the SIM query firing off
too quickly and resulted in the SIM initially being identifed
as ABSENT.

Change-Id: Iaef6ffe1315560262e19ebacd304716982bb8174
cm11 ril
Telephony: DcTracker: Fix CDMA APN Data issues.

Fix CDMA data issue when it can't find an APN match. This fixes cases
CDMA NV or RIUM/SIM doesn't have the information to pass on.
It assumes GSM like mode on CDMA. So fix that and pass on to CDMA
stubbed apn found in android 4.2.

Change-Id: I53a229de353bae34b7180ef3e7253d83d1f9d20c
Moar hacks...
Heck with it, just do it the easy way.