Example usage for android.telephony ServiceState getClass

List of usage examples for android.telephony ServiceState getClass

Introduction

In this page you can find the example usage for android.telephony ServiceState getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:org.restcomm.app.utillib.DataObjects.PhoneState.java

public static int getVoiceNetworkType(ServiceState serviceState) {
    Method m = null;//  ww w. j a v  a2 s.  com
    try {
        // Java reflection to gain access to TelephonyManager's
        // ITelephony getter
        Class c = Class.forName(serviceState.getClass().getName());
        Method mI = c.getDeclaredMethod("getRilVoiceRadioTechnology");
        mI.setAccessible(true);
        int voiceTechRil = (Integer) mI.invoke(serviceState);
        int voiceTech = PhoneState.rilRadioTechnologyToNetworkType(voiceTechRil);
        return voiceTech;
    } catch (Exception e) {
        String s = e.toString();
        //LoggerUtil.logToFile(LoggerUtil.Level.ERROR, TAG, "getVoiceNetworkType", "exception", e);
    }
    return -1;
}

From source file:org.restcomm.app.utillib.DataObjects.PhoneState.java

private String listServiceStateFields(ServiceState cell) {
    if (cell != null) {
        String strCells = "";

        Field[] fields = null;/*w ww  . ja v a 2 s.  c o m*/
        try {
            fields = cell.getClass().getDeclaredFields();
            int i;
            for (i = 0; i < fields.length; i++) {
                fields[i].setAccessible(true);
                if (fields[i].getName().indexOf("m") == 0) {
                    strCells += fields[i].getName() + "=";
                    if (fields[i].get(cell) == null)
                        strCells += "null";
                    else
                        strCells += fields[i].get(cell).toString() + ",";
                }
            }

            return strCells;
        } catch (SecurityException e) {
            LoggerUtil.logToFile(LoggerUtil.Level.DEBUG, TAG, "listServiceStateFields", "SecurityException", e);
        } catch (Exception e) {
            LoggerUtil.logToFile(LoggerUtil.Level.DEBUG, TAG, "listServiceStateFields", "exception", e);
        }
    }
    return "";
}

From source file:org.restcomm.app.utillib.DataObjects.PhoneState.java

private String listSignalFields(ServiceState serviceState) {
    int i;/*from   ww  w  .  j a va 2s .  c  o m*/
    SignalEx mmcsignal = getLastMMCSignal();
    String strSignals = "";
    if (mmcsignal != null && !mmcsignal.isUnknown()) {
        Object signalStrength = mmcsignal.getSignalStrength();

        Field[] fields = null;
        try {
            fields = signalStrength.getClass().getDeclaredFields();

            for (i = 0; i < fields.length; i++) {
                fields[i].setAccessible(true);
                //if (!fields[i].getName().equals("CREATOR") && !fields[i].getName().equals("LOG_TAG") &&
                //      fields[i].getName().indexOf("INVALID") == -1 && fields[i].getName().indexOf("STRENGTH") == -1)
                if (fields[i].getName().toLowerCase().substring(0, 1)
                        .equals(fields[i].getName().substring(0, 1))) {
                    try {
                        strSignals += fields[i].getName() + "=";
                        if (fields[i].get(signalStrength) != null)
                            strSignals += fields[i].get(signalStrength).toString() + ",";
                        else
                            strSignals += "null";
                    } catch (Exception e) {
                        LoggerUtil.logToFile(LoggerUtil.Level.DEBUG, TAG, "listSignalFields", "exception", e);
                    }
                }
            }
        } catch (SecurityException e) {
            LoggerUtil.logToFile(LoggerUtil.Level.DEBUG, TAG, "listSignalFields", "SecurityException", e);
        } catch (Exception e) {
            LoggerUtil.logToFile(LoggerUtil.Level.DEBUG, TAG, "listSignalFields", "exception", e);
        }
    }
    if (serviceState != null) {
        Field[] fields = null;
        try {
            fields = serviceState.getClass().getDeclaredFields();
            for (i = 0; i < fields.length; i++) {
                fields[i].setAccessible(true);
                if (fields[i].getName().toLowerCase().substring(0, 1)
                        .equals(fields[i].getName().substring(0, 1))) {
                    try {
                        strSignals += fields[i].getName() + "=";
                        if (fields[i].get(serviceState) != null)
                            strSignals += fields[i].get(serviceState).toString() + ",";
                        else
                            strSignals += "null";
                    } catch (Exception e) {
                        LoggerUtil.logToFile(LoggerUtil.Level.DEBUG, TAG, "listSignalFields", "exception", e);
                    }
                }
            }
            //MMCLogger.logToFile(MMCLogger.Level.DEBUG, TAG, "listSignalFields", strSignals);

        } catch (SecurityException e) {
            LoggerUtil.logToFile(LoggerUtil.Level.DEBUG, TAG, "listSignalFields", "SecurityException", e);
        } catch (Exception e) {
            LoggerUtil.logToFile(LoggerUtil.Level.DEBUG, TAG, "listSignalFields", "exception", e);
        }
    }
    return strSignals;
}