Add CtsVerifier tests for settings lockdowns
Adding tests for DISALLOW_CONFIG_WIFI and DISALLOW_CONFIG_BLUETOOTH.
Bug: 18928048
Change-Id: Ic9538a073d3356907aa84e6b6184aa7317e988e6
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index d7ff938..750d8db 100644
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -1737,7 +1737,30 @@
\n
Use the Back button to return to this page.
</string>
- <string name="device_owner_device_admin_visible_go">Go</string>
+ <string name="device_owner_disallow_config_bt">Disallow configuring Bluetooth</string>
+ <string name="device_owner_disallow_config_bt_info">
+ Please press the Set restriction button to set the user restriction.
+ Then press Go to open the Bluetooth page in Settings.
+ Confirm that:\n
+ \n
+ - You cannot view Bluetooth devices in range.\n
+ - You cannot edit, add or remove any already paired devices.\n
+ \n
+ Use the Back button to return to this page.
+ </string>
+ <string name="device_owner_disallow_config_wifi">Disallow configuring WiFi</string>
+ <string name="device_owner_disallow_config_wifi_info">
+ Please press the Set restriction button to set the user restriction.
+ Then press Go to open the WiFi page in Settings.
+ Confirm that:\n
+ \n
+ - You cannot view WiFi networks in range.\n
+ - You cannot edit, add or remove any existing WiFi configs.\n
+ \n
+ Use the Back button to return to this page.
+ </string>
+ <string name="device_owner_user_restriction_set">Set restriction</string>
+ <string name="device_owner_settings_go">Go</string>
<!-- Strings for JobScheduler Tests -->
<string name="js_test_description">This test is mostly automated, but requires some user interaction. You can pass this test once the list items below are checked.</string>
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceOwnerPositiveTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceOwnerPositiveTestActivity.java
index 4c0c59c..a6a5e5a 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceOwnerPositiveTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceOwnerPositiveTestActivity.java
@@ -25,6 +25,7 @@
import android.content.pm.PackageManager;
import android.database.DataSetObserver;
import android.os.Bundle;
+import android.os.UserManager;
import android.provider.Settings;
import android.util.Log;
import android.view.View;
@@ -72,6 +73,8 @@
private static final String DISABLE_KEYGUARD_TEST_ID = "DISABLE_KEYGUARD";
private static final String CHECK_PERMISSION_LOCKDOWN_TEST_ID =
PermissionLockdownTestActivity.class.getName();
+ private static final String DISALLOW_CONFIG_BT_ID = "DISALLOW_CONFIG_BT";
+ private static final String DISALLOW_CONFIG_WIFI_ID = "DISALLOW_CONFIG_WIFI";
private static final String REMOVE_DEVICE_OWNER_TEST_ID = "REMOVE_DEVICE_OWNER";
@Override
@@ -139,15 +142,43 @@
R.string.device_owner_device_admin_visible,
R.string.device_owner_device_admin_visible_info,
new ButtonInfo(
- R.string.device_owner_device_admin_visible_go,
+ R.string.device_owner_settings_go,
new Intent(Settings.ACTION_SECURITY_SETTINGS))));
- // WiFi Lock down tests
PackageManager packageManager = getPackageManager();
if (packageManager.hasSystemFeature(PackageManager.FEATURE_WIFI)) {
+ // WiFi Lock down tests
adapter.add(createTestItem(this, WIFI_LOCKDOWN_TEST_ID,
R.string.device_owner_wifi_lockdown_test,
new Intent(this, WifiLockdownTestActivity.class)));
+
+ // DISALLOW_CONFIG_WIFI
+ adapter.add(createInteractiveTestItem(this, DISALLOW_CONFIG_WIFI_ID,
+ R.string.device_owner_disallow_config_wifi,
+ R.string.device_owner_disallow_config_wifi_info,
+ new ButtonInfo[] {
+ new ButtonInfo(
+ R.string.device_owner_user_restriction_set,
+ createSetUserRestrictionIntent(
+ UserManager.DISALLOW_CONFIG_WIFI)),
+ new ButtonInfo(
+ R.string.device_owner_settings_go,
+ new Intent(Settings.ACTION_WIFI_SETTINGS))}));
+ }
+
+ // DISALLOW_CONFIG_BLUETOOTH
+ if (packageManager.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) {
+ adapter.add(createInteractiveTestItem(this, DISALLOW_CONFIG_BT_ID,
+ R.string.device_owner_disallow_config_bt,
+ R.string.device_owner_disallow_config_bt_info,
+ new ButtonInfo[] {
+ new ButtonInfo(
+ R.string.device_owner_user_restriction_set,
+ createSetUserRestrictionIntent(
+ UserManager.DISALLOW_CONFIG_BLUETOOTH)),
+ new ButtonInfo(
+ R.string.device_owner_settings_go,
+ new Intent(Settings.ACTION_BLUETOOTH_SETTINGS))}));
}
// setStatusBarDisabled
@@ -226,6 +257,12 @@
.putExtra(EXTRA_PARAMETER_1, value);
}
+ private Intent createSetUserRestrictionIntent(String restriction) {
+ return new Intent(this, CommandReceiver.class)
+ .putExtra(EXTRA_COMMAND, COMMAND_ADD_USER_RESTRICTION)
+ .putExtra(EXTRA_RESTRICTION, restriction);
+ }
+
public static class CommandReceiver extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -287,6 +324,8 @@
dpm.setStatusBarDisabled(admin, false);
dpm.setKeyguardDisabled(admin, false);
+ dpm.clearUserRestriction(admin, UserManager.DISALLOW_CONFIG_BLUETOOTH);
+ dpm.clearUserRestriction(admin, UserManager.DISALLOW_CONFIG_WIFI);
dpm.clearDeviceOwnerApp(getPackageName());
}
}