Fix the ContactsTest account type and sync adapter (1/2)

* Add TestSyncService$Basic to the AndroidManifest and give
  it the fallback account type unit test contacts.xml.

* Remove "common" from the testauth package name

* Change the test accountType to end with testauth.basic
  instead of authtest.basic since it's testauth
  everywhere else.

* UI changes
- Give the test account type the same name as the app
- Remove the ic_contact_picture test account type icon
  since it just looks like a black square and we can
  just use the default (after we add a guard against
  null icons in the DrawerActivity)

Test: manually add a user of the test account type and
  toggle sync, then add a contact of the test account
  type in the app.

Bug: 30759296
Bug: 31549157

Change-Id: I363fff8dfbce3d2d1b888e23abe6e20a40da2d1c
diff --git a/src/com/android/contacts/ContactsDrawerActivity.java b/src/com/android/contacts/ContactsDrawerActivity.java
index 09281ee..729d75f 100644
--- a/src/com/android/contacts/ContactsDrawerActivity.java
+++ b/src/com/android/contacts/ContactsDrawerActivity.java
@@ -497,9 +497,11 @@
                     return true;
                 }
             });
-            menuItem.setIcon(displayableAccount.getIcon());
-            // Get rid of the default menu item overlay and show original account icons.
-            menuItem.getIcon().setColorFilter(Color.TRANSPARENT, PorterDuff.Mode.SRC_ATOP);
+            if (displayableAccount.getIcon() != null) {
+                menuItem.setIcon(displayableAccount.getIcon());
+                // Get rid of the default menu item overlay and show original account icons.
+                menuItem.getIcon().setColorFilter(Color.TRANSPARENT, PorterDuff.Mode.SRC_ATOP);
+            }
             // Create a dummy action view to attach extra hidden content description to the menuItem
             // for Talkback. We want Talkback to read out the account type but not have it be part
             // of the menuItem title.
diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml
index 65c04bc..87f9a8a 100644
--- a/tests/AndroidManifest.xml
+++ b/tests/AndroidManifest.xml
@@ -69,6 +69,17 @@
                 android:name="android.accounts.AccountAuthenticator"
                 android:resource="@xml/test_basic_authenticator" />
         </service>
+        <service android:name=".testauth.TestSyncService$Basic" android:exported="true" >
+            <intent-filter>
+                <action android:name="android.content.SyncAdapter"/>
+            </intent-filter>
+            <meta-data
+                android:name="android.content.SyncAdapter"
+                android:resource="@xml/test_basic_syncadapter" />
+            <meta-data
+                android:name="android.provider.CONTACTS_STRUCTURE"
+                android:resource="@xml/contacts_fallback" />
+        </service>
 
         <service android:name=".QueryService" />
         <service android:name=".PhoneNumberTestService" />
diff --git a/tests/res/drawable/ic_contact_picture.png b/tests/res/drawable/ic_contact_picture.png
deleted file mode 100644
index 6876777..0000000
--- a/tests/res/drawable/ic_contact_picture.png
+++ /dev/null
Binary files differ
diff --git a/tests/res/values/donottranslate_strings.xml b/tests/res/values/donottranslate_strings.xml
index 1528112..76cf4e4 100644
--- a/tests/res/values/donottranslate_strings.xml
+++ b/tests/res/values/donottranslate_strings.xml
@@ -104,7 +104,5 @@
     <string name="attribution_flicker">Flicker</string>
     <string name="attribution_twitter">Twitter</string>
 
-    <string name="authenticator_basic_label">Test adapter</string>
-
     <string name="test_string">TEST STRING</string>
 </resources>
diff --git a/tests/res/xml/test_basic_authenticator.xml b/tests/res/xml/test_basic_authenticator.xml
index ecd100a..efcdadf 100644
--- a/tests/res/xml/test_basic_authenticator.xml
+++ b/tests/res/xml/test_basic_authenticator.xml
@@ -18,8 +18,6 @@
 -->
 
 <account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
-    android:accountType="com.android.contacts.tests.authtest.basic"
-    android:icon="@drawable/ic_contact_picture"
-    android:smallIcon="@drawable/ic_contact_picture"
-    android:label="@string/authenticator_basic_label"
+    android:accountType="com.android.contacts.tests.testauth.basic"
+    android:label="@string/applicationLabel"
 />
diff --git a/tests/res/xml/test_basic_syncadapter.xml b/tests/res/xml/test_basic_syncadapter.xml
index fecc0eb..b897185 100644
--- a/tests/res/xml/test_basic_syncadapter.xml
+++ b/tests/res/xml/test_basic_syncadapter.xml
@@ -19,7 +19,7 @@
 
 <sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
     android:contentAuthority="com.android.contacts"
-    android:accountType="com.android.contacts.tests.authtest.basic"
+    android:accountType="com.android.contacts.tests.testauth.basic"
     android:supportsUploading="true"
     android:userVisible="true"
 />
diff --git a/tests/src/com/android/contacts/tests/FakeDeviceAccountTypeFactory.java b/tests/src/com/android/contacts/tests/FakeDeviceAccountTypeFactory.java
index 6a500ec..65f8014 100644
--- a/tests/src/com/android/contacts/tests/FakeDeviceAccountTypeFactory.java
+++ b/tests/src/com/android/contacts/tests/FakeDeviceAccountTypeFactory.java
@@ -16,12 +16,10 @@
 package com.android.contacts.tests;
 
 import com.android.contacts.common.model.account.AccountType;
-import com.android.contacts.common.model.account.FallbackAccountType;
 import com.android.contacts.common.util.DeviceLocalAccountTypeFactory;
 
 import java.util.HashMap;
 import java.util.Map;
-import java.util.Set;
 
 public class FakeDeviceAccountTypeFactory implements DeviceLocalAccountTypeFactory {
 
diff --git a/tests/src/com/android/contacts/common/tests/testauth/TestAuthenticationService.java b/tests/src/com/android/contacts/tests/testauth/TestAuthenticationService.java
similarity index 96%
rename from tests/src/com/android/contacts/common/tests/testauth/TestAuthenticationService.java
rename to tests/src/com/android/contacts/tests/testauth/TestAuthenticationService.java
index 93d1f4a..84f3f0f 100644
--- a/tests/src/com/android/contacts/common/tests/testauth/TestAuthenticationService.java
+++ b/tests/src/com/android/contacts/tests/testauth/TestAuthenticationService.java
@@ -14,7 +14,7 @@
  * the License.
  */
 
-package com.android.contacts.common.tests.testauth;
+package com.android.contacts.tests.testauth;
 
 import android.app.Service;
 import android.content.Intent;
diff --git a/tests/src/com/android/contacts/common/tests/testauth/TestAuthenticator.java b/tests/src/com/android/contacts/tests/testauth/TestAuthenticator.java
similarity index 98%
rename from tests/src/com/android/contacts/common/tests/testauth/TestAuthenticator.java
rename to tests/src/com/android/contacts/tests/testauth/TestAuthenticator.java
index 2f676c7..97e2e4d 100644
--- a/tests/src/com/android/contacts/common/tests/testauth/TestAuthenticator.java
+++ b/tests/src/com/android/contacts/tests/testauth/TestAuthenticator.java
@@ -14,7 +14,7 @@
  * the License.
  */
 
-package com.android.contacts.common.tests.testauth;
+package com.android.contacts.tests.testauth;
 
 import android.accounts.AbstractAccountAuthenticator;
 import android.accounts.Account;
diff --git a/tests/src/com/android/contacts/common/tests/testauth/TestSyncAdapter.java b/tests/src/com/android/contacts/tests/testauth/TestSyncAdapter.java
similarity index 92%
rename from tests/src/com/android/contacts/common/tests/testauth/TestSyncAdapter.java
rename to tests/src/com/android/contacts/tests/testauth/TestSyncAdapter.java
index a7c0f83..feef8ec 100644
--- a/tests/src/com/android/contacts/common/tests/testauth/TestSyncAdapter.java
+++ b/tests/src/com/android/contacts/tests/testauth/TestSyncAdapter.java
@@ -13,10 +13,9 @@
  * License for the specific language governing permissions and limitations under
  * the License.
  */
-package com.android.contacts.common.tests.testauth;
+package com.android.contacts.tests.testauth;
 
 import android.accounts.Account;
-import android.accounts.AccountManager;
 import android.content.AbstractThreadedSyncAdapter;
 import android.content.ContentProviderClient;
 import android.content.ContentResolver;
@@ -32,14 +31,12 @@
  *
  */
 public class TestSyncAdapter extends AbstractThreadedSyncAdapter {
-    private final AccountManager mAccountManager;
 
     private final Context mContext;
 
     public TestSyncAdapter(Context context, boolean autoInitialize) {
         super(context, autoInitialize);
         mContext = context.getApplicationContext();
-        mAccountManager = AccountManager.get(mContext);
     }
 
     /**
diff --git a/tests/src/com/android/contacts/common/tests/testauth/TestSyncService.java b/tests/src/com/android/contacts/tests/testauth/TestSyncService.java
similarity index 95%
rename from tests/src/com/android/contacts/common/tests/testauth/TestSyncService.java
rename to tests/src/com/android/contacts/tests/testauth/TestSyncService.java
index 3354cb4..9928777 100644
--- a/tests/src/com/android/contacts/common/tests/testauth/TestSyncService.java
+++ b/tests/src/com/android/contacts/tests/testauth/TestSyncService.java
@@ -13,7 +13,7 @@
  * License for the specific language governing permissions and limitations under
  * the License.
  */
-package com.android.contacts.common.tests.testauth;
+package com.android.contacts.tests.testauth;
 
 import android.app.Service;
 import android.content.Intent;
diff --git a/tests/src/com/android/contacts/common/tests/testauth/TestauthConstants.java b/tests/src/com/android/contacts/tests/testauth/TestauthConstants.java
similarity index 92%
rename from tests/src/com/android/contacts/common/tests/testauth/TestauthConstants.java
rename to tests/src/com/android/contacts/tests/testauth/TestauthConstants.java
index 3ce7f5a..717ed35 100644
--- a/tests/src/com/android/contacts/common/tests/testauth/TestauthConstants.java
+++ b/tests/src/com/android/contacts/tests/testauth/TestauthConstants.java
@@ -14,7 +14,7 @@
  * the License.
  */
 
-package com.android.contacts.common.tests.testauth;
+package com.android.contacts.tests.testauth;
 
 class TestauthConstants {
     public static final String LOG_TAG = "Testauth";