Crash bad callers earlier
Instead of crashing when parceling the NetworkInfo object, crash at the time the bad call is made. Bug: 145972387 Test: FrameworksNetTests Change-Id: If8b5fd3d7b800c97211bcd16c9a8c5812708d4ab
This commit is contained in:
@@ -179,21 +179,19 @@ public class NetworkInfo implements Parcelable {
|
|||||||
|
|
||||||
/** {@hide} */
|
/** {@hide} */
|
||||||
@UnsupportedAppUsage
|
@UnsupportedAppUsage
|
||||||
public NetworkInfo(NetworkInfo source) {
|
public NetworkInfo(@NonNull NetworkInfo source) {
|
||||||
if (source != null) {
|
synchronized (source) {
|
||||||
synchronized (source) {
|
mNetworkType = source.mNetworkType;
|
||||||
mNetworkType = source.mNetworkType;
|
mSubtype = source.mSubtype;
|
||||||
mSubtype = source.mSubtype;
|
mTypeName = source.mTypeName;
|
||||||
mTypeName = source.mTypeName;
|
mSubtypeName = source.mSubtypeName;
|
||||||
mSubtypeName = source.mSubtypeName;
|
mState = source.mState;
|
||||||
mState = source.mState;
|
mDetailedState = source.mDetailedState;
|
||||||
mDetailedState = source.mDetailedState;
|
mReason = source.mReason;
|
||||||
mReason = source.mReason;
|
mExtraInfo = source.mExtraInfo;
|
||||||
mExtraInfo = source.mExtraInfo;
|
mIsFailover = source.mIsFailover;
|
||||||
mIsFailover = source.mIsFailover;
|
mIsAvailable = source.mIsAvailable;
|
||||||
mIsAvailable = source.mIsAvailable;
|
mIsRoaming = source.mIsRoaming;
|
||||||
mIsRoaming = source.mIsRoaming;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -479,7 +477,7 @@ public class NetworkInfo implements Parcelable {
|
|||||||
* @param detailedState the {@link DetailedState}.
|
* @param detailedState the {@link DetailedState}.
|
||||||
* @param reason a {@code String} indicating the reason for the state change,
|
* @param reason a {@code String} indicating the reason for the state change,
|
||||||
* if one was supplied. May be {@code null}.
|
* if one was supplied. May be {@code null}.
|
||||||
* @param extraInfo an optional {@code String} providing addditional network state
|
* @param extraInfo an optional {@code String} providing additional network state
|
||||||
* information passed up from the lower networking layers.
|
* information passed up from the lower networking layers.
|
||||||
* @deprecated Use {@link NetworkCapabilities} instead.
|
* @deprecated Use {@link NetworkCapabilities} instead.
|
||||||
*/
|
*/
|
||||||
@@ -491,6 +489,11 @@ public class NetworkInfo implements Parcelable {
|
|||||||
this.mState = stateMap.get(detailedState);
|
this.mState = stateMap.get(detailedState);
|
||||||
this.mReason = reason;
|
this.mReason = reason;
|
||||||
this.mExtraInfo = extraInfo;
|
this.mExtraInfo = extraInfo;
|
||||||
|
// Catch both the case where detailedState is null and the case where it's some
|
||||||
|
// unknown value
|
||||||
|
if (null == mState) {
|
||||||
|
throw new NullPointerException("Unknown DetailedState : " + detailedState);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -109,8 +109,8 @@ public class Nat464XlatTest {
|
|||||||
|
|
||||||
mNai.linkProperties = new LinkProperties();
|
mNai.linkProperties = new LinkProperties();
|
||||||
mNai.linkProperties.setInterfaceName(BASE_IFACE);
|
mNai.linkProperties.setInterfaceName(BASE_IFACE);
|
||||||
mNai.networkInfo = new NetworkInfo(null);
|
mNai.networkInfo = new NetworkInfo(ConnectivityManager.TYPE_WIFI, 0 /* subtype */,
|
||||||
mNai.networkInfo.setType(ConnectivityManager.TYPE_WIFI);
|
null /* typeName */, null /* subtypeName */);
|
||||||
mNai.networkCapabilities = new NetworkCapabilities();
|
mNai.networkCapabilities = new NetworkCapabilities();
|
||||||
markNetworkConnected();
|
markNetworkConnected();
|
||||||
when(mNai.connService()).thenReturn(mConnectivity);
|
when(mNai.connService()).thenReturn(mConnectivity);
|
||||||
|
|||||||
Reference in New Issue
Block a user