Merge "Rename variables and refine the format style from ag/14346184" into sc-dev
This commit is contained in:
@@ -155,8 +155,8 @@ public class BatteryDiffEntry {
|
||||
break;
|
||||
case ConvertUtils.CONSUMER_TYPE_SYSTEM_BATTERY:
|
||||
final BatteryEntry.NameAndIcon nameAndIconForSystem =
|
||||
BatteryEntry.getNameAndIconFromPowerComponent(
|
||||
mContext, mBatteryHistEntry.mPowerComponentId);
|
||||
BatteryEntry.getNameAndIconFromPowerComponent(
|
||||
mContext, mBatteryHistEntry.mDrainType);
|
||||
if (nameAndIconForSystem != null) {
|
||||
mAppLabel = nameAndIconForSystem.name;
|
||||
if (nameAndIconForSystem.iconId != 0) {
|
||||
|
@@ -15,6 +15,7 @@ package com.android.settings.fuelgauge;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.database.Cursor;
|
||||
import android.os.BatteryConsumer;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
@@ -59,7 +60,9 @@ public class BatteryHistEntry {
|
||||
public final double mPercentOfTotal;
|
||||
public final long mForegroundUsageTimeInMs;
|
||||
public final long mBackgroundUsageTimeInMs;
|
||||
public final int mPowerComponentId;
|
||||
@BatteryConsumer.PowerComponent
|
||||
public final int mDrainType;
|
||||
@ConvertUtils.ConsumerType
|
||||
public final int mConsumerType;
|
||||
// Records the battery intent relative information.
|
||||
public final int mBatteryLevel;
|
||||
@@ -83,7 +86,7 @@ public class BatteryHistEntry {
|
||||
mPercentOfTotal = getDouble(values, KEY_PERCENT_OF_TOTAL);
|
||||
mForegroundUsageTimeInMs = getLong(values, KEY_FOREGROUND_USAGE_TIME);
|
||||
mBackgroundUsageTimeInMs = getLong(values, KEY_BACKGROUND_USAGE_TIME);
|
||||
mPowerComponentId = getInteger(values, KEY_DRAIN_TYPE);
|
||||
mDrainType = getInteger(values, KEY_DRAIN_TYPE);
|
||||
mConsumerType = getInteger(values, KEY_CONSUMER_TYPE);
|
||||
mBatteryLevel = getInteger(values, KEY_BATTERY_LEVEL);
|
||||
mBatteryStatus = getInteger(values, KEY_BATTERY_STATUS);
|
||||
@@ -104,7 +107,7 @@ public class BatteryHistEntry {
|
||||
mPercentOfTotal = getDouble(cursor, KEY_PERCENT_OF_TOTAL);
|
||||
mForegroundUsageTimeInMs = getLong(cursor, KEY_FOREGROUND_USAGE_TIME);
|
||||
mBackgroundUsageTimeInMs = getLong(cursor, KEY_BACKGROUND_USAGE_TIME);
|
||||
mPowerComponentId = getInteger(cursor, KEY_DRAIN_TYPE);
|
||||
mDrainType = getInteger(cursor, KEY_DRAIN_TYPE);
|
||||
mConsumerType = getInteger(cursor, KEY_CONSUMER_TYPE);
|
||||
mBatteryLevel = getInteger(cursor, KEY_BATTERY_LEVEL);
|
||||
mBatteryStatus = getInteger(cursor, KEY_BATTERY_STATUS);
|
||||
@@ -139,7 +142,7 @@ public class BatteryHistEntry {
|
||||
mKey = Long.toString(mUid);
|
||||
break;
|
||||
case ConvertUtils.CONSUMER_TYPE_SYSTEM_BATTERY:
|
||||
mKey = "S|" + mPowerComponentId;
|
||||
mKey = "S|" + mDrainType;
|
||||
break;
|
||||
case ConvertUtils.CONSUMER_TYPE_USER_BATTERY:
|
||||
mKey = "U|" + mUserId;
|
||||
@@ -162,7 +165,8 @@ public class BatteryHistEntry {
|
||||
mPercentOfTotal, mTotalPower, mConsumePower,
|
||||
Duration.ofMillis(mForegroundUsageTimeInMs).getSeconds(),
|
||||
Duration.ofMillis(mBackgroundUsageTimeInMs).getSeconds()))
|
||||
.append(String.format("\n\tdrain=%d|consumer=%d", mPowerComponentId, mConsumerType))
|
||||
.append(String.format("\n\tdrainType=%d|consumerType=%d",
|
||||
mDrainType, mConsumerType))
|
||||
.append(String.format("\n\tbattery=%d|status=%d|health=%d\n}",
|
||||
mBatteryLevel, mBatteryStatus, mBatteryHealth));
|
||||
return builder.toString();
|
||||
|
@@ -102,9 +102,9 @@ public final class ConvertUtils {
|
||||
values.put(BatteryHistEntry.KEY_BACKGROUND_USAGE_TIME,
|
||||
Long.valueOf(entry.getTimeInBackgroundMs()));
|
||||
values.put(BatteryHistEntry.KEY_DRAIN_TYPE,
|
||||
entry.getPowerComponentId());
|
||||
Integer.valueOf(entry.getPowerComponentId()));
|
||||
values.put(BatteryHistEntry.KEY_CONSUMER_TYPE,
|
||||
entry.getConsumerType());
|
||||
Integer.valueOf(entry.getConsumerType()));
|
||||
} else {
|
||||
values.put(BatteryHistEntry.KEY_PACKAGE_NAME, FAKE_PACKAGE_NAME);
|
||||
}
|
||||
|
@@ -111,9 +111,9 @@ public final class BatteryDiffEntryTest {
|
||||
public void testLoadLabelAndIcon_forSystemBattery_returnExpectedResult() {
|
||||
// Generates fake testing data.
|
||||
final ContentValues values = getContentValuesWithType(
|
||||
ConvertUtils.CONSUMER_TYPE_SYSTEM_BATTERY);
|
||||
ConvertUtils.CONSUMER_TYPE_SYSTEM_BATTERY);
|
||||
values.put("drainType",
|
||||
Integer.valueOf(BatteryConsumer.POWER_COMPONENT_AMBIENT_DISPLAY));
|
||||
Integer.valueOf(BatteryConsumer.POWER_COMPONENT_AMBIENT_DISPLAY));
|
||||
final BatteryHistEntry batteryHistEntry = new BatteryHistEntry(values);
|
||||
|
||||
final BatteryDiffEntry entry = createBatteryDiffEntry(10, batteryHistEntry);
|
||||
|
@@ -62,7 +62,7 @@ public final class BatteryHistEntryTest {
|
||||
when(mockBatteryEntry.getTimeInBackgroundMs()).thenReturn(5689L);
|
||||
when(mockBatteryEntry.getPowerComponentId()).thenReturn(expectedType);
|
||||
when(mockBatteryEntry.getConsumerType())
|
||||
.thenReturn(ConvertUtils.CONSUMER_TYPE_SYSTEM_BATTERY);
|
||||
.thenReturn(ConvertUtils.CONSUMER_TYPE_SYSTEM_BATTERY);
|
||||
final ContentValues values =
|
||||
ConvertUtils.convert(
|
||||
mockBatteryEntry,
|
||||
@@ -223,7 +223,7 @@ public final class BatteryHistEntryTest {
|
||||
assertThat(entry.mPercentOfTotal).isEqualTo(percentOfTotal);
|
||||
assertThat(entry.mForegroundUsageTimeInMs).isEqualTo(1234L);
|
||||
assertThat(entry.mBackgroundUsageTimeInMs).isEqualTo(5689L);
|
||||
assertThat(entry.mPowerComponentId).isEqualTo(drainType);
|
||||
assertThat(entry.mDrainType).isEqualTo(drainType);
|
||||
assertThat(entry.mConsumerType)
|
||||
.isEqualTo(ConvertUtils.CONSUMER_TYPE_SYSTEM_BATTERY);
|
||||
assertThat(entry.mBatteryLevel).isEqualTo(12);
|
||||
|
@@ -71,7 +71,7 @@ public final class ConvertUtilsTest {
|
||||
when(mockBatteryEntry.getTimeInBackgroundMs()).thenReturn(5689L);
|
||||
when(mockBatteryEntry.getPowerComponentId()).thenReturn(expectedType);
|
||||
when(mockBatteryEntry.getConsumerType())
|
||||
.thenReturn(ConvertUtils.CONSUMER_TYPE_SYSTEM_BATTERY);
|
||||
.thenReturn(ConvertUtils.CONSUMER_TYPE_SYSTEM_BATTERY);
|
||||
|
||||
final ContentValues values =
|
||||
ConvertUtils.convert(
|
||||
|
Reference in New Issue
Block a user