Home | History | Annotate | Download | only in metrics
      1 /*
      2  * Copyright (C) 2018 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License
     15  */
     16 
     17 package com.android.dialer.metrics;
     18 
     19 import android.app.Application;
     20 import android.support.annotation.Nullable;
     21 
     22 /** Logs metrics. */
     23 public interface Metrics {
     24 
     25   String APPLICATION_ON_CREATE_EVENT_NAME = "Application.onCreate";
     26   String DIALTACTS_ON_CREATE_EVENT_NAME = "GoogleDialtactsActivity.onCreate";
     27   String MAIN_ACTIVITY_ON_CREATE_EVENT_NAME = "GoogleMainActivity.onCreate";
     28   String ON_CALL_ADDED_TO_ON_INCALL_UI_SHOWN_INCOMING =
     29       "CallList.onCallAdded_To_InCallActivity.onCreate_Incoming";
     30   String ON_CALL_ADDED_TO_ON_INCALL_UI_SHOWN_OUTGOING =
     31       "CallList.onCallAdded_To_InCallActivity.onCreate_Outgoing";
     32   String DIALTACTS_ON_RESUME_MEMORY_EVENT_NAME = "GoogleDialtactsActivity.onResume";
     33   String OLD_MAIN_ACTIVITY_PEER_ON_RESUME_MEMORY_EVENT_NAME = "OldMainActivityPeer.onResume";
     34   String INCALL_ACTIVITY_ON_RESUME_MEMORY_EVENT_NAME = "IncallActivity.OnResume";
     35   String INCALL_ACTIVITY_ON_STOP_MEMORY_EVENT_NAME = "IncallActivity.OnStop";
     36   String OLD_CALL_LOG_JANK_EVENT_NAME = "OldCallLog.Jank";
     37   String NEW_CALL_LOG_JANK_EVENT_NAME = "NewCallLog.Jank";
     38 
     39   // Events related to refreshing the annotated call log.
     40   String NEW_CALL_LOG_COALESCE = "NewCallLog.Coalesce";
     41   String ANNOTATED_CALL_LOG_NOT_DIRTY = "RefreshAnnotatedCallLogReceiver.NotDirty";
     42   String ANNOTATED_CALL_LOG_CHANGES_NEEDED = "RefreshAnnotatedCallLogReceiver.ChangesNeeded";
     43   String ANNOTATED_LOG_NO_CHANGES_NEEDED = "RefreshAnnotatedCallLogReceiver.NoChangesNeeded";
     44   String ANNOTATED_CALL_LOG_FORCE_REFRESH_CHANGES_NEEDED =
     45       "RefreshAnnotatedCallLogReceiver.ForceRefreshChangesNeeded";
     46   String NEW_CALL_LOG_FORCE_REFRESH_NO_CHANGES_NEEDED =
     47       "RefreshAnnotatedCallLogReceiver.ForceRefreshNoChangesNeeded";
     48 
     49   String INITIAL_FILL_EVENT_NAME = "RefreshAnnotatedCallLog.Initial.Fill";
     50   String INITIAL_ON_SUCCESSFUL_FILL_EVENT_NAME = "RefreshAnnotatedCallLog.Initial.OnSuccessfulFill";
     51   String INITIAL_APPLY_MUTATIONS_EVENT_NAME = "RefreshAnnotatedCallLog.Initial.ApplyMutations";
     52 
     53   String IS_DIRTY_EVENT_NAME = "RefreshAnnotatedCallLog.IsDirty";
     54   String FILL_EVENT_NAME = "RefreshAnnotatedCallLog.Fill";
     55   String ON_SUCCESSFUL_FILL_EVENT_NAME = "RefreshAnnotatedCallLog.OnSuccessfulFill";
     56   String APPLY_MUTATIONS_EVENT_NAME = "RefreshAnnotatedCallLog.ApplyMutations";
     57 
     58   // These templates are prefixed with a CallLogDataSource or PhoneLookup simple class name.
     59   String INITIAL_FILL_TEMPLATE = "%s.Initial.Fill";
     60   String INITIAL_GET_MOST_RECENT_INFO_TEMPLATE = "%s.Initial.GetMostRecentInfo";
     61   String INITIAL_ON_SUCCESSFUL_FILL_TEMPLATE = "%s.Initial.OnSuccessfulFill";
     62   String INITIAL_ON_SUCCESSFUL_BULK_UPDATE_TEMPLATE = "%s.Initial.OnSuccessfulBulkUpdate";
     63 
     64   String IS_DIRTY_TEMPLATE = "%s.IsDirty";
     65   String FILL_TEMPLATE = "%s.Fill";
     66   String GET_MOST_RECENT_INFO_TEMPLATE = "%s.GetMostRecentInfo";
     67   String ON_SUCCESSFUL_FILL_TEMPLATE = "%s.OnSuccessfulFill";
     68   String ON_SUCCESSFUL_BULK_UPDATE_TEMPLATE = "%s.OnSuccessfulBulkUpdate";
     69   String LOOKUP_TEMPLATE = "%s.Lookup";
     70 
     71   /** Start a timer. */
     72   void startTimer(String timerEventName);
     73 
     74   /**
     75    * Starts a timer for which the name is not yet known.
     76    *
     77    * @return opaque identifier for the event which should be provided back to {@link
     78    *     #stopUnnamedTimer(int, String)} to stop the timer. Null if the timer cannot be started, for
     79    *     example because the user is locked.
     80    */
     81   @Nullable
     82   Integer startUnnamedTimer();
     83 
     84   /**
     85    * Stop a timer which was started with {@link #startUnnamedTimer()}.
     86    *
     87    * @param timerId the value returned in the corresponding call to {@link #startUnnamedTimer()}
     88    */
     89   void stopUnnamedTimer(int timerId, String timerEventName);
     90 
     91   /** Stop a timer. */
     92   void stopTimer(String timerEventName);
     93 
     94   /** Start a jank recorder. */
     95   void startJankRecorder(String eventName);
     96 
     97   /** Stop a jank recorder. */
     98   void stopJankRecorder(String eventName);
     99 
    100   /** Record memory. */
    101   void recordMemory(String memoryEventName);
    102 
    103   /** Initiazer for metrics. */
    104   interface Initializer {
    105     /** Initialize metrics for the application . */
    106     void initialize(Application application);
    107   }
    108 }
    109