@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mAdminReceiverComponent = new ComponentName(this, DeviceAdminTestReceiver.class.getName());

    disableComponent();
    mPrepareTestButton.setText(R.string.provisioning_byod_start);
    mPrepareTestButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            startByodProvisioning();
          }
        });

    // If we are started by managed provisioning (fresh managed provisioning after encryption
    // reboot), redirect the user back to the main test list. This is because the test result
    // is only saved by the parent TestListActivity, and if we did allow the user to proceed
    // here, the test result would be lost when this activity finishes.
    if (ByodHelperActivity.ACTION_PROFILE_OWNER_STATUS.equals(getIntent().getAction())) {
      startActivity(new Intent(this, TestListActivity.class));
      // Calling super.finish() because we delete managed profile in our overridden of finish(),
      // which is not what we want to do here.
      super.finish();
    } else {
      queryProfileOwner(false);
    }
  }
 @Override
 protected void onNewIntent(Intent intent) {
   // This is called when managed provisioning completes successfully without reboot.
   super.onNewIntent(intent);
   if (ByodHelperActivity.ACTION_PROFILE_OWNER_STATUS.equals(intent.getAction())) {
     handleStatusUpdate(RESULT_OK, intent);
   }
 }