summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TK MUN <tk.mun@samsung.com> 2011-02-23 18:55:55 +0900
committer Simon Wilson <simonwilson@google.com> 2011-03-09 22:37:08 -0800
commit4bdab1751f0db3b2f03e8c58ef5c11a543dfa3c7 (patch)
tree6411cda792c42125741dde1fbf27a5e1ea97db0e
parent33029221619f14577bd0d0e7c2f815abc8f1b8ea (diff)
DO NOT MERGE WiMAX support
- In Connectivity service, start WiMAX service - 4G icon display in StatusBarPolicy - Add DHCP renew - Add radio for WiMAX Change-Id: Iffff012b270d80e84ec8fbd4486921a8adb847dd Signed-off-by: TK MUN <tk.mun@samsung.com>
-rw-r--r--core/java/android/net/ConnectivityManager.java4
-rw-r--r--core/java/android/net/NetworkUtils.java12
-rw-r--r--core/java/android/net/wimax/WimaxManagerConstants.java85
-rw-r--r--core/java/android/provider/Settings.java6
-rw-r--r--core/jni/android_net_NetUtils.cpp32
-rw-r--r--core/res/AndroidManifest.xml16
-rwxr-xr-xcore/res/res/values/config.xml13
-rwxr-xr-xcore/res/res/values/strings.xml12
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/StatusBarPolicy.java50
-rw-r--r--services/java/com/android/server/ConnectivityService.java112
10 files changed, 335 insertions, 7 deletions
diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java
index 711c6cd012d6..cd5ceeb8756d 100644
--- a/core/java/android/net/ConnectivityManager.java
+++ b/core/java/android/net/ConnectivityManager.java
@@ -219,9 +219,9 @@ public class ConnectivityManager
/** {@hide} */
public static final int TYPE_ETHERNET = 9;
/** {@hide} TODO: Need to adjust this for WiMAX. */
- public static final int MAX_RADIO_TYPE = TYPE_WIFI;
+ public static final int MAX_RADIO_TYPE = TYPE_ETHERNET;
/** {@hide} TODO: Need to adjust this for WiMAX. */
- public static final int MAX_NETWORK_TYPE = TYPE_MOBILE_HIPRI;
+ public static final int MAX_NETWORK_TYPE = TYPE_ETHERNET;
public static final int DEFAULT_NETWORK_PREFERENCE = TYPE_WIFI;
diff --git a/core/java/android/net/NetworkUtils.java b/core/java/android/net/NetworkUtils.java
index e4f3d5c0f104..81362c928394 100644
--- a/core/java/android/net/NetworkUtils.java
+++ b/core/java/android/net/NetworkUtils.java
@@ -143,4 +143,16 @@ public class NetworkUtils {
}
return result;
}
+
+ /**
+ * Start the DHCP renew service for wimax,
+ * This call blocks until it obtains a result (either success
+ * or failure) from the daemon.
+ * @param interfaceName the name of the interface to configure
+ * @param ipInfo if the request succeeds, this object is filled in with
+ * the IP address information.
+ * @return {@code true} for success, {@code false} for failure
+ * {@hide}
+ */
+ public native static boolean runDhcpRenew(String interfaceName, DhcpInfo ipInfo);
}
diff --git a/core/java/android/net/wimax/WimaxManagerConstants.java b/core/java/android/net/wimax/WimaxManagerConstants.java
new file mode 100644
index 000000000000..72e63b9d90e2
--- /dev/null
+++ b/core/java/android/net/wimax/WimaxManagerConstants.java
@@ -0,0 +1,85 @@
+package android.net.wimax;
+
+/**
+ * {@hide}
+ */
+public class WimaxManagerConstants
+{
+
+ /**
+ * Used by android.net.wimax.WimaxManager for handling management of
+ * Wimax access.
+ */
+ public static final String WIMAX_SERVICE="WiMax";
+
+ /**
+ * Broadcast intent action indicating that Wimax has been enabled, disabled,
+ * enabling, disabling, or unknown. One extra provides this state as an int.
+ * Another extra provides the previous state, if available.
+ */
+ public static final String WIMAX_STATUS_CHANGED_ACTION
+ = "android.net.wimax.WIMAX_STATUS_CHANGED";
+
+ /**
+ * The lookup key for an int that indicates whether Wimax is enabled,
+ * disabled, enabling, disabling, or unknown.
+ */
+ public static final String EXTRA_WIMAX_STATUS = "wimax_status";
+
+ /**
+ * Broadcast intent action indicating that Wimax data has been recieved, sent. One extra
+ * provides the state as int.
+ */
+ public static final String WIMAX_DATA_USED_ACTION = "android.net.wimax.WIMAX_DATA_USED";
+
+ /**
+ * The lookup key for an int that indicates whether Wimax is data is being recieved or sent,
+ * up indicates data is being sent and down indicates data being recieved.
+ */
+ public static final String EXTRA_UP_DOWN_DATA = "upDownData";
+
+ /**
+ * Indicatates Wimax is disabled.
+ */
+ public static final int WIMAX_STATUS_DISABLED = 1;
+
+ /**
+ * Indicatates Wimax is enabled.
+ */
+ public static final int WIMAX_STATUS_ENABLED = 3;
+
+ /**
+ * Indicatates Wimax status is known.
+ */
+ public static final int WIMAX_STATUS_UNKNOWN = 4;
+
+ /**
+ * Indicatates Wimax is in idle state.
+ */
+ public static final int WIMAX_IDLE = 6;
+
+ /**
+ * Indicatates Wimax is being deregistered.
+ */
+ public static final int WIMAX_DEREGISTRATION = 8;
+
+ /**
+ * Indicatates no data on wimax.
+ */
+ public static final int NO_DATA = 0;
+
+ /**
+ * Indicatates data is being sent.
+ */
+ public static final int UP_DATA = 1;
+
+ /**
+ * Indicatates dats is being revieved.
+ */
+ public static final int DOWN_DATA = 2;
+
+ /**
+ * Indicatates data is being recieved and sent simultaneously.
+ */
+ public static final int UP_DOWN_DATA = 3;
+}
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 5aa22fbda3ca..02c90b4843f2 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -1101,6 +1101,12 @@ public final class Settings {
public static final String RADIO_CELL = "cell";
/**
+ * Constant for use in AIRPLANE_MODE_RADIOS to specify WiMAX radio.
+ * @hide
+ */
+ public static final String RADIO_WIMAX = "wimax";
+
+ /**
* A comma separated list of radios that need to be disabled when airplane mode
* is on. This overrides WIFI_ON and BLUETOOTH_ON, if Wi-Fi and bluetooth are
* included in the comma separated list.
diff --git a/core/jni/android_net_NetUtils.cpp b/core/jni/android_net_NetUtils.cpp
index feb0dadc15b1..fe151cdb29c0 100644
--- a/core/jni/android_net_NetUtils.cpp
+++ b/core/jni/android_net_NetUtils.cpp
@@ -44,6 +44,15 @@ int dhcp_do_request(const char *ifname,
int dhcp_stop(const char *ifname);
int dhcp_release_lease(const char *ifname);
char *dhcp_get_errmsg();
+
+int dhcp_do_request_renew(const char *ifname,
+ in_addr_t *ipaddr,
+ in_addr_t *gateway,
+ in_addr_t *mask,
+ in_addr_t *dns1,
+ in_addr_t *dns2,
+ in_addr_t *server,
+ uint32_t *lease);
}
#define NETUTILS_PKG_NAME "android/net/NetworkUtils"
@@ -212,6 +221,28 @@ static jboolean android_net_utils_configureInterface(JNIEnv* env,
return (jboolean)(result == 0);
}
+static jboolean android_net_utils_runDhcpRenew(JNIEnv* env, jobject clazz, jstring ifname, jobject info)
+{
+ int result = -1;
+ in_addr_t ipaddr, gateway, mask, dns1, dns2, server;
+ uint32_t lease;
+
+ const char *nameStr = env->GetStringUTFChars(ifname, NULL);
+ result = ::dhcp_do_request_renew(nameStr, &ipaddr, &gateway, &mask,
+ &dns1, &dns2, &server, &lease);
+ env->ReleaseStringUTFChars(ifname, nameStr);
+ if (result == 0 && dhcpInfoFieldIds.dhcpInfoClass != NULL) {
+ env->SetIntField(info, dhcpInfoFieldIds.ipaddress, ipaddr);
+ env->SetIntField(info, dhcpInfoFieldIds.gateway, gateway);
+ env->SetIntField(info, dhcpInfoFieldIds.netmask, mask);
+ env->SetIntField(info, dhcpInfoFieldIds.dns1, dns1);
+ env->SetIntField(info, dhcpInfoFieldIds.dns2, dns2);
+ env->SetIntField(info, dhcpInfoFieldIds.serverAddress, server);
+ env->SetIntField(info, dhcpInfoFieldIds.leaseDuration, lease);
+ }
+
+ return (jboolean)(result == 0);
+}
// ----------------------------------------------------------------------------
/*
@@ -233,6 +264,7 @@ static JNINativeMethod gNetworkUtilMethods[] = {
{ "releaseDhcpLease", "(Ljava/lang/String;)Z", (void *)android_net_utils_releaseDhcpLease },
{ "configureNative", "(Ljava/lang/String;IIIII)Z", (void *)android_net_utils_configureInterface },
{ "getDhcpError", "()Ljava/lang/String;", (void*) android_net_utils_getDhcpError },
+ { "runDhcpRenew", "(Ljava/lang/String;Landroid/net/DhcpInfo;)Z", (void *)android_net_utils_runDhcpRenew}
};
int register_android_net_NetworkUtils(JNIEnv* env)
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 1ac22bcf6698..56ca05765f38 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -332,6 +332,14 @@
android:description="@string/permdesc_accessWifiState"
android:label="@string/permlab_accessWifiState" />
+ <!-- Allows applications to access information about WiMAX networks
+ @hide -->
+ <permission android:name="android.permission.ACCESS_WIMAX_STATE"
+ android:permissionGroup="android.permission-group.NETWORK"
+ android:protectionLevel="normal"
+ android:description="@string/permdesc_accessWimaxState"
+ android:label="@string/permlab_accessWimaxState" />
+
<!-- Allows applications to connect to paired bluetooth devices -->
<permission android:name="android.permission.BLUETOOTH"
android:permissionGroup="android.permission-group.NETWORK"
@@ -842,6 +850,14 @@
android:description="@string/permdesc_changeWifiState"
android:label="@string/permlab_changeWifiState" />
+ <!-- Allows applications to change WiMAX connectivity state
+ @hide -->
+ <permission android:name="android.permission.CHANGE_WIMAX_STATE"
+ android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
+ android:protectionLevel="dangerous"
+ android:description="@string/permdesc_changeWimaxState"
+ android:label="@string/permlab_changeWimaxState" />
+
<!-- Allows applications to enter Wi-Fi Multicast mode -->
<permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE"
android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index a2c805426f10..5a9551ec7ae8 100755
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -403,4 +403,17 @@
If false, mms read reports are not supported and the preference
option to enable/disable read reports is removed in the Messaging app. -->
<bool name="config_mms_read_reports_support">true</bool>
+
+ <!-- Set and Unsets WiMAX -->
+ <bool name="config_wimaxEnabled">false</bool>
+ <!-- Location of the wimax framwork jar location -->
+ <string name="config_wimaxServiceJarLocation"></string>
+ <!-- Location of the wimax native library locaiton -->
+ <string name="config_wimaxNativeLibLocation"></string>
+ <!-- Name of the wimax manager class -->
+ <string name="config_wimaxManagerClassname"></string>
+ <!-- Name of the wimax service class -->
+ <string name="config_wimaxServiceClassname"></string>
+ <!-- Name of the wimax state tracker clas -->
+ <string name="config_wimaxStateTrackerClassname"></string>
</resources>
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 37203eb9c44d..613e6111cf65 100755
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -1139,6 +1139,18 @@
than the non-multicast mode.</string>
<!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+ <string name="permlab_accessWimaxState">view WiMAX state</string>
+ <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+ <string name="permdesc_accessWimaxState">Allows an application to view
+ the information about the state of WiMAX.</string>
+
+ <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+ <string name="permlab_changeWimaxState">change WiMAX state</string>
+ <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+ <string name="permdesc_changeWimaxState">Allows an application to connect
+ to and disconnect from WiMAX network.</string>
+
+ <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permlab_bluetoothAdmin">bluetooth administration</string>
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permdesc_bluetoothAdmin">Allows an application to configure
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarPolicy.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarPolicy.java
index 9ef6e6f7efa8..a4789a18813c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarPolicy.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarPolicy.java
@@ -74,6 +74,7 @@ import com.android.internal.telephony.cdma.TtyIntent;
import com.android.server.am.BatteryStatsService;
import com.android.systemui.R;
+import android.net.wimax.WimaxManagerConstants;
/**
* This class contains all of the policy about which icons are installed in the status
@@ -341,6 +342,19 @@ public class StatusBarPolicy {
private int mLastWifiSignalLevel = -1;
private boolean mIsWifiConnected = false;
+ //4G
+ private static final int[][] sDataNetType_4g = {
+ { R.drawable.stat_sys_data_connected_4g,
+ R.drawable.stat_sys_data_out_4g,
+ R.drawable.stat_sys_data_in_4g,
+ R.drawable.stat_sys_data_inandout_4g },
+ { R.drawable.stat_sys_data_fully_connected_4g,
+ R.drawable.stat_sys_data_fully_out_4g,
+ R.drawable.stat_sys_data_fully_in_4g,
+ R.drawable.stat_sys_data_fully_inandout_4g }
+ };
+ private boolean mIsWimaxConnected = false;
+
// state of inet connection - 0 not connected, 100 connected
private int mInetCondition = 0;
@@ -398,6 +412,9 @@ public class StatusBarPolicy {
// TODO - stop using other means to get wifi/mobile info
updateConnectivity(intent);
}
+ else if (action.equals(WimaxManagerConstants.WIMAX_DATA_USED_ACTION)) {
+ updateWiMAX(intent);
+ }
}
};
@@ -438,6 +455,15 @@ public class StatusBarPolicy {
mService.setIconVisibility("wifi", false);
// wifi will get updated by the sticky intents
+ // wimax
+ //enable/disable wimax depending on the value in config.xml
+ boolean isWimaxEnabled = mContext.getResources().getBoolean(
+ com.android.internal.R.bool.config_wimaxEnabled);
+ if (isWimaxEnabled) {
+ mService.setIcon("wimax", R.drawable.stat_sys_data_connected_4g, 0);
+ mService.setIconVisibility("wimax", false);
+ }
+
// TTY status
mService.setIcon("tty", R.drawable.stat_sys_tty_mode, 0);
mService.setIconVisibility("tty", false);
@@ -503,6 +529,8 @@ public class StatusBarPolicy {
filter.addAction(TtyIntent.TTY_ENABLED_CHANGE_ACTION);
filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
filter.addAction(ConnectivityManager.INET_CONDITION_ACTION);
+ filter.addAction(WimaxManagerConstants.WIMAX_DATA_USED_ACTION);
+
mContext.registerReceiver(mIntentReceiver, filter, null, mHandler);
// load config to determine if to distinguish Hspa data icon
@@ -744,6 +772,17 @@ public class StatusBarPolicy {
}
updateSignalStrength(); // apply any change in mInetCondition
break;
+ case ConnectivityManager.TYPE_WIMAX:
+ mInetCondition = inetCondition;
+ if (info.isConnected()) {
+ mIsWimaxConnected = true;
+ mService.setIconVisibility("wimax", true);
+ } else {
+ mIsWimaxConnected = false;
+ mService.setIconVisibility("wimax", false);
+ }
+ updateWiMAX(intent);
+ break;
}
}
@@ -1124,6 +1163,17 @@ public class StatusBarPolicy {
}
}
+ private final void updateWiMAX(Intent intent) {
+ final String action = intent.getAction();
+ int iconId = sDataNetType_4g[0][0];
+ if (action.equals(WimaxManagerConstants.WIMAX_DATA_USED_ACTION)) {
+ int nUpDown = intent.getIntExtra(WimaxManagerConstants.EXTRA_UP_DOWN_DATA, 0);
+ iconId = sDataNetType_4g[mInetCondition][nUpDown];
+ mService.setIcon("wimax", iconId, 0);
+ mService.setIconVisibility("wimax", mIsWimaxConnected);
+ }
+ }
+
private final void updateGps(Intent intent) {
final String action = intent.getAction();
final boolean enabled = intent.getBooleanExtra(LocationManager.EXTRA_GPS_ENABLED, false);
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java
index 4e5aa334fa27..43aa32d11490 100644
--- a/services/java/com/android/server/ConnectivityService.java
+++ b/services/java/com/android/server/ConnectivityService.java
@@ -18,16 +18,20 @@ 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;
import android.net.NetworkInfo;
import android.net.NetworkStateTracker;
import android.net.wifi.WifiStateTracker;
+import android.net.wimax.WimaxManagerConstants;
import android.os.Binder;
import android.os.Handler;
import android.os.IBinder;
@@ -40,17 +44,21 @@ 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;
+
+
/**
* @hide
*/
@@ -100,7 +108,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;
@@ -378,6 +385,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);
@@ -397,6 +411,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.