Use MessageUtils in ConnectivityManager.
Change-Id: I0179b45bc54ffced8e5647d6f005b891b5de93ab
diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java
index 7004e97..09ea8f9 100644
--- a/core/java/android/net/ConnectivityManager.java
+++ b/core/java/android/net/ConnectivityManager.java
@@ -45,10 +45,12 @@
import android.telephony.SubscriptionManager;
import android.util.ArrayMap;
import android.util.Log;
+import android.util.SparseArray;
import com.android.internal.telephony.ITelephony;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.util.Protocol;
+import com.android.internal.util.MessageUtils;
import libcore.net.event.NetworkEventDispatcher;
@@ -79,6 +81,13 @@
public class ConnectivityManager {
private static final String TAG = "ConnectivityManager";
+ private static final SparseArray<String> sMagicDecoderRing = MessageUtils.findMessageNames(
+ new Class[]{ConnectivityManager.class}, new String[]{"CALLBACK_"});
+
+ private static final String whatToString(int what) {
+ return sMagicDecoderRing.get(what, Integer.toString(what));
+ }
+
/**
* A change in network connectivity has occurred. A default connection has either
* been established or lost. The NetworkInfo for the affected network is
@@ -2563,9 +2572,11 @@
@Override
public void handleMessage(Message message) {
- if (DBG) Log.d(TAG, "CM callback handler got msg " + message.what);
NetworkRequest request = (NetworkRequest) getObject(message, NetworkRequest.class);
Network network = (Network) getObject(message, Network.class);
+ if (DBG) {
+ Log.d(TAG, whatToString(message.what) + " for network " + network);
+ }
switch (message.what) {
case CALLBACK_PRECHECK: {
NetworkCallback callback = getCallback(request, "PRECHECK");