Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 61a5ab57 authored by Wink Saville's avatar Wink Saville Committed by Android Git Automerger
Browse files

am f89ea7a5: Merge "Change getLteOnCdmaModeStatic to dynamically determine its...

am f89ea7a5: Merge "Change getLteOnCdmaModeStatic to dynamically determine its result." into honeycomb-LTE

* commit 'f89ea7a5':
  Change getLteOnCdmaModeStatic to dynamically determine its result.
parents 070a19e0 f89ea7a5
Loading
Loading
Loading
Loading
+62 −3
Original line number Original line Diff line number Diff line
@@ -26,6 +26,11 @@ import android.os.SystemProperties;
import android.util.Config;
import android.util.Config;
import android.util.Log;
import android.util.Log;


import java.io.FileInputStream;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
/**
 * {@hide}
 * {@hide}
 */
 */
@@ -794,6 +799,34 @@ public abstract class BaseCommands implements CommandsInterface {
    protected void onRadioAvailable() {
    protected void onRadioAvailable() {
    }
    }


    /**
     * 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}
     * {@inheritDoc}
     */
     */
@@ -802,6 +835,17 @@ public abstract class BaseCommands implements CommandsInterface {
        return getLteOnCdmaModeStatic();
        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
     * Return if the current radio is LTE on CDMA. This
     * is a tri-state return value as for a period of time
     * 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}
     * or {@link Phone#LTE_ON_CDMA_TRUE}
     */
     */
    public static int getLteOnCdmaModeStatic() {
    public static int getLteOnCdmaModeStatic() {
        int retVal = SystemProperties.getInt(TelephonyProperties.PROPERTY_NETWORK_LTE_ON_CDMA,
        int retVal;
                Phone.LTE_ON_CDMA_FALSE);
        String productType;
        Log.d(LOG_TAG, "getLteOnCdmaMode=" + retVal);

        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;
        return retVal;
    }
    }
}
}
+5 −3
Original line number Original line Diff line number Diff line
@@ -72,10 +72,12 @@ public interface TelephonyProperties
     */
     */
    static final String PROPERTY_OPERATOR_ISO_COUNTRY = "gsm.operator.iso-country";
    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";
    static final String CURRENT_ACTIVE_PHONE = "gsm.current.phone-type";