Skip to content

Commit 4bdab17

Browse files
TK MUNSimon Wilson
authored andcommitted
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>
1 parent 3302922 commit 4bdab17

File tree

10 files changed

+335
-7
lines changed

10 files changed

+335
-7
lines changed

core/java/android/net/ConnectivityManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,9 @@ public class ConnectivityManager
219219
/** {@hide} */
220220
public static final int TYPE_ETHERNET = 9;
221221
/** {@hide} TODO: Need to adjust this for WiMAX. */
222-
public static final int MAX_RADIO_TYPE = TYPE_WIFI;
222+
public static final int MAX_RADIO_TYPE = TYPE_ETHERNET;
223223
/** {@hide} TODO: Need to adjust this for WiMAX. */
224-
public static final int MAX_NETWORK_TYPE = TYPE_MOBILE_HIPRI;
224+
public static final int MAX_NETWORK_TYPE = TYPE_ETHERNET;
225225

226226
public static final int DEFAULT_NETWORK_PREFERENCE = TYPE_WIFI;
227227

core/java/android/net/NetworkUtils.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,16 @@ public static int v4StringToInt(String str) {
143143
}
144144
return result;
145145
}
146+
147+
/**
148+
* Start the DHCP renew service for wimax,
149+
* This call blocks until it obtains a result (either success
150+
* or failure) from the daemon.
151+
* @param interfaceName the name of the interface to configure
152+
* @param ipInfo if the request succeeds, this object is filled in with
153+
* the IP address information.
154+
* @return {@code true} for success, {@code false} for failure
155+
* {@hide}
156+
*/
157+
public native static boolean runDhcpRenew(String interfaceName, DhcpInfo ipInfo);
146158
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
package android.net.wimax;
2+
3+
/**
4+
* {@hide}
5+
*/
6+
public class WimaxManagerConstants
7+
{
8+
9+
/**
10+
* Used by android.net.wimax.WimaxManager for handling management of
11+
* Wimax access.
12+
*/
13+
public static final String WIMAX_SERVICE="WiMax";
14+
15+
/**
16+
* Broadcast intent action indicating that Wimax has been enabled, disabled,
17+
* enabling, disabling, or unknown. One extra provides this state as an int.
18+
* Another extra provides the previous state, if available.
19+
*/
20+
public static final String WIMAX_STATUS_CHANGED_ACTION
21+
= "android.net.wimax.WIMAX_STATUS_CHANGED";
22+
23+
/**
24+
* The lookup key for an int that indicates whether Wimax is enabled,
25+
* disabled, enabling, disabling, or unknown.
26+
*/
27+
public static final String EXTRA_WIMAX_STATUS = "wimax_status";
28+
29+
/**
30+
* Broadcast intent action indicating that Wimax data has been recieved, sent. One extra
31+
* provides the state as int.
32+
*/
33+
public static final String WIMAX_DATA_USED_ACTION = "android.net.wimax.WIMAX_DATA_USED";
34+
35+
/**
36+
* The lookup key for an int that indicates whether Wimax is data is being recieved or sent,
37+
* up indicates data is being sent and down indicates data being recieved.
38+
*/
39+
public static final String EXTRA_UP_DOWN_DATA = "upDownData";
40+
41+
/**
42+
* Indicatates Wimax is disabled.
43+
*/
44+
public static final int WIMAX_STATUS_DISABLED = 1;
45+
46+
/**
47+
* Indicatates Wimax is enabled.
48+
*/
49+
public static final int WIMAX_STATUS_ENABLED = 3;
50+
51+
/**
52+
* Indicatates Wimax status is known.
53+
*/
54+
public static final int WIMAX_STATUS_UNKNOWN = 4;
55+
56+
/**
57+
* Indicatates Wimax is in idle state.
58+
*/
59+
public static final int WIMAX_IDLE = 6;
60+
61+
/**
62+
* Indicatates Wimax is being deregistered.
63+
*/
64+
public static final int WIMAX_DEREGISTRATION = 8;
65+
66+
/**
67+
* Indicatates no data on wimax.
68+
*/
69+
public static final int NO_DATA = 0;
70+
71+
/**
72+
* Indicatates data is being sent.
73+
*/
74+
public static final int UP_DATA = 1;
75+
76+
/**
77+
* Indicatates dats is being revieved.
78+
*/
79+
public static final int DOWN_DATA = 2;
80+
81+
/**
82+
* Indicatates data is being recieved and sent simultaneously.
83+
*/
84+
public static final int UP_DOWN_DATA = 3;
85+
}

core/java/android/provider/Settings.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,6 +1100,12 @@ public static void setShowGTalkServiceStatus(ContentResolver cr, boolean flag) {
11001100
*/
11011101
public static final String RADIO_CELL = "cell";
11021102

1103+
/**
1104+
* Constant for use in AIRPLANE_MODE_RADIOS to specify WiMAX radio.
1105+
* @hide
1106+
*/
1107+
public static final String RADIO_WIMAX = "wimax";
1108+
11031109
/**
11041110
* A comma separated list of radios that need to be disabled when airplane mode
11051111
* is on. This overrides WIFI_ON and BLUETOOTH_ON, if Wi-Fi and bluetooth are

core/jni/android_net_NetUtils.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ int dhcp_do_request(const char *ifname,
4444
int dhcp_stop(const char *ifname);
4545
int dhcp_release_lease(const char *ifname);
4646
char *dhcp_get_errmsg();
47+
48+
int dhcp_do_request_renew(const char *ifname,
49+
in_addr_t *ipaddr,
50+
in_addr_t *gateway,
51+
in_addr_t *mask,
52+
in_addr_t *dns1,
53+
in_addr_t *dns2,
54+
in_addr_t *server,
55+
uint32_t *lease);
4756
}
4857

4958
#define NETUTILS_PKG_NAME "android/net/NetworkUtils"
@@ -212,6 +221,28 @@ static jboolean android_net_utils_configureInterface(JNIEnv* env,
212221
return (jboolean)(result == 0);
213222
}
214223

224+
static jboolean android_net_utils_runDhcpRenew(JNIEnv* env, jobject clazz, jstring ifname, jobject info)
225+
{
226+
int result = -1;
227+
in_addr_t ipaddr, gateway, mask, dns1, dns2, server;
228+
uint32_t lease;
229+
230+
const char *nameStr = env->GetStringUTFChars(ifname, NULL);
231+
result = ::dhcp_do_request_renew(nameStr, &ipaddr, &gateway, &mask,
232+
&dns1, &dns2, &server, &lease);
233+
env->ReleaseStringUTFChars(ifname, nameStr);
234+
if (result == 0 && dhcpInfoFieldIds.dhcpInfoClass != NULL) {
235+
env->SetIntField(info, dhcpInfoFieldIds.ipaddress, ipaddr);
236+
env->SetIntField(info, dhcpInfoFieldIds.gateway, gateway);
237+
env->SetIntField(info, dhcpInfoFieldIds.netmask, mask);
238+
env->SetIntField(info, dhcpInfoFieldIds.dns1, dns1);
239+
env->SetIntField(info, dhcpInfoFieldIds.dns2, dns2);
240+
env->SetIntField(info, dhcpInfoFieldIds.serverAddress, server);
241+
env->SetIntField(info, dhcpInfoFieldIds.leaseDuration, lease);
242+
}
243+
244+
return (jboolean)(result == 0);
245+
}
215246
// ----------------------------------------------------------------------------
216247

217248
/*
@@ -233,6 +264,7 @@ static JNINativeMethod gNetworkUtilMethods[] = {
233264
{ "releaseDhcpLease", "(Ljava/lang/String;)Z", (void *)android_net_utils_releaseDhcpLease },
234265
{ "configureNative", "(Ljava/lang/String;IIIII)Z", (void *)android_net_utils_configureInterface },
235266
{ "getDhcpError", "()Ljava/lang/String;", (void*) android_net_utils_getDhcpError },
267+
{ "runDhcpRenew", "(Ljava/lang/String;Landroid/net/DhcpInfo;)Z", (void *)android_net_utils_runDhcpRenew}
236268
};
237269

238270
int register_android_net_NetworkUtils(JNIEnv* env)

core/res/AndroidManifest.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,14 @@
332332
android:description="@string/permdesc_accessWifiState"
333333
android:label="@string/permlab_accessWifiState" />
334334

335+
<!-- Allows applications to access information about WiMAX networks
336+
@hide -->
337+
<permission android:name="android.permission.ACCESS_WIMAX_STATE"
338+
android:permissionGroup="android.permission-group.NETWORK"
339+
android:protectionLevel="normal"
340+
android:description="@string/permdesc_accessWimaxState"
341+
android:label="@string/permlab_accessWimaxState" />
342+
335343
<!-- Allows applications to connect to paired bluetooth devices -->
336344
<permission android:name="android.permission.BLUETOOTH"
337345
android:permissionGroup="android.permission-group.NETWORK"
@@ -842,6 +850,14 @@
842850
android:description="@string/permdesc_changeWifiState"
843851
android:label="@string/permlab_changeWifiState" />
844852

853+
<!-- Allows applications to change WiMAX connectivity state
854+
@hide -->
855+
<permission android:name="android.permission.CHANGE_WIMAX_STATE"
856+
android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
857+
android:protectionLevel="dangerous"
858+
android:description="@string/permdesc_changeWimaxState"
859+
android:label="@string/permlab_changeWimaxState" />
860+
845861
<!-- Allows applications to enter Wi-Fi Multicast mode -->
846862
<permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE"
847863
android:permissionGroup="android.permission-group.SYSTEM_TOOLS"

core/res/res/values/config.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,4 +403,17 @@
403403
If false, mms read reports are not supported and the preference
404404
option to enable/disable read reports is removed in the Messaging app. -->
405405
<bool name="config_mms_read_reports_support">true</bool>
406+
407+
<!-- Set and Unsets WiMAX -->
408+
<bool name="config_wimaxEnabled">false</bool>
409+
<!-- Location of the wimax framwork jar location -->
410+
<string name="config_wimaxServiceJarLocation"></string>
411+
<!-- Location of the wimax native library locaiton -->
412+
<string name="config_wimaxNativeLibLocation"></string>
413+
<!-- Name of the wimax manager class -->
414+
<string name="config_wimaxManagerClassname"></string>
415+
<!-- Name of the wimax service class -->
416+
<string name="config_wimaxServiceClassname"></string>
417+
<!-- Name of the wimax state tracker clas -->
418+
<string name="config_wimaxStateTrackerClassname"></string>
406419
</resources>

core/res/res/values/strings.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,6 +1138,18 @@
11381138
useful when discovering services offered near by. It uses more power
11391139
than the non-multicast mode.</string>
11401140

1141+
<!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
1142+
<string name="permlab_accessWimaxState">view WiMAX state</string>
1143+
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
1144+
<string name="permdesc_accessWimaxState">Allows an application to view
1145+
the information about the state of WiMAX.</string>
1146+
1147+
<!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
1148+
<string name="permlab_changeWimaxState">change WiMAX state</string>
1149+
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
1150+
<string name="permdesc_changeWimaxState">Allows an application to connect
1151+
to and disconnect from WiMAX network.</string>
1152+
11411153
<!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
11421154
<string name="permlab_bluetoothAdmin">bluetooth administration</string>
11431155
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->

packages/SystemUI/src/com/android/systemui/statusbar/StatusBarPolicy.java

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
import com.android.server.am.BatteryStatsService;
7575

7676
import com.android.systemui.R;
77+
import android.net.wimax.WimaxManagerConstants;
7778

7879
/**
7980
* This class contains all of the policy about which icons are installed in the status
@@ -341,6 +342,19 @@ public class StatusBarPolicy {
341342
private int mLastWifiSignalLevel = -1;
342343
private boolean mIsWifiConnected = false;
343344

345+
//4G
346+
private static final int[][] sDataNetType_4g = {
347+
{ R.drawable.stat_sys_data_connected_4g,
348+
R.drawable.stat_sys_data_out_4g,
349+
R.drawable.stat_sys_data_in_4g,
350+
R.drawable.stat_sys_data_inandout_4g },
351+
{ R.drawable.stat_sys_data_fully_connected_4g,
352+
R.drawable.stat_sys_data_fully_out_4g,
353+
R.drawable.stat_sys_data_fully_in_4g,
354+
R.drawable.stat_sys_data_fully_inandout_4g }
355+
};
356+
private boolean mIsWimaxConnected = false;
357+
344358
// state of inet connection - 0 not connected, 100 connected
345359
private int mInetCondition = 0;
346360

@@ -398,6 +412,9 @@ else if (action.equals(ConnectivityManager.CONNECTIVITY_ACTION) ||
398412
// TODO - stop using other means to get wifi/mobile info
399413
updateConnectivity(intent);
400414
}
415+
else if (action.equals(WimaxManagerConstants.WIMAX_DATA_USED_ACTION)) {
416+
updateWiMAX(intent);
417+
}
401418
}
402419
};
403420

@@ -438,6 +455,15 @@ public StatusBarPolicy(Context context) {
438455
mService.setIconVisibility("wifi", false);
439456
// wifi will get updated by the sticky intents
440457

458+
// wimax
459+
//enable/disable wimax depending on the value in config.xml
460+
boolean isWimaxEnabled = mContext.getResources().getBoolean(
461+
com.android.internal.R.bool.config_wimaxEnabled);
462+
if (isWimaxEnabled) {
463+
mService.setIcon("wimax", R.drawable.stat_sys_data_connected_4g, 0);
464+
mService.setIconVisibility("wimax", false);
465+
}
466+
441467
// TTY status
442468
mService.setIcon("tty", R.drawable.stat_sys_tty_mode, 0);
443469
mService.setIconVisibility("tty", false);
@@ -503,6 +529,8 @@ public StatusBarPolicy(Context context) {
503529
filter.addAction(TtyIntent.TTY_ENABLED_CHANGE_ACTION);
504530
filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
505531
filter.addAction(ConnectivityManager.INET_CONDITION_ACTION);
532+
filter.addAction(WimaxManagerConstants.WIMAX_DATA_USED_ACTION);
533+
506534
mContext.registerReceiver(mIntentReceiver, filter, null, mHandler);
507535

508536
// load config to determine if to distinguish Hspa data icon
@@ -744,6 +772,17 @@ private void updateConnectivity(Intent intent) {
744772
}
745773
updateSignalStrength(); // apply any change in mInetCondition
746774
break;
775+
case ConnectivityManager.TYPE_WIMAX:
776+
mInetCondition = inetCondition;
777+
if (info.isConnected()) {
778+
mIsWimaxConnected = true;
779+
mService.setIconVisibility("wimax", true);
780+
} else {
781+
mIsWimaxConnected = false;
782+
mService.setIconVisibility("wimax", false);
783+
}
784+
updateWiMAX(intent);
785+
break;
747786
}
748787
}
749788

@@ -1124,6 +1163,17 @@ private final void updateWifi(Intent intent) {
11241163
}
11251164
}
11261165

1166+
private final void updateWiMAX(Intent intent) {
1167+
final String action = intent.getAction();
1168+
int iconId = sDataNetType_4g[0][0];
1169+
if (action.equals(WimaxManagerConstants.WIMAX_DATA_USED_ACTION)) {
1170+
int nUpDown = intent.getIntExtra(WimaxManagerConstants.EXTRA_UP_DOWN_DATA, 0);
1171+
iconId = sDataNetType_4g[mInetCondition][nUpDown];
1172+
mService.setIcon("wimax", iconId, 0);
1173+
mService.setIconVisibility("wimax", mIsWimaxConnected);
1174+
}
1175+
}
1176+
11271177
private final void updateGps(Intent intent) {
11281178
final String action = intent.getAction();
11291179
final boolean enabled = intent.getBooleanExtra(LocationManager.EXTRA_GPS_ENABLED, false);

0 commit comments

Comments
 (0)