Search in sources :

Example 1 with PowerProfile

use of com.android.internal.os.PowerProfile in project platform_frameworks_base by android.

the class BatteryStatsService method publish.

public void publish(Context context) {
    mContext = context;
    mStats.setRadioScanningTimeout(mContext.getResources().getInteger(com.android.internal.R.integer.config_radioScanningTimeout) * 1000L);
    mStats.setPowerProfile(new PowerProfile(context));
    ServiceManager.addService(BatteryStats.SERVICE_NAME, asBinder());
}
Also used : PowerProfile(com.android.internal.os.PowerProfile)

Example 2 with PowerProfile

use of com.android.internal.os.PowerProfile in project android_frameworks_base by ResurrectionRemix.

the class BatteryStatsService method publish.

public void publish(Context context) {
    mContext = context;
    mStats.setRadioScanningTimeout(mContext.getResources().getInteger(com.android.internal.R.integer.config_radioScanningTimeout) * 1000L);
    mStats.setPowerProfile(new PowerProfile(context));
    ServiceManager.addService(BatteryStats.SERVICE_NAME, asBinder());
}
Also used : PowerProfile(com.android.internal.os.PowerProfile)

Example 3 with PowerProfile

use of com.android.internal.os.PowerProfile in project android_frameworks_base by AOSPA.

the class BatteryStatsService method publish.

public void publish(Context context) {
    mContext = context;
    mStats.setRadioScanningTimeout(mContext.getResources().getInteger(com.android.internal.R.integer.config_radioScanningTimeout) * 1000L);
    mStats.setPowerProfile(new PowerProfile(context));
    ServiceManager.addService(BatteryStats.SERVICE_NAME, asBinder());
}
Also used : PowerProfile(com.android.internal.os.PowerProfile)

Example 4 with PowerProfile

use of com.android.internal.os.PowerProfile in project android_frameworks_base by DirtyUnicorns.

the class BatteryStatsService method publish.

public void publish(Context context) {
    mContext = context;
    mStats.setRadioScanningTimeout(mContext.getResources().getInteger(com.android.internal.R.integer.config_radioScanningTimeout) * 1000L);
    mStats.setPowerProfile(new PowerProfile(context));
    ServiceManager.addService(BatteryStats.SERVICE_NAME, asBinder());
}
Also used : PowerProfile(com.android.internal.os.PowerProfile)

Example 5 with PowerProfile

use of com.android.internal.os.PowerProfile in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class PowerUsageSummary method refreshStats.

protected void refreshStats() {
    super.refreshStats();
    updatePreference(mHistPref);
    cacheRemoveAllPrefs(mAppListGroup);
    mAppListGroup.setOrderingAsAdded(false);
    boolean addedSome = false;
    final PowerProfile powerProfile = mStatsHelper.getPowerProfile();
    final BatteryStats stats = mStatsHelper.getStats();
    final double averagePower = powerProfile.getAveragePower(PowerProfile.POWER_SCREEN_FULL);
    TypedValue value = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.colorControlNormal, value, true);
    int colorControl = getContext().getColor(value.resourceId);
    if (averagePower >= MIN_AVERAGE_POWER_THRESHOLD_MILLI_AMP || USE_FAKE_DATA) {
        final List<BatterySipper> usageList = getCoalescedUsageList(USE_FAKE_DATA ? getFakeStats() : mStatsHelper.getUsageList());
        final int dischargeAmount = USE_FAKE_DATA ? 5000 : stats != null ? stats.getDischargeAmount(mStatsType) : 0;
        final int numSippers = usageList.size();
        for (int i = 0; i < numSippers; i++) {
            final BatterySipper sipper = usageList.get(i);
            if ((sipper.totalPowerMah * SECONDS_IN_HOUR) < MIN_POWER_THRESHOLD_MILLI_AMP) {
                continue;
            }
            double totalPower = USE_FAKE_DATA ? 4000 : mStatsHelper.getTotalPower();
            final double percentOfTotal = ((sipper.totalPowerMah / totalPower) * dischargeAmount);
            if (((int) (percentOfTotal + .5)) < 1) {
                continue;
            }
            if (sipper.drainType == BatterySipper.DrainType.OVERCOUNTED) {
                // the largest real entry, and its percent of total is more significant
                if (sipper.totalPowerMah < ((mStatsHelper.getMaxRealPower() * 2) / 3)) {
                    continue;
                }
                if (percentOfTotal < 10) {
                    continue;
                }
                if ("user".equals(Build.TYPE) || "userdebug".equals(Build.TYPE)) {
                    continue;
                }
            }
            if (sipper.drainType == BatterySipper.DrainType.UNACCOUNTED) {
                // the largest real entry, and its percent of total is more significant
                if (sipper.totalPowerMah < (mStatsHelper.getMaxRealPower() / 2)) {
                    continue;
                }
                if (percentOfTotal < 5) {
                    continue;
                }
                if ("user".equals(Build.TYPE) || "userdebug".equals(Build.TYPE)) {
                    continue;
                }
            }
            final UserHandle userHandle = new UserHandle(UserHandle.getUserId(sipper.getUid()));
            final BatteryEntry entry = new BatteryEntry(getActivity(), mHandler, mUm, sipper);
            final Drawable badgedIcon = mUm.getBadgedIconForUser(entry.getIcon(), userHandle);
            final CharSequence contentDescription = mUm.getBadgedLabelForUser(entry.getLabel(), userHandle);
            final String key = sipper.drainType == DrainType.APP ? sipper.getPackages() != null ? TextUtils.concat(sipper.getPackages()).toString() : String.valueOf(sipper.getUid()) : sipper.drainType.toString();
            PowerGaugePreference pref = (PowerGaugePreference) getCachedPreference(key);
            if (pref == null) {
                pref = new PowerGaugePreference(getPrefContext(), badgedIcon, contentDescription, entry);
                pref.setKey(key);
            }
            final double percentOfMax = (sipper.totalPowerMah * 100) / mStatsHelper.getMaxPower();
            sipper.percent = percentOfTotal;
            pref.setTitle(entry.getLabel());
            pref.setOrder(i + 1);
            pref.setPercent(percentOfMax, percentOfTotal);
            if (sipper.uidObj != null) {
                pref.setKey(Integer.toString(sipper.uidObj.getUid()));
            }
            if ((sipper.drainType != DrainType.APP || sipper.uidObj.getUid() == 0) && sipper.drainType != DrainType.USER) {
                pref.setTint(colorControl);
            }
            addedSome = true;
            mAppListGroup.addPreference(pref);
            if (mAppListGroup.getPreferenceCount() - getCachedCount() > (MAX_ITEMS_TO_LIST + 1)) {
                break;
            }
        }
    }
    if (!addedSome) {
        addNotAvailableMessage();
    }
    removeCachedPrefs(mAppListGroup);
    BatteryEntry.startRequestQueue();
}
Also used : BatterySipper(com.android.internal.os.BatterySipper) Drawable(android.graphics.drawable.Drawable) BatteryStats(android.os.BatteryStats) UserHandle(android.os.UserHandle) PowerProfile(com.android.internal.os.PowerProfile) TypedValue(android.util.TypedValue)

Aggregations

PowerProfile (com.android.internal.os.PowerProfile)6 Drawable (android.graphics.drawable.Drawable)1 BatteryStats (android.os.BatteryStats)1 UserHandle (android.os.UserHandle)1 TypedValue (android.util.TypedValue)1 BatterySipper (com.android.internal.os.BatterySipper)1