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

Commit 7d6b590a authored by Xin Li's avatar Xin Li
Browse files

Merge Android R

Bug: 168057903
Merged-In: I3ce47d83598d773b3bc180cc6a3aaa30498f7ccc
Change-Id: Ib821458e67b3e2c4b69e82b5620ded50fc95d794
parents 42e428ed 268fb3fe
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -271,16 +271,16 @@ public class DrawerAdapter extends BaseAdapter {
            result.setId(item.id);
        }
        final ContactListFilter account = item.account;
        final AccountDisplayInfo displayableAccount =
                mAccountDisplayFactory.getAccountDisplayInfoFor(item.account);
        final TextView textView = ((TextView) result.findViewById(R.id.title));
        textView.setText(account.accountName);
        textView.setText(displayableAccount.getNameLabel());
        final boolean activated = account.equals(mSelectedAccount)
                && mSelectedView == ContactsView.ACCOUNT_VIEW;
        textView.setTextAppearance(mActivity, activated
                ? TYPEFACE_STYLE_ACTIVATE : TYPEFACE_STYLE_INACTIVE);

        final ImageView icon = (ImageView) result.findViewById(R.id.icon);
        final AccountDisplayInfo displayableAccount =
                mAccountDisplayFactory.getAccountDisplayInfoFor(item.account);
        icon.setScaleType(ImageView.ScaleType.FIT_CENTER);
        icon.setImageDrawable(displayableAccount.getIcon());

+20 −22
Original line number Diff line number Diff line
@@ -405,9 +405,8 @@ class AccountTypeManagerImpl extends AccountTypeManager

        ContentResolver.addStatusChangeListener(ContentResolver.SYNC_OBSERVER_TYPE_SETTINGS, this);

        if (Flags.getInstance().getBoolean(Experiments.CP2_DEVICE_ACCOUNT_DETECTION_ENABLED)) {
        // Observe changes to RAW_CONTACTS so that we will update the list of "Device" accounts
            // if a new device contact is added.
        // if a new device contact is added or removed.
        mContext.getContentResolver().registerContentObserver(
                ContactsContract.RawContacts.CONTENT_URI, /* notifyDescendents */ true,
                new ContentObserver(mMainThreadHandler) {
@@ -426,7 +425,6 @@ class AccountTypeManagerImpl extends AccountTypeManager
                        reloadLocalAccounts();
                    }
                });
        }
        loadAccountTypes();
    }

+11 −7
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.contacts.model;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.Context;
import android.database.Cursor;
import android.provider.ContactsContract;

import com.android.contacts.Experiments;
import com.android.contacts.model.account.AccountWithDataSet;
@@ -69,23 +71,25 @@ public abstract class DeviceLocalAccountLocator {
            return new Cp2DeviceLocalAccountLocator(context.getContentResolver(),
                    ObjectFactory.getDeviceLocalAccountTypeFactory(context), knownTypes);
        } else {
            return new NexusDeviceAccountLocator(accountManager);
            return new NexusDeviceAccountLocator(context, accountManager);
        }
    }

    /**
     * On Nexus the "device" account uses "null" values for the account name and type columns
     *
     * <p>However, the focus sync adapter automatically migrates contacts from this null
     * account to a Google account if one exists. Hence, the device account should be returned
     * only when there is no Google Account added
     * <p>However, the focus sync adapter migrates contacts from this null account to a Google
     * account if one exists. Hence, the device account should be returned only when there is no
     * Google Account added or when there already exists contacts in the null account.
     * </p>
     */
    public static class NexusDeviceAccountLocator extends DeviceLocalAccountLocator {

        private final Context mContext;
        private final AccountManager mAccountManager;

        public NexusDeviceAccountLocator(AccountManager accountManager) {

        public NexusDeviceAccountLocator(Context context, AccountManager accountManager) {
            mContext = context;
            mAccountManager = accountManager;
        }

@@ -95,7 +99,7 @@ public abstract class DeviceLocalAccountLocator {
            final Account[] accounts = mAccountManager
                    .getAccountsByType(GoogleAccountType.ACCOUNT_TYPE);

            if (accounts.length > 0) {
            if (accounts.length > 0 && !AccountWithDataSet.getNullAccount().hasData(mContext)) {
                return Collections.emptyList();
            } else {
                return Collections.singletonList(AccountWithDataSet.getNullAccount());
+2 −0
Original line number Diff line number Diff line
@@ -22,4 +22,6 @@ android_test {
        "android.test.base.stubs",
        "android.test.mock.stubs",
    ],

    test_suites: ["general-tests"],
}

tests/AndroidTest.xml

0 → 100644
+29 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2020 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.
-->
<configuration description="Runs Tests for Contacts.">
  <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
    <option name="cleanup-apks" value="true" />
    <option name="test-file-name" value="ContactsTests.apk" />
  </target_preparer>

  <option name="test-suite-tag" value="apct" />
  <option name="test-tag" value="ContactsTests" />
  <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
    <option name="package" value="com.android.contacts.tests" />
    <option name="runner" value="androidx.test.runner.AndroidJUnitRunner" />
    <option name="hidden-api-checks" value="false"/>
  </test>
</configuration>
Loading