Search in sources :

Example 21 with MetricsFeatureProvider

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

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> stickyCards = new ArrayList<>();
    final List<ContextualCard> visibleCards = new ArrayList<>();
    final List<ContextualCard> hiddenCards = new ArrayList<>();
    final int maxCardCount = getCardCount();
    eligibleCards.forEach(card -> {
        if (card.getCategory() != STICKY_VALUE) {
            return;
        }
        if (stickyCards.size() < maxCardCount) {
            stickyCards.add(card);
        } else {
            hiddenCards.add(card);
        }
    });
    final int nonStickyCardCount = maxCardCount - stickyCards.size();
    eligibleCards.forEach(card -> {
        if (card.getCategory() == STICKY_VALUE) {
            return;
        }
        if (visibleCards.size() < nonStickyCardCount) {
            visibleCards.add(card);
        } else {
            hiddenCards.add(card);
        }
    });
    visibleCards.addAll(stickyCards);
    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 22 with MetricsFeatureProvider

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

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 23 with MetricsFeatureProvider

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

the class AnomalyDetectionJobService method onStartJob.

@Override
public boolean onStartJob(JobParameters params) {
    synchronized (mLock) {
        mIsJobCanceled = false;
    }
    ThreadUtils.postOnBackgroundThread(() -> {
        final Context context = AnomalyDetectionJobService.this;
        final BatteryDatabaseManager batteryDatabaseManager = BatteryDatabaseManager.getInstance(this);
        final BatteryTipPolicy policy = new BatteryTipPolicy(this);
        final BatteryUtils batteryUtils = BatteryUtils.getInstance(this);
        final ContentResolver contentResolver = getContentResolver();
        final UserManager userManager = getSystemService(UserManager.class);
        final PowerWhitelistBackend powerWhitelistBackend = PowerWhitelistBackend.getInstance(context);
        final PowerUsageFeatureProvider powerUsageFeatureProvider = FeatureFactory.getFactory(this).getPowerUsageFeatureProvider(this);
        final MetricsFeatureProvider metricsFeatureProvider = FeatureFactory.getFactory(this).getMetricsFeatureProvider();
        for (JobWorkItem item = dequeueWork(params); item != null; item = dequeueWork(params)) {
            saveAnomalyToDatabase(context, userManager, batteryDatabaseManager, batteryUtils, policy, powerWhitelistBackend, contentResolver, powerUsageFeatureProvider, metricsFeatureProvider, item.getIntent().getExtras());
            completeWork(params, item);
        }
    });
    return true;
}
Also used : Context(android.content.Context) MetricsFeatureProvider(com.android.settingslib.core.instrumentation.MetricsFeatureProvider) UserManager(android.os.UserManager) PowerUsageFeatureProvider(com.android.settings.fuelgauge.PowerUsageFeatureProvider) PowerWhitelistBackend(com.android.settingslib.fuelgauge.PowerWhitelistBackend) BatteryUtils(com.android.settings.fuelgauge.BatteryUtils) JobWorkItem(android.app.job.JobWorkItem) ContentResolver(android.content.ContentResolver)

Example 24 with MetricsFeatureProvider

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

the class DrawOverlayDetails method logSpecialPermissionChange.

@VisibleForTesting
void logSpecialPermissionChange(boolean newState, String packageName) {
    int logCategory = newState ? SettingsEnums.APP_SPECIAL_PERMISSION_APPDRAW_ALLOW : SettingsEnums.APP_SPECIAL_PERMISSION_APPDRAW_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 25 with MetricsFeatureProvider

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

the class SliceContextualCardController method onDismissed.

@Override
public void onDismissed(ContextualCard card) {
    ThreadUtils.postOnBackgroundThread(() -> {
        final CardDatabaseHelper dbHelper = CardDatabaseHelper.getInstance(mContext);
        dbHelper.markContextualCardAsDismissed(mContext, card.getName());
    });
    showFeedbackDialog(card);
    final MetricsFeatureProvider metricsFeatureProvider = FeatureFactory.getFactory(mContext).getMetricsFeatureProvider();
    metricsFeatureProvider.action(mContext, SettingsEnums.ACTION_CONTEXTUAL_CARD_DISMISS, ContextualCardLogUtils.buildCardDismissLog(card));
}
Also used : MetricsFeatureProvider(com.android.settingslib.core.instrumentation.MetricsFeatureProvider) CardDatabaseHelper(com.android.settings.homepage.contextualcards.CardDatabaseHelper)

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