Skip to content

Commit

Permalink
[Android] Check whether MockGrantCredentialsPermissionsActivity can b…
Browse files Browse the repository at this point in the history
…e started.

BUG=406596

Review URL: https://codereview.chromium.org/467363004

Cr-Commit-Position: refs/heads/master@{#292975}
  • Loading branch information
jbudorick authored and Commit bot committed Sep 2, 2014
1 parent a55ae06 commit d2787a3
Showing 1 changed file with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
Expand Down Expand Up @@ -349,9 +351,26 @@ private void applyPreparedPermission(AccountAuthTokenPreparation prep) {

private Intent newGrantCredentialsPermissionIntent(boolean hasActivity, Account account,
String authTokenType) {
ComponentName component = new ComponentName(mTestContext,
MockGrantCredentialsPermissionActivity.class.getCanonicalName());

// Make sure we can start the activity.
ActivityInfo ai = null;
try {
ai = mContext.getPackageManager().getActivityInfo(component, 0);
} catch (PackageManager.NameNotFoundException e) {
throw new IllegalStateException(
"Unable to find " + component.getClassName());
}
if (ai.applicationInfo != mContext.getApplicationInfo() && !ai.exported) {
throw new IllegalStateException(
"Unable to start " + ai.name + ". " +
"The accounts you added to MockAccountManager may not be " +
"configured correctly.");
}

Intent intent = new Intent();
intent.setComponent(new ComponentName(mTestContext,
MockGrantCredentialsPermissionActivity.class.getCanonicalName()));
intent.setComponent(component);
intent.putExtra(MockGrantCredentialsPermissionActivity.ACCOUNT, account);
intent.putExtra(MockGrantCredentialsPermissionActivity.AUTH_TOKEN_TYPE, authTokenType);
if (!hasActivity) {
Expand Down

0 comments on commit d2787a3

Please sign in to comment.