Remove redundant methods and refactor
Remove the summary method and write the code in AOSP directly instead to force string consistency. Also refactor a bit after the modification. Fixes: 276399056 Test: robotests Change-Id: I76ad740b694363a3cdfb3748e41c840fb678b93d
This commit is contained in:
@@ -64,8 +64,10 @@ import com.google.protobuf.MessageLite;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.FormatStyle;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -671,6 +673,14 @@ public class BatteryUtils {
|
||||
}
|
||||
return summary.toString();
|
||||
}
|
||||
/** Format the date of battery related info */
|
||||
public static CharSequence getBatteryInfoFormattedDate(long dateInMs) {
|
||||
final Instant instant = Instant.ofEpochMilli(dateInMs);
|
||||
final String localDate = instant.atZone(ZoneId.systemDefault()).toLocalDate().format(
|
||||
DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG));
|
||||
|
||||
return localDate;
|
||||
}
|
||||
|
||||
/** Builds the battery usage time information for one timestamp. */
|
||||
private static String buildBatteryUsageTimeInfo(final Context context, long timeInMs,
|
||||
|
||||
Reference in New Issue
Block a user