Exclude screen on time in battery usage page when the device is in charging.
Bug: 265751163 Fix: 265751163 Test: manual Change-Id: I4ed71e1d6fad56a7cbfc9cd47ed4d791f45261ce
This commit is contained in:
@@ -38,6 +38,7 @@ import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.settings.fuelgauge.BatteryUtils;
|
||||
import com.android.settings.fuelgauge.batteryusage.db.AppUsageEventEntity;
|
||||
import com.android.settings.fuelgauge.batteryusage.db.BatteryEventEntity;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -125,6 +126,15 @@ public final class ConvertUtils {
|
||||
return values;
|
||||
}
|
||||
|
||||
/** Converts {@link BatteryEvent} to content values */
|
||||
public static ContentValues convertBatteryEventToContentValues(final BatteryEvent event) {
|
||||
final ContentValues values = new ContentValues();
|
||||
values.put(BatteryEventEntity.KEY_TIMESTAMP, event.getTimestamp());
|
||||
values.put(BatteryEventEntity.KEY_BATTERY_EVENT_TYPE, event.getType().getNumber());
|
||||
values.put(BatteryEventEntity.KEY_BATTERY_LEVEL, event.getBatteryLevel());
|
||||
return values;
|
||||
}
|
||||
|
||||
/** Gets the encoded string from {@link BatteryInformation} instance. */
|
||||
public static String convertBatteryInformationToString(
|
||||
final BatteryInformation batteryInformation) {
|
||||
@@ -237,6 +247,29 @@ public final class ConvertUtils {
|
||||
return eventBuilder.build();
|
||||
}
|
||||
|
||||
/** Converts to {@link BatteryEvent} from {@link BatteryEventType} */
|
||||
public static BatteryEvent convertToBatteryEvent(
|
||||
long timestamp, BatteryEventType type, int batteryLevel) {
|
||||
final BatteryEvent.Builder eventBuilder = BatteryEvent.newBuilder();
|
||||
eventBuilder.setTimestamp(timestamp);
|
||||
eventBuilder.setType(type);
|
||||
eventBuilder.setBatteryLevel(batteryLevel);
|
||||
return eventBuilder.build();
|
||||
}
|
||||
|
||||
/** Converts to {@link BatteryEvent} from {@link Cursor} */
|
||||
public static BatteryEvent convertToBatteryEventFromCursor(final Cursor cursor) {
|
||||
final BatteryEvent.Builder eventBuilder = BatteryEvent.newBuilder();
|
||||
eventBuilder.setTimestamp(getLongFromCursor(cursor, BatteryEventEntity.KEY_TIMESTAMP));
|
||||
eventBuilder.setType(
|
||||
BatteryEventType.forNumber(
|
||||
getIntegerFromCursor(
|
||||
cursor, BatteryEventEntity.KEY_BATTERY_EVENT_TYPE)));
|
||||
eventBuilder.setBatteryLevel(
|
||||
getIntegerFromCursor(cursor, BatteryEventEntity.KEY_BATTERY_LEVEL));
|
||||
return eventBuilder.build();
|
||||
}
|
||||
|
||||
/** Converts UTC timestamp to local time string for logging only, so use the US locale for
|
||||
* better readability in debugging. */
|
||||
public static String utcToLocalTimeForLogging(long timestamp) {
|
||||
|
||||
Reference in New Issue
Block a user