Fix inexact argument type warning
Assign the corresponding VpnProfileState for the null argument. The varargs parameter has type "VpnProfileState...". It needs to decide whether the implementation want the argument to be treated as a single-element of type VpnProfileState or no arguement. Otherwise, it will confuse the compiler and cause warning. Test: atest VpnTest Change-Id: Ic1dee696bb50cd78849de4812fb46fd764b23c6e
This commit is contained in:
@@ -1293,12 +1293,12 @@ public class VpnTest extends VpnTestBase {
|
||||
}
|
||||
|
||||
private void verifyVpnManagerEvent(String sessionKey, String category, int errorClass,
|
||||
int errorCode, String[] packageName, VpnProfileState... profileState) {
|
||||
int errorCode, String[] packageName, @NonNull VpnProfileState... profileState) {
|
||||
final Context userContext =
|
||||
mContext.createContextAsUser(UserHandle.of(PRIMARY_USER.id), 0 /* flags */);
|
||||
final ArgumentCaptor<Intent> intentArgumentCaptor = ArgumentCaptor.forClass(Intent.class);
|
||||
|
||||
final int verifyTimes = (profileState == null) ? 1 : profileState.length;
|
||||
final int verifyTimes = profileState.length;
|
||||
verify(userContext, times(verifyTimes)).startService(intentArgumentCaptor.capture());
|
||||
|
||||
for (int i = 0; i < verifyTimes; i++) {
|
||||
@@ -1329,10 +1329,8 @@ public class VpnTest extends VpnTestBase {
|
||||
VpnManager.EXTRA_UNDERLYING_LINK_PROPERTIES));
|
||||
}
|
||||
|
||||
if (profileState != null) {
|
||||
assertEquals(profileState[i], intent.getParcelableExtra(
|
||||
VpnManager.EXTRA_VPN_PROFILE_STATE, VpnProfileState.class));
|
||||
}
|
||||
assertEquals(profileState[i], intent.getParcelableExtra(
|
||||
VpnManager.EXTRA_VPN_PROFILE_STATE, VpnProfileState.class));
|
||||
}
|
||||
reset(userContext);
|
||||
}
|
||||
@@ -1341,7 +1339,11 @@ public class VpnTest extends VpnTestBase {
|
||||
// CATEGORY_EVENT_DEACTIVATED_BY_USER is not an error event, so both of errorClass and
|
||||
// errorCode won't be set.
|
||||
verifyVpnManagerEvent(sessionKey, VpnManager.CATEGORY_EVENT_DEACTIVATED_BY_USER,
|
||||
-1 /* errorClass */, -1 /* errorCode */, packageName, null /* profileState */);
|
||||
-1 /* errorClass */, -1 /* errorCode */, packageName,
|
||||
// VPN NetworkAgnet does not switch to CONNECTED in the test, and the state is not
|
||||
// important here. Verify that the state as it is, i.e. CONNECTING state.
|
||||
new VpnProfileState(VpnProfileState.STATE_CONNECTING,
|
||||
sessionKey, false /* alwaysOn */, false /* lockdown */));
|
||||
}
|
||||
|
||||
private void verifyAlwaysOnStateChanged(String[] packageName, VpnProfileState... profileState) {
|
||||
@@ -1586,7 +1588,10 @@ public class VpnTest extends VpnTestBase {
|
||||
verifyPowerSaveTempWhitelistApp(TEST_VPN_PKG);
|
||||
reset(mDeviceIdleInternal);
|
||||
verifyVpnManagerEvent(sessionKey, category, errorType, errorCode,
|
||||
new String[] {TEST_VPN_PKG}, null /* profileState */);
|
||||
// VPN NetworkAgnet does not switch to CONNECTED in the test, and the state is not
|
||||
// important here. Verify that the state as it is, i.e. CONNECTING state.
|
||||
new String[] {TEST_VPN_PKG}, new VpnProfileState(VpnProfileState.STATE_CONNECTING,
|
||||
sessionKey, false /* alwaysOn */, false /* lockdown */));
|
||||
if (errorType == VpnManager.ERROR_CLASS_NOT_RECOVERABLE) {
|
||||
verify(mConnectivityManager, timeout(TEST_TIMEOUT_MS))
|
||||
.unregisterNetworkCallback(eq(cb));
|
||||
|
||||
Reference in New Issue
Block a user