Search in sources :

Example 6 with MetricsFeatureProvider

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

the class EligibleCardChecker method call.

@Override
public ContextualCard call() throws Exception {
    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 7 with MetricsFeatureProvider

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

the class VrListenerSettings method logSpecialPermissionChange.

@VisibleForTesting
void logSpecialPermissionChange(boolean enable, String packageName) {
    int logCategory = enable ? SettingsEnums.APP_SPECIAL_PERMISSION_VRHELPER_ALLOW : SettingsEnums.APP_SPECIAL_PERMISSION_VRHELPER_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 8 with MetricsFeatureProvider

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

the class PictureInPictureDetails method logSpecialPermissionChange.

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

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

the class PremiumSmsAccess method logSpecialPermissionChange.

@VisibleForTesting
void logSpecialPermissionChange(int smsState, String packageName) {
    int category = SmsUsageMonitor.PREMIUM_SMS_PERMISSION_UNKNOWN;
    switch(smsState) {
        case SmsUsageMonitor.PREMIUM_SMS_PERMISSION_ASK_USER:
            category = SettingsEnums.APP_SPECIAL_PERMISSION_PREMIUM_SMS_ASK;
            break;
        case SmsUsageMonitor.PREMIUM_SMS_PERMISSION_NEVER_ALLOW:
            category = SettingsEnums.APP_SPECIAL_PERMISSION_PREMIUM_SMS_DENY;
            break;
        case SmsUsageMonitor.PREMIUM_SMS_PERMISSION_ALWAYS_ALLOW:
            category = SettingsEnums.APP_SPECIAL_PERMISSION_PREMIUM_SMS_ALWAYS_ALLOW;
            break;
    }
    if (category != SmsUsageMonitor.PREMIUM_SMS_PERMISSION_UNKNOWN) {
        // TODO(117860032): Category is wrong. It should be defined in SettingsEnums.
        final MetricsFeatureProvider metricsFeatureProvider = FeatureFactory.getFactory(getContext()).getMetricsFeatureProvider();
        metricsFeatureProvider.action(metricsFeatureProvider.getAttribution(getActivity()), category, getMetricsCategory(), packageName, smsState);
    }
}
Also used : MetricsFeatureProvider(com.android.settingslib.core.instrumentation.MetricsFeatureProvider) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 10 with MetricsFeatureProvider

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

the class SliceDeferredSetupCardRendererHelper method bindView.

void bindView(RecyclerView.ViewHolder holder, ContextualCard card, Slice slice) {
    final DeferredSetupCardViewHolder view = (DeferredSetupCardViewHolder) holder;
    final SliceMetadata sliceMetadata = SliceMetadata.from(mContext, slice);
    final SliceAction primaryAction = sliceMetadata.getPrimaryAction();
    view.icon.setImageDrawable(primaryAction.getIcon().loadDrawable(mContext));
    view.title.setText(primaryAction.getTitle());
    view.summary.setText(sliceMetadata.getSubtitle());
    view.button.setOnClickListener(v -> {
        try {
            primaryAction.getAction().send();
        } catch (PendingIntent.CanceledException e) {
            Log.w(TAG, "Failed to start intent " + primaryAction.getTitle());
        }
        final String log = ContextualCardLogUtils.buildCardClickLog(card, 0, /* row */
        EventInfo.ACTION_TYPE_CONTENT, view.getAdapterPosition());
        final MetricsFeatureProvider metricsFeatureProvider = FeatureFactory.getFactory(mContext).getMetricsFeatureProvider();
        metricsFeatureProvider.action(mContext, SettingsEnums.ACTION_CONTEXTUAL_CARD_CLICK, log);
    });
}
Also used : MetricsFeatureProvider(com.android.settingslib.core.instrumentation.MetricsFeatureProvider) SliceMetadata(androidx.slice.SliceMetadata) SliceAction(androidx.slice.core.SliceAction) PendingIntent(android.app.PendingIntent)

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