Search in sources :

Example 1 with MetricsFeatureProvider

use of com.android.settingslib.core.instrumentation.MetricsFeatureProvider in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DashboardFragmentTest method onExpandButtonClick_shouldLogAdvancedButtonExpand.

@Test
public void onExpandButtonClick_shouldLogAdvancedButtonExpand() {
    final MetricsFeatureProvider metricsFeatureProvider = mFakeFeatureFactory.getMetricsFeatureProvider();
    mTestFragment.onExpandButtonClick();
    verify(metricsFeatureProvider).action(SettingsEnums.PAGE_UNKNOWN, MetricsEvent.ACTION_SETTINGS_ADVANCED_BUTTON_EXPAND, DASHBOARD_CONTAINER, null, 0);
}
Also used : MetricsFeatureProvider(com.android.settingslib.core.instrumentation.MetricsFeatureProvider) Test(org.junit.Test)

Example 2 with MetricsFeatureProvider

use of com.android.settingslib.core.instrumentation.MetricsFeatureProvider in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class MetricsFeatureProviderTest method getFactory_shouldReuseCachedInstance.

@Test
public void getFactory_shouldReuseCachedInstance() {
    MetricsFeatureProvider feature1 = FeatureFactory.getFactory(mContext).getMetricsFeatureProvider();
    MetricsFeatureProvider feature2 = FeatureFactory.getFactory(mContext).getMetricsFeatureProvider();
    assertThat(feature1).isSameAs(feature2);
}
Also used : MetricsFeatureProvider(com.android.settingslib.core.instrumentation.MetricsFeatureProvider) Test(org.junit.Test)

Example 3 with MetricsFeatureProvider

use of com.android.settingslib.core.instrumentation.MetricsFeatureProvider in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class UsageAccessDetails method logSpecialPermissionChange.

@VisibleForTesting
void logSpecialPermissionChange(boolean newState, String packageName) {
    int logCategory = newState ? SettingsEnums.APP_SPECIAL_PERMISSION_USAGE_VIEW_ALLOW : SettingsEnums.APP_SPECIAL_PERMISSION_USAGE_VIEW_DENY;
    final MetricsFeatureProvider metricsFeatureProvider = FeatureFactory.getFactory(getContext()).getMetricsFeatureProvider();
    metricsFeatureProvider.action(metricsFeatureProvider.getAttribution(getActivity()), logCategory, getMetricsCategory(), packageName, 0);
}
Also used : MetricsFeatureProvider(com.android.settingslib.core.instrumentation.MetricsFeatureProvider) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 4 with MetricsFeatureProvider

use of com.android.settingslib.core.instrumentation.MetricsFeatureProvider in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ContextualCardLoader method getDisplayableCards.

// Get final displayed cards and log what cards will be displayed/hidden
@VisibleForTesting
List<ContextualCard> getDisplayableCards(List<ContextualCard> candidates) {
    final List<ContextualCard> eligibleCards = filterEligibleCards(candidates);
    final List<ContextualCard> visibleCards = new ArrayList<>();
    final List<ContextualCard> hiddenCards = new ArrayList<>();
    final int size = eligibleCards.size();
    for (int i = 0; i < size; i++) {
        if (i < DEFAULT_CARD_COUNT) {
            visibleCards.add(eligibleCards.get(i));
        } else {
            hiddenCards.add(eligibleCards.get(i));
        }
    }
    if (!CardContentProvider.DELETE_CARD_URI.equals(mNotifyUri)) {
        final MetricsFeatureProvider metricsFeatureProvider = FeatureFactory.getFactory(mContext).getMetricsFeatureProvider();
        metricsFeatureProvider.action(mContext, SettingsEnums.ACTION_CONTEXTUAL_CARD_NOT_SHOW, ContextualCardLogUtils.buildCardListLog(hiddenCards));
    }
    return visibleCards;
}
Also used : MetricsFeatureProvider(com.android.settingslib.core.instrumentation.MetricsFeatureProvider) ArrayList(java.util.ArrayList) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 5 with MetricsFeatureProvider

use of com.android.settingslib.core.instrumentation.MetricsFeatureProvider in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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)

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