diff options
| author | Fred Quintana <fredq@google.com> | 2010-01-14 12:22:55 -0800 |
|---|---|---|
| committer | Fred Quintana <fredq@google.com> | 2010-01-14 12:22:55 -0800 |
| commit | 26a72c269de84a9b0e8311a23a14d76d50913df2 (patch) | |
| tree | 47f7366a05431ece95af0458b1daeb960e6fd984 /apps | |
| parent | 7ae10a3eae8c1ac240b6d2ae328eb68a94f0ffc3 (diff) | |
| download | android_development-26a72c269de84a9b0e8311a23a14d76d50913df2.tar.gz android_development-26a72c269de84a9b0e8311a23a14d76d50913df2.tar.bz2 android_development-26a72c269de84a9b0e8311a23a14d76d50913df2.zip | |
add support for testing testFeatures()
Diffstat (limited to 'apps')
| -rw-r--r-- | apps/Development/res/layout/account_list_context_menu.xml | 3 | ||||
| -rw-r--r-- | apps/Development/res/values/strings.xml | 3 | ||||
| -rw-r--r-- | apps/Development/src/com/android/development/AccountsTester.java | 41 |
3 files changed, 45 insertions, 2 deletions
diff --git a/apps/Development/res/layout/account_list_context_menu.xml b/apps/Development/res/layout/account_list_context_menu.xml index 50e7ca1ee..89f8241aa 100644 --- a/apps/Development/res/layout/account_list_context_menu.xml +++ b/apps/Development/res/layout/account_list_context_menu.xml @@ -22,6 +22,9 @@ <item android:id="@+id/accounts_tester_get_auth_token" android:title="@string/accounts_tester_get_auth_token" /> + <item android:id="@+id/accounts_tester_test_has_features" + android:title="@string/accounts_tester_test_has_features" /> + <item android:id="@+id/accounts_tester_invalidate_auth_token" android:title="@string/accounts_tester_invalidate_auth_token" /> diff --git a/apps/Development/res/values/strings.xml b/apps/Development/res/values/strings.xml index d0fd50ffe..538741f49 100644 --- a/apps/Development/res/values/strings.xml +++ b/apps/Development/res/values/strings.xml @@ -162,7 +162,8 @@ <string name="accounts_tester_select_account_type">Select Account Type</string> <string name="accounts_tester_process_name_header">Process Name:</string> <string name="accounts_tester_remove_account">remove</string> - <string name="accounts_tester_get_auth_token">authenticate</string> + <string name="accounts_tester_get_auth_token">get authtoken</string> + <string name="accounts_tester_test_has_features">test has features</string> <string name="accounts_tester_invalidate_auth_token">invalidate token</string> <string name="accounts_tester_account_context_menu_title">account operations</string> <string name="accounts_tester_do_get_auth_token">Ok</string> diff --git a/apps/Development/src/com/android/development/AccountsTester.java b/apps/Development/src/com/android/development/AccountsTester.java index 8e09c3dfb..9ec6cd30e 100644 --- a/apps/Development/src/com/android/development/AccountsTester.java +++ b/apps/Development/src/com/android/development/AccountsTester.java @@ -46,8 +46,11 @@ public class AccountsTester extends Activity implements OnAccountsUpdateListener private static final int GET_AUTH_TOKEN_DIALOG_ID = 1; private static final int UPDATE_CREDENTIALS_DIALOG_ID = 2; private static final int INVALIDATE_AUTH_TOKEN_DIALOG_ID = 3; + private static final int TEST_HAS_FEATURES_DIALOG_ID = 4; + private static final int MESSAGE_DIALOG_ID = 5; private EditText mDesiredAuthTokenTypeEditText; private EditText mDesiredFeaturesEditText; + private volatile CharSequence mDialogMessage; @Override protected void onCreate(Bundle savedInstanceState) { @@ -268,6 +271,8 @@ public class AccountsTester extends Activity implements OnAccountsUpdateListener }, null /* handler */); } else if (item.getItemId() == R.id.accounts_tester_get_auth_token) { showDialog(GET_AUTH_TOKEN_DIALOG_ID); + } else if (item.getItemId() == R.id.accounts_tester_test_has_features) { + showDialog(TEST_HAS_FEATURES_DIALOG_ID); } else if (item.getItemId() == R.id.accounts_tester_invalidate_auth_token) { showDialog(INVALIDATE_AUTH_TOKEN_DIALOG_ID); } else if (item.getItemId() == R.id.accounts_tester_update_credentials) { @@ -282,7 +287,7 @@ public class AccountsTester extends Activity implements OnAccountsUpdateListener @Override protected Dialog onCreateDialog(final int id) { if (id == GET_AUTH_TOKEN_DIALOG_ID || id == INVALIDATE_AUTH_TOKEN_DIALOG_ID - || id == UPDATE_CREDENTIALS_DIALOG_ID) { + || id == UPDATE_CREDENTIALS_DIALOG_ID || id == TEST_HAS_FEATURES_DIALOG_ID) { final View view = LayoutInflater.from(this).inflate(R.layout.get_auth_token_view, null); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setPositiveButton(R.string.accounts_tester_do_get_auth_token, @@ -316,6 +321,10 @@ public class AccountsTester extends Activity implements OnAccountsUpdateListener } else if (id == INVALIDATE_AUTH_TOKEN_DIALOG_ID) { mAccountManager.getAuthToken(account, authTokenType, false, new GetAndInvalidateAuthTokenCallback(), null); + } else if (id == TEST_HAS_FEATURES_DIALOG_ID) { + String[] features = TextUtils.split(authTokenType, ","); + mAccountManager.testHasFeatures(account, features, + new TestHasFeaturesCallback(), null); } else { mAccountManager.updateCredentials( account, @@ -327,6 +336,11 @@ public class AccountsTester extends Activity implements OnAccountsUpdateListener builder.setView(view); return builder.create(); } + if (id == MESSAGE_DIALOG_ID) { + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setMessage(mDialogMessage); + return builder.create(); + } return super.onCreateDialog(id); } @@ -413,6 +427,31 @@ public class AccountsTester extends Activity implements OnAccountsUpdateListener } } + private void showMessageDialog(String message) { + mDialogMessage = message; + removeDialog(MESSAGE_DIALOG_ID); + showDialog(MESSAGE_DIALOG_ID); + } + + private class TestHasFeaturesCallback implements AccountManagerCallback<Boolean> { + public void run(AccountManagerFuture<Boolean> future) { + try { + Boolean hasFeatures = future.getResult(); + Log.d(TAG, "hasFeatures: " + hasFeatures); + showMessageDialog("hasFeatures: " + hasFeatures); + } catch (OperationCanceledException e) { + Log.d(TAG, "interrupted"); + showMessageDialog("operation was canceled"); + } catch (IOException e) { + Log.d(TAG, "error", e); + showMessageDialog("operation got an IOException"); + } catch (AuthenticatorException e) { + Log.d(TAG, "error", e); + showMessageDialog("operation got an AuthenticationException"); + } + } + } + private static class ConfirmCredentialsCallback implements AccountManagerCallback<Bundle> { public void run(AccountManagerFuture<Bundle> future) { try { |
