1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 package org.chromium.sync.test.util;
7 import android.accounts.Account;
8 import android.app.Activity;
9 import android.content.Intent;
10 import android.os.Bundle;
11 import android.os.Handler;
12 import android.os.Looper;
13 import android.util.Log;
14 import android.widget.TextView;
17 * A dummy implementation of the Android {@link GrantCredentialsPermissionActivity} that is used
18 * when displaying the Allow/Deny dialog when an application asks for an auth token
19 * for a given auth token type and that app has never gotten the permission.
21 * Currently this activity just starts up, broadcasts an intent, and finishes.
23 * This class is used by {@link MockAccountManager}.
25 public class MockGrantCredentialsPermissionActivity extends Activity {
27 private static final String TAG = "MockGrantCredentialsPermissionActivity";
29 static final String ACCOUNT = "account";
31 static final String AUTH_TOKEN_TYPE = "authTokenType";
34 protected void onCreate(Bundle savedInstanceState) {
35 super.onCreate(savedInstanceState);
36 TextView textView = new TextView(this);
37 Account account = (Account) getIntent().getParcelableExtra(ACCOUNT);
38 String authTokenType = getIntent().getStringExtra(AUTH_TOKEN_TYPE);
39 String accountName = account == null ? null : account.name;
40 String message = "account = " + accountName + ", authTokenType = " + authTokenType;
41 textView.setText(message);
42 setContentView(textView);
46 protected void onResume() {
48 // Send out the broadcast after the Activity has completely started up.
49 Handler handler = new Handler(Looper.getMainLooper());
50 handler.post(new Runnable() {
53 Log.d(TAG, "Broadcasting " + MockAccountManager.MUTEX_WAIT_ACTION);
54 sendBroadcast(new Intent(MockAccountManager.MUTEX_WAIT_ACTION));