am 141623d4: DO NOT MERGE WiMAX support
* commit '141623d480fe0a6944e5bfea04a2dd4f78b52f20': DO NOT MERGE WiMAX support
This commit is contained in:
@@ -18,10 +18,13 @@ package com.android.server;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContextWrapper;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.Resources.NotFoundException;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.IConnectivityManager;
|
||||
import android.net.MobileDataStateTracker;
|
||||
@@ -29,6 +32,7 @@ import android.net.NetworkInfo;
|
||||
import android.net.NetworkStateTracker;
|
||||
import android.net.NetworkUtils;
|
||||
import android.net.wifi.WifiStateTracker;
|
||||
import android.net.wimax.WimaxManagerConstants;
|
||||
import android.os.Binder;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
@@ -41,19 +45,23 @@ import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.EventLog;
|
||||
import android.util.Slog;
|
||||
|
||||
import com.android.internal.telephony.Phone;
|
||||
|
||||
import com.android.server.connectivity.Tethering;
|
||||
|
||||
import dalvik.system.DexClassLoader;
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.PrintWriter;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
@@ -103,7 +111,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
||||
|
||||
private boolean mTestMode;
|
||||
private static ConnectivityService sServiceInstance;
|
||||
|
||||
private static final int ENABLED = 1;
|
||||
private static final int DISABLED = 0;
|
||||
|
||||
@@ -381,6 +388,13 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
||||
mNetTrackers[netType].teardown();
|
||||
}
|
||||
break;
|
||||
case ConnectivityManager.TYPE_WIMAX:
|
||||
NetworkStateTracker nst = makeWimaxStateTracker();
|
||||
if (nst != null) {
|
||||
nst.startMonitoring();
|
||||
}
|
||||
mNetTrackers[netType] = nst;
|
||||
break;
|
||||
default:
|
||||
Slog.e(TAG, "Trying to create a DataStateTracker for an unknown radio type " +
|
||||
mNetAttributes[netType].mRadio);
|
||||
@@ -400,6 +414,94 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
private NetworkStateTracker makeWimaxStateTracker() {
|
||||
//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 = mContext.getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_wimaxEnabled);
|
||||
|
||||
if (isWimaxEnabled) {
|
||||
try {
|
||||
wimaxJarLocation = mContext.getResources().getString(
|
||||
com.android.internal.R.string.config_wimaxServiceJarLocation);
|
||||
wimaxLibLocation = mContext.getResources().getString(
|
||||
com.android.internal.R.string.config_wimaxNativeLibLocation);
|
||||
wimaxManagerClassName = mContext.getResources().getString(
|
||||
com.android.internal.R.string.config_wimaxManagerClassname);
|
||||
wimaxServiceClassName = mContext.getResources().getString(
|
||||
com.android.internal.R.string.config_wimaxServiceClassname);
|
||||
wimaxStateTrackerClassName = mContext.getResources().getString(
|
||||
com.android.internal.R.string.config_wimaxStateTrackerClassname);
|
||||
|
||||
wimaxClassLoader = new DexClassLoader(wimaxJarLocation,
|
||||
new ContextWrapper(mContext).getCacheDir().getAbsolutePath(),
|
||||
wimaxLibLocation,ClassLoader.getSystemClassLoader());
|
||||
|
||||
try {
|
||||
wimaxManagerClass = wimaxClassLoader.loadClass(wimaxManagerClassName);
|
||||
wimaxStateTrackerClass = wimaxClassLoader.loadClass(wimaxStateTrackerClassName);
|
||||
wimaxServiceClass = wimaxClassLoader.loadClass(wimaxServiceClassName);
|
||||
} catch (ClassNotFoundException ex) {
|
||||
ex.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
} catch(Resources.NotFoundException ex) {
|
||||
Slog.e(TAG, "Wimax Resources does not exist!!! ");
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
Slog.v(TAG, "Starting Wimax Service... ");
|
||||
|
||||
Constructor wmxStTrkrConst = wimaxStateTrackerClass.getConstructor
|
||||
(new Class[] {Context.class,Handler.class});
|
||||
wimaxStateTracker = (NetworkStateTracker)wmxStTrkrConst.newInstance(mContext,mHandler);
|
||||
|
||||
Constructor wmxSrvConst = wimaxServiceClass.getDeclaredConstructor
|
||||
(new Class[] {Context.class,wimaxStateTrackerClass});
|
||||
wmxSrvConst.setAccessible(true);
|
||||
IBinder svcInvoker = (IBinder) wmxSrvConst.newInstance(mContext,wimaxStateTracker);
|
||||
wmxSrvConst.setAccessible(false);
|
||||
|
||||
ServiceManager.addService(WimaxManagerConstants.WIMAX_SERVICE, svcInvoker);
|
||||
|
||||
} catch(ClassCastException ex) {
|
||||
ex.printStackTrace();
|
||||
return null;
|
||||
} catch (NoSuchMethodException ex) {
|
||||
ex.printStackTrace();
|
||||
return null;
|
||||
} catch (InstantiationException ex) {
|
||||
ex.printStackTrace();
|
||||
return null;
|
||||
} catch(IllegalAccessException ex) {
|
||||
ex.printStackTrace();
|
||||
return null;
|
||||
} catch(InvocationTargetException ex) {
|
||||
ex.printStackTrace();
|
||||
return null;
|
||||
} catch(Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
Slog.e(TAG, "Wimax is not enabled or not added to the network attributes!!! ");
|
||||
return null;
|
||||
}
|
||||
|
||||
return wimaxStateTracker;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the preferred network.
|
||||
|
||||
Reference in New Issue
Block a user