Merge changes from topic "presubmit-am-baca0ede84674175a9bb058e662c605a" into sc-qpr1-dev am: e49133bca0

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/providers/ContactsProvider/+/16155841

Change-Id: I4e054a19ff76f2d3c47a912f9497b07cf76ea73e
diff --git a/src/com/android/providers/contacts/ContactsProvider2.java b/src/com/android/providers/contacts/ContactsProvider2.java
index 0c6e819..4b2b37a 100644
--- a/src/com/android/providers/contacts/ContactsProvider2.java
+++ b/src/com/android/providers/contacts/ContactsProvider2.java
@@ -20,6 +20,7 @@
 import static android.Manifest.permission.INTERACT_ACROSS_USERS_FULL;
 import static android.content.pm.PackageManager.PERMISSION_GRANTED;
 
+import android.os.Looper;
 import android.accounts.Account;
 import android.accounts.AccountManager;
 import android.accounts.OnAccountsUpdateListener;
@@ -64,7 +65,6 @@
 import android.os.Bundle;
 import android.os.CancellationSignal;
 import android.os.Handler;
-import android.os.Looper;
 import android.os.ParcelFileDescriptor;
 import android.os.ParcelFileDescriptor.AutoCloseInputStream;
 import android.os.RemoteException;
@@ -126,6 +126,7 @@
 import com.android.common.content.ProjectionMap;
 import com.android.common.content.SyncStateContentProviderHelper;
 import com.android.common.io.MoreCloseables;
+import com.android.i18n.phonenumbers.Phonenumber;
 import com.android.internal.util.ArrayUtils;
 import com.android.providers.contacts.ContactLookupKey.LookupKeySegment;
 import com.android.providers.contacts.ContactsDatabaseHelper.AccountsColumns;
@@ -2272,10 +2273,6 @@
 
     @Override
     public Bundle call(String method, String arg, Bundle extras) {
-        LogFields.Builder logBuilder =
-                LogFields.Builder.aLogFields()
-                        .setApiType(LogUtils.ApiType.CALL)
-                        .setStartNanos(SystemClock.elapsedRealtimeNanos());
         waitForAccess(mReadAccessLatch);
         switchToContactMode();
         if (Authorization.AUTHORIZATION_METHOD.equals(method)) {
@@ -2316,54 +2313,34 @@
                 throw new IllegalArgumentException("Account name or type is empty");
             }
 
-            long resultId = -1;
             final Bundle response = new Bundle();
             final SQLiteDatabase db = mDbHelper.get().getWritableDatabase();
             db.beginTransaction();
             try {
-                resultId = mDbHelper.get().createSimAccountIdInTransaction(
+                mDbHelper.get().createSimAccountIdInTransaction(
                         AccountWithDataSet.get(accountName, accountType, null), simSlot, efType);
                 db.setTransactionSuccessful();
-            } catch (Exception e) {
-                logBuilder.setException(e);
-                throw e;
             } finally {
-                LogUtils.log(
-                        logBuilder
-                                .setMethodCall(LogUtils.MethodCall.ADD_SIM_ACCOUNTS)
-                                .setResultCount(resultId > -1 ? 1 : 0)
-                                .build());
                 db.endTransaction();
             }
-
             getContext().sendBroadcast(new Intent(SimContacts.ACTION_SIM_ACCOUNTS_CHANGED));
             return response;
         } else if (SimContacts.REMOVE_SIM_ACCOUNT_METHOD.equals(method)) {
-            ContactsPermissions.enforceCallingOrSelfPermission(
-                    getContext(), MANAGE_SIM_ACCOUNTS_PERMISSION);
+            ContactsPermissions.enforceCallingOrSelfPermission(getContext(),
+                    MANAGE_SIM_ACCOUNTS_PERMISSION);
 
             final int simSlot = extras.getInt(SimContacts.KEY_SIM_SLOT_INDEX, -1);
             if (simSlot < 0) {
                 throw new IllegalArgumentException("Sim slot is negative");
             }
-
-            int removedCount = 0;
             final Bundle response = new Bundle();
             final SQLiteDatabase db = mDbHelper.get().getWritableDatabase();
             db.beginTransaction();
             try {
-                removedCount = mDbHelper.get().removeSimAccounts(simSlot);
+                mDbHelper.get().removeSimAccounts(simSlot);
                 scheduleBackgroundTask(BACKGROUND_TASK_UPDATE_ACCOUNTS);
                 db.setTransactionSuccessful();
-            } catch (Exception e) {
-                logBuilder.setException(e);
-                throw e;
             } finally {
-                LogUtils.log(
-                        logBuilder
-                                .setMethodCall(LogUtils.MethodCall.REMOVE_SIM_ACCOUNTS)
-                                .setResultCount(removedCount)
-                                .build());
                 db.endTransaction();
             }
             getContext().sendBroadcast(new Intent(SimContacts.ACTION_SIM_ACCOUNTS_CHANGED));
@@ -2371,22 +2348,11 @@
         } else if (SimContacts.QUERY_SIM_ACCOUNTS_METHOD.equals(method)) {
             ContactsPermissions.enforceCallingOrSelfPermission(getContext(), READ_PERMISSION);
             final Bundle response = new Bundle();
-            int accountsCount = 0;
-            try {
-                final List<SimAccount> simAccounts = mDbHelper.get().getAllSimAccounts();
-                response.putParcelableList(SimContacts.KEY_SIM_ACCOUNTS, simAccounts);
-                accountsCount = simAccounts.size();
-                return response;
-            } catch (Exception e) {
-                logBuilder.setException(e);
-                throw e;
-            } finally {
-                LogUtils.log(
-                        logBuilder
-                                .setMethodCall(LogUtils.MethodCall.GET_SIM_ACCOUNTS)
-                                .setResultCount(accountsCount)
-                                .build());
-            }
+
+            final List<SimAccount> simAccounts = mDbHelper.get().getAllSimAccounts();
+            response.putParcelableList(SimContacts.KEY_SIM_ACCOUNTS, simAccounts);
+
+            return response;
         }
         return null;
     }
diff --git a/src/com/android/providers/contacts/util/LogFields.java b/src/com/android/providers/contacts/util/LogFields.java
index 4d07ca4..f4a60fe 100644
--- a/src/com/android/providers/contacts/util/LogFields.java
+++ b/src/com/android/providers/contacts/util/LogFields.java
@@ -34,8 +34,6 @@
 
     private int resultCount;
 
-    private int methodCall;
-
     public LogFields(int apiType, int uriType, boolean callerIsSyncAdapter, long startNanos) {
         this.apiType = apiType;
         this.uriType = uriType;
@@ -71,10 +69,6 @@
         return resultCount;
     }
 
-    public int getMethodCall() {
-        return methodCall;
-    }
-
     public static final class Builder {
         private int apiType;
         private int uriType;
@@ -83,7 +77,6 @@
         private Exception exception;
         private Uri resultUri;
         private int resultCount;
-        private int methodCall;
 
         private Builder() {
         }
@@ -127,17 +120,11 @@
             return this;
         }
 
-        public Builder setMethodCall(int methodCall) {
-            this.methodCall = methodCall;
-            return this;
-        }
-
         public LogFields build() {
             LogFields logFields = new LogFields(apiType, uriType, callerIsSyncAdapter, startNanos);
             logFields.resultCount = this.resultCount;
             logFields.exception = this.exception;
             logFields.resultUri = this.resultUri;
-            logFields.methodCall = this.methodCall;
             return logFields;
         }
     }
diff --git a/src/com/android/providers/contacts/util/LogUtils.java b/src/com/android/providers/contacts/util/LogUtils.java
index a564a35..9e12325 100644
--- a/src/com/android/providers/contacts/util/LogUtils.java
+++ b/src/com/android/providers/contacts/util/LogUtils.java
@@ -37,7 +37,6 @@
         int INSERT = 2;
         int UPDATE = 3;
         int DELETE = 4;
-        int CALL = 5;
     }
 
     // Keep in sync with ContactsProviderStatus#CallerType in
@@ -47,14 +46,6 @@
         int CALLER_IS_NOT_SYNC_ADAPTER = 2;
     }
 
-    // Keep in sync with ContactsProviderStatus#MethodCall in
-    // frameworks/proto_logging/stats/atoms.proto file.
-    public interface MethodCall {
-        int ADD_SIM_ACCOUNTS = 1;
-        int REMOVE_SIM_ACCOUNTS = 2;
-        int GET_SIM_ACCOUNTS = 3;
-    }
-
     private static final int STATSD_LOG_ATOM_ID = 301;
 
     public static void log(LogFields logFields) {
@@ -66,8 +57,6 @@
                 .writeInt(getResultType(logFields.getException()))
                 .writeInt(logFields.getResultCount())
                 .writeLong(getLatencyMicros(logFields.getStartNanos()))
-                .writeInt(0) // Empty value for TaskType
-                .writeInt(logFields.getMethodCall())
                 .usePooledBuffer()
                 .build());
     }