P2p enhancements
- ConnectivityService interaction and support for running dhcp server and client - State machine enhancements for connectivity interaction Change-Id: Iba3beb8c87554ffd67a7b7e852bbb4dd8666a4f5
This commit is contained in:
@@ -260,11 +260,18 @@ public class ConnectivityManager {
|
|||||||
*/
|
*/
|
||||||
public static final int TYPE_MOBILE_CBS = 12;
|
public static final int TYPE_MOBILE_CBS = 12;
|
||||||
|
|
||||||
/** {@hide} */
|
/**
|
||||||
public static final int MAX_RADIO_TYPE = TYPE_MOBILE_CBS;
|
* A Wi-Fi p2p connection. Only requesting processes will have access to
|
||||||
|
* the peers connected.
|
||||||
|
* {@hide}
|
||||||
|
*/
|
||||||
|
public static final int TYPE_WIFI_P2P = 13;
|
||||||
|
|
||||||
/** {@hide} */
|
/** {@hide} */
|
||||||
public static final int MAX_NETWORK_TYPE = TYPE_MOBILE_CBS;
|
public static final int MAX_RADIO_TYPE = TYPE_WIFI_P2P;
|
||||||
|
|
||||||
|
/** {@hide} */
|
||||||
|
public static final int MAX_NETWORK_TYPE = TYPE_WIFI_P2P;
|
||||||
|
|
||||||
public static final int DEFAULT_NETWORK_PREFERENCE = TYPE_WIFI;
|
public static final int DEFAULT_NETWORK_PREFERENCE = TYPE_WIFI;
|
||||||
|
|
||||||
@@ -303,6 +310,8 @@ public class ConnectivityManager {
|
|||||||
return "MOBILE_IMS";
|
return "MOBILE_IMS";
|
||||||
case TYPE_MOBILE_CBS:
|
case TYPE_MOBILE_CBS:
|
||||||
return "MOBILE_CBS";
|
return "MOBILE_CBS";
|
||||||
|
case TYPE_WIFI_P2P:
|
||||||
|
return "WIFI_P2P";
|
||||||
default:
|
default:
|
||||||
return Integer.toString(type);
|
return Integer.toString(type);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -468,13 +468,9 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
for (int netType : mPriorityList) {
|
for (int netType : mPriorityList) {
|
||||||
switch (mNetConfigs[netType].radio) {
|
switch (mNetConfigs[netType].radio) {
|
||||||
case ConnectivityManager.TYPE_WIFI:
|
case ConnectivityManager.TYPE_WIFI:
|
||||||
if (DBG) log("Starting Wifi Service.");
|
mNetTrackers[netType] = new WifiStateTracker(netType,
|
||||||
WifiStateTracker wst = new WifiStateTracker();
|
mNetConfigs[netType].name);
|
||||||
WifiService wifiService = new WifiService(context);
|
mNetTrackers[netType].startMonitoring(context, mHandler);
|
||||||
ServiceManager.addService(Context.WIFI_SERVICE, wifiService);
|
|
||||||
wifiService.checkAndStartWifi();
|
|
||||||
mNetTrackers[ConnectivityManager.TYPE_WIFI] = wst;
|
|
||||||
wst.startMonitoring(context, mHandler);
|
|
||||||
break;
|
break;
|
||||||
case ConnectivityManager.TYPE_MOBILE:
|
case ConnectivityManager.TYPE_MOBILE:
|
||||||
mNetTrackers[netType] = new MobileDataStateTracker(netType,
|
mNetTrackers[netType] = new MobileDataStateTracker(netType,
|
||||||
@@ -882,15 +878,8 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
|
|
||||||
FeatureUser f = new FeatureUser(networkType, feature, binder);
|
FeatureUser f = new FeatureUser(networkType, feature, binder);
|
||||||
|
|
||||||
// TODO - move this into the MobileDataStateTracker
|
// TODO - move this into individual networktrackers
|
||||||
int usedNetworkType = networkType;
|
int usedNetworkType = convertFeatureToNetworkType(networkType, feature);
|
||||||
if(networkType == ConnectivityManager.TYPE_MOBILE) {
|
|
||||||
usedNetworkType = convertFeatureToNetworkType(feature);
|
|
||||||
if (usedNetworkType < 0) {
|
|
||||||
loge("Can't match any netTracker!");
|
|
||||||
usedNetworkType = networkType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mProtectedNetworks.contains(usedNetworkType)) {
|
if (mProtectedNetworks.contains(usedNetworkType)) {
|
||||||
enforceConnectivityInternalPermission();
|
enforceConnectivityInternalPermission();
|
||||||
@@ -900,7 +889,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
if (network != null) {
|
if (network != null) {
|
||||||
Integer currentPid = new Integer(getCallingPid());
|
Integer currentPid = new Integer(getCallingPid());
|
||||||
if (usedNetworkType != networkType) {
|
if (usedNetworkType != networkType) {
|
||||||
NetworkStateTracker radio = mNetTrackers[networkType];
|
|
||||||
NetworkInfo ni = network.getNetworkInfo();
|
NetworkInfo ni = network.getNetworkInfo();
|
||||||
|
|
||||||
if (ni.isAvailable() == false) {
|
if (ni.isAvailable() == false) {
|
||||||
@@ -1046,14 +1034,9 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO - move to MobileDataStateTracker
|
// TODO - move to individual network trackers
|
||||||
int usedNetworkType = networkType;
|
int usedNetworkType = convertFeatureToNetworkType(networkType, feature);
|
||||||
if (networkType == ConnectivityManager.TYPE_MOBILE) {
|
|
||||||
usedNetworkType = convertFeatureToNetworkType(feature);
|
|
||||||
if (usedNetworkType < 0) {
|
|
||||||
usedNetworkType = networkType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tracker = mNetTrackers[usedNetworkType];
|
tracker = mNetTrackers[usedNetworkType];
|
||||||
if (tracker == null) {
|
if (tracker == null) {
|
||||||
if (DBG) log("ignoring - no known tracker for net type " + usedNetworkType);
|
if (DBG) log("ignoring - no known tracker for net type " + usedNetworkType);
|
||||||
@@ -2637,25 +2620,38 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
Slog.e(TAG, s);
|
Slog.e(TAG, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
int convertFeatureToNetworkType(String feature){
|
int convertFeatureToNetworkType(int networkType, String feature) {
|
||||||
int networkType = -1;
|
int usedNetworkType = networkType;
|
||||||
|
|
||||||
|
if(networkType == ConnectivityManager.TYPE_MOBILE) {
|
||||||
if (TextUtils.equals(feature, Phone.FEATURE_ENABLE_MMS)) {
|
if (TextUtils.equals(feature, Phone.FEATURE_ENABLE_MMS)) {
|
||||||
networkType = ConnectivityManager.TYPE_MOBILE_MMS;
|
usedNetworkType = ConnectivityManager.TYPE_MOBILE_MMS;
|
||||||
} else if (TextUtils.equals(feature, Phone.FEATURE_ENABLE_SUPL)) {
|
} else if (TextUtils.equals(feature, Phone.FEATURE_ENABLE_SUPL)) {
|
||||||
networkType = ConnectivityManager.TYPE_MOBILE_SUPL;
|
usedNetworkType = ConnectivityManager.TYPE_MOBILE_SUPL;
|
||||||
} else if (TextUtils.equals(feature, Phone.FEATURE_ENABLE_DUN) ||
|
} else if (TextUtils.equals(feature, Phone.FEATURE_ENABLE_DUN) ||
|
||||||
TextUtils.equals(feature, Phone.FEATURE_ENABLE_DUN_ALWAYS)) {
|
TextUtils.equals(feature, Phone.FEATURE_ENABLE_DUN_ALWAYS)) {
|
||||||
networkType = ConnectivityManager.TYPE_MOBILE_DUN;
|
usedNetworkType = ConnectivityManager.TYPE_MOBILE_DUN;
|
||||||
} else if (TextUtils.equals(feature, Phone.FEATURE_ENABLE_HIPRI)) {
|
} else if (TextUtils.equals(feature, Phone.FEATURE_ENABLE_HIPRI)) {
|
||||||
networkType = ConnectivityManager.TYPE_MOBILE_HIPRI;
|
usedNetworkType = ConnectivityManager.TYPE_MOBILE_HIPRI;
|
||||||
} else if (TextUtils.equals(feature, Phone.FEATURE_ENABLE_FOTA)) {
|
} else if (TextUtils.equals(feature, Phone.FEATURE_ENABLE_FOTA)) {
|
||||||
networkType = ConnectivityManager.TYPE_MOBILE_FOTA;
|
usedNetworkType = ConnectivityManager.TYPE_MOBILE_FOTA;
|
||||||
} else if (TextUtils.equals(feature, Phone.FEATURE_ENABLE_IMS)) {
|
} else if (TextUtils.equals(feature, Phone.FEATURE_ENABLE_IMS)) {
|
||||||
networkType = ConnectivityManager.TYPE_MOBILE_IMS;
|
usedNetworkType = ConnectivityManager.TYPE_MOBILE_IMS;
|
||||||
} else if (TextUtils.equals(feature, Phone.FEATURE_ENABLE_CBS)) {
|
} else if (TextUtils.equals(feature, Phone.FEATURE_ENABLE_CBS)) {
|
||||||
networkType = ConnectivityManager.TYPE_MOBILE_CBS;
|
usedNetworkType = ConnectivityManager.TYPE_MOBILE_CBS;
|
||||||
|
} else {
|
||||||
|
Slog.e(TAG, "Can't match any mobile netTracker!");
|
||||||
}
|
}
|
||||||
return networkType;
|
} else if (networkType == ConnectivityManager.TYPE_WIFI) {
|
||||||
|
if (TextUtils.equals(feature, "p2p")) {
|
||||||
|
usedNetworkType = ConnectivityManager.TYPE_WIFI_P2P;
|
||||||
|
} else {
|
||||||
|
Slog.e(TAG, "Can't match any wifi netTracker!");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Slog.e(TAG, "Unexpected network type");
|
||||||
|
}
|
||||||
|
return usedNetworkType;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T> T checkNotNull(T value, String message) {
|
private static <T> T checkNotNull(T value, String message) {
|
||||||
|
|||||||
Reference in New Issue
Block a user