Merge "Always report non-null TetherStatesParcel"
This commit is contained in:
@@ -1944,7 +1944,8 @@ public class Tethering {
|
||||
parcel.tetheringSupported = mDeps.isTetheringSupported();
|
||||
parcel.upstreamNetwork = mTetherUpstream;
|
||||
parcel.config = mConfig.toStableParcelable();
|
||||
parcel.states = mTetherStatesParcel;
|
||||
parcel.states =
|
||||
mTetherStatesParcel != null ? mTetherStatesParcel : emptyTetherStatesParcel();
|
||||
try {
|
||||
callback.onCallbackStarted(parcel);
|
||||
} catch (RemoteException e) {
|
||||
@@ -1953,6 +1954,17 @@ public class Tethering {
|
||||
});
|
||||
}
|
||||
|
||||
private TetherStatesParcel emptyTetherStatesParcel() {
|
||||
final TetherStatesParcel parcel = new TetherStatesParcel();
|
||||
parcel.availableList = new String[0];
|
||||
parcel.tetheredList = new String[0];
|
||||
parcel.localOnlyList = new String[0];
|
||||
parcel.erroredIfaceList = new String[0];
|
||||
parcel.lastErrorList = new int[0];
|
||||
|
||||
return parcel;
|
||||
}
|
||||
|
||||
/** Unregister tethering event callback */
|
||||
void unregisterTetheringEventCallback(ITetheringEventCallback callback) {
|
||||
mHandler.post(() -> {
|
||||
|
||||
@@ -127,6 +127,7 @@ import com.android.internal.util.StateMachine;
|
||||
import com.android.internal.util.test.BroadcastInterceptingContext;
|
||||
import com.android.internal.util.test.FakeSettingsProvider;
|
||||
import com.android.networkstack.tethering.R;
|
||||
import com.android.testutils.MiscAssertsKt;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
@@ -1220,6 +1221,16 @@ public class TetheringTest {
|
||||
}
|
||||
}
|
||||
|
||||
private void assertTetherStatesNotNullButEmpty(final TetherStatesParcel parcel) {
|
||||
assertFalse(parcel == null);
|
||||
assertEquals(0, parcel.availableList.length);
|
||||
assertEquals(0, parcel.tetheredList.length);
|
||||
assertEquals(0, parcel.localOnlyList.length);
|
||||
assertEquals(0, parcel.erroredIfaceList.length);
|
||||
assertEquals(0, parcel.lastErrorList.length);
|
||||
MiscAssertsKt.assertFieldCountEquals(5, TetherStatesParcel.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRegisterTetheringEventCallback() throws Exception {
|
||||
TestTetheringEventCallback callback = new TestTetheringEventCallback();
|
||||
@@ -1232,7 +1243,7 @@ public class TetheringTest {
|
||||
callback.expectConfigurationChanged(
|
||||
mTethering.getTetheringConfiguration().toStableParcelable());
|
||||
TetherStatesParcel tetherState = callback.pollTetherStatesChanged();
|
||||
assertEquals(tetherState, null);
|
||||
assertTetherStatesNotNullButEmpty(tetherState);
|
||||
// 2. Enable wifi tethering.
|
||||
UpstreamNetworkState upstreamState = buildMobileDualStackUpstreamState();
|
||||
when(mUpstreamNetworkMonitor.getCurrentPreferredUpstream()).thenReturn(upstreamState);
|
||||
|
||||
Reference in New Issue
Block a user