Loading src/com/android/contacts/drawer/DrawerAdapter.java +3 −3 Original line number Diff line number Diff line Loading @@ -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()); Loading src/com/android/contacts/model/AccountTypeManager.java +20 −22 Original line number Diff line number Diff line Loading @@ -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) { Loading @@ -426,7 +425,6 @@ class AccountTypeManagerImpl extends AccountTypeManager reloadLocalAccounts(); } }); } loadAccountTypes(); } Loading src/com/android/contacts/model/DeviceLocalAccountLocator.java +11 −7 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; } Loading @@ -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()); Loading tests/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -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
src/com/android/contacts/drawer/DrawerAdapter.java +3 −3 Original line number Diff line number Diff line Loading @@ -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()); Loading
src/com/android/contacts/model/AccountTypeManager.java +20 −22 Original line number Diff line number Diff line Loading @@ -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) { Loading @@ -426,7 +425,6 @@ class AccountTypeManagerImpl extends AccountTypeManager reloadLocalAccounts(); } }); } loadAccountTypes(); } Loading
src/com/android/contacts/model/DeviceLocalAccountLocator.java +11 −7 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; } Loading @@ -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()); Loading
tests/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -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>