Merge changes I5187d17c,I49a76582 am: 8b41dd0318 am: f2e5cf715d
am: 31259c219f Change-Id: I174179db3a08ba51aef737cfb3956d1cf789b362
This commit is contained in:
@@ -361,11 +361,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
*/
|
||||
private static final int EVENT_SET_ACCEPT_UNVALIDATED = 28;
|
||||
|
||||
/**
|
||||
* used to specify whether a network should not be penalized when it becomes unvalidated.
|
||||
*/
|
||||
private static final int EVENT_SET_AVOID_UNVALIDATED = 35;
|
||||
|
||||
/**
|
||||
* used to ask the user to confirm a connection to an unvalidated network.
|
||||
* obj = network
|
||||
@@ -383,6 +378,16 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
*/
|
||||
private static final int EVENT_REGISTER_NETWORK_LISTENER_WITH_INTENT = 31;
|
||||
|
||||
/**
|
||||
* used to specify whether a network should not be penalized when it becomes unvalidated.
|
||||
*/
|
||||
private static final int EVENT_SET_AVOID_UNVALIDATED = 35;
|
||||
|
||||
/**
|
||||
* used to trigger revalidation of a network.
|
||||
*/
|
||||
private static final int EVENT_REVALIDATE_NETWORK = 36;
|
||||
|
||||
private static String eventName(int what) {
|
||||
return sMagicDecoderRing.get(what, Integer.toString(what));
|
||||
}
|
||||
@@ -858,8 +863,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
}
|
||||
|
||||
private void handleMobileDataAlwaysOn() {
|
||||
final boolean enable = (Settings.Global.getInt(
|
||||
mContext.getContentResolver(), Settings.Global.MOBILE_DATA_ALWAYS_ON, 1) == 1);
|
||||
final boolean enable = toBool(Settings.Global.getInt(
|
||||
mContext.getContentResolver(), Settings.Global.MOBILE_DATA_ALWAYS_ON, 1));
|
||||
final boolean isEnabled = (mNetworkRequests.get(mDefaultMobileDataRequest) != null);
|
||||
if (enable == isEnabled) {
|
||||
return; // Nothing to do.
|
||||
@@ -2097,7 +2102,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
}
|
||||
case NetworkMonitor.EVENT_PROVISIONING_NOTIFICATION: {
|
||||
final int netId = msg.arg2;
|
||||
final boolean visible = (msg.arg1 != 0);
|
||||
final boolean visible = toBool(msg.arg1);
|
||||
final NetworkAgentInfo nai;
|
||||
synchronized (mNetworkForNetId) {
|
||||
nai = mNetworkForNetId.get(netId);
|
||||
@@ -2550,7 +2555,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
public void setAcceptUnvalidated(Network network, boolean accept, boolean always) {
|
||||
enforceConnectivityInternalPermission();
|
||||
mHandler.sendMessage(mHandler.obtainMessage(EVENT_SET_ACCEPT_UNVALIDATED,
|
||||
accept ? 1 : 0, always ? 1: 0, network));
|
||||
encodeBool(accept), encodeBool(always), network));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2587,7 +2592,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
|
||||
if (always) {
|
||||
nai.asyncChannel.sendMessage(
|
||||
NetworkAgent.CMD_SAVE_ACCEPT_UNVALIDATED, accept ? 1 : 0);
|
||||
NetworkAgent.CMD_SAVE_ACCEPT_UNVALIDATED, encodeBool(accept));
|
||||
}
|
||||
|
||||
if (!accept) {
|
||||
@@ -2788,7 +2793,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
break;
|
||||
}
|
||||
case EVENT_SET_ACCEPT_UNVALIDATED: {
|
||||
handleSetAcceptUnvalidated((Network) msg.obj, msg.arg1 != 0, msg.arg2 != 0);
|
||||
Network network = (Network) msg.obj;
|
||||
handleSetAcceptUnvalidated(network, toBool(msg.arg1), toBool(msg.arg2));
|
||||
break;
|
||||
}
|
||||
case EVENT_SET_AVOID_UNVALIDATED: {
|
||||
@@ -2822,6 +2828,10 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EVENT_REVALIDATE_NETWORK: {
|
||||
handleReportNetworkConnectivity((Network) msg.obj, msg.arg1, toBool(msg.arg2));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2936,9 +2946,10 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
@Override
|
||||
public boolean isTetheringSupported() {
|
||||
enforceTetherAccessPermission();
|
||||
int defaultVal = (mSystemProperties.get("ro.tether.denied").equals("true") ? 0 : 1);
|
||||
boolean tetherEnabledInSettings = (Settings.Global.getInt(mContext.getContentResolver(),
|
||||
Settings.Global.TETHER_SUPPORTED, defaultVal) != 0)
|
||||
int defaultVal = encodeBool(!mSystemProperties.get("ro.tether.denied").equals("true"));
|
||||
boolean tetherSupported = toBool(Settings.Global.getInt(mContext.getContentResolver(),
|
||||
Settings.Global.TETHER_SUPPORTED, defaultVal));
|
||||
boolean tetherEnabledInSettings = tetherSupported
|
||||
&& !mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_TETHERING);
|
||||
|
||||
// Elevate to system UID to avoid caller requiring MANAGE_USERS permission.
|
||||
@@ -2950,8 +2961,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
Binder.restoreCallingIdentity(token);
|
||||
}
|
||||
|
||||
return tetherEnabledInSettings && adminUser &&
|
||||
mTethering.hasTetherableConfiguration();
|
||||
return tetherEnabledInSettings && adminUser && mTethering.hasTetherableConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -3029,8 +3039,14 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
public void reportNetworkConnectivity(Network network, boolean hasConnectivity) {
|
||||
enforceAccessPermission();
|
||||
enforceInternetPermission();
|
||||
final int uid = Binder.getCallingUid();
|
||||
final int connectivityInfo = encodeBool(hasConnectivity);
|
||||
mHandler.sendMessage(
|
||||
mHandler.obtainMessage(EVENT_REVALIDATE_NETWORK, uid, connectivityInfo, network));
|
||||
}
|
||||
|
||||
// TODO: execute this logic on ConnectivityService handler.
|
||||
private void handleReportNetworkConnectivity(
|
||||
Network network, int uid, boolean hasConnectivity) {
|
||||
final NetworkAgentInfo nai;
|
||||
if (network == null) {
|
||||
nai = getDefaultNetwork();
|
||||
@@ -3045,10 +3061,9 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
if (hasConnectivity == nai.lastValidated) {
|
||||
return;
|
||||
}
|
||||
final int uid = Binder.getCallingUid();
|
||||
if (DBG) {
|
||||
log("reportNetworkConnectivity(" + nai.network.netId + ", " + hasConnectivity +
|
||||
") by " + uid);
|
||||
int netid = nai.network.netId;
|
||||
log("reportNetworkConnectivity(" + netid + ", " + hasConnectivity + ") by " + uid);
|
||||
}
|
||||
// Validating a network that has not yet connected could result in a call to
|
||||
// rematchNetworkAndRequests() which is not meant to work on such networks.
|
||||
@@ -3755,7 +3770,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
final long ident = Binder.clearCallingIdentity();
|
||||
try {
|
||||
final ContentResolver cr = mContext.getContentResolver();
|
||||
Settings.Global.putInt(cr, Settings.Global.AIRPLANE_MODE_ON, enable ? 1 : 0);
|
||||
Settings.Global.putInt(cr, Settings.Global.AIRPLANE_MODE_ON, encodeBool(enable));
|
||||
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
|
||||
intent.putExtra("state", enable);
|
||||
mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
|
||||
@@ -5427,4 +5442,12 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
private void logNetworkEvent(NetworkAgentInfo nai, int evtype) {
|
||||
mMetricsLog.log(new NetworkEvent(nai.network.netId, evtype));
|
||||
}
|
||||
|
||||
private static boolean toBool(int encodedBoolean) {
|
||||
return encodedBoolean != 0; // Only 0 means false.
|
||||
}
|
||||
|
||||
private static int encodeBool(boolean b) {
|
||||
return b ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user