Remove Protocol.BASE_* usage in Connectivity

ConnectivityManager and NetworkAgent do not share their handler with any
other component, so there is no reason to use addresses that do not
overlap. Protocol.BASE_* was written to allow for interaction "between
different StateMachine implementations without a conflict", but the
classes do not use StateMachine, and they do not have such interactions.

Bug: 177046265
Test: atest FrameworksNetTests
Change-Id: I18c341d4a2c01cb9559d682a9ad1ff259e6b5855
This commit is contained in:
Remi NGUYEN VAN
2021-03-12 15:24:06 +09:00
parent b67cbe2631
commit 4ea08c2ab4
3 changed files with 15 additions and 17 deletions

View File

@@ -59,8 +59,6 @@ public class Protocol {
public static final int BASE_TETHERING = 0x00050000;
public static final int BASE_NSD_MANAGER = 0x00060000;
public static final int BASE_NETWORK_STATE_TRACKER = 0x00070000;
public static final int BASE_CONNECTIVITY_MANAGER = 0x00080000;
public static final int BASE_NETWORK_AGENT = 0x00081000;
public static final int BASE_NETWORK_FACTORY = 0x00083000;
public static final int BASE_ETHERNET = 0x00084000;
public static final int BASE_LOWPAN = 0x00085000;

View File

@@ -77,7 +77,6 @@ import android.util.SparseIntArray;
import com.android.connectivity.aidl.INetworkAgent;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.util.Preconditions;
import com.android.internal.util.Protocol;
import libcore.net.event.NetworkEventDispatcher;
@@ -3551,29 +3550,28 @@ public class ConnectivityManager {
}
}
private static final int BASE = Protocol.BASE_CONNECTIVITY_MANAGER;
/** @hide */
public static final int CALLBACK_PRECHECK = BASE + 1;
public static final int CALLBACK_PRECHECK = 1;
/** @hide */
public static final int CALLBACK_AVAILABLE = BASE + 2;
public static final int CALLBACK_AVAILABLE = 2;
/** @hide arg1 = TTL */
public static final int CALLBACK_LOSING = BASE + 3;
public static final int CALLBACK_LOSING = 3;
/** @hide */
public static final int CALLBACK_LOST = BASE + 4;
public static final int CALLBACK_LOST = 4;
/** @hide */
public static final int CALLBACK_UNAVAIL = BASE + 5;
public static final int CALLBACK_UNAVAIL = 5;
/** @hide */
public static final int CALLBACK_CAP_CHANGED = BASE + 6;
public static final int CALLBACK_CAP_CHANGED = 6;
/** @hide */
public static final int CALLBACK_IP_CHANGED = BASE + 7;
public static final int CALLBACK_IP_CHANGED = 7;
/** @hide obj = NetworkCapabilities, arg1 = seq number */
private static final int EXPIRE_LEGACY_REQUEST = BASE + 8;
private static final int EXPIRE_LEGACY_REQUEST = 8;
/** @hide */
public static final int CALLBACK_SUSPENDED = BASE + 9;
public static final int CALLBACK_SUSPENDED = 9;
/** @hide */
public static final int CALLBACK_RESUMED = BASE + 10;
public static final int CALLBACK_RESUMED = 10;
/** @hide */
public static final int CALLBACK_BLK_CHANGED = BASE + 11;
public static final int CALLBACK_BLK_CHANGED = 11;
/** @hide */
public static String getCallbackName(int whichCallback) {

View File

@@ -37,7 +37,6 @@ import android.util.Log;
import com.android.connectivity.aidl.INetworkAgent;
import com.android.connectivity.aidl.INetworkAgentRegistry;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.Protocol;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -125,7 +124,10 @@ public abstract class NetworkAgent {
*/
public final int providerId;
private static final int BASE = Protocol.BASE_NETWORK_AGENT;
// ConnectivityService parses message constants from itself and NetworkAgent with MessageUtils
// for debugging purposes, and crashes if some messages have the same values.
// TODO: have ConnectivityService store message names in different maps and remove this base
private static final int BASE = 200;
/**
* Sent by ConnectivityService to the NetworkAgent to inform it of