Search in sources :

Example 31 with MetricsFeatureProvider

use of com.android.settingslib.core.instrumentation.MetricsFeatureProvider in project android_packages_apps_Settings by omnirom.

the class ContextualCardManager method onFinishCardLoading.

@Override
public void onFinishCardLoading(List<ContextualCard> cards) {
    final long loadTime = System.currentTimeMillis() - mStartTime;
    Log.d(TAG, "Total loading time = " + loadTime);
    final List<ContextualCard> cardsToKeep = getCardsToKeep(cards);
    final MetricsFeatureProvider metricsFeatureProvider = FeatureFactory.getFactory(mContext).getMetricsFeatureProvider();
    // navigate back to the homepage, screen rotate or after card dismissal
    if (!mIsFirstLaunch) {
        onContextualCardUpdated(cardsToKeep.stream().collect(groupingBy(ContextualCard::getCardType)));
        metricsFeatureProvider.action(mContext, SettingsEnums.ACTION_CONTEXTUAL_CARD_SHOW, ContextualCardLogUtils.buildCardListLog(cardsToKeep));
        return;
    }
    final long timeoutLimit = getCardLoaderTimeout();
    if (loadTime <= timeoutLimit) {
        onContextualCardUpdated(cards.stream().collect(groupingBy(ContextualCard::getCardType)));
        metricsFeatureProvider.action(mContext, SettingsEnums.ACTION_CONTEXTUAL_CARD_SHOW, ContextualCardLogUtils.buildCardListLog(cards));
    } else {
        // log timeout occurrence
        metricsFeatureProvider.action(SettingsEnums.PAGE_UNKNOWN, SettingsEnums.ACTION_CONTEXTUAL_CARD_LOAD_TIMEOUT, SettingsEnums.SETTINGS_HOMEPAGE, null, /* key */
        (int) loadTime);
    }
    // only log homepage display upon a fresh launch
    final long totalTime = System.currentTimeMillis() - mStartTime;
    metricsFeatureProvider.action(mContext, SettingsEnums.ACTION_CONTEXTUAL_HOME_SHOW, (int) totalTime);
    mIsFirstLaunch = false;
}
Also used : MetricsFeatureProvider(com.android.settingslib.core.instrumentation.MetricsFeatureProvider)

Example 32 with MetricsFeatureProvider

use of com.android.settingslib.core.instrumentation.MetricsFeatureProvider in project android_packages_apps_Settings by omnirom.

the class EligibleCardChecker method call.

@Override
public ContextualCard call() {
    final long startTime = System.currentTimeMillis();
    final MetricsFeatureProvider metricsFeatureProvider = FeatureFactory.getFactory(mContext).getMetricsFeatureProvider();
    ContextualCard result;
    if (isCardEligibleToDisplay(mCard)) {
        metricsFeatureProvider.action(SettingsEnums.PAGE_UNKNOWN, SettingsEnums.ACTION_CONTEXTUAL_CARD_ELIGIBILITY, SettingsEnums.SETTINGS_HOMEPAGE, mCard.getTextSliceUri(), /* key */
        1);
        result = mCard;
    } else {
        metricsFeatureProvider.action(SettingsEnums.PAGE_UNKNOWN, SettingsEnums.ACTION_CONTEXTUAL_CARD_ELIGIBILITY, SettingsEnums.SETTINGS_HOMEPAGE, mCard.getTextSliceUri(), /* key */
        0);
        result = null;
    }
    // Log individual card loading time
    metricsFeatureProvider.action(SettingsEnums.PAGE_UNKNOWN, SettingsEnums.ACTION_CONTEXTUAL_CARD_LOAD, SettingsEnums.SETTINGS_HOMEPAGE, mCard.getTextSliceUri(), /* key */
    (int) (System.currentTimeMillis() - startTime));
    return result;
}
Also used : MetricsFeatureProvider(com.android.settingslib.core.instrumentation.MetricsFeatureProvider)

Example 33 with MetricsFeatureProvider

use of com.android.settingslib.core.instrumentation.MetricsFeatureProvider in project android_packages_apps_Settings by omnirom.

the class ConditionFooterContextualCardRenderer method bindView.

@Override
public void bindView(RecyclerView.ViewHolder holder, ContextualCard card) {
    final MetricsFeatureProvider metricsFeatureProvider = FeatureFactory.getFactory(mContext).getMetricsFeatureProvider();
    holder.itemView.setOnClickListener(v -> {
        metricsFeatureProvider.action(SettingsEnums.PAGE_UNKNOWN, SettingsEnums.ACTION_SETTINGS_CONDITION_EXPAND, SettingsEnums.SETTINGS_HOMEPAGE, null, /* key */
        0);
        final ConditionContextualCardController controller = mControllerRendererPool.getController(mContext, ContextualCard.CardType.CONDITIONAL_FOOTER);
        controller.setIsExpanded(false);
        controller.onConditionsChanged();
    });
}
Also used : MetricsFeatureProvider(com.android.settingslib.core.instrumentation.MetricsFeatureProvider)

Example 34 with MetricsFeatureProvider

use of com.android.settingslib.core.instrumentation.MetricsFeatureProvider in project android_packages_apps_Settings by omnirom.

the class ConditionHeaderContextualCardRenderer method bindView.

@Override
public void bindView(RecyclerView.ViewHolder holder, ContextualCard contextualCard) {
    final ConditionHeaderContextualCard headerCard = (ConditionHeaderContextualCard) contextualCard;
    final ConditionHeaderCardHolder view = (ConditionHeaderCardHolder) holder;
    final MetricsFeatureProvider metricsFeatureProvider = FeatureFactory.getFactory(mContext).getMetricsFeatureProvider();
    view.icons.removeAllViews();
    headerCard.getConditionalCards().forEach(card -> {
        final ImageView icon = (ImageView) LayoutInflater.from(mContext).inflate(R.layout.conditional_card_header_icon, view.icons, false);
        icon.setImageDrawable(card.getIconDrawable());
        view.icons.addView(icon);
    });
    view.itemView.setOnClickListener(v -> {
        metricsFeatureProvider.action(SettingsEnums.PAGE_UNKNOWN, SettingsEnums.ACTION_SETTINGS_CONDITION_EXPAND, SettingsEnums.SETTINGS_HOMEPAGE, null, /* key */
        1);
        final ConditionContextualCardController controller = mControllerRendererPool.getController(mContext, ContextualCard.CardType.CONDITIONAL_HEADER);
        controller.setIsExpanded(true);
        controller.onConditionsChanged();
    });
}
Also used : MetricsFeatureProvider(com.android.settingslib.core.instrumentation.MetricsFeatureProvider) ImageView(android.widget.ImageView)

Example 35 with MetricsFeatureProvider

use of com.android.settingslib.core.instrumentation.MetricsFeatureProvider in project android_packages_apps_Settings by omnirom.

the class StorageCategoryFragment method onPreferenceClick.

@Override
public boolean onPreferenceClick(Preference preference) {
    if (preference == mFreeUpSpacePreference) {
        final Context context = getContext();
        final MetricsFeatureProvider metricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
        metricsFeatureProvider.logClickedPreference(preference, getMetricsCategory());
        metricsFeatureProvider.action(context, SettingsEnums.STORAGE_FREE_UP_SPACE_NOW);
        final Intent intent = new Intent(StorageManager.ACTION_MANAGE_STORAGE);
        context.startActivityAsUser(intent, new UserHandle(mUserId));
        return true;
    }
    return false;
}
Also used : Context(android.content.Context) MetricsFeatureProvider(com.android.settingslib.core.instrumentation.MetricsFeatureProvider) UserHandle(android.os.UserHandle) Intent(android.content.Intent)

Aggregations

MetricsFeatureProvider (com.android.settingslib.core.instrumentation.MetricsFeatureProvider)41 VisibleForTesting (androidx.annotation.VisibleForTesting)12 Context (android.content.Context)6 Test (org.junit.Test)4 PendingIntent (android.app.PendingIntent)3 SliceMetadata (androidx.slice.SliceMetadata)3 SliceAction (androidx.slice.core.SliceAction)3 JobWorkItem (android.app.job.JobWorkItem)2 ContentResolver (android.content.ContentResolver)2 Intent (android.content.Intent)2 UserHandle (android.os.UserHandle)2 UserManager (android.os.UserManager)2 ImageView (android.widget.ImageView)2 BatteryUtils (com.android.settings.fuelgauge.BatteryUtils)2 PowerUsageFeatureProvider (com.android.settings.fuelgauge.PowerUsageFeatureProvider)2 ContextualCardFeatureProvider (com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider)2 ArrayList (java.util.ArrayList)2 CardDatabaseHelper (com.android.settings.homepage.contextualcards.CardDatabaseHelper)1 PowerAllowlistBackend (com.android.settingslib.fuelgauge.PowerAllowlistBackend)1 PowerWhitelistBackend (com.android.settingslib.fuelgauge.PowerWhitelistBackend)1