[device owner] result_canceled counts as vpn restricted
This can mean the SystemUI didn't even bother showing a message to the
user and just canceled the connection straight away.
In future we might want to differentiate these two failure cases and
show a policy transparency dialog to explain what happened.
Change-Id: If2550e64865ea55cfc90565da2a6ee4673adb262
Fix: 31606338
Test: yes
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index 2c81626..744cb94 100644
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -2258,10 +2258,6 @@
This was expected.\n
Mark this test as passed.\n
</string>
- <string name="device_owner_vpn_connection_canceled">
- Cannot establish a VPN connection.\n
- Connection canceled by user.\n
- </string>
<string name="device_owner_vpn_test">Check VPN</string>
<string name="device_owner_vpn_info_default">Vpn test message</string>
@@ -2275,7 +2271,8 @@
- You cannot edit, add or remove any existing VPNs.\n
- Trying to perform any of the above actions will trigger a support message.\n\n
2. Press Check VPN to check programmatic Vpn test.\n
- - Check Vpn setup\n\n
+ - Check Vpn setup is not allowed\n
+ - If prompted to allow a VPN connection, press OK.\n\n
Use the Back button to return to this page.
</string>
<string name="device_owner_user_vpn_restriction_set">Set VPN restriction</string>
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/VpnTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/VpnTestActivity.java
index 49c0c20..b7c10bb 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/VpnTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/VpnTestActivity.java
@@ -56,7 +56,7 @@
private DevicePolicyManager mDevicePolicyManager;
private UserManager mUserManager;
private static final String TAG = "DeviceOwnerPositiveTestActivity";
- private static final int REQUEST_VPN_CODE = 1;
+ private static final int REQUEST_VPN_CODE = 54321;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -81,12 +81,13 @@
@Override
protected void onActivityResult(int requestCode, int result, Intent data) {
- if (requestCode == REQUEST_VPN_CODE && result == RESULT_OK) {
+ if (requestCode == REQUEST_VPN_CODE) {
+ // We don't care about the result - ideally it should automatically cancel, but if
+ // some custom component doesn't do that, try to establish the connection anyway
+ // and see what happens.
establishVpn();
} else {
- // vpn connection canceled by user
- Log.w(TAG, "Test failed, canceled by user");
- populateInfo(R.string.device_owner_vpn_connection_canceled);
+ Log.w(TAG, "Unexpected request code: " + requestCode);
}
}