Search in sources :

Example 1 with PowerUsageFeatureProvider

use of com.android.settings.fuelgauge.PowerUsageFeatureProvider 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 2 with PowerUsageFeatureProvider

use of com.android.settings.fuelgauge.PowerUsageFeatureProvider 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 3 with PowerUsageFeatureProvider

use of com.android.settings.fuelgauge.PowerUsageFeatureProvider in project android_packages_apps_Settings by omnirom.

the class AppBatteryPreferenceController method refreshFeatureFlag.

private void refreshFeatureFlag(Context context) {
    if (isWorkProfile(context)) {
        try {
            context = context.createPackageContextAsUser(context.getPackageName(), 0, UserHandle.OWNER);
        } catch (PackageManager.NameNotFoundException e) {
            Log.e(TAG, "context.createPackageContextAsUser() fail: " + e);
        }
    }
    final PowerUsageFeatureProvider powerUsageFeatureProvider = FeatureFactory.getFactory(context).getPowerUsageFeatureProvider(context);
    mIsChartGraphEnabled = powerUsageFeatureProvider.isChartGraphEnabled(context);
}
Also used : PackageManager(android.content.pm.PackageManager) PowerUsageFeatureProvider(com.android.settings.fuelgauge.PowerUsageFeatureProvider)

Aggregations

PowerUsageFeatureProvider (com.android.settings.fuelgauge.PowerUsageFeatureProvider)3 JobWorkItem (android.app.job.JobWorkItem)2 ContentResolver (android.content.ContentResolver)2 Context (android.content.Context)2 UserManager (android.os.UserManager)2 BatteryUtils (com.android.settings.fuelgauge.BatteryUtils)2 MetricsFeatureProvider (com.android.settingslib.core.instrumentation.MetricsFeatureProvider)2 PackageManager (android.content.pm.PackageManager)1 PowerAllowlistBackend (com.android.settingslib.fuelgauge.PowerAllowlistBackend)1 PowerWhitelistBackend (com.android.settingslib.fuelgauge.PowerWhitelistBackend)1