diff options
author | Wink Saville <wink@google.com> | 2011-05-20 12:12:00 -0700 |
---|---|---|
committer | Wink Saville <wink@google.com> | 2011-05-20 12:27:16 -0700 |
commit | fe071d3d37c8b3e2f332b5ad8c30f02717501153 (patch) | |
tree | 44575bd3a66456cb5b50247848cb6402a5221824 /telephony | |
parent | dbfd055d51b51b7a6f412155c2391666efbb638a (diff) | |
download | frameworks_base-fe071d3d37c8b3e2f332b5ad8c30f02717501153.zip frameworks_base-fe071d3d37c8b3e2f332b5ad8c30f02717501153.tar.gz frameworks_base-fe071d3d37c8b3e2f332b5ad8c30f02717501153.tar.bz2 |
Change getLteOnCdmaModeStatic to dynamically determine its result.
bug: 4202572
Change-Id: I956b61840e2043229df29054dd2a6daccd7a845f
Diffstat (limited to 'telephony')
-rw-r--r-- | telephony/java/com/android/internal/telephony/BaseCommands.java | 65 | ||||
-rw-r--r-- | telephony/java/com/android/internal/telephony/TelephonyProperties.java | 8 |
2 files changed, 67 insertions, 6 deletions
diff --git a/telephony/java/com/android/internal/telephony/BaseCommands.java b/telephony/java/com/android/internal/telephony/BaseCommands.java index aa8c200..e1d8c85 100644 --- a/telephony/java/com/android/internal/telephony/BaseCommands.java +++ b/telephony/java/com/android/internal/telephony/BaseCommands.java @@ -26,6 +26,11 @@ import android.os.SystemProperties; import android.util.Config; import android.util.Log; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + /** * {@hide} */ @@ -795,6 +800,34 @@ public abstract class BaseCommands implements CommandsInterface { } /** + * The contents of the /proc/cmdline file + */ + private static String getProcCmdLine() + { + String cmdline = ""; + FileInputStream is = null; + try { + is = new FileInputStream("/proc/cmdline"); + byte [] buffer = new byte[2048]; + int count = is.read(buffer); + if (count > 0) { + cmdline = new String(buffer, 0, count); + } + } catch (IOException e) { + Log.d(LOG_TAG, "No /proc/cmdline exception=" + e); + } finally { + if (is != null) { + try { + is.close(); + } catch (IOException e) { + } + } + } + Log.d(LOG_TAG, "/proc/cmdline=" + cmdline); + return cmdline; + } + + /** * {@inheritDoc} */ @Override @@ -802,6 +835,17 @@ public abstract class BaseCommands implements CommandsInterface { return getLteOnCdmaModeStatic(); } + /** Kernel command line */ + private static final String sKernelCmdLine = getProcCmdLine(); + + /** Pattern for selecting the product type from the kernel command line */ + private static final Pattern sProductTypePattern = + Pattern.compile("\\sproduct_type\\s*=\\s*(\\w+)"); + + /** The ProductType used for LTE on CDMA devices */ + private static final String sLteOnCdmaProductType = + SystemProperties.get(TelephonyProperties.PROPERTY_LTE_ON_CDMA_PRODUCT_TYPE, ""); + /** * Return if the current radio is LTE on CDMA. This * is a tri-state return value as for a period of time @@ -811,9 +855,24 @@ public abstract class BaseCommands implements CommandsInterface { * or {@link Phone#LTE_ON_CDMA_TRUE} */ public static int getLteOnCdmaModeStatic() { - int retVal = SystemProperties.getInt(TelephonyProperties.PROPERTY_NETWORK_LTE_ON_CDMA, - Phone.LTE_ON_CDMA_FALSE); - Log.d(LOG_TAG, "getLteOnCdmaMode=" + retVal); + int retVal; + String productType; + + Matcher matcher = sProductTypePattern.matcher(sKernelCmdLine); + if (matcher.find()) { + productType = matcher.group(1); + if (sLteOnCdmaProductType.equals(productType)) { + retVal = Phone.LTE_ON_CDMA_TRUE; + } else { + retVal = Phone.LTE_ON_CDMA_FALSE; + } + } else { + retVal = Phone.LTE_ON_CDMA_FALSE; + productType = ""; + } + + Log.d(LOG_TAG, "getLteOnCdmaMode=" + retVal + " product_type='" + productType + + "' lteOnCdmaProductType='" + sLteOnCdmaProductType + "'"); return retVal; } } diff --git a/telephony/java/com/android/internal/telephony/TelephonyProperties.java b/telephony/java/com/android/internal/telephony/TelephonyProperties.java index 4927006..4309309 100644 --- a/telephony/java/com/android/internal/telephony/TelephonyProperties.java +++ b/telephony/java/com/android/internal/telephony/TelephonyProperties.java @@ -72,10 +72,12 @@ public interface TelephonyProperties */ static final String PROPERTY_OPERATOR_ISO_COUNTRY = "gsm.operator.iso-country"; - /** 'true' if device supports both LTE and CDMA mode of operation. - * Availability: Set only on devices supporting LTE and CDMA. + /** + * The contents of this property is the value of the kernel command line + * product_type variable that corresponds to a product that supports LTE on CDMA. + * {@see BaseCommands#getLteOnCdmaMode()} */ - static final String PROPERTY_NETWORK_LTE_ON_CDMA = "telephony.lte_on_cdma"; + static final String PROPERTY_LTE_ON_CDMA_PRODUCT_TYPE = "telephony.lteOnCdmaProductType"; static final String CURRENT_ACTIVE_PHONE = "gsm.current.phone-type"; |