Update ConnectivityDiagnosticsCallback function name.

API Council feedback suggests renaming ConnectivityDiagnosticsCallback
'onConnectivityReport' function to be 'onConnectivityReportAvailable'.

Bug: 150598997
Test: atest FrameworksNetTests
Change-Id: Ieea727ecee6cf358a53a215fd4b06233dfe967ea
(cherry picked from commit 324b224cc48fcb12125bd1727be70ad2effbfce3)
This commit is contained in:
Cody Kesting
2020-03-05 15:19:48 -08:00
parent 518e54c7b0
commit 22d0bfd7c4
4 changed files with 12 additions and 11 deletions

View File

@@ -233,8 +233,8 @@ public class ConnectivityDiagnosticsManager {
* Constructor for ConnectivityReport. * Constructor for ConnectivityReport.
* *
* <p>Apps should obtain instances through {@link * <p>Apps should obtain instances through {@link
* ConnectivityDiagnosticsCallback#onConnectivityReport} instead of instantiating their own * ConnectivityDiagnosticsCallback#onConnectivityReportAvailable} instead of instantiating
* instances (unless for testing purposes). * their own instances (unless for testing purposes).
* *
* @param network The Network for which this ConnectivityReport applies * @param network The Network for which this ConnectivityReport applies
* @param reportTimestamp The timestamp for the report * @param reportTimestamp The timestamp for the report
@@ -622,10 +622,10 @@ public class ConnectivityDiagnosticsManager {
/** @hide */ /** @hide */
@VisibleForTesting @VisibleForTesting
public void onConnectivityReport(@NonNull ConnectivityReport report) { public void onConnectivityReportAvailable(@NonNull ConnectivityReport report) {
Binder.withCleanCallingIdentity(() -> { Binder.withCleanCallingIdentity(() -> {
mExecutor.execute(() -> { mExecutor.execute(() -> {
mCb.onConnectivityReport(report); mCb.onConnectivityReportAvailable(report);
}); });
}); });
} }
@@ -666,7 +666,7 @@ public class ConnectivityDiagnosticsManager {
* *
* @param report The ConnectivityReport containing information about a connectivity check * @param report The ConnectivityReport containing information about a connectivity check
*/ */
public void onConnectivityReport(@NonNull ConnectivityReport report) {} public void onConnectivityReportAvailable(@NonNull ConnectivityReport report) {}
/** /**
* Called when the platform suspects a data stall on some Network. * Called when the platform suspects a data stall on some Network.

View File

@@ -7817,7 +7817,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
getMatchingPermissionedCallbacks(nai); getMatchingPermissionedCallbacks(nai);
for (final IConnectivityDiagnosticsCallback cb : results) { for (final IConnectivityDiagnosticsCallback cb : results) {
try { try {
cb.onConnectivityReport(report); cb.onConnectivityReportAvailable(report);
} catch (RemoteException ex) { } catch (RemoteException ex) {
loge("Error invoking onConnectivityReport", ex); loge("Error invoking onConnectivityReport", ex);
} }

View File

@@ -304,12 +304,12 @@ public class ConnectivityDiagnosticsManagerTest {
} }
@Test @Test
public void testConnectivityDiagnosticsCallbackOnConnectivityReport() { public void testConnectivityDiagnosticsCallbackOnConnectivityReportAvailable() {
mBinder.onConnectivityReport(createSampleConnectivityReport()); mBinder.onConnectivityReportAvailable(createSampleConnectivityReport());
// The callback will be invoked synchronously by inline executor. Immediately check the // The callback will be invoked synchronously by inline executor. Immediately check the
// latch without waiting. // latch without waiting.
verify(mCb).onConnectivityReport(eq(createSampleConnectivityReport())); verify(mCb).onConnectivityReportAvailable(eq(createSampleConnectivityReport()));
} }
@Test @Test

View File

@@ -6894,14 +6894,15 @@ public class ConnectivityServiceTest {
} }
@Test @Test
public void testConnectivityDiagnosticsCallbackOnConnectivityReport() throws Exception { public void testConnectivityDiagnosticsCallbackOnConnectivityReportAvailable()
throws Exception {
setUpConnectivityDiagnosticsCallback(); setUpConnectivityDiagnosticsCallback();
// Block until all other events are done processing. // Block until all other events are done processing.
HandlerUtilsKt.waitForIdle(mCsHandlerThread, TIMEOUT_MS); HandlerUtilsKt.waitForIdle(mCsHandlerThread, TIMEOUT_MS);
// Verify onConnectivityReport fired // Verify onConnectivityReport fired
verify(mConnectivityDiagnosticsCallback).onConnectivityReport( verify(mConnectivityDiagnosticsCallback).onConnectivityReportAvailable(
argThat(report -> { argThat(report -> {
final NetworkCapabilities nc = report.getNetworkCapabilities(); final NetworkCapabilities nc = report.getNetworkCapabilities();
return nc.getUids() == null return nc.getUids() == null