Build ethernet framework source into framework-connectivity-tiramisu
- move ethernet APIs, build it into framework-connectivity-tiramisu - start ethernet service from ConnectivityServiceInitializer - fix EthernetManager dependnecy in Tethering module - fix EthernetNetworkSpecifier dependency in framework-connectivity - fix the ethernet related config resource Bug: 210586283 Test: m Test: atest FrameworksNetTests EthernetServiceTests Change-Id: I54857b8517649048a343c72797668394d5225766 Merged-In: I54857b8517649048a343c72797668394d5225766
This commit is contained in:
@@ -21,6 +21,8 @@ import android.util.Log;
|
||||
|
||||
import com.android.modules.utils.build.SdkLevel;
|
||||
import com.android.networkstack.apishim.ConstantsShim;
|
||||
import com.android.server.ethernet.EthernetService;
|
||||
import com.android.server.ethernet.EthernetServiceImpl;
|
||||
import com.android.server.nearby.NearbyService;
|
||||
|
||||
/**
|
||||
@@ -29,15 +31,19 @@ import com.android.server.nearby.NearbyService;
|
||||
*/
|
||||
public final class ConnectivityServiceInitializer extends SystemService {
|
||||
private static final String TAG = ConnectivityServiceInitializer.class.getSimpleName();
|
||||
private final Context mContext;
|
||||
private final ConnectivityService mConnectivity;
|
||||
private final IpSecService mIpSecService;
|
||||
private final NsdService mNsdService;
|
||||
private final NearbyService mNearbyService;
|
||||
private final EthernetServiceImpl mEthernetServiceImpl;
|
||||
|
||||
public ConnectivityServiceInitializer(Context context) {
|
||||
super(context);
|
||||
mContext = context;
|
||||
// Load JNI libraries used by ConnectivityService and its dependencies
|
||||
System.loadLibrary("service-connectivity");
|
||||
mEthernetServiceImpl = createEthernetService(context);
|
||||
mConnectivity = new ConnectivityService(context);
|
||||
mIpSecService = createIpSecService(context);
|
||||
mNsdService = createNsdService(context);
|
||||
@@ -46,6 +52,12 @@ public final class ConnectivityServiceInitializer extends SystemService {
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
if (mConnectivity.deviceSupportsEthernet(mContext)) {
|
||||
Log.i(TAG, "Registering " + Context.ETHERNET_SERVICE);
|
||||
publishBinderService(Context.ETHERNET_SERVICE, mEthernetServiceImpl,
|
||||
/* allowIsolated= */ false);
|
||||
}
|
||||
|
||||
Log.i(TAG, "Registering " + Context.CONNECTIVITY_SERVICE);
|
||||
publishBinderService(Context.CONNECTIVITY_SERVICE, mConnectivity,
|
||||
/* allowIsolated= */ false);
|
||||
@@ -65,6 +77,7 @@ public final class ConnectivityServiceInitializer extends SystemService {
|
||||
publishBinderService(ConstantsShim.NEARBY_SERVICE, mNearbyService,
|
||||
/* allowIsolated= */ false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -72,6 +85,10 @@ public final class ConnectivityServiceInitializer extends SystemService {
|
||||
if (mNearbyService != null) {
|
||||
mNearbyService.onBootPhase(phase);
|
||||
}
|
||||
|
||||
if (phase == SystemService.PHASE_SYSTEM_SERVICES_READY && mEthernetServiceImpl != null) {
|
||||
mEthernetServiceImpl.start();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,4 +123,15 @@ public final class ConnectivityServiceInitializer extends SystemService {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return EthernetServiceImpl instance or null if current SDK is lower than T or Ethernet
|
||||
* service isn't necessary.
|
||||
*/
|
||||
private EthernetServiceImpl createEthernetService(final Context context) {
|
||||
if (!SdkLevel.isAtLeastT() || !mConnectivity.deviceSupportsEthernet(context)) {
|
||||
return null;
|
||||
}
|
||||
return EthernetService.create(context);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user