Start Nearby from Connectivity ServiceInitializer
On T+, start and register Nearby services from the initializer, and send proper callbacks. Bug: 189355156 Test: Booted, service started Merged-In: I7e280495f1eefada0939dad2ce7f47f45885ad66 Change-Id: Ieca032c80cb37e424d07c500257a844c8418fe3e
This commit is contained in:
committed by
Tyler Wear
parent
b52c67d5d7
commit
5906c8b290
@@ -38,6 +38,7 @@ java_library {
|
||||
"framework-connectivity-t-pre-jarjar",
|
||||
"framework-tethering.stubs.module_lib",
|
||||
"service-connectivity-pre-jarjar",
|
||||
"service-nearby",
|
||||
"unsupportedappusage",
|
||||
],
|
||||
static_libs: [
|
||||
|
||||
@@ -20,16 +20,18 @@ import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.modules.utils.build.SdkLevel;
|
||||
import com.android.server.nearby.NearbyService;
|
||||
|
||||
/**
|
||||
* Connectivity service initializer for core networking. This is called by system server to create
|
||||
* a new instance of ConnectivityService.
|
||||
* a new instance of connectivity services.
|
||||
*/
|
||||
public final class ConnectivityServiceInitializer extends SystemService {
|
||||
private static final String TAG = ConnectivityServiceInitializer.class.getSimpleName();
|
||||
private final ConnectivityService mConnectivity;
|
||||
private final IpSecService mIpSecService;
|
||||
private final NsdService mNsdService;
|
||||
private final NearbyService mNearbyService;
|
||||
|
||||
public ConnectivityServiceInitializer(Context context) {
|
||||
super(context);
|
||||
@@ -38,6 +40,7 @@ public final class ConnectivityServiceInitializer extends SystemService {
|
||||
mConnectivity = new ConnectivityService(context);
|
||||
mIpSecService = createIpSecService(context);
|
||||
mNsdService = createNsdService(context);
|
||||
mNearbyService = createNearbyService(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,6 +58,19 @@ public final class ConnectivityServiceInitializer extends SystemService {
|
||||
Log.i(TAG, "Registering " + Context.NSD_SERVICE);
|
||||
publishBinderService(Context.NSD_SERVICE, mNsdService, /* allowIsolated= */ false);
|
||||
}
|
||||
|
||||
if (mNearbyService != null) {
|
||||
Log.i(TAG, "Registering " + Context.NEARBY_SERVICE);
|
||||
publishBinderService(Context.NEARBY_SERVICE, mNearbyService,
|
||||
/* allowIsolated= */ false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBootPhase(int phase) {
|
||||
if (mNearbyService != null) {
|
||||
mNearbyService.onBootPhase(phase);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,4 +92,10 @@ public final class ConnectivityServiceInitializer extends SystemService {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** Return Nearby service instance or null if current SDK is lower than T */
|
||||
private NearbyService createNearbyService(final Context context) {
|
||||
if (!SdkLevel.isAtLeastT()) return null;
|
||||
return new NearbyService(context);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user