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>
This commit is contained in:
TK MUN
2011-02-23 18:55:55 +09:00
committed by Simon Wilson
parent 3302922161
commit 4bdab1751f
10 changed files with 335 additions and 7 deletions

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -1100,6 +1100,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

View File

@@ -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)

View File

@@ -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"

View File

@@ -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>

View File

@@ -1138,6 +1138,18 @@
useful when discovering services offered near by. It uses more power
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. -->

View File

@@ -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);

View File

@@ -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.