resolve merge conflicts of 7bbd03be361f to oc-dev-plus-aosp
Conflits were:
- static import section of ConnectivityService
- code deleted in commit 8d96292e08
Test: built.
Change-Id: I0e026522558f39d8ae6812b62a30f2501923ab86
This commit is contained in:
@@ -48,7 +48,6 @@ import android.util.SparseIntArray;
|
|||||||
|
|
||||||
import com.android.internal.telephony.ITelephony;
|
import com.android.internal.telephony.ITelephony;
|
||||||
import com.android.internal.telephony.PhoneConstants;
|
import com.android.internal.telephony.PhoneConstants;
|
||||||
import com.android.internal.util.MessageUtils;
|
|
||||||
import com.android.internal.util.Preconditions;
|
import com.android.internal.util.Preconditions;
|
||||||
import com.android.internal.util.Protocol;
|
import com.android.internal.util.Protocol;
|
||||||
|
|
||||||
@@ -2765,46 +2764,46 @@ public class ConnectivityManager {
|
|||||||
NetworkRequest request = getObject(message, NetworkRequest.class);
|
NetworkRequest request = getObject(message, NetworkRequest.class);
|
||||||
Network network = getObject(message, Network.class);
|
Network network = getObject(message, Network.class);
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
Log.d(TAG, whatToString(message.what) + " for network " + network);
|
Log.d(TAG, getCallbackName(message.what) + " for network " + network);
|
||||||
}
|
}
|
||||||
switch (message.what) {
|
switch (message.what) {
|
||||||
case CALLBACK_PRECHECK: {
|
case CALLBACK_PRECHECK: {
|
||||||
NetworkCallback callback = getCallback(request, "PRECHECK");
|
NetworkCallback callback = getCallback(message);
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback.onPreCheck(network);
|
callback.onPreCheck(network);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CALLBACK_AVAILABLE: {
|
case CALLBACK_AVAILABLE: {
|
||||||
NetworkCallback callback = getCallback(request, "AVAILABLE");
|
NetworkCallback callback = getCallback(message);
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback.onAvailable(network);
|
callback.onAvailable(network);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CALLBACK_LOSING: {
|
case CALLBACK_LOSING: {
|
||||||
NetworkCallback callback = getCallback(request, "LOSING");
|
NetworkCallback callback = getCallback(message);
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback.onLosing(network, message.arg1);
|
callback.onLosing(network, message.arg1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CALLBACK_LOST: {
|
case CALLBACK_LOST: {
|
||||||
NetworkCallback callback = getCallback(request, "LOST");
|
NetworkCallback callback = getCallback(message);
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback.onLost(network);
|
callback.onLost(network);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CALLBACK_UNAVAIL: {
|
case CALLBACK_UNAVAIL: {
|
||||||
NetworkCallback callback = getCallback(request, "UNAVAIL");
|
NetworkCallback callback = getCallback(message);
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback.onUnavailable();
|
callback.onUnavailable();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CALLBACK_CAP_CHANGED: {
|
case CALLBACK_CAP_CHANGED: {
|
||||||
NetworkCallback callback = getCallback(request, "CAP_CHANGED");
|
NetworkCallback callback = getCallback(message);
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
NetworkCapabilities cap = getObject(message, NetworkCapabilities.class);
|
NetworkCapabilities cap = getObject(message, NetworkCapabilities.class);
|
||||||
callback.onCapabilitiesChanged(network, cap);
|
callback.onCapabilitiesChanged(network, cap);
|
||||||
@@ -2812,7 +2811,7 @@ public class ConnectivityManager {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CALLBACK_IP_CHANGED: {
|
case CALLBACK_IP_CHANGED: {
|
||||||
NetworkCallback callback = getCallback(request, "IP_CHANGED");
|
NetworkCallback callback = getCallback(message);
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
LinkProperties lp = getObject(message, LinkProperties.class);
|
LinkProperties lp = getObject(message, LinkProperties.class);
|
||||||
callback.onLinkPropertiesChanged(network, lp);
|
callback.onLinkPropertiesChanged(network, lp);
|
||||||
@@ -2820,14 +2819,14 @@ public class ConnectivityManager {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CALLBACK_SUSPENDED: {
|
case CALLBACK_SUSPENDED: {
|
||||||
NetworkCallback callback = getCallback(request, "SUSPENDED");
|
NetworkCallback callback = getCallback(message);
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback.onNetworkSuspended(network);
|
callback.onNetworkSuspended(network);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CALLBACK_RESUMED: {
|
case CALLBACK_RESUMED: {
|
||||||
NetworkCallback callback = getCallback(request, "RESUMED");
|
NetworkCallback callback = getCallback(message);
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback.onNetworkResumed(network);
|
callback.onNetworkResumed(network);
|
||||||
}
|
}
|
||||||
@@ -2850,13 +2849,14 @@ public class ConnectivityManager {
|
|||||||
return (T) msg.getData().getParcelable(c.getSimpleName());
|
return (T) msg.getData().getParcelable(c.getSimpleName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private NetworkCallback getCallback(NetworkRequest req, String name) {
|
private NetworkCallback getCallback(Message msg) {
|
||||||
|
final NetworkRequest req = getObject(msg, NetworkRequest.class);
|
||||||
final NetworkCallback callback;
|
final NetworkCallback callback;
|
||||||
synchronized(sCallbacks) {
|
synchronized(sCallbacks) {
|
||||||
callback = sCallbacks.get(req);
|
callback = sCallbacks.get(req);
|
||||||
}
|
}
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
Log.w(TAG, "callback not found for " + name + " message");
|
Log.w(TAG, "callback not found for " + getCallbackName(msg.what) + " message");
|
||||||
}
|
}
|
||||||
return callback;
|
return callback;
|
||||||
}
|
}
|
||||||
@@ -3746,32 +3746,4 @@ public class ConnectivityManager {
|
|||||||
throw e.rethrowFromSystemServer();
|
throw e.rethrowFromSystemServer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* A holder class for debug info (mapping CALLBACK values to field names). This is stored
|
|
||||||
* in a holder for two reasons:
|
|
||||||
* 1) The reflection necessary to establish the map can't be run at compile-time. Thus, this
|
|
||||||
* code will make the enclosing class not compile-time initializeable, deferring its
|
|
||||||
* initialization to zygote startup. This leads to dirty (but shared) memory.
|
|
||||||
* As this is debug info, use a holder that isn't initialized by default. This way the map
|
|
||||||
* will be created on demand, while ConnectivityManager can be compile-time initialized.
|
|
||||||
* 2) Static initialization is still preferred for its strong thread safety guarantees without
|
|
||||||
* requiring a lock.
|
|
||||||
*/
|
|
||||||
private static class NoPreloadHolder {
|
|
||||||
public static final SparseArray<String> sMagicDecoderRing = MessageUtils.findMessageNames(
|
|
||||||
new Class[]{ConnectivityManager.class}, new String[]{"CALLBACK_"});
|
|
||||||
}
|
|
||||||
|
|
||||||
static {
|
|
||||||
// When debug is enabled, aggressively initialize the holder by touching the field (which
|
|
||||||
// will guarantee static initialization).
|
|
||||||
if (CallbackHandler.DBG) {
|
|
||||||
Object dummy = NoPreloadHolder.sMagicDecoderRing;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String whatToString(int what) {
|
|
||||||
return NoPreloadHolder.sMagicDecoderRing.get(what, Integer.toString(what));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import static android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET;
|
|||||||
import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_METERED;
|
import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_METERED;
|
||||||
import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED;
|
import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED;
|
||||||
import static android.net.NetworkCapabilities.NET_CAPABILITY_VALIDATED;
|
import static android.net.NetworkCapabilities.NET_CAPABILITY_VALIDATED;
|
||||||
|
import static com.android.internal.util.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.app.BroadcastOptions;
|
import android.app.BroadcastOptions;
|
||||||
@@ -3326,13 +3327,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
Slog.e(TAG, s, t);
|
Slog.e(TAG, s, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T> T checkNotNull(T value, String message) {
|
|
||||||
if (value == null) {
|
|
||||||
throw new NullPointerException(message);
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare for a VPN application.
|
* Prepare for a VPN application.
|
||||||
* VPN permissions are checked in the {@link Vpn} class. If the caller is not {@code userId},
|
* VPN permissions are checked in the {@link Vpn} class. If the caller is not {@code userId},
|
||||||
@@ -4631,8 +4625,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
msg.setData(bundle);
|
msg.setData(bundle);
|
||||||
try {
|
try {
|
||||||
if (VDBG) {
|
if (VDBG) {
|
||||||
log("sending notification " + notifyTypeToName(notificationType) +
|
String notification = ConnectivityManager.getCallbackName(notificationType);
|
||||||
" for " + nri.request);
|
log("sending notification " + notification + " for " + nri.request);
|
||||||
}
|
}
|
||||||
nri.messenger.send(msg);
|
nri.messenger.send(msg);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
@@ -5242,7 +5236,10 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void notifyNetworkCallbacks(NetworkAgentInfo networkAgent, int notifyType, int arg1) {
|
protected void notifyNetworkCallbacks(NetworkAgentInfo networkAgent, int notifyType, int arg1) {
|
||||||
if (VDBG) log("notifyType " + notifyTypeToName(notifyType) + " for " + networkAgent.name());
|
if (VDBG) {
|
||||||
|
String notification = ConnectivityManager.getCallbackName(notifyType);
|
||||||
|
log("notifyType " + notification + " for " + networkAgent.name());
|
||||||
|
}
|
||||||
for (int i = 0; i < networkAgent.numNetworkRequests(); i++) {
|
for (int i = 0; i < networkAgent.numNetworkRequests(); i++) {
|
||||||
NetworkRequest nr = networkAgent.requestAt(i);
|
NetworkRequest nr = networkAgent.requestAt(i);
|
||||||
NetworkRequestInfo nri = mNetworkRequests.get(nr);
|
NetworkRequestInfo nri = mNetworkRequests.get(nr);
|
||||||
@@ -5261,20 +5258,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
notifyNetworkCallbacks(networkAgent, notifyType, 0);
|
notifyNetworkCallbacks(networkAgent, notifyType, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String notifyTypeToName(int notifyType) {
|
|
||||||
switch (notifyType) {
|
|
||||||
case ConnectivityManager.CALLBACK_PRECHECK: return "PRECHECK";
|
|
||||||
case ConnectivityManager.CALLBACK_AVAILABLE: return "AVAILABLE";
|
|
||||||
case ConnectivityManager.CALLBACK_LOSING: return "LOSING";
|
|
||||||
case ConnectivityManager.CALLBACK_LOST: return "LOST";
|
|
||||||
case ConnectivityManager.CALLBACK_UNAVAIL: return "UNAVAILABLE";
|
|
||||||
case ConnectivityManager.CALLBACK_CAP_CHANGED: return "CAP_CHANGED";
|
|
||||||
case ConnectivityManager.CALLBACK_IP_CHANGED: return "IP_CHANGED";
|
|
||||||
case ConnectivityManager.CALLBACK_RELEASED: return "RELEASED";
|
|
||||||
}
|
|
||||||
return "UNKNOWN";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notify NetworkStatsService that the set of active ifaces has changed, or that one of the
|
* Notify NetworkStatsService that the set of active ifaces has changed, or that one of the
|
||||||
* properties tracked by NetworkStatsService on an active iface has changed.
|
* properties tracked by NetworkStatsService on an active iface has changed.
|
||||||
|
|||||||
Reference in New Issue
Block a user