Search in sources :

Example 16 with MetricsFeatureProvider

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

the class PremiumSmsAccess method logSpecialPermissionChange.

@VisibleForTesting
void logSpecialPermissionChange(int smsState, String packageName) {
    int category = SmsManager.PREMIUM_SMS_CONSENT_UNKNOWN;
    switch(smsState) {
        case SmsManager.PREMIUM_SMS_CONSENT_ASK_USER:
            category = SettingsEnums.APP_SPECIAL_PERMISSION_PREMIUM_SMS_ASK;
            break;
        case SmsManager.PREMIUM_SMS_CONSENT_NEVER_ALLOW:
            category = SettingsEnums.APP_SPECIAL_PERMISSION_PREMIUM_SMS_DENY;
            break;
        case SmsManager.PREMIUM_SMS_CONSENT_ALWAYS_ALLOW:
            category = SettingsEnums.APP_SPECIAL_PERMISSION_PREMIUM_SMS_ALWAYS_ALLOW;
            break;
    }
    if (category != SmsManager.PREMIUM_SMS_CONSENT_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 17 with MetricsFeatureProvider

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

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 PowerAllowlistBackend powerAllowlistBackend = PowerAllowlistBackend.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, powerAllowlistBackend, 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) PowerAllowlistBackend(com.android.settingslib.fuelgauge.PowerAllowlistBackend) PowerUsageFeatureProvider(com.android.settings.fuelgauge.PowerUsageFeatureProvider) BatteryUtils(com.android.settings.fuelgauge.BatteryUtils) JobWorkItem(android.app.job.JobWorkItem) ContentResolver(android.content.ContentResolver)

Example 18 with MetricsFeatureProvider

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

the class BluetoothDevicePreference method onClicked.

void onClicked() {
    Context context = getContext();
    int bondState = mCachedDevice.getBondState();
    final MetricsFeatureProvider metricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
    if (mCachedDevice.isConnected()) {
        metricsFeatureProvider.action(context, SettingsEnums.ACTION_SETTINGS_BLUETOOTH_DISCONNECT);
        askDisconnect();
    } else if (bondState == BluetoothDevice.BOND_BONDED) {
        metricsFeatureProvider.action(context, SettingsEnums.ACTION_SETTINGS_BLUETOOTH_CONNECT);
        mCachedDevice.connect();
    } else if (bondState == BluetoothDevice.BOND_NONE) {
        metricsFeatureProvider.action(context, SettingsEnums.ACTION_SETTINGS_BLUETOOTH_PAIR);
        if (!mCachedDevice.hasHumanReadableName()) {
            metricsFeatureProvider.action(context, SettingsEnums.ACTION_SETTINGS_BLUETOOTH_PAIR_DEVICES_WITHOUT_NAMES);
        }
        pair();
    }
}
Also used : Context(android.content.Context) MetricsFeatureProvider(com.android.settingslib.core.instrumentation.MetricsFeatureProvider)

Example 19 with MetricsFeatureProvider

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

the class StorageDashboardFragment 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)

Example 20 with MetricsFeatureProvider

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

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)

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