From ae2a00fc5afeabe6bc0a332450087ee278159de6 Mon Sep 17 00:00:00 2001 From: Fan Zhang Date: Wed, 24 Aug 2016 17:03:11 -0700 Subject: [PATCH] Log support disclaimer dialog visibility change. Bug: 30681529 Test: RunSettingsRoboTests Added InstrumentedDialogFragment, and use it to observe visiblity changes in support disclaimer fragment. Change-Id: I9f851c4769f8d59e791986fffc145d014ffde3a3 --- .../InstrumentedDialogFragment.java | 27 +++++++++++++++++++ .../SupportDisclaimerDialogFragment.java | 12 ++++++--- 2 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 src/com/android/settings/core/instrumentation/InstrumentedDialogFragment.java diff --git a/src/com/android/settings/core/instrumentation/InstrumentedDialogFragment.java b/src/com/android/settings/core/instrumentation/InstrumentedDialogFragment.java new file mode 100644 index 00000000000..6f970681cf4 --- /dev/null +++ b/src/com/android/settings/core/instrumentation/InstrumentedDialogFragment.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.settings.core.instrumentation; + +import com.android.settings.core.lifecycle.ObservableDialogFragment; + +public abstract class InstrumentedDialogFragment extends ObservableDialogFragment + implements Instrumentable { + + public InstrumentedDialogFragment() { + mLifecycle.addObserver(new VisibilityLoggerMixin(getMetricsCategory())); + } + +} diff --git a/src/com/android/settings/support/SupportDisclaimerDialogFragment.java b/src/com/android/settings/support/SupportDisclaimerDialogFragment.java index db74f0fb979..dc2b98376b8 100644 --- a/src/com/android/settings/support/SupportDisclaimerDialogFragment.java +++ b/src/com/android/settings/support/SupportDisclaimerDialogFragment.java @@ -35,14 +35,15 @@ import android.widget.TextView; import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.MetricsProto; import com.android.settings.R; +import com.android.settings.core.instrumentation.InstrumentedDialogFragment; import com.android.settings.overlay.FeatureFactory; import com.android.settings.overlay.SupportFeatureProvider; /** * {@link DialogFragment} for support disclaimer. */ -public final class SupportDisclaimerDialogFragment extends DialogFragment implements - DialogInterface.OnClickListener { +public final class SupportDisclaimerDialogFragment extends InstrumentedDialogFragment + implements DialogInterface.OnClickListener { public static final String TAG = "SupportDisclaimerDialog"; private static final String EXTRA_TYPE = "extra_type"; @@ -90,7 +91,7 @@ public final class SupportDisclaimerDialogFragment extends DialogFragment implem final Bundle bundle = getArguments(); MetricsLogger.action(activity, MetricsProto.MetricsEvent.ACTION_SUPPORT_DISCLAIMER_OK); supportFeatureProvider.startSupport(getActivity(), - (Account) bundle.getParcelable(EXTRA_ACCOUNT), bundle.getInt(EXTRA_TYPE)); + bundle.getParcelable(EXTRA_ACCOUNT), bundle.getInt(EXTRA_TYPE)); } @Override @@ -115,6 +116,11 @@ public final class SupportDisclaimerDialogFragment extends DialogFragment implem } } + @Override + public int getMetricsCategory() { + return MetricsProto.MetricsEvent.DIALOG_SUPPORT_DISCLAIMER; + } + /** * A {@link URLSpan} that doesn't decorate the link with underline. */