Search in sources :

Example 6 with NetworkStateTracker

use of android.net.NetworkStateTracker in project android_frameworks_base by ParanoidAndroid.

the class ConnectivityService method dump.

@Override
protected void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
    final IndentingPrintWriter pw = new IndentingPrintWriter(writer, "  ");
    if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) != PackageManager.PERMISSION_GRANTED) {
        pw.println("Permission Denial: can't dump ConnectivityService " + "from from pid=" + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid());
        return;
    }
    // TODO: add locking to get atomic snapshot
    pw.println();
    for (int i = 0; i < mNetTrackers.length; i++) {
        final NetworkStateTracker nst = mNetTrackers[i];
        if (nst != null) {
            pw.println("NetworkStateTracker for " + getNetworkTypeName(i) + ":");
            pw.increaseIndent();
            if (nst.getNetworkInfo().isConnected()) {
                pw.println("Active network: " + nst.getNetworkInfo().getTypeName());
            }
            pw.println(nst.getNetworkInfo());
            pw.println(nst.getLinkProperties());
            pw.println(nst);
            pw.println();
            pw.decreaseIndent();
        }
    }
    pw.println("Network Requester Pids:");
    pw.increaseIndent();
    for (int net : mPriorityList) {
        String pidString = net + ": ";
        for (Integer pid : mNetRequestersPids[net]) {
            pidString = pidString + pid.toString() + ", ";
        }
        pw.println(pidString);
    }
    pw.println();
    pw.decreaseIndent();
    pw.println("FeatureUsers:");
    pw.increaseIndent();
    for (Object requester : mFeatureUsers) {
        pw.println(requester.toString());
    }
    pw.println();
    pw.decreaseIndent();
    synchronized (this) {
        pw.println("NetworkTranstionWakeLock is currently " + (mNetTransitionWakeLock.isHeld() ? "" : "not ") + "held.");
        pw.println("It was last requested for " + mNetTransitionWakeLockCausedBy);
    }
    pw.println();
    mTethering.dump(fd, pw, args);
    if (mInetLog != null) {
        pw.println();
        pw.println("Inet condition reports:");
        pw.increaseIndent();
        for (int i = 0; i < mInetLog.size(); i++) {
            pw.println(mInetLog.get(i));
        }
        pw.decreaseIndent();
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) NetworkStateTracker(android.net.NetworkStateTracker) IndentingPrintWriter(com.android.internal.util.IndentingPrintWriter)

Example 7 with NetworkStateTracker

use of android.net.NetworkStateTracker in project android_frameworks_base by ParanoidAndroid.

the class ConnectivityService method makeWimaxStateTracker.

/**
     * Loads external WiMAX library and registers as system service, returning a
     * {@link NetworkStateTracker} for WiMAX. Caller is still responsible for
     * invoking {@link NetworkStateTracker#startMonitoring(Context, Handler)}.
     */
private static NetworkStateTracker makeWimaxStateTracker(Context context, Handler trackerHandler) {
    // Initialize Wimax
    DexClassLoader wimaxClassLoader;
    Class wimaxStateTrackerClass = null;
    Class wimaxServiceClass = null;
    Class wimaxManagerClass;
    String wimaxJarLocation;
    String wimaxLibLocation;
    String wimaxManagerClassName;
    String wimaxServiceClassName;
    String wimaxStateTrackerClassName;
    NetworkStateTracker wimaxStateTracker = null;
    boolean isWimaxEnabled = context.getResources().getBoolean(com.android.internal.R.bool.config_wimaxEnabled);
    if (isWimaxEnabled) {
        try {
            wimaxJarLocation = context.getResources().getString(com.android.internal.R.string.config_wimaxServiceJarLocation);
            wimaxLibLocation = context.getResources().getString(com.android.internal.R.string.config_wimaxNativeLibLocation);
            wimaxManagerClassName = context.getResources().getString(com.android.internal.R.string.config_wimaxManagerClassname);
            wimaxServiceClassName = context.getResources().getString(com.android.internal.R.string.config_wimaxServiceClassname);
            wimaxStateTrackerClassName = context.getResources().getString(com.android.internal.R.string.config_wimaxStateTrackerClassname);
            if (DBG)
                log("wimaxJarLocation: " + wimaxJarLocation);
            wimaxClassLoader = new DexClassLoader(wimaxJarLocation, new ContextWrapper(context).getCacheDir().getAbsolutePath(), wimaxLibLocation, ClassLoader.getSystemClassLoader());
            try {
                wimaxManagerClass = wimaxClassLoader.loadClass(wimaxManagerClassName);
                wimaxStateTrackerClass = wimaxClassLoader.loadClass(wimaxStateTrackerClassName);
                wimaxServiceClass = wimaxClassLoader.loadClass(wimaxServiceClassName);
            } catch (ClassNotFoundException ex) {
                loge("Exception finding Wimax classes: " + ex.toString());
                return null;
            }
        } catch (Resources.NotFoundException ex) {
            loge("Wimax Resources does not exist!!! ");
            return null;
        }
        try {
            if (DBG)
                log("Starting Wimax Service... ");
            Constructor wmxStTrkrConst = wimaxStateTrackerClass.getConstructor(new Class[] { Context.class, Handler.class });
            wimaxStateTracker = (NetworkStateTracker) wmxStTrkrConst.newInstance(context, trackerHandler);
            Constructor wmxSrvConst = wimaxServiceClass.getDeclaredConstructor(new Class[] { Context.class, wimaxStateTrackerClass });
            wmxSrvConst.setAccessible(true);
            IBinder svcInvoker = (IBinder) wmxSrvConst.newInstance(context, wimaxStateTracker);
            wmxSrvConst.setAccessible(false);
            ServiceManager.addService(WimaxManagerConstants.WIMAX_SERVICE, svcInvoker);
        } catch (Exception ex) {
            loge("Exception creating Wimax classes: " + ex.toString());
            return null;
        }
    } else {
        loge("Wimax is not enabled or not added to the network attributes!!! ");
        return null;
    }
    return wimaxStateTracker;
}
Also used : IBinder(android.os.IBinder) Constructor(java.lang.reflect.Constructor) DexClassLoader(dalvik.system.DexClassLoader) Resources(android.content.res.Resources) NetworkStateTracker(android.net.NetworkStateTracker) ContextWrapper(android.content.ContextWrapper) RemoteException(android.os.RemoteException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) FileNotFoundException(java.io.FileNotFoundException) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) ActivityNotFoundException(android.content.ActivityNotFoundException)

Example 8 with NetworkStateTracker

use of android.net.NetworkStateTracker in project android_frameworks_base by ParanoidAndroid.

the class ConnectivityService method setRadio.

public boolean setRadio(int netType, boolean turnOn) {
    enforceChangePermission();
    if (!ConnectivityManager.isNetworkTypeValid(netType)) {
        return false;
    }
    NetworkStateTracker tracker = mNetTrackers[netType];
    return tracker != null && tracker.setRadio(turnOn);
}
Also used : NetworkStateTracker(android.net.NetworkStateTracker)

Example 9 with NetworkStateTracker

use of android.net.NetworkStateTracker in project android_frameworks_base by ParanoidAndroid.

the class ConnectivityService method setRadios.

public boolean setRadios(boolean turnOn) {
    boolean result = true;
    enforceChangePermission();
    for (NetworkStateTracker t : mNetTrackers) {
        if (t != null)
            result = t.setRadio(turnOn) && result;
    }
    return result;
}
Also used : NetworkStateTracker(android.net.NetworkStateTracker)

Example 10 with NetworkStateTracker

use of android.net.NetworkStateTracker in project android_frameworks_base by ParanoidAndroid.

the class ConnectivityService method removeDataActivityTracking.

/**
     * Remove data activity tracking when network disconnects.
     */
private void removeDataActivityTracking(int type) {
    final NetworkStateTracker net = mNetTrackers[type];
    final String iface = net.getLinkProperties().getInterfaceName();
    if (iface != null && (ConnectivityManager.isNetworkTypeMobile(type) || ConnectivityManager.TYPE_WIFI == type)) {
        try {
            // the call fails silently if no idletimer setup for this interface
            mNetd.removeIdleTimer(iface);
        } catch (RemoteException e) {
        }
    }
}
Also used : NetworkStateTracker(android.net.NetworkStateTracker) RemoteException(android.os.RemoteException)

Aggregations

NetworkStateTracker (android.net.NetworkStateTracker)17 NetworkInfo (android.net.NetworkInfo)6 RemoteException (android.os.RemoteException)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 LinkProperties (android.net.LinkProperties)4 UnknownHostException (java.net.UnknownHostException)4 ActivityNotFoundException (android.content.ActivityNotFoundException)3 FileNotFoundException (java.io.FileNotFoundException)3 IOException (java.io.IOException)3 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)3 InetAddress (java.net.InetAddress)2 PendingIntent (android.app.PendingIntent)1 ContextWrapper (android.content.ContextWrapper)1 Intent (android.content.Intent)1 Resources (android.content.res.Resources)1 LinkAddress (android.net.LinkAddress)1 DetailedState (android.net.NetworkInfo.DetailedState)1 NetworkState (android.net.NetworkState)1 IBinder (android.os.IBinder)1 IndentingPrintWriter (com.android.internal.util.IndentingPrintWriter)1