OSDN Git Service

Add logging when entity header buttons are clicked
authorFan Zhang <zhfan@google.com>
Mon, 19 Jun 2017 19:31:30 +0000 (12:31 -0700)
committerFan Zhang <zhfan@google.com>
Tue, 20 Jun 2017 16:53:14 +0000 (16:53 +0000)
Change-Id: I673e5b4a6c5f8736bbec72e259a82acb3f514828
Fix: 62709062
Test: make RunSettingsRoboTests

res/values/strings.xml
src/com/android/settings/widget/EntityHeaderController.java
tests/robotests/src/com/android/settings/widget/EntityHeaderControllerTest.java

index 78a30ca..7771ac0 100644 (file)
     <string name="help_url_audio_accessory_not_supported" translatable="false"></string>
 
     <!-- Title label for new device suggestion, which is displayed in Settings homepage [CHAR LIMIT=100] -->
-    <string name="new_device_suggestion_title">What's new and exciting?</string>
+    <string name="new_device_suggestion_title">What\'s new and exciting?</string>
 
     <!-- Summary label for new device suggestion, which is displayed in Settings homepage [CHAR LIMIT=100] -->
     <string name="new_device_suggestion_summary">Check out the top 5 features</string>
index c9e0805..8f64920 100644 (file)
@@ -52,6 +52,10 @@ import com.android.settingslib.core.lifecycle.Lifecycle;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent
+        .ACTION_OPEN_APP_NOTIFICATION_SETTING;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.ACTION_OPEN_APP_SETTING;
+
 public class EntityHeaderController {
 
     @IntDef({ActionType.ACTION_NONE,
@@ -310,6 +314,9 @@ public class EntityHeaderController {
                     button.setOnClickListener(new View.OnClickListener() {
                         @Override
                         public void onClick(View v) {
+                            FeatureFactory.getFactory(mAppContext).getMetricsFeatureProvider()
+                                    .actionWithSource(mAppContext, mMetricsCategory,
+                                            ACTION_OPEN_APP_NOTIFICATION_SETTING);
                             mFragment.startActivity(mAppNotifPrefIntent);
                         }
                     });
@@ -327,6 +334,9 @@ public class EntityHeaderController {
                 button.setOnClickListener(new View.OnClickListener() {
                     @Override
                     public void onClick(View v) {
+                        FeatureFactory.getFactory(mAppContext).getMetricsFeatureProvider()
+                                .actionWithSource(mAppContext, mMetricsCategory,
+                                        ACTION_OPEN_APP_SETTING);
                         mFragment.startActivity(intent);
                     }
                 });
index 49d5e7d..4294dcf 100644 (file)
@@ -32,11 +32,12 @@ import android.view.LayoutInflater;
 import android.view.View;
 import android.widget.TextView;
 
+import com.android.internal.logging.nano.MetricsProto;
 import com.android.settings.R;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settings.TestConfig;
 import com.android.settings.applications.LayoutPreference;
 import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -70,11 +71,12 @@ public class EntityHeaderControllerTest {
     private LayoutInflater mLayoutInflater;
     private PackageInfo mInfo;
     private EntityHeaderController mController;
+    private FakeFeatureFactory mFeatureFactory;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        FakeFeatureFactory.setupForTest(mContext);
+        mFeatureFactory = FakeFeatureFactory.setupForTest(mContext);
         mShadowContext = RuntimeEnvironment.application;
         when(mActivity.getApplicationContext()).thenReturn(mShadowContext);
         when(mContext.getApplicationContext()).thenReturn(mContext);
@@ -154,6 +156,9 @@ public class EntityHeaderControllerTest {
         } catch (Exception e) {
             // Ignore exception because the launching intent is fake.
         }
+        verify(mFeatureFactory.metricsFeatureProvider).actionWithSource(mContext,
+                MetricsProto.MetricsEvent.VIEW_UNKNOWN,
+                MetricsProto.MetricsEvent.ACTION_OPEN_APP_SETTING);
         verify(mFragment).startActivity(any(Intent.class));
     }