Add new keyguard disable features tests for primary profile to CTS
Verifier

bug:21512534
Change-Id: I480785b3b5b0a08f94544e829a3959a50d45d5b4
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index 43a469c..a29e594 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -110,6 +110,26 @@
         <!-- A generic activity for intent based tests -->
         <activity android:name=".IntentDrivenTestActivity"/>
 
+        <activity android:name=".admin.DeviceAdminKeyguardDisabledFeaturesActivity"
+                android:label="@string/da_kg_disabled_features_test"
+                android:configChanges="keyboardHidden|orientation|screenSize">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.cts.intent.category.MANUAL_TEST" />
+            </intent-filter>
+            <meta-data android:name="test_category" android:value="@string/test_category_device_admin" />
+        </activity>
+
+        <activity android:name=".admin.RedactedNotificationKeyguardDisabledFeaturesActivity"
+                android:label="@string/rn_kg_disabled_features_test"
+                android:configChanges="keyboardHidden|orientation|screenSize">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.cts.intent.category.MANUAL_TEST" />
+            </intent-filter>
+            <meta-data android:name="test_category" android:value="@string/test_category_device_admin" />
+        </activity>
+
         <activity android:name=".admin.ScreenLockTestActivity"
                 android:label="@string/da_screen_lock_test"
                 android:configChanges="keyboardHidden|orientation|screenSize">
@@ -122,15 +142,6 @@
                        android:value="android.hardware.type.television:android.software.leanback:android.hardware.type.watch" />
         </activity>
 
-        <receiver android:name=".admin.TestDeviceAdminReceiver"
-                android:permission="android.permission.BIND_DEVICE_ADMIN">
-            <meta-data android:name="android.app.device_admin"
-                    android:resource="@xml/device_admin" />
-            <intent-filter>
-                <action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
-            </intent-filter>
-        </receiver>
-
         <activity android:name=".backup.BackupTestActivity" android:label="@string/backup_test">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
@@ -1449,6 +1460,9 @@
                 <action android:name="com.android.cts.verifier.managedprovisioning.action.TEST_CROSS_PROFILE_INTENTS_DIALOG" />
                 <action android:name="com.android.cts.verifier.managedprovisioning.action.TEST_APP_LINKING_DIALOG" />
                 <action android:name="com.android.cts.verifier.managedprovisioning.BYOD_SET_LOCATION_AND_CHECK" />
+                <action android:name="com.android.cts.verifier.managedprovisioning.NOTIFICATION" />
+                <action android:name="com.android.cts.verifier.managedprovisioning.LOCKSCREEN_NOTIFICATION" />
+                <action android:name="com.android.cts.verifier.managedprovisioning.CLEAR_NOTIFICATION" />
                 <category android:name="android.intent.category.DEFAULT"></category>
             </intent-filter>
         </activity>
@@ -1568,15 +1582,6 @@
             </intent-filter>
         </activity>
 
-        <activity android:name=".managedprovisioning.WorkNotificationTestActivity">
-            <intent-filter>
-                <action android:name="com.android.cts.verifier.managedprovisioning.WORK_NOTIFICATION" />
-                <action android:name="com.android.cts.verifier.managedprovisioning.LOCKSCREEN_NOTIFICATION" />
-                <action android:name="com.android.cts.verifier.managedprovisioning.CLEAR_WORK_NOTIFICATION" />
-                <category android:name="android.intent.category.DEFAULT"></category>
-            </intent-filter>
-        </activity>
-
         <receiver android:name=".managedprovisioning.DeviceAdminTestReceiver"
                 android:label="@string/afw_device_admin"
                 android:permission="android.permission.BIND_DEVICE_ADMIN">
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index 9d0b85c..6c2e333 100644
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -124,6 +124,8 @@
         settings that may specify a timeout.\n\nClick the \"Force Lock\" button to lock the screen.
         Your screen should be locked and require the password to be entered.
     </string>
+    <string name="da_kg_disabled_features_test">Keyguard Disabled Features Test</string>
+    <string name="rn_kg_disabled_features_test">Redacted Notifications Keyguard Disabled Features Test</string>
     <string name="da_force_lock">Force Lock</string>
     <string name="da_lock_success">It appears the screen was locked successfully!</string>
     <string name="da_lock_error">It does not look like the screen was locked...</string>
@@ -1423,8 +1425,29 @@
     <string name="snsr_rotation_vector_set_final">Place the device back to the reference position.</string>
     <string name="snsr_rotation_vector_verification">Angular deviation [%1$4.1f %2$4.1f %3$4.1f]. Current: %4$f deg. Max tolerated: %5$f.</string>
 
+    <!-- Strings for device admin tests -->
+    <string name="device_admin_notification">This is device admin notification</string>
+    <string name="device_admin_keyguard_disable_camera">Disable camera</string>
+    <string name="device_admin_keyguard_disable_camera_instruction">
+        Please press the Go button to lock the screen. Then try to open the camera
+        from the lower right corner of the screen. Expected result is you cannot
+        open the camera from lock screen and it will ask for password instead.
+    </string>
+    <string name="device_admin_disable_notifications">Disable notifications</string>
+    <string name="device_admin_disable_notifications_instruction">
+        Please press the Go button to lock the screen. Wait a few seconds to see
+        if a notification appears. Expected result is no notifications appear.
+        You should be able to see one after unlocking.
+    </string>
+    <string name="device_admin_disable_unredacted_notifications">Disable unredacted notifications</string>
+    <string name="device_admin_disable_unredacted_notifications_instruction">
+        Please press the Go button to lock the screen. Wait a few seconds to see
+        if a notification appears. Expected result is a notification appear with
+        its content hidden. You should be able to see the content after unlocking.
+    </string>
+
     <!-- Strings common for BYOD and DO managed provisioning tests. -->
-    <string name="afw_device_admin">CTS Verifier - AfW Admin</string>
+    <string name="afw_device_admin">CTS Verifier</string>
 
     <!-- Strings for BYOD managed provisioning tests (ByodFlowTestActivity) -->
     <string name="test_category_managed_provisioning">Managed Provisioning</string>
@@ -1492,7 +1515,7 @@
     </string>
     <string name="provisioning_byod_keyguard_disabled_features_instruction">
         Please go to Settings &gt; Security &gt; Device administrators and set
-        \"CTS Verifier - AfW Admin\" as active admin.\n
+        \"CTS Verifier\" as active admin.\n
         After that please press the \"Prepare test\" button to disable trust agents.\n
         Then please press through the following verification steps.\n
         Note: Device password will be set to \"testpassword\". After leaving the screen device
@@ -1509,8 +1532,9 @@
     <string name="provisioning_byod_fingerprint_disabled_in_settings">Fingerprint is disabled in Settings</string>
     <string name="provisioning_byod_fingerprint_disabled_in_settings_instruction">
         Please press the Go button to go to Settings > Security. Then go to Fingerprint and\n
-        check if the screen is shown as disabled by the administrator.
-        Then please press Back and mark the test as \"Pass\" or \"Fail\".
+        check if the disclaimer at the bottom of screen is altered to warn the users for\n
+        fingerprint being disabled in lock screen. Then please press Back and mark the \n
+        test as \"Pass\" or \"Fail\".
     </string>
     <string name="provisioning_byod_disable_fingerprint">Fingerprint disabled on keyguard</string>
     <string name="provisioning_byod_disable_fingerprint_instruction">
@@ -1518,12 +1542,12 @@
         Expected result is you cannot log in using your fingerprint.\n
         After you log back in, please navigate back to CtsVerifier and mark the test as \"Pass\" or \"Fail\".
     </string>
-    <string name="provisioning_byod_disable_notifications">Notifications disabled on keyguard</string>
-    <string name="provisioning_byod_disable_notifications_instruction">
+    <string name="provisioning_byod_disable_unredacted_notifications">Unredacted notifications disabled on keyguard</string>
+    <string name="provisioning_byod_disable_unredacted_notifications_instruction">
         Please press the Go button to lock the screen. Wait a couple of seconds and look out for a
         notification from CtsVerifier.\n
         Expected result is the notification is shown as \"Contents hidden\", you can not see the contents
-        (Which would read \"This is a work notification\").\n
+        (Which would read \"This is a notification\"). You should be seeing a work badge.\n
         After you log back in, please navigate back to CtsVerifier and mark the test as \"Pass\" or \"Fail\".
     </string>
     <string name="provisioning_byod_work_notification">Work notification is badged</string>
@@ -1532,7 +1556,7 @@
         \n
         Verify that the notification is badged (see sample badge below). Then mark this test accordingly.
     </string>
-    <string name="provisioning_byod_work_notification_title">This is a work notification</string>
+    <string name="provisioning_byod_notification_title">This is a notification</string>
     <string name="provisioning_byod_work_status_icon">Work status icon is displayed</string>
     <string name="provisioning_byod_work_status_icon_instruction">
         Verify that the current status bar does not have a work status icon (see sample icon below).
@@ -1577,7 +1601,7 @@
         Navigate to Device administrators and confirm that:\n
         \n
         - Both Personal and Work categories exist.\n
-        - \"CTS Verifier - AfW Admin\" exists under the Work category, and is activated.\n
+        - \"CTS Verifier\" exists under the Work category, and is activated.\n
         \n
         Use the Back button to return to this page.
     </string>
@@ -1844,8 +1868,8 @@
         Please press the Go button to open the Security page in Settings.
         Navigate to Device administrators and confirm that:\n
         \n
-        - \"CTS Verifier - AfW Admin\" exists and is activated.\n
-        - \"CTS Verifier - AfW Admin\" cannot be disabled.\n
+        - \"CTS Verifier\" exists and is activated.\n
+        - \"CTS Verifier\" cannot be disabled.\n
         \n
         Use the Back button to return to this page.
     </string>
diff --git a/apps/CtsVerifier/res/xml/device_admin.xml b/apps/CtsVerifier/res/xml/device_admin.xml
deleted file mode 100644
index 49d705a..0000000
--- a/apps/CtsVerifier/res/xml/device_admin.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<!-- Copyright (C) 2011 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<device-admin xmlns:android="http://schemas.android.com/apk/res/android">
-    <uses-policies>
-        <limit-password />
-        <watch-login />
-        <reset-password />
-        <force-lock />
-        <wipe-data />
-        <expire-password />
-    </uses-policies>
-</device-admin>
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/DialogTestListActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/DialogTestListActivity.java
index 7212609..167fd84 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/DialogTestListActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/DialogTestListActivity.java
@@ -188,6 +188,7 @@
         try {
             startActivity(intent);
         } catch (ActivityNotFoundException e) {
+            Log.w(TAG, "Cannot start activity.", e);
             Toast.makeText(this, "Cannot start " + intent, Toast.LENGTH_LONG).show();
             setTestResult(test, TestResult.TEST_RESULT_FAILED);
             return false;
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/admin/DeviceAdminKeyguardDisabledFeaturesActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/admin/DeviceAdminKeyguardDisabledFeaturesActivity.java
new file mode 100644
index 0000000..2ad77f6
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/admin/DeviceAdminKeyguardDisabledFeaturesActivity.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.cts.verifier.admin;
+
+import android.app.admin.DevicePolicyManager;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.hardware.fingerprint.FingerprintManager;
+import android.provider.Settings;
+
+import com.android.cts.verifier.ArrayTestListAdapter;
+import com.android.cts.verifier.R;
+import com.android.cts.verifier.DialogTestListActivity;
+import com.android.cts.verifier.managedprovisioning.ByodHelperActivity;
+import com.android.cts.verifier.managedprovisioning.DeviceAdminTestReceiver;
+import com.android.cts.verifier.managedprovisioning.KeyguardDisabledFeaturesActivity;
+
+
+/**
+ * Tests for Device Admin keyguard disabled features.
+ */
+public class DeviceAdminKeyguardDisabledFeaturesActivity extends KeyguardDisabledFeaturesActivity {
+    @Override
+    protected int getKeyguardDisabledFeatures() {
+        return DevicePolicyManager.KEYGUARD_DISABLE_FEATURES_ALL;
+    }
+
+    @Override
+    protected void setKeyguardDisabledFeatures() {
+        int flags = getKeyguardDisabledFeatures();
+        mDpm.setKeyguardDisabledFeatures(getAdminComponent(), flags);
+    }
+
+    @Override
+    protected String getTestIdPrefix() {
+        return "DeviceAdmin_";
+    }
+
+    @Override
+    protected void setupTests(ArrayTestListAdapter adapter) {
+        setupFingerprintTests(adapter);
+        setupDisableTrustAgentsTest(adapter);
+        adapter.add(new DialogTestListItem(this, R.string.device_admin_keyguard_disable_camera,
+                getTestIdPrefix()+"KeyguardDisableCamera",
+                R.string.device_admin_keyguard_disable_camera_instruction,
+                new Intent(ByodHelperActivity.ACTION_LOCKNOW)));
+
+        adapter.add(new DialogTestListItem(this, R.string.device_admin_disable_notifications,
+                "DeviceAdmin_DisableNotifications",
+                R.string.device_admin_disable_notifications_instruction,
+                new Intent(ByodHelperActivity.ACTION_NOTIFICATION_ON_LOCKSCREEN)));
+    }
+}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/admin/PolicySerializationTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/admin/PolicySerializationTestActivity.java
index 1591df3..ee24868 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/admin/PolicySerializationTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/admin/PolicySerializationTestActivity.java
@@ -16,6 +16,7 @@
 
 package com.android.cts.verifier.admin;
 
+import com.android.cts.verifier.managedprovisioning.DeviceAdminTestReceiver;
 import com.android.cts.verifier.PassFailButtons;
 import com.android.cts.verifier.R;
 
@@ -73,7 +74,7 @@
         setPassFailButtonClickListeners();
 
         mDevicePolicyManager = (DevicePolicyManager) getSystemService(DEVICE_POLICY_SERVICE);
-        mAdmin = TestDeviceAdminReceiver.getComponent(this);
+        mAdmin = DeviceAdminTestReceiver.getReceiverComponentName();
 
         mGeneratePolicyButton = findViewById(R.id.generate_policy_button);
         mGeneratePolicyButton.setOnClickListener(new OnClickListener() {
@@ -136,7 +137,7 @@
     private void applyPolicy() {
         Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
         intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN,
-                TestDeviceAdminReceiver.getComponent(this));
+                DeviceAdminTestReceiver.getReceiverComponentName());
         startActivityForResult(intent, ADD_DEVICE_ADMIN_REQUEST_CODE);
     }
 
@@ -152,7 +153,7 @@
 
     private void handleAddDeviceAdminResult(int resultCode, Intent data) {
         if (resultCode == RESULT_OK) {
-            ComponentName admin = TestDeviceAdminReceiver.getComponent(this);
+            ComponentName admin = DeviceAdminTestReceiver.getReceiverComponentName();
             for (PolicyItem<?> item : mPolicyItems) {
                 item.applyExpectedValue(mDevicePolicyManager, admin);
             }
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/admin/RedactedNotificationKeyguardDisabledFeaturesActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/admin/RedactedNotificationKeyguardDisabledFeaturesActivity.java
new file mode 100644
index 0000000..711fd8c
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/admin/RedactedNotificationKeyguardDisabledFeaturesActivity.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.cts.verifier.admin;
+
+import android.app.admin.DevicePolicyManager;
+
+import android.content.Intent;
+
+
+import com.android.cts.verifier.ArrayTestListAdapter;
+import com.android.cts.verifier.R;
+import com.android.cts.verifier.DialogTestListActivity;
+import com.android.cts.verifier.managedprovisioning.ByodHelperActivity;
+
+/**
+ * Tests for Device Admin keyguard redacted notification feature. This test is taken out from
+ * DeviceAdminKeyguardDisabledFeaturesActivity class, because KEYGUARD_DISABLE_SECURE_NOTIFICATIONS
+ * would mask KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS.
+ *  */
+
+public class RedactedNotificationKeyguardDisabledFeaturesActivity
+    extends DeviceAdminKeyguardDisabledFeaturesActivity {
+  @Override
+  protected int getKeyguardDisabledFeatures() {
+    return DevicePolicyManager.KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS;
+  }
+
+  @Override
+  protected void setupTests(ArrayTestListAdapter adapter) {
+    adapter.add(new DialogTestListItem(this, R.string.device_admin_disable_unredacted_notifications,
+        "DeviceAdmin_DisableUnredactedNotifications",
+        R.string.device_admin_disable_unredacted_notifications_instruction,
+        new Intent(ByodHelperActivity.ACTION_NOTIFICATION_ON_LOCKSCREEN)));
+  }
+}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/admin/ScreenLockTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/admin/ScreenLockTestActivity.java
index 5520bb7..41217a6 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/admin/ScreenLockTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/admin/ScreenLockTestActivity.java
@@ -16,6 +16,7 @@
 
 package com.android.cts.verifier.admin;
 
+import com.android.cts.verifier.managedprovisioning.DeviceAdminTestReceiver;
 import com.android.cts.verifier.PassFailButtons;
 import com.android.cts.verifier.R;
 
@@ -72,7 +73,7 @@
     private void sendAddDeviceAdminIntent() {
         Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
         intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN,
-                TestDeviceAdminReceiver.getComponent(this));
+                DeviceAdminTestReceiver.getReceiverComponentName());
         startActivityForResult(intent, ADD_DEVICE_ADMIN_REQUEST_CODE);
     }
 
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/admin/TestDeviceAdminReceiver.java b/apps/CtsVerifier/src/com/android/cts/verifier/admin/TestDeviceAdminReceiver.java
deleted file mode 100644
index 5ecb36d..0000000
--- a/apps/CtsVerifier/src/com/android/cts/verifier/admin/TestDeviceAdminReceiver.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.cts.verifier.admin;
-
-import android.app.admin.DeviceAdminReceiver;
-import android.content.ComponentName;
-import android.content.Context;
-
-public class TestDeviceAdminReceiver extends DeviceAdminReceiver {
-
-    public static ComponentName getComponent(Context context) {
-        return new ComponentName(context, TestDeviceAdminReceiver.class);
-    }
-}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodFlowTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodFlowTestActivity.java
index 509408d..33e613f 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodFlowTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodFlowTestActivity.java
@@ -97,7 +97,7 @@
         super.onCreate(savedInstanceState);
         mAdminReceiverComponent = new ComponentName(this, DeviceAdminTestReceiver.class.getName());
 
-        disableComponent();
+        enableComponent(PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
         mPrepareTestButton.setText(R.string.provisioning_byod_start);
         mPrepareTestButton.setOnClickListener(new OnClickListener() {
             @Override
@@ -160,6 +160,7 @@
         // Pass and fail buttons are known to call finish() when clicked, and this is when we want to
         // clean up the provisioned profile.
         requestDeleteProfileOwner();
+        enableComponent(PackageManager.COMPONENT_ENABLED_STATE_DEFAULT);
         super.finish();
     }
 
@@ -189,7 +190,7 @@
                 R.string.provisioning_byod_work_notification,
                 "BYOD_WorkNotificationBadgedTest",
                 R.string.provisioning_byod_work_notification_instruction,
-                new Intent(WorkNotificationTestActivity.ACTION_WORK_NOTIFICATION),
+                new Intent(ByodHelperActivity.ACTION_NOTIFICATION),
                 R.drawable.ic_corp_icon);
 
         Intent workStatusIcon = new Intent(WorkStatusTestActivity.ACTION_WORK_STATUS_ICON);
@@ -473,11 +474,11 @@
     @Override
     protected void clearRemainingState(final DialogTestListItem test) {
         super.clearRemainingState(test);
-        if (WorkNotificationTestActivity.ACTION_WORK_NOTIFICATION.equals(
+        if (ByodHelperActivity.ACTION_NOTIFICATION.equals(
                 test.getManualTestIntent().getAction())) {
             try {
                 startActivity(new Intent(
-                        WorkNotificationTestActivity.ACTION_CLEAR_WORK_NOTIFICATION));
+                        ByodHelperActivity.ACTION_CLEAR_NOTIFICATION));
             } catch (ActivityNotFoundException e) {
                 // User shouldn't run this test before work profile is set up.
             }
@@ -552,12 +553,15 @@
                 intentFiltersSet ? TestResult.TEST_RESULT_PASSED : TestResult.TEST_RESULT_FAILED);
     }
 
-    private void disableComponent() {
-        // Disable app components in the current profile, so only the counterpart in the other profile
-        // can respond (via cross-profile intent filter)
+    /**
+     *  Disable or enable app components in the current profile. When they are disabled only the
+     * counterpart in the other profile can respond (via cross-profile intent filter).
+     * @param enabledState {@link PackageManager#COMPONENT_ENABLED_STATE_DISABLED} or
+     *                      {@link PackageManager#COMPONENT_ENABLED_STATE_DEFAULT}
+     */
+    private void enableComponent(final int enabledState) {
         final String[] components = {
             ByodHelperActivity.class.getName(),
-            WorkNotificationTestActivity.class.getName(),
             WorkStatusTestActivity.class.getName(),
             PermissionLockdownTestActivity.ACTIVITY_ALIAS,
             AuthenticationBoundKeyTestActivity.class.getName(),
@@ -565,8 +569,7 @@
         };
         for (String component : components) {
             getPackageManager().setComponentEnabledSetting(new ComponentName(this, component),
-                    PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
-                    PackageManager.DONT_KILL_APP);
+                    enabledState, PackageManager.DONT_KILL_APP);
         }
     }
 
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodHelperActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodHelperActivity.java
index bfac469..ef7c952 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodHelperActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodHelperActivity.java
@@ -19,6 +19,8 @@
 import android.app.Activity;
 import android.app.admin.DevicePolicyManager;
 import android.app.Dialog;
+import android.app.Notification;
+import android.app.NotificationManager;
 import android.content.BroadcastReceiver;
 import android.content.ComponentName;
 import android.content.Context;
@@ -105,6 +107,12 @@
     // Primary -> managed intent: request to goto the location settings page and listen to updates.
     public static final String ACTION_SET_LOCATION_AND_CHECK_UPDATES =
             "com.android.cts.verifier.managedprovisioning.BYOD_SET_LOCATION_AND_CHECK";
+    public static final String ACTION_NOTIFICATION =
+            "com.android.cts.verifier.managedprovisioning.NOTIFICATION";
+    public static final String ACTION_NOTIFICATION_ON_LOCKSCREEN =
+            "com.android.cts.verifier.managedprovisioning.LOCKSCREEN_NOTIFICATION";
+    public static final String ACTION_CLEAR_NOTIFICATION =
+            "com.android.cts.verifier.managedprovisioning.CLEAR_NOTIFICATION";
 
     public static final int RESULT_FAILED = RESULT_FIRST_USER;
 
@@ -115,6 +123,10 @@
     private static final int REQUEST_LOCATION_UPDATE = 5;
 
     private static final String ORIGINAL_SETTINGS_NAME = "original settings";
+
+    private static final int NOTIFICATION_ID = 7;
+
+    private NotificationManager mNotificationManager;
     private Bundle mOriginalSettings;
 
     private static final int MSG_TIMEOUT = 1;
@@ -132,6 +144,17 @@
 
     private ArrayList<File> mTempFiles = new ArrayList<File>();
 
+    private void showNotification(int visibility) {
+        final Notification notification = new Notification.Builder(this)
+                .setSmallIcon(R.drawable.icon)
+                .setContentTitle(getString(R.string.provisioning_byod_notification_title))
+                .setVisibility(visibility)
+                .setAutoCancel(true)
+                .build();
+        mNotificationManager.notify(NOTIFICATION_ID, notification);
+    }
+
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -148,6 +171,7 @@
         mLocationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
         mHandler = new Handler(this);
         mIsLocationUpdated = false;
+        mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
         Intent intent = getIntent();
         String action = intent.getAction();
         Log.d(TAG, "ByodHelperActivity.onCreate: " + action);
@@ -166,6 +190,8 @@
             // Request to delete work profile.
         } else if (action.equals(ACTION_REMOVE_PROFILE_OWNER)) {
             if (isProfileOwner()) {
+                Log.d(TAG, "Clearing cross profile intents");
+                mDevicePolicyManager.clearCrossProfileIntentFilters(mAdminReceiverComponent);
                 mDevicePolicyManager.wipeData(0);
                 showToast(R.string.provisioning_byod_profile_deleted);
             }
@@ -270,6 +296,15 @@
             mLocationManager.requestLocationUpdates(
                     LocationManager.GPS_PROVIDER, 0, 0, mLocationListener);
             return;
+        } else if (action.equals(ACTION_NOTIFICATION)) {
+            showNotification(Notification.VISIBILITY_PUBLIC);
+        } else if (ACTION_NOTIFICATION_ON_LOCKSCREEN.equals(action)) {
+            DevicePolicyManager dpm = (DevicePolicyManager) getSystemService(
+                    Context.DEVICE_POLICY_SERVICE);
+            dpm.lockNow();
+            showNotification(Notification.VISIBILITY_PRIVATE);
+        } else if (ACTION_CLEAR_NOTIFICATION.equals(action)) {
+            mNotificationManager.cancel(NOTIFICATION_ID);
         }
         // This activity has no UI and is only used to respond to CtsVerifier in the primary side.
         finish();
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceAdminTestReceiver.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceAdminTestReceiver.java
index 05c9384..039cc09 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceAdminTestReceiver.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceAdminTestReceiver.java
@@ -67,10 +67,10 @@
             filter.addAction(ByodHelperActivity.ACTION_TEST_NFC_BEAM);
             filter.addAction(ByodHelperActivity.ACTION_TEST_CROSS_PROFILE_INTENTS_DIALOG);
             filter.addAction(ByodHelperActivity.ACTION_TEST_APP_LINKING_DIALOG);
+            filter.addAction(ByodHelperActivity.ACTION_NOTIFICATION);
+            filter.addAction(ByodHelperActivity.ACTION_NOTIFICATION_ON_LOCKSCREEN);
+            filter.addAction(ByodHelperActivity.ACTION_CLEAR_NOTIFICATION);
             filter.addAction(CrossProfileTestActivity.ACTION_CROSS_PROFILE_TO_WORK);
-            filter.addAction(WorkNotificationTestActivity.ACTION_WORK_NOTIFICATION);
-            filter.addAction(WorkNotificationTestActivity.ACTION_WORK_NOTIFICATION_ON_LOCKSCREEN);
-            filter.addAction(WorkNotificationTestActivity.ACTION_CLEAR_WORK_NOTIFICATION);
             filter.addAction(WorkStatusTestActivity.ACTION_WORK_STATUS_TOAST);
             filter.addAction(WorkStatusTestActivity.ACTION_WORK_STATUS_ICON);
             filter.addAction(
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/KeyguardDisabledFeaturesActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/KeyguardDisabledFeaturesActivity.java
index 1a158f8..1b4edcf 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/KeyguardDisabledFeaturesActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/KeyguardDisabledFeaturesActivity.java
@@ -34,7 +34,7 @@
 
 public class KeyguardDisabledFeaturesActivity extends DialogTestListActivity {
 
-    private DevicePolicyManager mDpm;
+    protected DevicePolicyManager mDpm;
 
     public KeyguardDisabledFeaturesActivity() {
         super(R.layout.provisioning_byod,
@@ -43,6 +43,12 @@
                 R.string.provisioning_byod_keyguard_disabled_features_instruction);
     }
 
+    protected int getKeyguardDisabledFeatures() {
+        return DevicePolicyManager.KEYGUARD_DISABLE_TRUST_AGENTS
+                | DevicePolicyManager.KEYGUARD_DISABLE_FINGERPRINT
+                | DevicePolicyManager.KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS;
+    }
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -54,25 +60,31 @@
         mPrepareTestButton.setOnClickListener(new OnClickListener() {
                 @Override
                 public void onClick(View v) {
-                    if (!mDpm.isAdminActive(DeviceAdminTestReceiver.getReceiverComponentName())) {
+                    if (!mDpm.isAdminActive(getAdminComponent())) {
                         Toast.makeText(KeyguardDisabledFeaturesActivity.this,
                                 R.string.provisioning_byod_keyguard_disabled_features_not_admin,
                                 Toast.LENGTH_SHORT).show();
                         return;
                     }
+                    setKeyguardDisabledFeatures();
                     mDpm.resetPassword("testpassword", 0);
-                    setKeyguardDisabledFeatures(DevicePolicyManager.KEYGUARD_DISABLE_TRUST_AGENTS |
-                            DevicePolicyManager.KEYGUARD_DISABLE_FINGERPRINT |
-                            DevicePolicyManager.KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS);
                 }
             });
     }
+    
+    protected ComponentName getAdminComponent() { 
+        return DeviceAdminTestReceiver.getReceiverComponentName();
+    }
+    
+    protected String getTestIdPrefix() {
+        return "BYOD_";
+    }
 
     @Override
     public void finish() {
         // Pass and fail buttons are known to call finish() when clicked, and this is when we want to
         // clear the password.
-        final ComponentName adminComponent = DeviceAdminTestReceiver.getReceiverComponentName();
+        final ComponentName adminComponent = getAdminComponent();
         if (mDpm.isAdminActive(adminComponent)) {
             mDpm.resetPassword(null, 0);
             mDpm.removeActiveAdmin(adminComponent);
@@ -80,47 +92,61 @@
         super.finish();
     }
 
-    private void setKeyguardDisabledFeatures(final int flags) {
-        Intent setKeyguardDisabledFeaturesIntent =
-                new Intent(ByodHelperActivity.ACTION_KEYGUARD_DISABLED_FEATURES)
-                .putExtra(ByodHelperActivity.EXTRA_PARAMETER_1, flags);
+    protected void setKeyguardDisabledFeatures() {
+        int flags = getKeyguardDisabledFeatures();
+        Intent setKeyguardDisabledFeaturesIntent = new Intent(
+                ByodHelperActivity.ACTION_KEYGUARD_DISABLED_FEATURES)
+                        .putExtra(ByodHelperActivity.EXTRA_PARAMETER_1, flags);
         startActivity(setKeyguardDisabledFeaturesIntent);
     }
-
-    @Override
-    protected void setupTests(ArrayTestListAdapter adapter) {
+    
+    protected void setupDisableTrustAgentsTest(ArrayTestListAdapter adapter) {
         adapter.add(new DialogTestListItem(this, R.string.provisioning_byod_disable_trust_agents,
-                "BYOD_DisableTrustAgentsTest",
+                getTestIdPrefix() + "DisableTrustAgentsTest",
                 R.string.provisioning_byod_disable_trust_agents_instruction,
                 new Intent(Settings.ACTION_SECURITY_SETTINGS)));
+    }
+    
+    protected void setupDisableUnredactedWorkNotification(ArrayTestListAdapter adapter) {
         adapter.add(new DialogTestListItemWithIcon(this,
-                R.string.provisioning_byod_disable_notifications,
-                "BYOD_DisableUnredactedNotifications",
-                R.string.provisioning_byod_disable_notifications_instruction,
-                new Intent(WorkNotificationTestActivity.ACTION_WORK_NOTIFICATION_ON_LOCKSCREEN),
+                R.string.provisioning_byod_disable_unredacted_notifications,
+                getTestIdPrefix() + "DisableUnredactedNotifications",
+                R.string.provisioning_byod_disable_unredacted_notifications_instruction,
+                new Intent(ByodHelperActivity.ACTION_NOTIFICATION_ON_LOCKSCREEN),
                 R.drawable.ic_corp_icon));
+    }
+    
+    protected void setupFingerprintTests(ArrayTestListAdapter adapter) {
         FingerprintManager fpm = (FingerprintManager) getSystemService(Context.FINGERPRINT_SERVICE);
         if (fpm.isHardwareDetected()) {
             adapter.add(new DialogTestListItem(this,
                     R.string.provisioning_byod_fingerprint_disabled_in_settings,
-                    "BYOD_FingerprintDisabledInSettings",
+                    getTestIdPrefix() + "FingerprintDisabledInSettings",
                     R.string.provisioning_byod_fingerprint_disabled_in_settings_instruction,
                     new Intent(Settings.ACTION_SECURITY_SETTINGS)));
             adapter.add(new DialogTestListItem(this, R.string.provisioning_byod_disable_fingerprint,
-                    "BYOD_DisableFingerprint",
+                    getTestIdPrefix() + "DisableFingerprint",
                     R.string.provisioning_byod_disable_fingerprint_instruction,
                     ByodHelperActivity.createLockIntent()));
         }
     }
 
     @Override
+    protected void setupTests(ArrayTestListAdapter adapter) {
+        setupDisableTrustAgentsTest(adapter);
+        setupDisableUnredactedWorkNotification(adapter);
+        setupFingerprintTests(adapter);
+        
+    }
+
+    @Override
     protected void clearRemainingState(final DialogTestListItem test) {
         super.clearRemainingState(test);
-        if (WorkNotificationTestActivity.ACTION_WORK_NOTIFICATION_ON_LOCKSCREEN.equals(
+        if (ByodHelperActivity.ACTION_NOTIFICATION_ON_LOCKSCREEN.equals(
                 test.getManualTestIntent().getAction())) {
             try {
                 startActivity(new Intent(
-                        WorkNotificationTestActivity.ACTION_CLEAR_WORK_NOTIFICATION));
+                        ByodHelperActivity.ACTION_CLEAR_NOTIFICATION));
             } catch (ActivityNotFoundException e) {
                 // User shouldn't run this test before work profile is set up.
             }
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/WorkNotificationTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/WorkNotificationTestActivity.java
deleted file mode 100644
index a912d2c..0000000
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/WorkNotificationTestActivity.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.cts.verifier.managedprovisioning;
-
-import android.app.Activity;
-import android.app.Notification;
-import android.app.NotificationManager;
-import android.app.admin.DevicePolicyManager;
-import android.content.Context;
-import android.content.Intent;
-import android.os.Bundle;
-
-import com.android.cts.verifier.R;
-
-/**
- * Test activity used to generate a notification.
- */
-public class WorkNotificationTestActivity extends Activity {
-    public static final String ACTION_WORK_NOTIFICATION =
-            "com.android.cts.verifier.managedprovisioning.WORK_NOTIFICATION";
-    public static final String ACTION_WORK_NOTIFICATION_ON_LOCKSCREEN =
-            "com.android.cts.verifier.managedprovisioning.LOCKSCREEN_NOTIFICATION";
-    public static final String ACTION_CLEAR_WORK_NOTIFICATION =
-            "com.android.cts.verifier.managedprovisioning.CLEAR_WORK_NOTIFICATION";
-    private static final int NOTIFICATION_ID = 7;
-    private NotificationManager mNotificationManager;
-
-    private void showWorkNotification(int visibility) {
-        final Notification notification = new Notification.Builder(this)
-                .setSmallIcon(R.drawable.icon)
-                .setContentTitle(getString(R.string.provisioning_byod_work_notification_title))
-                .setVisibility(visibility)
-                .setAutoCancel(true)
-                .build();
-        mNotificationManager.notify(NOTIFICATION_ID, notification);
-    }
-
-    @Override
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        final String action = getIntent().getAction();
-        mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
-        if (ACTION_WORK_NOTIFICATION.equals(action)) {
-            showWorkNotification(Notification.VISIBILITY_PUBLIC);
-        } else if (ACTION_WORK_NOTIFICATION_ON_LOCKSCREEN.equals(action)) {
-            DevicePolicyManager dpm = (DevicePolicyManager) getSystemService(
-                    Context.DEVICE_POLICY_SERVICE);
-            dpm.lockNow();
-            showWorkNotification(Notification.VISIBILITY_PRIVATE);
-        } else if (ACTION_CLEAR_WORK_NOTIFICATION.equals(action)) {
-            mNotificationManager.cancel(NOTIFICATION_ID);
-        }
-        finish();
-    }
-}