OSDN Git Service

Update panel logging to include all hide page cases
authorlindatseng <lindatseng@google.com>
Fri, 12 Apr 2019 17:42:09 +0000 (10:42 -0700)
committerlindatseng <lindatseng@google.com>
Fri, 12 Apr 2019 18:33:41 +0000 (11:33 -0700)
The old logging only include see_more, done, and clicked_out when hiding
the panel page.  We were missing many cases that user might use back
button, app switch button to close the page.

Update the hide page keys to change the clicked_out to others to
include all the other cases which hide the page.

Test: Manual verification
Test: atest PanelFragmentTest SettingsPanelActivityTest
Fixes: 130169553
Change-Id: Icede9a8dcb84565cba183963c9fb554507631c98

src/com/android/settings/panel/PanelFragment.java
src/com/android/settings/panel/PanelLoggingContract.java
src/com/android/settings/panel/SettingsPanelActivity.java
tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java
tests/robotests/src/com/android/settings/panel/SettingsPanelActivityTest.java

index f1391dc..7f71925 100644 (file)
@@ -19,6 +19,7 @@ package com.android.settings.panel;
 import android.app.settings.SettingsEnums;
 import android.content.Context;
 import android.os.Bundle;
+import android.text.TextUtils;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
@@ -50,6 +51,7 @@ public class PanelFragment extends Fragment {
 
     private PanelContent mPanel;
     private MetricsFeatureProvider mMetricsProvider;
+    private String mPanelClosedKey;
 
     @VisibleForTesting
     PanelSlicesAdapter mAdapter;
@@ -111,15 +113,26 @@ public class PanelFragment extends Fragment {
         return view;
     }
 
+    @Override
+    public void onDestroyView() {
+        super.onDestroyView();
+
+        if (TextUtils.isEmpty(mPanelClosedKey)) {
+            mPanelClosedKey = PanelClosedKeys.KEY_OTHERS;
+        }
+
+        mMetricsProvider.action(
+                0 /* attribution */,
+                SettingsEnums.PAGE_HIDE,
+                mPanel.getMetricsCategory(),
+                mPanelClosedKey,
+                0 /* value */);
+    }
+
     @VisibleForTesting
     View.OnClickListener getSeeMoreListener() {
         return (v) -> {
-            mMetricsProvider.action(
-                    0 /* attribution */,
-                    SettingsEnums.PAGE_HIDE ,
-                    mPanel.getMetricsCategory(),
-                    PanelClosedKeys.KEY_SEE_MORE,
-                    0 /* value */);
+            mPanelClosedKey = PanelClosedKeys.KEY_SEE_MORE;
             final FragmentActivity activity = getActivity();
             activity.startActivityForResult(mPanel.getSeeMoreIntent(), 0);
             activity.finish();
@@ -129,12 +142,7 @@ public class PanelFragment extends Fragment {
     @VisibleForTesting
     View.OnClickListener getCloseListener() {
         return (v) -> {
-            mMetricsProvider.action(
-                    0 /* attribution */,
-                    SettingsEnums.PAGE_HIDE,
-                    mPanel.getMetricsCategory(),
-                    PanelClosedKeys.KEY_DONE,
-                    0 /* value */);
+            mPanelClosedKey = PanelClosedKeys.KEY_DONE;
             getActivity().finish();
         };
     }
index e149186..e6e3012 100644 (file)
@@ -39,8 +39,9 @@ public class PanelLoggingContract {
         String KEY_DONE = "done";
 
         /**
-         * The user clicked outside the dialog, closing the Panel.
+         * The user closed the panel by other ways, for example: clicked outside of dialog, tapping
+         * on back button, etc.
          */
-        String KEY_CLICKED_OUT = "clicked_out";
+        String KEY_OTHERS = "others";
     }
 }
index 8aee382..eabd715 100644 (file)
@@ -97,21 +97,4 @@ public class SettingsPanelActivity extends FragmentActivity {
             fragmentManager.beginTransaction().add(R.id.main_content, panelFragment).commit();
         }
     }
-
-    @Override
-    public boolean onTouchEvent(MotionEvent event) {
-        if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
-            final PanelContent panelContent = FeatureFactory.getFactory(this)
-                    .getPanelFeatureProvider()
-                    .getPanel(this, getIntent().getAction(), null /* Media Package Name */);
-            FeatureFactory.getFactory(this)
-                    .getMetricsFeatureProvider()
-                    .action(0 /* attribution */,
-                            SettingsEnums.PAGE_HIDE,
-                            panelContent.getMetricsCategory(),
-                            PanelClosedKeys.KEY_CLICKED_OUT,
-                            0 /* value */);
-        }
-        return super.onTouchEvent(event);
-    }
 }
index be8d8bc..d606ac7 100644 (file)
@@ -100,6 +100,16 @@ public class PanelFragmentTest {
     }
 
     @Test
+    public void onDestroy_logCloseEvent() {
+        mPanelFragment.onDestroy();
+        verify(mFakeFeatureFactory.metricsFeatureProvider).action(
+                0,
+                SettingsEnums.PAGE_VISIBLE,
+                mFakePanelContent.getMetricsCategory(),
+                any(String.class),
+                0);    }
+
+    @Test
     public void panelSeeMoreClick_logsCloseEvent() {
         final View.OnClickListener listener = mPanelFragment.getSeeMoreListener();
 
index 1d5c3c2..fa15aa0 100644 (file)
@@ -99,7 +99,7 @@ public class SettingsPanelActivityTest {
                 0,
                 SettingsEnums.PAGE_HIDE,
                 SettingsEnums.TESTING,
-                PanelLoggingContract.PanelClosedKeys.KEY_CLICKED_OUT,
+                PanelLoggingContract.PanelClosedKeys.KEY_OTHERS,
                 0
         );
     }