Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 81c4c8af authored by Hongming Jin's avatar Hongming Jin
Browse files

Test: AccountManagerService APCT test.

Setup test authenticators, add tests for startAddAccountSession.

Bug: 31346530
Change-Id: I0fb460a8a1c35e2c88c624d0e291b20051110b34
parent 094119df
Loading
Loading
Loading
Loading
+22 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
        package="com.android.frameworks.servicestests">

    <uses-permission android:name="android.permission.READ_LOGS" />
    <uses-permission android:name="android.permission.ACCOUNT_MANAGER" />
    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
    <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
@@ -65,6 +66,24 @@
          </intent-filter>
        </service>

        <service android:name="com.android.server.accounts.TestAccountType1AuthenticatorService"
            android:exported="false">
          <intent-filter>
            <action android:name="android.accounts.AccountAuthenticator" />
          </intent-filter>
          <meta-data android:name="android.accounts.AccountAuthenticator"
              android:resource="@xml/test_account_type1_authenticator" />
        </service>

        <service android:name="com.android.server.accounts.TestAccountType2AuthenticatorService"
            android:exported="false">
          <intent-filter>
            <action android:name="android.accounts.AccountAuthenticator" />
          </intent-filter>
          <meta-data android:name="android.accounts.AccountAuthenticator"
              android:resource="@xml/test_account_type2_authenticator" />
        </service>

        <receiver android:name="com.android.server.devicepolicy.ApplicationRestrictionsTest$AdminReceiver"
                android:permission="android.permission.BIND_DEVICE_ADMIN">
            <meta-data android:name="android.app.device_admin"
@@ -119,6 +138,8 @@
        <activity android:name="com.android.server.pm.ShortcutTestActivity"
                 android:enabled="true" android:exported="true" />

        <activity android:name="com.android.server.accounts.AccountAuthenticatorDummyActivity" />

        <activity-alias android:name="a.ShortcutEnabled"
            android:targetActivity="com.android.server.pm.ShortcutTestActivity"
            android:enabled="true" android:exported="true">
+4 −0
Original line number Diff line number Diff line
@@ -21,4 +21,8 @@
    <string name="shortcut_title2"></string>
    <string name="shortcut_text2"></string>
    <string name="shortcut_disabled_message2"></string>
    <string name="test_account_type1_authenticator_label">AccountManagerService Test Account Type1</string>
    <string name="test_account_type2_authenticator_label">AccountManagerService Test Account Type2</string>
    <string name="test_account_type1">com.android.server.accounts.account_manager_service_test.account.type1</string>
    <string name="test_account_type2">com.android.server.accounts.account_manager_service_test.account.type2</string>
</resources>
+21 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2017 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
    android:accountType="@string/test_account_type1"
    android:icon="@drawable/icon1"
    android:smallIcon="@drawable/icon1"
    android:label="@string/test_account_type1_authenticator_label" />
+21 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2017 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
    android:accountType="@string/test_account_type2"
    android:icon="@drawable/icon1"
    android:smallIcon="@drawable/icon1"
    android:label="@string/test_account_type2_authenticator_label" />
+42 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.android.server.accounts;

import android.accounts.AccountAuthenticatorResponse;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

/**
 * Activity used by {@link com.android.server.accounts.TestAccountAuthenticator} to test the
 * behavior of {@link AccountManagerService} when authenticator returns intent.
 */
public class AccountAuthenticatorDummyActivity extends Activity {

    @Override
    protected void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        Intent intent = getIntent();
        AccountAuthenticatorResponse response =
                intent.getParcelableExtra(AccountManagerServiceTestFixtures.KEY_CALLBACK);
        Intent result = intent.getParcelableExtra(AccountManagerServiceTestFixtures.KEY_RESULT);
        if (response != null) {
            response.onResult(result.getExtras());
        }
        setResult(RESULT_OK, result);
        finish();
    }
}
Loading