1 /* 2 * Copyright (C) 2012 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.cts.verifier.managedprovisioning; 18 19 import android.app.admin.DevicePolicyManager; 20 import android.content.ActivityNotFoundException; 21 import android.content.ComponentName; 22 import android.content.Intent; 23 import android.content.pm.PackageManager; 24 import android.os.Bundle; 25 import android.provider.Settings; 26 import android.util.Log; 27 import android.view.View; 28 import android.view.View.OnClickListener; 29 import android.widget.Toast; 30 31 import com.android.cts.verifier.ArrayTestListAdapter; 32 import com.android.cts.verifier.DialogTestListActivity; 33 import com.android.cts.verifier.R; 34 import com.android.cts.verifier.TestListActivity; 35 import com.android.cts.verifier.TestListAdapter.TestListItem; 36 import com.android.cts.verifier.TestResult; 37 38 /** 39 * CTS verifier test for BYOD managed provisioning flow. 40 * This activity is responsible for starting the managed provisioning flow and verify the outcome of provisioning. 41 * It performs the following verifications: 42 * Full disk encryption is enabled. 43 * Profile owner is correctly installed. 44 * Profile owner shows up in the Settings app. 45 * Badged work apps show up in launcher. 46 * The first two verifications are performed automatically, by interacting with profile owner using 47 * cross-profile intents, while the last two are carried out manually by the user. 48 */ 49 public class ByodFlowTestActivity extends DialogTestListActivity { 50 51 private final String TAG = "ByodFlowTestActivity"; 52 private static final int REQUEST_MANAGED_PROVISIONING = 0; 53 private static final int REQUEST_PROFILE_OWNER_STATUS = 1; 54 private static final int REQUEST_INTENT_FILTERS_STATUS = 2; 55 56 private ComponentName mAdminReceiverComponent; 57 58 private DialogTestListItem mProfileOwnerInstalled; 59 private DialogTestListItem mProfileAccountVisibleTest; 60 private DialogTestListItem mDeviceAdminVisibleTest; 61 private DialogTestListItem mWorkAppVisibleTest; 62 private DialogTestListItem mCrossProfileIntentFiltersTestFromPersonal; 63 private DialogTestListItem mCrossProfileIntentFiltersTestFromWork; 64 private DialogTestListItem mAppLinkingTest; 65 private DialogTestListItem mDisableNonMarketTest; 66 private DialogTestListItem mEnableNonMarketTest; 67 private DialogTestListItem mWorkNotificationBadgedTest; 68 private DialogTestListItem mWorkStatusBarIconTest; 69 private DialogTestListItem mWorkStatusBarToastTest; 70 private DialogTestListItem mAppSettingsVisibleTest; 71 private DialogTestListItem mLocationSettingsVisibleTest; 72 private DialogTestListItem mBatterySettingsVisibleTest; 73 private DialogTestListItem mDataUsageSettingsVisibleTest; 74 private DialogTestListItem mCredSettingsVisibleTest; 75 private DialogTestListItem mPrintSettingsVisibleTest; 76 private DialogTestListItem mIntentFiltersTest; 77 private DialogTestListItem mPermissionLockdownTest; 78 private DialogTestListItem mCrossProfileImageCaptureSupportTest; 79 private DialogTestListItem mCrossProfileVideoCaptureSupportTest; 80 private DialogTestListItem mCrossProfileAudioCaptureSupportTest; 81 private TestListItem mKeyguardDisabledFeaturesTest; 82 private DialogTestListItem mDisableNfcBeamTest; 83 84 public ByodFlowTestActivity() { 85 super(R.layout.provisioning_byod, 86 R.string.provisioning_byod, R.string.provisioning_byod_info, 87 R.string.provisioning_byod_instructions); 88 } 89 90 @Override 91 protected void onCreate(Bundle savedInstanceState) { 92 super.onCreate(savedInstanceState); 93 mAdminReceiverComponent = new ComponentName(this, DeviceAdminTestReceiver.class.getName()); 94 95 disableComponent(); 96 mPrepareTestButton.setText(R.string.provisioning_byod_start); 97 mPrepareTestButton.setOnClickListener(new OnClickListener() { 98 @Override 99 public void onClick(View v) { 100 startByodProvisioning(); 101 } 102 }); 103 104 // If we are started by managed provisioning (fresh managed provisioning after encryption 105 // reboot), redirect the user back to the main test list. This is because the test result 106 // is only saved by the parent TestListActivity, and if we did allow the user to proceed 107 // here, the test result would be lost when this activity finishes. 108 if (ByodHelperActivity.ACTION_PROFILE_OWNER_STATUS.equals(getIntent().getAction())) { 109 startActivity(new Intent(this, TestListActivity.class)); 110 // Calling super.finish() because we delete managed profile in our overridden of finish(), 111 // which is not what we want to do here. 112 super.finish(); 113 } else { 114 queryProfileOwner(false); 115 } 116 } 117 118 @Override 119 protected void onNewIntent(Intent intent) { 120 // This is called when managed provisioning completes successfully without reboot. 121 super.onNewIntent(intent); 122 if (ByodHelperActivity.ACTION_PROFILE_OWNER_STATUS.equals(intent.getAction())) { 123 handleStatusUpdate(RESULT_OK, intent); 124 } 125 } 126 127 @Override 128 protected void handleActivityResult(int requestCode, int resultCode, Intent data) { 129 switch (requestCode) { 130 case REQUEST_MANAGED_PROVISIONING: 131 return; 132 case REQUEST_PROFILE_OWNER_STATUS: { 133 // Called after queryProfileOwner() 134 handleStatusUpdate(resultCode, data); 135 } break; 136 case REQUEST_INTENT_FILTERS_STATUS: { 137 // Called after checkIntentFilters() 138 handleIntentFiltersStatus(resultCode); 139 } break; 140 default: { 141 super.handleActivityResult(requestCode, resultCode, data); 142 } 143 } 144 } 145 146 private void handleStatusUpdate(int resultCode, Intent data) { 147 boolean provisioned = data != null && 148 data.getBooleanExtra(ByodHelperActivity.EXTRA_PROVISIONED, false); 149 setTestResult(mProfileOwnerInstalled, (provisioned && resultCode == RESULT_OK) ? 150 TestResult.TEST_RESULT_PASSED : TestResult.TEST_RESULT_FAILED); 151 } 152 153 @Override 154 public void finish() { 155 // Pass and fail buttons are known to call finish() when clicked, and this is when we want to 156 // clean up the provisioned profile. 157 requestDeleteProfileOwner(); 158 super.finish(); 159 } 160 161 @Override 162 protected void setupTests(ArrayTestListAdapter adapter) { 163 mProfileOwnerInstalled = new DialogTestListItem(this, 164 R.string.provisioning_byod_profileowner, 165 "BYOD_ProfileOwnerInstalled") { 166 @Override 167 public void performTest(DialogTestListActivity activity) { 168 queryProfileOwner(true); 169 } 170 }; 171 172 /* 173 * To keep the image in this test up to date, use the instructions in 174 * {@link ByodIconSamplerActivity}. 175 */ 176 mWorkAppVisibleTest = new DialogTestListItemWithIcon(this, 177 R.string.provisioning_byod_workapps_visible, 178 "BYOD_WorkAppVisibleTest", 179 R.string.provisioning_byod_workapps_visible_instruction, 180 new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME), 181 R.drawable.badged_icon); 182 183 mWorkNotificationBadgedTest = new DialogTestListItemWithIcon(this, 184 R.string.provisioning_byod_work_notification, 185 "BYOD_WorkNotificationBadgedTest", 186 R.string.provisioning_byod_work_notification_instruction, 187 new Intent(WorkNotificationTestActivity.ACTION_WORK_NOTIFICATION), 188 R.drawable.ic_corp_icon); 189 190 Intent workStatusIcon = new Intent(WorkStatusTestActivity.ACTION_WORK_STATUS_ICON); 191 workStatusIcon.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 192 mWorkStatusBarIconTest = new DialogTestListItemWithIcon(this, 193 R.string.provisioning_byod_work_status_icon, 194 "BYOD_WorkStatusBarIconTest", 195 R.string.provisioning_byod_work_status_icon_instruction, 196 workStatusIcon, 197 R.drawable.stat_sys_managed_profile_status); 198 199 Intent workStatusToast = new Intent(WorkStatusTestActivity.ACTION_WORK_STATUS_TOAST); 200 workStatusToast.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 201 mWorkStatusBarToastTest = new DialogTestListItem(this, 202 R.string.provisioning_byod_work_status_toast, 203 "BYOD_WorkStatusBarToastTest", 204 R.string.provisioning_byod_work_status_toast_instruction, 205 workStatusToast); 206 207 mDisableNonMarketTest = new DialogTestListItem(this, 208 R.string.provisioning_byod_nonmarket_deny, 209 "BYOD_DisableNonMarketTest", 210 R.string.provisioning_byod_nonmarket_deny_info, 211 new Intent(ByodHelperActivity.ACTION_INSTALL_APK) 212 .putExtra(ByodHelperActivity.EXTRA_ALLOW_NON_MARKET_APPS, false)); 213 214 mEnableNonMarketTest = new DialogTestListItem(this, 215 R.string.provisioning_byod_nonmarket_allow, 216 "BYOD_EnableNonMarketTest", 217 R.string.provisioning_byod_nonmarket_allow_info, 218 new Intent(ByodHelperActivity.ACTION_INSTALL_APK) 219 .putExtra(ByodHelperActivity.EXTRA_ALLOW_NON_MARKET_APPS, true)); 220 221 mProfileAccountVisibleTest = new DialogTestListItem(this, 222 R.string.provisioning_byod_profile_visible, 223 "BYOD_ProfileAccountVisibleTest", 224 R.string.provisioning_byod_profile_visible_instruction, 225 new Intent(Settings.ACTION_SETTINGS)); 226 227 mAppSettingsVisibleTest = new DialogTestListItem(this, 228 R.string.provisioning_byod_app_settings, 229 "BYOD_AppSettingsVisibleTest", 230 R.string.provisioning_byod_app_settings_instruction, 231 new Intent(Settings.ACTION_APPLICATION_SETTINGS)); 232 233 mDeviceAdminVisibleTest = new DialogTestListItem(this, 234 R.string.provisioning_byod_admin_visible, 235 "BYOD_DeviceAdminVisibleTest", 236 R.string.provisioning_byod_admin_visible_instruction, 237 new Intent(Settings.ACTION_SECURITY_SETTINGS)); 238 239 mCredSettingsVisibleTest = new DialogTestListItem(this, 240 R.string.provisioning_byod_cred_settings, 241 "BYOD_CredSettingsVisibleTest", 242 R.string.provisioning_byod_cred_settings_instruction, 243 new Intent(Settings.ACTION_SECURITY_SETTINGS)); 244 245 mLocationSettingsVisibleTest = new DialogTestListItem(this, 246 R.string.provisioning_byod_location_settings, 247 "BYOD_LocationSettingsVisibleTest", 248 R.string.provisioning_byod_location_settings_instruction, 249 new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)); 250 251 mBatterySettingsVisibleTest = new DialogTestListItem(this, 252 R.string.provisioning_byod_battery_settings, 253 "BYOD_BatterySettingsVisibleTest", 254 R.string.provisioning_byod_battery_settings_instruction, 255 new Intent(Intent.ACTION_POWER_USAGE_SUMMARY)); 256 257 mDataUsageSettingsVisibleTest = new DialogTestListItem(this, 258 R.string.provisioning_byod_data_usage_settings, 259 "BYOD_DataUsageSettingsVisibleTest", 260 R.string.provisioning_byod_data_usage_settings_instruction, 261 new Intent(Settings.ACTION_SETTINGS)); 262 263 mPrintSettingsVisibleTest = new DialogTestListItem(this, 264 R.string.provisioning_byod_print_settings, 265 "BYOD_PrintSettingsVisibleTest", 266 R.string.provisioning_byod_print_settings_instruction, 267 new Intent(Settings.ACTION_PRINT_SETTINGS)); 268 269 Intent intent = new Intent(CrossProfileTestActivity.ACTION_CROSS_PROFILE_TO_WORK); 270 intent.putExtra(CrossProfileTestActivity.EXTRA_STARTED_FROM_WORK, false); 271 Intent chooser = Intent.createChooser(intent, 272 getResources().getString(R.string.provisioning_cross_profile_chooser)); 273 mCrossProfileIntentFiltersTestFromPersonal = new DialogTestListItem(this, 274 R.string.provisioning_byod_cross_profile_from_personal, 275 "BYOD_CrossProfileIntentFiltersTestFromPersonal", 276 R.string.provisioning_byod_cross_profile_from_personal_instruction, 277 chooser); 278 279 mCrossProfileIntentFiltersTestFromWork = new DialogTestListItem(this, 280 R.string.provisioning_byod_cross_profile_from_work, 281 "BYOD_CrossProfileIntentFiltersTestFromWork", 282 R.string.provisioning_byod_cross_profile_from_work_instruction, 283 new Intent(ByodHelperActivity.ACTION_TEST_CROSS_PROFILE_INTENTS_DIALOG)); 284 285 mAppLinkingTest = new DialogTestListItem(this, 286 R.string.provisioning_app_linking, 287 "BYOD_AppLinking", 288 R.string.provisioning_byod_app_linking_instruction, 289 new Intent(ByodHelperActivity.ACTION_TEST_APP_LINKING_DIALOG)); 290 291 mKeyguardDisabledFeaturesTest = TestListItem.newTest(this, 292 R.string.provisioning_byod_keyguard_disabled_features, 293 KeyguardDisabledFeaturesActivity.class.getName(), 294 new Intent(this, KeyguardDisabledFeaturesActivity.class), null); 295 296 // Test for checking if the required intent filters are set during managed provisioning. 297 mIntentFiltersTest = new DialogTestListItem(this, 298 R.string.provisioning_byod_cross_profile_intent_filters, 299 "BYOD_IntentFiltersTest") { 300 @Override 301 public void performTest(DialogTestListActivity activity) { 302 checkIntentFilters(); 303 } 304 }; 305 306 Intent permissionCheckIntent = new Intent( 307 PermissionLockdownTestActivity.ACTION_MANAGED_PROFILE_CHECK_PERMISSION_LOCKDOWN); 308 mPermissionLockdownTest = new DialogTestListItem(this, 309 R.string.device_profile_owner_permission_lockdown_test, 310 "BYOD_PermissionLockdownTest", 311 R.string.profile_owner_permission_lockdown_test_info, 312 permissionCheckIntent); 313 314 adapter.add(mProfileOwnerInstalled); 315 316 // Badge related tests 317 adapter.add(mWorkAppVisibleTest); 318 adapter.add(mWorkNotificationBadgedTest); 319 adapter.add(mWorkStatusBarIconTest); 320 adapter.add(mWorkStatusBarToastTest); 321 322 // Settings related tests. 323 adapter.add(mProfileAccountVisibleTest); 324 adapter.add(mDeviceAdminVisibleTest); 325 adapter.add(mCredSettingsVisibleTest); 326 adapter.add(mAppSettingsVisibleTest); 327 adapter.add(mLocationSettingsVisibleTest); 328 adapter.add(mBatterySettingsVisibleTest); 329 adapter.add(mDataUsageSettingsVisibleTest); 330 adapter.add(mPrintSettingsVisibleTest); 331 332 adapter.add(mCrossProfileIntentFiltersTestFromPersonal); 333 adapter.add(mCrossProfileIntentFiltersTestFromWork); 334 adapter.add(mAppLinkingTest); 335 adapter.add(mDisableNonMarketTest); 336 adapter.add(mEnableNonMarketTest); 337 adapter.add(mIntentFiltersTest); 338 adapter.add(mPermissionLockdownTest); 339 adapter.add(mKeyguardDisabledFeaturesTest); 340 341 if (canResolveIntent(ByodHelperActivity.getCaptureImageIntent())) { 342 // Capture image intent can be resolved in primary profile, so test. 343 mCrossProfileImageCaptureSupportTest = new DialogTestListItem(this, 344 R.string.provisioning_byod_capture_image_support, 345 "BYOD_CrossProfileImageCaptureSupportTest", 346 R.string.provisioning_byod_capture_image_support_info, 347 new Intent(ByodHelperActivity.ACTION_CAPTURE_AND_CHECK_IMAGE)); 348 adapter.add(mCrossProfileImageCaptureSupportTest); 349 } else { 350 // Capture image intent cannot be resolved in primary profile, so skip test. 351 Toast.makeText(ByodFlowTestActivity.this, 352 R.string.provisioning_byod_no_image_capture_resolver, Toast.LENGTH_SHORT) 353 .show(); 354 } 355 356 if (canResolveIntent(ByodHelperActivity.getCaptureVideoIntent())) { 357 // Capture video intent can be resolved in primary profile, so test. 358 mCrossProfileVideoCaptureSupportTest = new DialogTestListItem(this, 359 R.string.provisioning_byod_capture_video_support, 360 "BYOD_CrossProfileVideoCaptureSupportTest", 361 R.string.provisioning_byod_capture_video_support_info, 362 new Intent(ByodHelperActivity.ACTION_CAPTURE_AND_CHECK_VIDEO)); 363 adapter.add(mCrossProfileVideoCaptureSupportTest); 364 } else { 365 // Capture video intent cannot be resolved in primary profile, so skip test. 366 Toast.makeText(ByodFlowTestActivity.this, 367 R.string.provisioning_byod_no_video_capture_resolver, Toast.LENGTH_SHORT) 368 .show(); 369 } 370 371 if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC)) { 372 mDisableNfcBeamTest = new DialogTestListItem(this, R.string.provisioning_byod_nfc_beam, 373 "BYOD_DisableNfcBeamTest", 374 R.string.provisioning_byod_nfc_beam_allowed_instruction, 375 new Intent(ByodHelperActivity.ACTION_TEST_NFC_BEAM)) { 376 @Override 377 public void performTest(final DialogTestListActivity activity) { 378 activity.showManualTestDialog(mDisableNfcBeamTest, 379 new DefaultTestCallback(mDisableNfcBeamTest) { 380 @Override 381 public void onPass() { 382 // Start a second test with beam disallowed by policy. 383 Intent testNfcBeamIntent = new Intent( 384 ByodHelperActivity.ACTION_TEST_NFC_BEAM); 385 testNfcBeamIntent.putExtra(NfcTestActivity.EXTRA_DISALLOW_BY_POLICY, 386 true); 387 DialogTestListItem disableNfcBeamTest2 = 388 new DialogTestListItem(activity, 389 R.string.provisioning_byod_nfc_beam, 390 "BYOD_DisableNfcBeamTest", 391 R.string.provisioning_byod_nfc_beam_disallowed_instruction, 392 testNfcBeamIntent); 393 // The result should be reflected on the original test. 394 activity.showManualTestDialog(disableNfcBeamTest2, 395 new DefaultTestCallback(mDisableNfcBeamTest)); 396 } 397 }); 398 } 399 }; 400 adapter.add(mDisableNfcBeamTest); 401 } 402 403 /* TODO: reinstate when bug b/20131958 is fixed 404 if (canResolveIntent(ByodHelperActivity.getCaptureAudioIntent())) { 405 // Capture audio intent can be resolved in primary profile, so test. 406 mCrossProfileAudioCaptureSupportTest = new DialogTestListItem(this, 407 R.string.provisioning_byod_capture_audio_support, 408 "BYOD_CrossProfileAudioCaptureSupportTest", 409 R.string.provisioning_byod_capture_audio_support_info, 410 new Intent(ByodHelperActivity.ACTION_CAPTURE_AND_CHECK_AUDIO)); 411 adapter.add(mCrossProfileAudioCaptureSupportTest); 412 } else { 413 // Capture audio intent cannot be resolved in primary profile, so skip test. 414 Toast.makeText(ByodFlowTestActivity.this, 415 R.string.provisioning_byod_no_audio_capture_resolver, Toast.LENGTH_SHORT) 416 .show(); 417 } 418 */ 419 } 420 421 // Return whether the intent can be resolved in the current profile 422 private boolean canResolveIntent(Intent intent) { 423 return intent.resolveActivity(getPackageManager()) != null; 424 } 425 426 @Override 427 protected void clearRemainingState(final DialogTestListItem test) { 428 super.clearRemainingState(test); 429 if (WorkNotificationTestActivity.ACTION_WORK_NOTIFICATION.equals( 430 test.getManualTestIntent().getAction())) { 431 try { 432 startActivity(new Intent( 433 WorkNotificationTestActivity.ACTION_CLEAR_WORK_NOTIFICATION)); 434 } catch (ActivityNotFoundException e) { 435 // User shouldn't run this test before work profile is set up. 436 } 437 } 438 } 439 440 private void startByodProvisioning() { 441 Intent sending = new Intent(DevicePolicyManager.ACTION_PROVISION_MANAGED_PROFILE); 442 sending.putExtra(DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME, 443 mAdminReceiverComponent); 444 445 if (sending.resolveActivity(getPackageManager()) != null) { 446 // ManagedProvisioning must be started with startActivityForResult, but we don't 447 // care about the result, so passing 0 as a requestCode 448 startActivityForResult(sending, REQUEST_MANAGED_PROVISIONING); 449 } else { 450 showToast(R.string.provisioning_byod_disabled); 451 } 452 } 453 454 private void queryProfileOwner(boolean showToast) { 455 try { 456 Intent intent = new Intent(ByodHelperActivity.ACTION_QUERY_PROFILE_OWNER); 457 startActivityForResult(intent, REQUEST_PROFILE_OWNER_STATUS); 458 } 459 catch (ActivityNotFoundException e) { 460 Log.d(TAG, "queryProfileOwner: ActivityNotFoundException", e); 461 setTestResult(mProfileOwnerInstalled, TestResult.TEST_RESULT_FAILED); 462 if (showToast) { 463 showToast(R.string.provisioning_byod_no_activity); 464 } 465 } 466 } 467 468 private void requestDeleteProfileOwner() { 469 try { 470 Intent intent = new Intent(ByodHelperActivity.ACTION_REMOVE_PROFILE_OWNER); 471 startActivity(intent); 472 showToast(R.string.provisioning_byod_delete_profile); 473 } 474 catch (ActivityNotFoundException e) { 475 Log.d(TAG, "requestDeleteProfileOwner: ActivityNotFoundException", e); 476 } 477 } 478 479 private void checkIntentFilters() { 480 try { 481 // We disable the ByodHelperActivity in the primary profile. So, this intent 482 // will be handled by the ByodHelperActivity in the managed profile. 483 Intent intent = new Intent(ByodHelperActivity.ACTION_CHECK_INTENT_FILTERS); 484 startActivityForResult(intent, REQUEST_INTENT_FILTERS_STATUS); 485 } catch (ActivityNotFoundException e) { 486 Log.d(TAG, "checkIntentFilters: ActivityNotFoundException", e); 487 setTestResult(mIntentFiltersTest, TestResult.TEST_RESULT_FAILED); 488 showToast(R.string.provisioning_byod_no_activity); 489 } 490 } 491 492 private void handleIntentFiltersStatus(int resultCode) { 493 // we use the resultCode from ByodHelperActivity in the managed profile to know if certain 494 // intents fired from the managed profile are forwarded. 495 final boolean intentFiltersSetForManagedIntents = (resultCode == RESULT_OK); 496 // Since the ByodFlowTestActivity is running in the primary profile, we directly use 497 // the IntentFiltersTestHelper to know if certain intents fired from the primary profile 498 // are forwarded. 499 final boolean intentFiltersSetForPrimaryIntents = 500 new IntentFiltersTestHelper(this).checkCrossProfileIntentFilters( 501 IntentFiltersTestHelper.FLAG_INTENTS_FROM_PRIMARY); 502 final boolean intentFiltersSet = 503 intentFiltersSetForPrimaryIntents & intentFiltersSetForManagedIntents; 504 setTestResult(mIntentFiltersTest, 505 intentFiltersSet ? TestResult.TEST_RESULT_PASSED : TestResult.TEST_RESULT_FAILED); 506 } 507 508 private void disableComponent() { 509 // Disable app components in the current profile, so only the counterpart in the other profile 510 // can respond (via cross-profile intent filter) 511 final String[] components = { 512 ByodHelperActivity.class.getName(), 513 WorkNotificationTestActivity.class.getName(), 514 WorkStatusTestActivity.class.getName(), 515 PermissionLockdownTestActivity.ACTIVITY_ALIAS 516 }; 517 for (String component : components) { 518 getPackageManager().setComponentEnabledSetting(new ComponentName(this, component), 519 PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 520 PackageManager.DONT_KILL_APP); 521 } 522 } 523 } 524