Send OffloadServiceInfos when registerOffloadEngine is called
When the OffloadEngine is registered, it should get notice about all the currently offloaded service. Bug: 297314970 Test: atest CtsNetTestCases Change-Id: I1b977a40476a1f5c30a075b559e72656a42865ae
This commit is contained in:
@@ -1162,7 +1162,7 @@ public class NsdService extends INsdManager.Stub {
|
||||
// TODO: Limits the number of registrations created by a given class.
|
||||
mOffloadEngines.register(offloadEngineInfo.mOffloadEngine,
|
||||
offloadEngineInfo);
|
||||
// TODO: Sends all the existing OffloadServiceInfos back.
|
||||
sendAllOffloadServiceInfos(offloadEngineInfo);
|
||||
break;
|
||||
case NsdManager.UNREGISTER_OFFLOAD_ENGINE:
|
||||
mOffloadEngines.unregister((IOffloadEngine) msg.obj);
|
||||
@@ -1834,6 +1834,21 @@ public class NsdService extends INsdManager.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
private void sendAllOffloadServiceInfos(@NonNull OffloadEngineInfo offloadEngineInfo) {
|
||||
final String targetInterface = offloadEngineInfo.mInterfaceName;
|
||||
final IOffloadEngine offloadEngine = offloadEngineInfo.mOffloadEngine;
|
||||
final List<MdnsAdvertiser.OffloadServiceInfoWrapper> offloadWrappers =
|
||||
mAdvertiser.getAllInterfaceOffloadServiceInfos(targetInterface);
|
||||
for (MdnsAdvertiser.OffloadServiceInfoWrapper wrapper : offloadWrappers) {
|
||||
try {
|
||||
offloadEngine.onOffloadServiceUpdated(wrapper.mOffloadServiceInfo);
|
||||
} catch (RemoteException e) {
|
||||
// Can happen in regular cases, do not log a stacktrace
|
||||
Log.i(TAG, "Failed to send offload callback, remote died: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void sendOffloadServiceInfosUpdate(@NonNull String targetInterfaceName,
|
||||
@NonNull OffloadServiceInfo offloadServiceInfo, boolean isRemove) {
|
||||
final int count = mOffloadEngines.beginBroadcast();
|
||||
@@ -1857,7 +1872,7 @@ public class NsdService extends INsdManager.Stub {
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
// Can happen in regular cases, do not log a stacktrace
|
||||
Log.i(TAG, "Failed to send offload callback, remote died", e);
|
||||
Log.i(TAG, "Failed to send offload callback, remote died: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user