Example usage for android.net ConnectivityManager TYPE_MOBILE_HIPRI

List of usage examples for android.net ConnectivityManager TYPE_MOBILE_HIPRI

Introduction

In this page you can find the example usage for android.net ConnectivityManager TYPE_MOBILE_HIPRI.

Prototype

int TYPE_MOBILE_HIPRI

To view the source code for android.net ConnectivityManager TYPE_MOBILE_HIPRI.

Click Source Link

Document

A High Priority Mobile data connection.

Usage

From source file:com.amazonaws.mobileconnectors.pinpoint.internal.core.system.AndroidConnectivity.java

private void determineAvailability() {
    ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    inAirplaneMode = Settings.System.getInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON,
            0) != 0;// w  w w.  j  a  va2 s  .c  om
    log.info("Airplane mode: " + inAirplaneMode);
    final NetworkInfo networkInfo = cm != null ? cm.getActiveNetworkInfo() : null;
    int networkType = 0;
    // default state
    hasWifi = false;
    // when we have connectivity manager, we assume we have some sort of
    // connectivity
    hasMobile = cm != null;
    // can we obtain network info?
    if (networkInfo != null) {
        if (networkInfo.isConnectedOrConnecting()) {
            networkType = networkInfo.getType();

            hasWifi = networkType == ConnectivityManager.TYPE_WIFI
                    || networkType == ConnectivityManager.TYPE_WIMAX;
            hasMobile = networkType == ConnectivityManager.TYPE_MOBILE
                    || networkType == ConnectivityManager.TYPE_MOBILE_DUN
                    || networkType == ConnectivityManager.TYPE_MOBILE_HIPRI
                    || networkType == ConnectivityManager.TYPE_MOBILE_MMS
                    || networkType == ConnectivityManager.TYPE_MOBILE_SUPL;
        } else {
            // if neither connected or connecting then hasMobile defaults
            // need to be changed to false
            hasMobile = false;
        }
    }
    log.info(String.format("Device Connectivity (%s)",
            hasWifi ? "On Wifi" : (hasMobile ? "On Mobile" : "No network connectivity")));
}

From source file:dev.ukanth.ufirewall.InterfaceTracker.java

private static InterfaceDetails getInterfaceDetails(Context context) {
    InterfaceDetails ret = new InterfaceDetails();

    ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo info = cm.getActiveNetworkInfo();

    if (info == null || info.isConnected() == false) {
        return ret;
    }// ww w  .  j  av  a 2  s  . c  o  m

    switch (info.getType()) {
    case ConnectivityManager.TYPE_MOBILE:
    case ConnectivityManager.TYPE_MOBILE_DUN:
    case ConnectivityManager.TYPE_MOBILE_HIPRI:
    case ConnectivityManager.TYPE_MOBILE_MMS:
    case ConnectivityManager.TYPE_MOBILE_SUPL:
    case ConnectivityManager.TYPE_WIMAX:
        ret.isRoaming = info.isRoaming();
        ret.netType = ConnectivityManager.TYPE_MOBILE;
        ret.netEnabled = true;
        break;
    case ConnectivityManager.TYPE_WIFI:
    case ConnectivityManager.TYPE_BLUETOOTH:
    case ConnectivityManager.TYPE_ETHERNET:
        ret.netType = ConnectivityManager.TYPE_WIFI;
        ret.netEnabled = true;
        break;
    }
    getTetherStatus(context, ret);

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) {
        OldInterfaceScanner.populateLanMasks(context, ITFS_WIFI, ret);
    } else {
        NewInterfaceScanner.populateLanMasks(context, ITFS_WIFI, ret);
    }

    return ret;
}

From source file:com.vonglasow.michael.satstat.GpsEventReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);

    // some logic to use the pre-1.7 setting KEY_PREF_UPDATE_WIFI as a
    // fallback if KEY_PREF_UPDATE_NETWORKS is not set
    Set<String> fallbackUpdateNetworks = new HashSet<String>();
    if (sharedPref.getBoolean(Const.KEY_PREF_UPDATE_WIFI, false)) {
        fallbackUpdateNetworks.add(Const.KEY_PREF_UPDATE_NETWORKS_WIFI);
    }//from   w w  w .j  a  v a  2s . c om
    Set<String> updateNetworks = sharedPref.getStringSet(Const.KEY_PREF_UPDATE_NETWORKS,
            fallbackUpdateNetworks);

    if (intent.getAction().equals(Const.GPS_ENABLED_CHANGE)
            || intent.getAction().equals(Const.GPS_ENABLED_CHANGE)) {
        //FIXME: why are we checking for the same intent twice? Should on of them be GPS_FIX_CHANGE?
        // an application has connected to GPS or disconnected from it, check if notification needs updating
        boolean notifyFix = sharedPref.getBoolean(Const.KEY_PREF_NOTIFY_FIX, false);
        boolean notifySearch = sharedPref.getBoolean(Const.KEY_PREF_NOTIFY_SEARCH, false);
        if (notifyFix || notifySearch) {
            boolean isRunning = false;
            ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
            for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
                if (PasvLocListenerService.class.getName().equals(service.service.getClassName())) {
                    isRunning = true;
                }
            }
            if (!isRunning) {
                Intent startServiceIntent = new Intent(context, PasvLocListenerService.class);
                startServiceIntent.setAction(intent.getAction());
                startServiceIntent.putExtras(intent.getExtras());
                context.startService(startServiceIntent);
            }
        }
    } else if (intent.getAction().equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)
            && updateNetworks.contains(Const.KEY_PREF_UPDATE_NETWORKS_WIFI)) {
        // change in WiFi connectivity, check if we are connected and need to refresh AGPS
        //FIXME: KEY_PREF_UPDATE_WIFI as fallback only
        NetworkInfo netinfo = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
        if (netinfo == null)
            return;
        if (!netinfo.isConnected())
            return;
        //Toast.makeText(context, "WiFi is connected", Toast.LENGTH_SHORT).show();
        Log.i(this.getClass().getSimpleName(), "WiFi is connected");
        refreshAgps(context, true, false);
    } else if ((intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION))
            || (intent.getAction().equals(Const.AGPS_DATA_EXPIRED))) {
        // change in network connectivity or AGPS expiration timer fired
        boolean isAgpsExpired = false;
        if (intent.getAction().equals(Const.AGPS_DATA_EXPIRED)) {
            Log.i(this.getClass().getSimpleName(), "AGPS data expired, checking available networks");
            isAgpsExpired = true;
        }
        NetworkInfo netinfo = ((ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE))
                .getActiveNetworkInfo();
        if (netinfo == null)
            return;
        if (!netinfo.isConnected())
            return;
        String type;
        if ((netinfo.getType() < ConnectivityManager.TYPE_MOBILE_MMS)
                || (netinfo.getType() > ConnectivityManager.TYPE_MOBILE_HIPRI)) {
            type = Integer.toString(netinfo.getType());
        } else {
            // specific mobile data connections will be treated as TYPE_MOBILE
            type = Const.KEY_PREF_UPDATE_NETWORKS_MOBILE;
        }
        if (!updateNetworks.contains(type))
            return;
        if (!isAgpsExpired)
            Log.i(this.getClass().getSimpleName(),
                    "Network of type " + netinfo.getTypeName() + " is connected");
        // Enforce the update interval if we were called by a network event
        // but not if we were called by a timer, because in that case the
        // check has already been done. (I am somewhat paranoid and don't
        // count on alarms not going off a few milliseconds too early.)
        refreshAgps(context, !isAgpsExpired, false);
    }
}

From source file:com.android.development.Connectivity.java

private void onRoutedRequest(int type) {
    String url = "www.google.com";

    InetAddress inetAddress = null;
    try {// w  w w. j  a  v a 2s  .  c o  m
        inetAddress = InetAddress.getByName(url);
    } catch (Exception e) {
        Log.e(TAG, "error fetching address for " + url);
        return;
    }

    mCm.requestRouteToHostAddress(ConnectivityManager.TYPE_MOBILE_HIPRI, inetAddress);

    switch (type) {
    case SOCKET:
        onBoundSocketRequest();
        break;
    case HTTP:
        HttpGet get = new HttpGet("http://" + url);
        HttpClient client = new DefaultHttpClient();
        try {
            HttpResponse httpResponse = client.execute(get);
            Log.d(TAG, "routed http request gives " + httpResponse.getStatusLine());
        } catch (Exception e) {
            Log.e(TAG, "routed http request exception = " + e);
        }
    }

}

From source file:at.alladin.rmbt.android.util.InformationCollector.java

/** Returns the network that the phone is on (e.g. Wifi, Edge, GPRS, etc). */
public int getNetwork() {
    int result = TelephonyManager.NETWORK_TYPE_UNKNOWN;

    if (connManager != null) {
        final NetworkInfo activeNetworkInfo = connManager.getActiveNetworkInfo();
        if (activeNetworkInfo != null) {
            final int type = activeNetworkInfo.getType();
            switch (type) {
            case ConnectivityManager.TYPE_WIFI:
                result = NETWORK_WIFI;/*  w w w.  j  av a  2  s. c  om*/
                break;

            case ConnectivityManager.TYPE_BLUETOOTH:
                result = NETWORK_BLUETOOTH;
                break;

            case ConnectivityManager.TYPE_ETHERNET:
                result = NETWORK_ETHERNET;
                break;

            case ConnectivityManager.TYPE_MOBILE:
            case ConnectivityManager.TYPE_MOBILE_DUN:
            case ConnectivityManager.TYPE_MOBILE_HIPRI:
            case ConnectivityManager.TYPE_MOBILE_MMS:
            case ConnectivityManager.TYPE_MOBILE_SUPL:
                result = telManager.getNetworkType();
                break;
            }
        }
    }

    /* detect change from wifi to mobile or reverse */
    final int lastNetworkType = this.lastNetworkType.get();
    if (result != TelephonyManager.NETWORK_TYPE_UNKNOWN
            && lastNetworkType != TelephonyManager.NETWORK_TYPE_UNKNOWN) {
        if ((result == ConnectivityManager.TYPE_WIFI && lastNetworkType != ConnectivityManager.TYPE_WIFI)
                || (result != ConnectivityManager.TYPE_WIFI
                        && lastNetworkType == ConnectivityManager.TYPE_WIFI))
            illegalNetworkTypeChangeDetcted.set(true);
    }
    if (result != lastNetworkType) {
        this.lastNetworkType.set(result);
        if (telListener != null)
            telListener.onSignalStrengthsChanged(null);
    }

    return result;
}

From source file:com.vonglasow.michael.satstat.ui.RadioSectionFragment.java

/**
 * Updates all cell data./*from w w w  .j  a  v a 2  s .c  om*/
 * 
 * This method is called whenever any change in the cell environment (cells in view or signal
 * strengths) is signaled, e.g. by a call to a {@link android.telephony.PhoneStateListener}. The
 * arguments of this method should be filled with the data passed to the
 * {@link android.telephony.PhoneStateListener} where possible, and null passed for all others.
 * 
 * To force an update of all cell data, simply call this method with each argument set to null.
 * 
 * If any of the arguments is null, this method will try to obtain that data by querying
 * {@link android.telephony.TelephonyManager}. The only exception is {@code signalStrength}, which
 * will not be explicitly queried if missing.
 * 
 * It will first process {@code aCellInfo}, then {@code aLocation}, querying current values from
 * {@link android.telephony.TelephonyManager} if one of these arguments is null. Next it will process
 * {@code signalStrength}, if supplied, and eventually obtain neighboring cells by calling
 * {@link android.telephony.TelephonyManager#getNeighboringCellInfo()} and process these. Eventually
 * it will refresh the list of cells.
 * 
 * @param aLocation The {@link android.telephony.CellLocation} reported by a
 * {@link android.telephony.PhoneStateListener}. If null, the current value will be queried.
 * @param aSignalStrength The {@link android.telephony.SignalStrength} reported by a
 * {@link android.telephony.PhoneStateListener}. If null, the signal strength of the serving cell
 * will either be taken from {@code aCellInfo}, if available, or not be updated at all.
 * @param aCellInfo A list of {@link android.telephony.CellInfo} instances reported by a
 * {@link android.telephony.PhoneStateListener}. If null, the current value will be queried.
 */
@SuppressLint("NewApi")
public void updateCellData(CellLocation aLocation, SignalStrength signalStrength, List<CellInfo> aCellInfo) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        try {
            /*
             * CellInfo requires API 17+ and should in theory return all cells in view. In practice,
             * some devices do not implement it or return only a partial list. On some devices,
             * PhoneStateListener#onCellInfoChanged() will fire but always receive a null argument.
             */
            List<CellInfo> cellInfo = (aCellInfo != null) ? aCellInfo
                    : mainActivity.telephonyManager.getAllCellInfo();
            mCellsGsm.updateAll(cellInfo);
            mCellsCdma.updateAll(cellInfo);
            mCellsLte.updateAll(cellInfo);
        } catch (SecurityException e) {
            // Permission not granted, can't retrieve cell data
            Log.w(TAG, "Permission not granted, TelephonyManager#getAllCellInfo() failed");
        }
    }

    try {
        /*
         * CellLocation should return the serving cell, unless it is LTE (in which case it should
         * return null). In practice, however, some devices do return LTE cells. The approach of
         * this method does not work well for devices with multiple radios.
         */
        CellLocation location = (aLocation != null) ? aLocation
                : mainActivity.telephonyManager.getCellLocation();
        String networkOperator = mainActivity.telephonyManager.getNetworkOperator();
        mCellsGsm.removeSource(CellTower.SOURCE_CELL_LOCATION);
        mCellsCdma.removeSource(CellTower.SOURCE_CELL_LOCATION);
        mCellsLte.removeSource(CellTower.SOURCE_CELL_LOCATION);
        if (location instanceof GsmCellLocation) {
            if (mLastNetworkGen < 4) {
                mServingCell = mCellsGsm.update(networkOperator, (GsmCellLocation) location);
                if ((mServingCell.getDbm() == CellTower.DBM_UNKNOWN) && (mServingCell instanceof CellTowerGsm))
                    ((CellTowerGsm) mServingCell).setAsu(mLastCellAsu);
            } else {
                mServingCell = mCellsLte.update(networkOperator, (GsmCellLocation) location);
                if (mServingCell.getDbm() == CellTower.DBM_UNKNOWN)
                    ((CellTowerLte) mServingCell).setAsu(mLastCellAsu);
            }
        } else if (location instanceof CdmaCellLocation) {
            mServingCell = mCellsCdma.update((CdmaCellLocation) location);
            if (mServingCell.getDbm() == CellTower.DBM_UNKNOWN)
                ((CellTowerCdma) mServingCell).setDbm(mLastCellDbm);
        }
        networkTimehandler.removeCallbacks(networkTimeRunnable);
    } catch (SecurityException e) {
        // Permission not granted, can't retrieve cell data
        Log.w(TAG, "Permission not granted, cannot retrieve cell location");
    }

    if ((mServingCell == null) || (mServingCell.getGeneration() <= 0)) {
        if ((mLastNetworkGen != 0) && (mServingCell != null))
            mServingCell.setGeneration(mLastNetworkGen);
        NetworkInfo netinfo = mainActivity.connectivityManager.getActiveNetworkInfo();
        if ((netinfo == null) || (netinfo.getType() < ConnectivityManager.TYPE_MOBILE_MMS)
                || (netinfo.getType() > ConnectivityManager.TYPE_MOBILE_HIPRI)) {
            networkTimehandler.postDelayed(networkTimeRunnable, NETWORK_REFRESH_DELAY);
        }
    } else if (mServingCell != null) {
        mLastNetworkGen = mServingCell.getGeneration();
    }

    if ((signalStrength != null) && (mServingCell != null)) {
        int pt = mainActivity.telephonyManager.getPhoneType();
        if (pt == PHONE_TYPE_GSM) {
            mLastCellAsu = signalStrength.getGsmSignalStrength();
            updateNeighboringCellInfo();
            if (mServingCell instanceof CellTowerGsm)
                ((CellTowerGsm) mServingCell).setAsu(mLastCellAsu);
            else
                Log.w(MainActivity.class.getSimpleName(),
                        "Got SignalStrength for PHONE_TYPE_GSM but serving cell is not GSM");
        } else if (pt == PHONE_TYPE_CDMA) {
            mLastCellDbm = signalStrength.getCdmaDbm();
            if ((mServingCell != null) && (mServingCell instanceof CellTowerCdma))
                mServingCell.setDbm(mLastCellDbm);
            else
                Log.w(MainActivity.class.getSimpleName(),
                        "Got SignalStrength for PHONE_TYPE_CDMA but serving cell is not CDMA");
        } else
            Log.w(MainActivity.class.getSimpleName(),
                    String.format("Got SignalStrength for unknown phone type (%d)", pt));
    } else if (mServingCell == null) {
        Log.w(MainActivity.class.getSimpleName(), "Got SignalStrength but serving cell is null");
    }

    updateNeighboringCellInfo();

    showCells();
}

From source file:com.vonglasow.michael.satstat.RadioSectionFragment.java

/**
 * Updates all cell data.//  www. jav  a2s.  co m
 * 
 * This method is called whenever any change in the cell environment (cells in view or signal
 * strengths) is signaled, e.g. by a call to a {@link android.telephony.PhoneStateListener}. The
 * arguments of this method should be filled with the data passed to the
 * {@link android.telephony.PhoneStateListener} where possible, and null passed for all others.
 * 
 * To force an update of all cell data, simply call this method with each argument set to null.
 * 
 * If any of the arguments is null, this method will try to obtain that data by querying
 * {@link android.telephony.TelephonyManager}. The only exception is {@code signalStrength}, which
 * will not be explicitly queried if missing.
 * 
 * It will first process {@code aCellInfo}, then {@code aLocation}, querying current values from
 * {@link android.telephony.TelephonyManager} if one of these arguments is null. Next it will process
 * {@code signalStrength}, if supplied, and eventually obtain neighboring cells by calling
 * {@link android.telephony.TelephonyManager#getNeighboringCellInfo()} and process these. Eventually
 * it will refresh the list of cells.
 * 
 * @param aLocation The {@link android.telephony.CellLocation} reported by a
 * {@link android.telephony.PhoneStateListener}. If null, the current value will be queried.
 * @param aSignalStrength The {@link android.telephony.SignalStrength} reported by a
 * {@link android.telephony.PhoneStateListener}. If null, the signal strength of the serving cell
 * will either be taken from {@code aCellInfo}, if available, or not be updated at all.
 * @param aCellInfo A list of {@link android.telephony.CellInfo} instances reported by a
 * {@link android.telephony.PhoneStateListener}. If null, the current value will be queried.
 */
@SuppressLint("NewApi")
public void updateCellData(CellLocation aLocation, SignalStrength signalStrength, List<CellInfo> aCellInfo) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        try {
            /*
             * CellInfo requires API 17+ and should in theory return all cells in view. In practice,
             * some devices do not implement it or return only a partial list. On some devices,
             * PhoneStateListener#onCellInfoChanged() will fire but always receive a null argument.
             */
            List<CellInfo> cellInfo = (aCellInfo != null) ? aCellInfo
                    : mainActivity.telephonyManager.getAllCellInfo();
            mCellsGsm.updateAll(cellInfo);
            mCellsCdma.updateAll(cellInfo);
            mCellsLte.updateAll(cellInfo);
        } catch (SecurityException e) {
            // Permission not granted, can't retrieve cell data
        }
    }

    try {
        /*
         * CellLocation should return the serving cell, unless it is LTE (in which case it should
         * return null). In practice, however, some devices do return LTE cells. The approach of
         * this method does not work well for devices with multiple radios.
         */
        CellLocation location = (aLocation != null) ? aLocation
                : mainActivity.telephonyManager.getCellLocation();
        String networkOperator = mainActivity.telephonyManager.getNetworkOperator();
        mCellsGsm.removeSource(CellTower.SOURCE_CELL_LOCATION);
        mCellsCdma.removeSource(CellTower.SOURCE_CELL_LOCATION);
        mCellsLte.removeSource(CellTower.SOURCE_CELL_LOCATION);
        if (location instanceof GsmCellLocation) {
            if (mLastNetworkGen < 4) {
                mServingCell = mCellsGsm.update(networkOperator, (GsmCellLocation) location);
                if ((mServingCell.getDbm() == CellTower.DBM_UNKNOWN) && (mServingCell instanceof CellTowerGsm))
                    ((CellTowerGsm) mServingCell).setAsu(mLastCellAsu);
            } else {
                mServingCell = mCellsLte.update(networkOperator, (GsmCellLocation) location);
                if (mServingCell.getDbm() == CellTower.DBM_UNKNOWN)
                    ((CellTowerLte) mServingCell).setAsu(mLastCellAsu);
            }
        } else if (location instanceof CdmaCellLocation) {
            mServingCell = mCellsCdma.update((CdmaCellLocation) location);
            if (mServingCell.getDbm() == CellTower.DBM_UNKNOWN)
                ((CellTowerCdma) mServingCell).setDbm(mLastCellDbm);
        }
        networkTimehandler.removeCallbacks(networkTimeRunnable);
    } catch (SecurityException e) {
        // Permission not granted, can't retrieve cell data
    }

    if ((mServingCell == null) || (mServingCell.getGeneration() <= 0)) {
        if ((mLastNetworkGen != 0) && (mServingCell != null))
            mServingCell.setGeneration(mLastNetworkGen);
        NetworkInfo netinfo = mainActivity.connectivityManager.getActiveNetworkInfo();
        if ((netinfo == null) || (netinfo.getType() < ConnectivityManager.TYPE_MOBILE_MMS)
                || (netinfo.getType() > ConnectivityManager.TYPE_MOBILE_HIPRI)) {
            networkTimehandler.postDelayed(networkTimeRunnable, NETWORK_REFRESH_DELAY);
        }
    } else if (mServingCell != null) {
        mLastNetworkGen = mServingCell.getGeneration();
    }

    if ((signalStrength != null) && (mServingCell != null)) {
        int pt = mainActivity.telephonyManager.getPhoneType();
        if (pt == PHONE_TYPE_GSM) {
            mLastCellAsu = signalStrength.getGsmSignalStrength();
            updateNeighboringCellInfo();
            if (mServingCell instanceof CellTowerGsm)
                ((CellTowerGsm) mServingCell).setAsu(mLastCellAsu);
            else
                Log.w(MainActivity.class.getSimpleName(),
                        "Got SignalStrength for PHONE_TYPE_GSM but serving cell is not GSM");
        } else if (pt == PHONE_TYPE_CDMA) {
            mLastCellDbm = signalStrength.getCdmaDbm();
            if ((mServingCell != null) && (mServingCell instanceof CellTowerCdma))
                mServingCell.setDbm(mLastCellDbm);
            else
                Log.w(MainActivity.class.getSimpleName(),
                        "Got SignalStrength for PHONE_TYPE_CDMA but serving cell is not CDMA");
        } else
            Log.w(MainActivity.class.getSimpleName(),
                    String.format("Got SignalStrength for unknown phone type (%d)", pt));
    } else if (mServingCell == null) {
        Log.w(MainActivity.class.getSimpleName(), "Got SignalStrength but serving cell is null");
    }

    try {
        /*
         * NeighboringCellInfo is not supported on some devices and will return no data. It lists
         * only GSM and successors' cells, but not CDMA cells.
         */
        List<NeighboringCellInfo> neighboringCells = mainActivity.telephonyManager.getNeighboringCellInfo();
        String networkOperator = mainActivity.telephonyManager.getNetworkOperator();
        mCellsGsm.updateAll(networkOperator, neighboringCells);
        mCellsLte.updateAll(networkOperator, neighboringCells);
    } catch (SecurityException e) {
        // Permission not granted, can't retrieve cell data
    }

    showCells();
}

From source file:com.ubiLive.GameCloud.Browser.WebBrowser.java

private void processNetworkType(Intent intent, Context context) {
    int netType;//  w  w  w .  java  2s  .c om
    int netSubtype;
    int networkType;
    boolean isConnected;
    String reloadUrl;
    DebugLog.d(TAG, "processNetworkType() enter");

    NetworkInfo netInfo = Utils.getCurNetworkInfo(context);
    if (netInfo == null || netInfo.isAvailable() == false) {
        DebugLog.d(TAG, "getCurNetworkInfo() is null");
        netInfo = (NetworkInfo) intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
    }

    if (netInfo == null || netInfo.isAvailable() == false) {
        DebugLog.d(TAG, "getCurNetworkInfo() netInfo is null line1383");
        if (mbNetworIsConnect != false) {
            mbNetworIsConnect = false;
            reloadUrl = GameInfo.getErrorUrl();
            reload(reloadUrl);
        }
        Utils.setNetworkType(Constants.NETWORKTYPE_NONE);
        return;
    }
    netType = netInfo.getType();
    netSubtype = netInfo.getSubtype();
    isConnected = netInfo.isConnected();
    DebugLog.e(TAG, "======processNetworkType nettype = " + netType + ",netSubtype = " + netSubtype
            + ",isConnect = " + isConnected);
    switch (netType) {
    case ConnectivityManager.TYPE_MOBILE_SUPL:
    case ConnectivityManager.TYPE_MOBILE_MMS:
    case ConnectivityManager.TYPE_MOBILE_HIPRI:
    case ConnectivityManager.TYPE_MOBILE_DUN:
    case ConnectivityManager.TYPE_MOBILE:
        DebugLog.d(TAG, "processNetworkType ConnectivityManager.TYPE_MOBILE netSubtype=" + netSubtype);
        if (netSubtype == TelephonyManager.NETWORK_TYPE_LTE) {//4
            DebugLog.d(TAG, "processNetworkType ConnectivityManager.TYPE_MOBILE 4G");
            networkType = Constants.NETWORKTYPE_LTE;
        } else {//3
            DebugLog.d(TAG, "processNetworkType ConnectivityManager.TYPE_MOBILE 3G");
            networkType = Constants.NETWORKTYPE_3G;
        }
        break;
    case ConnectivityManager.TYPE_WIFI:
        DebugLog.d(TAG, "processNetworkType ConnectivityManager.TYPE_WIFI");
        networkType = Constants.NETWORKTYPE_WIFI;
        break;
    case ConnectivityManager.TYPE_ETHERNET:
        DebugLog.d(TAG, "processNetworkType ConnectivityManager.TYPE_ETHERNET");
        networkType = Constants.NETWORKTYPE_ETHERNET;
        break;
    default:
        DebugLog.d(TAG, "other network status");
        networkType = Constants.NETWORKTYPE_OTHERS;
        break;
    }
    DebugLog.e(TAG, "======processNetworkType nettype = " + netType + ",netSubtype = " + netSubtype
            + ",isConnect = " + isConnected + ",mbNetworIsConnect = " + mbNetworIsConnect);
    if (isConnected) {
        reloadUrl = Utils.checkUrl(GameInfo.DEFAULT_URL);
        Utils.setNetworkType(networkType);
        //         Utils.setNetworkType(Constants.NETWORKTYPE_WIFI);//temp change
    } else {
        reloadUrl = GameInfo.getErrorUrl();
        Utils.setNetworkType(Constants.NETWORKTYPE_NONE);
    }

    //      if((networkType == Constants.NETWORKTYPE_WIFI || networkType == Constants.NETWORKTYPE_LTE) && mbNetworIsConnect != isConnected){
    if (mbNetworIsConnect != isConnected) {
        mbNetworIsConnect = isConnected;
        reload(reloadUrl);
        DebugLog.d(TAG, "Notify reload finish");
    }
}

From source file:com.shinymayhem.radiopresets.ServiceRadioPlayer.java

protected int getConnectionType() {
    int newState = mNetworkInfo.getType();
    if (LOCAL_LOGV) {
        String str = "";

        switch (newState) {
        case ConnectivityManager.TYPE_WIFI:
            str += "wifi";
            break;
        case ConnectivityManager.TYPE_MOBILE:
            str += "mobile";
            break;
        case ConnectivityManager.TYPE_MOBILE_DUN:
            str += "mobile-dun";
            break;
        case ConnectivityManager.TYPE_MOBILE_HIPRI:
            str += "moblie-hipri";
            break;
        case ConnectivityManager.TYPE_MOBILE_MMS:
            str += "mobile-mms";
            break;
        case ConnectivityManager.TYPE_MOBILE_SUPL:
            str += "mobile-supl";
            break;
        case ConnectivityManager.TYPE_WIMAX:
            str += "wimax";
            break;
        case ConnectivityManager.TYPE_ETHERNET:
            str += "ethernet";
            break;
        case ConnectivityManager.TYPE_BLUETOOTH:
            str += "bluetooth";
            break;
        case ConnectivityManager.TYPE_DUMMY:
            str += "dummy";
            break;
        }/*from w  w w .j  a  va  2  s.  co  m*/
        str += " detected";
        log(str, "v");
    }
    return newState;
}

From source file:com.chen.emailsync.SyncManager.java

/**
 * Taken from ConnectivityManager using public constants
 *//*from w  w w  . ja v a 2 s.  c om*/
public static boolean isNetworkTypeMobile(int networkType) {
    switch (networkType) {
    case ConnectivityManager.TYPE_MOBILE:
    case ConnectivityManager.TYPE_MOBILE_MMS:
    case ConnectivityManager.TYPE_MOBILE_SUPL:
    case ConnectivityManager.TYPE_MOBILE_DUN:
    case ConnectivityManager.TYPE_MOBILE_HIPRI:
        return true;
    default:
        return false;
    }
}