@Test public void validWithTesterAppUpdateSetupFailedAndNoTaskRoot() { Intent intent = mock(Intent.class); when(intent.getStringExtra(DistributeConstants.EXTRA_REQUEST_ID)).thenReturn("mock1"); when(intent.getStringExtra(DistributeConstants.EXTRA_TESTER_APP_UPDATE_SETUP_FAILED)).thenReturn("mock2"); when(intent.getFlags()).thenReturn(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY); DeepLinkActivity activity = spy(new DeepLinkActivity()); when(activity.getIntent()).thenReturn(intent); activity.onCreate(null); verify(activity, never()).startActivity(any(Intent.class)); verify(mDistribute, never()).storeRedirectionParameters(anyString(), anyString(), anyString()); verify(activity).finish(); verify(mDistribute).storeTesterAppUpdateSetupFailedParameter("mock1", "mock2"); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); String requestId = intent.getStringExtra(EXTRA_REQUEST_ID); String distributionGroupId = intent.getStringExtra(EXTRA_DISTRIBUTION_GROUP_ID); String updateToken = intent.getStringExtra(EXTRA_UPDATE_TOKEN); String updateSetupFailed = intent.getStringExtra(EXTRA_UPDATE_SETUP_FAILED); String testerAppUpdateSetupFailed = intent.getStringExtra(EXTRA_TESTER_APP_UPDATE_SETUP_FAILED); AppCenterLog.debug(LOG_TAG, getLocalClassName() + ".getIntent()=" + intent); AppCenterLog.debug(LOG_TAG, "Intent requestId=" + requestId); AppCenterLog.debug(LOG_TAG, "Intent distributionGroupId=" + distributionGroupId); AppCenterLog.debug(LOG_TAG, "Intent updateToken passed=" + (updateToken != null)); AppCenterLog.debug(LOG_TAG, "Intent updateSetupFailed passed=" + (updateSetupFailed != null)); AppCenterLog.debug(LOG_TAG, "Intent testerAppUpdateSetupFailed passed=" + (testerAppUpdateSetupFailed != null)); if (requestId != null && distributionGroupId != null) { Distribute.getInstance().storeRedirectionParameters(requestId, distributionGroupId, updateToken); } else if (requestId != null && updateSetupFailed != null) { Distribute.getInstance().storeUpdateSetupFailedParameter(requestId, updateSetupFailed); } if (requestId != null && testerAppUpdateSetupFailed != null) { Distribute.getInstance().storeTesterAppUpdateSetupFailedParameter(requestId, testerAppUpdateSetupFailed); } finish(); if (!((getIntent().getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) == Intent.FLAG_ACTIVITY_NEW_TASK)) { AppCenterLog.debug(LOG_TAG, "Using restart work around to correctly resume app."); startActivity(intent.cloneFilter().addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); } else if (isTaskRoot()) { Intent launchIntentForPackage = getPackageManager().getLaunchIntentForPackage(getPackageName()); if (launchIntentForPackage != null) { startActivity(launchIntentForPackage); } } }
DeepLinkActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); String requestId = intent.getStringExtra(EXTRA_REQUEST_ID); String distributionGroupId = intent.getStringExtra(EXTRA_DISTRIBUTION_GROUP_ID); String updateToken = intent.getStringExtra(EXTRA_UPDATE_TOKEN); String updateSetupFailed = intent.getStringExtra(EXTRA_UPDATE_SETUP_FAILED); String testerAppUpdateSetupFailed = intent.getStringExtra(EXTRA_TESTER_APP_UPDATE_SETUP_FAILED); AppCenterLog.debug(LOG_TAG, getLocalClassName() + ".getIntent()=" + intent); AppCenterLog.debug(LOG_TAG, "Intent requestId=" + requestId); AppCenterLog.debug(LOG_TAG, "Intent distributionGroupId=" + distributionGroupId); AppCenterLog.debug(LOG_TAG, "Intent updateToken passed=" + (updateToken != null)); AppCenterLog.debug(LOG_TAG, "Intent updateSetupFailed passed=" + (updateSetupFailed != null)); AppCenterLog.debug(LOG_TAG, "Intent testerAppUpdateSetupFailed passed=" + (testerAppUpdateSetupFailed != null)); if (requestId != null && distributionGroupId != null) { Distribute.getInstance().storeRedirectionParameters(requestId, distributionGroupId, updateToken); } else if (requestId != null && updateSetupFailed != null) { Distribute.getInstance().storeUpdateSetupFailedParameter(requestId, updateSetupFailed); } if (requestId != null && testerAppUpdateSetupFailed != null) { Distribute.getInstance().storeTesterAppUpdateSetupFailedParameter(requestId, testerAppUpdateSetupFailed); } finish(); if (!((getIntent().getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) == Intent.FLAG_ACTIVITY_NEW_TASK)) { AppCenterLog.debug(LOG_TAG, "Using restart work around to correctly resume app."); startActivity(intent.cloneFilter().addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); } else if (isTaskRoot()) { Intent launchIntentForPackage = getPackageManager().getLaunchIntentForPackage(getPackageName()); if (launchIntentForPackage != null) { startActivity(launchIntentForPackage); } } } }
DeepLinkActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); String requestId = intent.getStringExtra(EXTRA_REQUEST_ID); String distributionGroupId = intent.getStringExtra(EXTRA_DISTRIBUTION_GROUP_ID); String updateToken = intent.getStringExtra(EXTRA_UPDATE_TOKEN); String updateSetupFailed = intent.getStringExtra(EXTRA_UPDATE_SETUP_FAILED); String testerAppUpdateSetupFailed = intent.getStringExtra(EXTRA_TESTER_APP_UPDATE_SETUP_FAILED); AppCenterLog.debug(LOG_TAG, getLocalClassName() + ".getIntent()=" + intent); AppCenterLog.debug(LOG_TAG, "Intent requestId=" + requestId); AppCenterLog.debug(LOG_TAG, "Intent distributionGroupId=" + distributionGroupId); AppCenterLog.debug(LOG_TAG, "Intent updateToken passed=" + (updateToken != null)); AppCenterLog.debug(LOG_TAG, "Intent updateSetupFailed passed=" + (updateSetupFailed != null)); AppCenterLog.debug(LOG_TAG, "Intent testerAppUpdateSetupFailed passed=" + (testerAppUpdateSetupFailed != null)); if (requestId != null && distributionGroupId != null) { Distribute.getInstance().storeRedirectionParameters(requestId, distributionGroupId, updateToken); } else if (requestId != null && updateSetupFailed != null) { Distribute.getInstance().storeUpdateSetupFailedParameter(requestId, updateSetupFailed); } if (requestId != null && testerAppUpdateSetupFailed != null) { Distribute.getInstance().storeTesterAppUpdateSetupFailedParameter(requestId, testerAppUpdateSetupFailed); } finish(); if (!((getIntent().getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) == Intent.FLAG_ACTIVITY_NEW_TASK)) { AppCenterLog.debug(LOG_TAG, "Using restart work around to correctly resume app."); startActivity(intent.cloneFilter().addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); } else if (isTaskRoot()) { Intent launchIntentForPackage = getPackageManager().getLaunchIntentForPackage(getPackageName()); if (launchIntentForPackage != null) { startActivity(launchIntentForPackage); } } }  }
DeepLinkActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); String requestId = intent.getStringExtra(EXTRA_REQUEST_ID); String distributionGroupId = intent.getStringExtra(EXTRA_DISTRIBUTION_GROUP_ID); String updateToken = intent.getStringExtra(EXTRA_UPDATE_TOKEN); String updateSetupFailed = intent.getStringExtra(EXTRA_UPDATE_SETUP_FAILED); String testerAppUpdateSetupFailed = intent.getStringExtra(EXTRA_TESTER_APP_UPDATE_SETUP_FAILED); AppCenterLog.debug(LOG_TAG, getLocalClassName() + ".getIntent()=" + intent); AppCenterLog.debug(LOG_TAG, "Intent requestId=" + requestId); AppCenterLog.debug(LOG_TAG, "Intent distributionGroupId=" + distributionGroupId); AppCenterLog.debug(LOG_TAG, "Intent updateToken passed=" + (updateToken != null)); AppCenterLog.debug(LOG_TAG, "Intent updateSetupFailed passed=" + (updateSetupFailed != null)); AppCenterLog.debug(LOG_TAG, "Intent testerAppUpdateSetupFailed passed=" + (testerAppUpdateSetupFailed != null)); if (requestId != null && distributionGroupId != null) { Distribute.getInstance().storeRedirectionParameters(requestId, distributionGroupId, updateToken); } else if (requestId != null && updateSetupFailed != null) { Distribute.getInstance().storeUpdateSetupFailedParameter(requestId, updateSetupFailed); } if (requestId != null && testerAppUpdateSetupFailed != null) { Distribute.getInstance().storeTesterAppUpdateSetupFailedParameter(requestId, testerAppUpdateSetupFailed); } finish(); if (!((getIntent().getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) == Intent.FLAG_ACTIVITY_NEW_TASK)) { AppCenterLog.debug(LOG_TAG, "Using restart work around to correctly resume app."); startActivity(intent.cloneFilter().addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); } else if (isTaskRoot()) { Intent launchIntentForPackage = getPackageManager().getLaunchIntentForPackage(getPackageName()); if (launchIntentForPackage != null) { startActivity(launchIntentForPackage); } } }  @Override void onCreate(Bundle savedInstanceState); }
DeepLinkActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); String requestId = intent.getStringExtra(EXTRA_REQUEST_ID); String distributionGroupId = intent.getStringExtra(EXTRA_DISTRIBUTION_GROUP_ID); String updateToken = intent.getStringExtra(EXTRA_UPDATE_TOKEN); String updateSetupFailed = intent.getStringExtra(EXTRA_UPDATE_SETUP_FAILED); String testerAppUpdateSetupFailed = intent.getStringExtra(EXTRA_TESTER_APP_UPDATE_SETUP_FAILED); AppCenterLog.debug(LOG_TAG, getLocalClassName() + ".getIntent()=" + intent); AppCenterLog.debug(LOG_TAG, "Intent requestId=" + requestId); AppCenterLog.debug(LOG_TAG, "Intent distributionGroupId=" + distributionGroupId); AppCenterLog.debug(LOG_TAG, "Intent updateToken passed=" + (updateToken != null)); AppCenterLog.debug(LOG_TAG, "Intent updateSetupFailed passed=" + (updateSetupFailed != null)); AppCenterLog.debug(LOG_TAG, "Intent testerAppUpdateSetupFailed passed=" + (testerAppUpdateSetupFailed != null)); if (requestId != null && distributionGroupId != null) { Distribute.getInstance().storeRedirectionParameters(requestId, distributionGroupId, updateToken); } else if (requestId != null && updateSetupFailed != null) { Distribute.getInstance().storeUpdateSetupFailedParameter(requestId, updateSetupFailed); } if (requestId != null && testerAppUpdateSetupFailed != null) { Distribute.getInstance().storeTesterAppUpdateSetupFailedParameter(requestId, testerAppUpdateSetupFailed); } finish(); if (!((getIntent().getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) == Intent.FLAG_ACTIVITY_NEW_TASK)) { AppCenterLog.debug(LOG_TAG, "Using restart work around to correctly resume app."); startActivity(intent.cloneFilter().addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); } else if (isTaskRoot()) { Intent launchIntentForPackage = getPackageManager().getLaunchIntentForPackage(getPackageName()); if (launchIntentForPackage != null) { startActivity(launchIntentForPackage); } } }  @Override void onCreate(Bundle savedInstanceState);  }