From 69d632664ec7cc60d5f9037ae306c97b4abfbb6f Mon Sep 17 00:00:00 2001
From: Tad <tad@spotco.us>
Date: Tue, 18 Dec 2018 23:35:40 -0500
Subject: [PATCH] Remove CMStats

Change-Id: I874c5b7eb571a0a2ac551dedd0da44eaa79af472
---
 AndroidManifest.xml                                |  2 --
 src/com/android/dialer/CallDetailActivity.java     |  7 -----
 src/com/android/dialer/CallDetailHeader.java       |  4 ---
 src/com/android/dialer/DialtactsActivity.java      | 33 ----------------------
 src/com/android/dialer/calllog/CallLogAdapter.java |  4 ---
 .../android/dialer/dialpad/DialpadFragment.java    |  3 --
 .../android/dialer/list/AllContactsActivity.java   |  4 ---
 src/com/android/dialer/list/SearchFragment.java    |  4 ---
 8 files changed, 61 deletions(-)

diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 0a36776..80e9939 100755
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -52,8 +52,6 @@
     <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
     <!-- allow brodcasting across all users -->
     <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" />
-    <!-- send analytic events through internal package -->
-    <uses-permission android:name="com.cyngn.cmstats.SEND_ANALYTICS" />
     <!-- This tells the activity manager to not delay any of our activity
      start requests, even if they happen immediately after the user
      presses home. -->
diff --git a/src/com/android/dialer/CallDetailActivity.java b/src/com/android/dialer/CallDetailActivity.java
index 711b616..89d723f 100755
--- a/src/com/android/dialer/CallDetailActivity.java
+++ b/src/com/android/dialer/CallDetailActivity.java
@@ -60,7 +60,6 @@ import com.android.dialer.calllog.ContactInfo;
 import com.android.dialer.calllog.ContactInfoHelper;
 import com.android.dialer.calllog.PhoneNumberDisplayHelper;
 import com.android.dialer.calllog.PhoneNumberUtilsWrapper;
-import com.android.dialer.cmstats.DialerStats;
 import com.android.dialer.util.AsyncTaskExecutor;
 import com.android.dialer.util.AsyncTaskExecutors;
 import com.android.dialer.util.CallRecordingPlayer;
@@ -453,12 +452,6 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware
                         isBusiness ? ContactPhotoManager.TYPE_BUSINESS :
                         ContactPhotoManager.TYPE_DEFAULT;
 
-                // Track percentage of time that contact photo is present on details page
-                String imageFound = firstDetails.photoUri != null ?
-                        "details_image_found" : "details_image_not_found";
-                DialerStats.sendEvent(CallDetailActivity.this,
-                            DialerStats.Categories.DETAILS_CONTACT_IMAGE, imageFound);
-
                 mCallDetailHeader.loadContactPhotos(firstDetails.photoUri, displayNameForDefaultImage, lookupKey, contactType);
 
                 findViewById(R.id.call_detail).setVisibility(View.VISIBLE);
diff --git a/src/com/android/dialer/CallDetailHeader.java b/src/com/android/dialer/CallDetailHeader.java
index 1247b6d..6b36f1a 100644
--- a/src/com/android/dialer/CallDetailHeader.java
+++ b/src/com/android/dialer/CallDetailHeader.java
@@ -56,7 +56,6 @@ import com.android.dialer.calllog.PhoneNumberDisplayHelper;
 import com.android.dialer.calllog.PhoneNumberUtilsWrapper;
 
 import android.provider.ContactsContract.DisplayNameSources;
-import com.android.dialer.cmstats.DialerStats;
 import com.android.internal.telephony.MSimConstants;
 
 public class CallDetailHeader {
@@ -110,9 +109,6 @@ public class CallDetailHeader {
                 return;
             }
             Intent intent = ((ViewEntry) view.getTag()).primaryIntent;
-            if (TextUtils.equals(intent.getAction(), Intent.ACTION_CALL_PRIVILEGED)) {
-                DialerStats.sendEvent(mActivity, DialerStats.Categories.INITIATE_CALL, "call_from_detail_page");
-            }
             mActivity.startActivity(intent);
         }
     };
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java
index a26bc17..49c2427 100644
--- a/src/com/android/dialer/DialtactsActivity.java
+++ b/src/com/android/dialer/DialtactsActivity.java
@@ -71,7 +71,6 @@ import com.android.contacts.common.dialog.ClearFrequentsDialog;
 import com.android.contacts.common.interactions.ImportExportDialogFragment;
 import com.android.contacts.common.list.OnPhoneNumberPickerActionListener;
 import com.android.dialer.calllog.CallLogActivity;
-import com.android.dialer.cmstats.DialerStats;
 import com.android.dialer.database.DialerDatabaseHelper;
 import com.android.dialer.dialpad.DialpadFragment;
 import com.android.dialer.dialpad.SmartDialNameMatcher;
@@ -285,14 +284,6 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
             new OnPhoneNumberPickerActionListener() {
                 @Override
                 public void onPickPhoneNumberAction(Uri dataUri) {
-                    if (mInDialpadSearch) {
-                        DialerStats.sendEvent(DialtactsActivity.this,
-                                DialerStats.Categories.INITIATE_CALL, "call_from_dialpad_search");
-                    } else if (mInRegularSearch) {
-                        DialerStats.sendEvent(DialtactsActivity.this,
-                                DialerStats.Categories.INITIATE_CALL, "call_from_regular_search");
-                    }
-
                     // Specify call-origin so that users will see the previous tab instead of
                     // CallLog screen (search UI will be automatically exited).
                     PhoneNumberInteraction.startInteractionForPhoneCall(
@@ -392,8 +383,6 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
 
         setContentView(R.layout.dialtacts_activity);
 
-        DialerStats.sendEvent(this, DialerStats.Categories.APP_LAUNCH, DialtactsActivity.class.getSimpleName());
-
         // Add the favorites fragment, and the dialpad fragment, but only if savedInstanceState
         // is null. Otherwise the fragment manager takes care of recreating these fragments.
         if (savedInstanceState == null) {
@@ -594,7 +583,6 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
                 }
                 break;
             case R.id.voice_search_button:
-                DialerStats.sendEvent(DialtactsActivity.this, DialerStats.Categories.BUTTON_EVENT, "voice_clicked");
                 try {
                     startActivityForResult(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH),
                             ACTIVITY_REQUEST_CODE_VOICE_SEARCH);
@@ -646,7 +634,6 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
     }
 
     private void showDialpadFragment(boolean animate) {
-        DialerStats.sendEvent(DialtactsActivity.this, DialerStats.Categories.BUTTON_EVENT, "dialer_shown");
         mDialpadFragment.setAdjustTranslationForAnimation(animate);
         final FragmentTransaction ft = getFragmentManager().beginTransaction();
         if (animate) {
@@ -692,7 +679,6 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
         mSearchView = (EditText) findViewById(R.id.search_view);
         mSearchView.addTextChangedListener(mPhoneSearchQueryTextListener);
         mSearchView.setHint(getString(R.string.dialer_hint_find_contact));
-        setupEvent(mSearchViewContainer, R.id.search_view, DialerStats.Categories.BUTTON_EVENT, "search_clicked");
 
         prepareVoiceSearchButton();
     }
@@ -948,14 +934,12 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
             new PhoneFavoriteFragment.Listener() {
         @Override
         public void onContactSelected(Uri contactUri) {
-            DialerStats.sendEvent(DialtactsActivity.this, DialerStats.Categories.INITIATE_CALL, "call_from_favorite_tile");
             PhoneNumberInteraction.startInteractionForPhoneCall(
                         DialtactsActivity.this, contactUri, getCallOrigin());
         }
 
         @Override
         public void onCallNumberDirectly(String phoneNumber) {
-            DialerStats.sendEvent(DialtactsActivity.this, DialerStats.Categories.INITIATE_CALL, "call_from_favorite_tile");
             Intent intent = CallUtil.getCallIntent(phoneNumber, getCallOrigin());
             startActivity(intent);
         }
@@ -1173,7 +1157,6 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
     }
 
     public void allContactsClick(View v) {
-        DialerStats.sendEvent(DialtactsActivity.this, DialerStats.Categories.BUTTON_EVENT, "contacts_clicked");
         onShowAllContacts();
     }
 
@@ -1245,20 +1228,4 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
         return getResources().getBoolean(R.bool.config_show_onscreen_dial_button);
     }
 
-    /**
-     * Add analytics event for view
-     * @param v
-     * @param buttonId
-     * @param category
-     * @param action
-     */
-    private void setupEvent(View v, int buttonId, final String category, final String action) {
-        final View pageviewButton = v.findViewById(buttonId);
-        pageviewButton.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                DialerStats.sendEvent(DialtactsActivity.this, category, action);
-            }
-        });
-    }
 }
diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java
index 26664fd..1571d22 100755
--- a/src/com/android/dialer/calllog/CallLogAdapter.java
+++ b/src/com/android/dialer/calllog/CallLogAdapter.java
@@ -44,7 +44,6 @@ import com.android.dialer.PhoneCallDetails;
 import com.android.dialer.PhoneCallDetailsHelper;
 import com.android.dialer.R;
 import com.android.dialer.calllog.CallLogAdapterHelper.NumberWithCountryIso;
-import com.android.dialer.cmstats.DialerStats;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Objects;
 
@@ -123,9 +122,6 @@ public class CallLogAdapter extends GroupingListAdapter
             final Intent intent = intentProvider.getIntent(mContext);
             // See IntentProvider.getCallDetailIntentProvider() for why this may be null.
             if (intent != null) {
-                if (mStatsLabel != null) {
-                    DialerStats.sendEvent(mContext, DialerStats.Categories.INITIATE_CALL, mStatsLabel);
-                }
                 mContext.startActivity(intent);
             }
         }
diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java
index 77cbb08..6edf4d2 100644
--- a/src/com/android/dialer/dialpad/DialpadFragment.java
+++ b/src/com/android/dialer/dialpad/DialpadFragment.java
@@ -84,7 +84,6 @@ import com.android.dialer.NeededForReflection;
 import com.android.dialer.DialtactsActivity;
 import com.android.dialer.R;
 import com.android.dialer.SpecialCharSequenceMgr;
-import com.android.dialer.cmstats.DialerStats;
 import com.android.dialer.SpeedDialUtils;
 import com.android.dialer.SpeedDialListActivity;
 import com.android.dialer.database.DialerDatabaseHelper;
@@ -1285,8 +1284,6 @@ public class DialpadFragment extends Fragment
         if (isDigitsEmpty()) { // No number entered.
             handleDialButtonClickWithEmptyDigits();
         } else {
-            DialerStats.sendEvent(getActivity(), DialerStats.Categories.INITIATE_CALL, "call_from_dialpad_direct");
-
             final String number = mDigits.getText().toString();
 
             // "persist.radio.otaspdial" is a temporary hack needed for one carrier's automated
diff --git a/src/com/android/dialer/list/AllContactsActivity.java b/src/com/android/dialer/list/AllContactsActivity.java
index 5773123..66a891b 100644
--- a/src/com/android/dialer/list/AllContactsActivity.java
+++ b/src/com/android/dialer/list/AllContactsActivity.java
@@ -32,7 +32,6 @@ import com.android.contacts.common.activity.TransactionSafeActivity;
 import com.android.contacts.common.list.OnPhoneNumberPickerActionListener;
 import com.android.dialer.DialtactsActivity;
 import com.android.dialer.R;
-import com.android.dialer.cmstats.DialerStats;
 import com.android.dialer.interactions.PhoneNumberInteraction;
 
 public class AllContactsActivity extends TransactionSafeActivity {
@@ -45,9 +44,6 @@ public class AllContactsActivity extends TransactionSafeActivity {
             new OnPhoneNumberPickerActionListener() {
                 @Override
                 public void onPickPhoneNumberAction(Uri dataUri) {
-                    DialerStats.sendEvent(AllContactsActivity.this,
-                            DialerStats.Categories.INITIATE_CALL, "call_from_all_contacts");
-
                     // Specify call-origin so that users will see the previous tab instead of
                     // CallLog screen (search UI will be automatically exited).
                     PhoneNumberInteraction.startInteractionForPhoneCall(
diff --git a/src/com/android/dialer/list/SearchFragment.java b/src/com/android/dialer/list/SearchFragment.java
index d7b0ef3..36871dc 100644
--- a/src/com/android/dialer/list/SearchFragment.java
+++ b/src/com/android/dialer/list/SearchFragment.java
@@ -30,7 +30,6 @@ import com.android.contacts.common.list.OnPhoneNumberPickerActionListener;
 import com.android.contacts.common.list.PhoneNumberPickerFragment;
 import com.android.dialer.DialtactsActivity;
 import com.android.dialer.R;
-import com.android.dialer.cmstats.DialerStats;
 import com.android.dialer.dialpad.DialpadFragment;
 import com.android.dialer.list.OnListFragmentScrolledListener;
 
@@ -104,15 +103,12 @@ public class SearchFragment extends PhoneNumberPickerFragment {
                     (DirectoryPartition)adapter.getPartition(adapter.getPartitionForPosition(position));
             if (TextUtils.equals(partition.getLabel(),
                     getResources().getString(R.string.nearby_places))) {
-                DialerStats.sendEvent(getContext(), "lookup", "nearby_lookup");
             }
             super.onItemClick(position, id);
         } else if (shortcutType == DialerPhoneNumberListAdapter.SHORTCUT_DIRECT_CALL) {
             final OnPhoneNumberPickerActionListener listener =
                     getOnPhoneNumberPickerListener();
             if (listener != null) {
-                DialerStats.sendEvent(getContext(),
-                        DialerStats.Categories.INITIATE_CALL, "call_from_direct_dial_search");
                 listener.onCallNumberDirectly(getQueryString());
             }
         } else if (shortcutType == DialerPhoneNumberListAdapter.SHORTCUT_ADD_NUMBER_TO_CONTACTS) {
-- 
1.8.3.1

