Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4db5c6ba authored by Kuan Wang's avatar Kuan Wang Committed by Zaiyue Xue
Browse files

Port new version battery usage chart implementation from master to tm-qpr-dev.

This cl is a merge of the following 36 cls:
ag/19250259	Duplicate BatteryChartPreferenceController and BatteryChartView into new files for better diff review purpose
ag/19279660	Use Mockito 4.6.1 API for BatteryChartPreferenceControllerV2Test
ag/19267975	Add class BatteryLevelData used to parcel the battery timestamps and levels. It behaves as an interface between UI and data.
ag/19289086	Refactor BatteryChartView X-axis labels. Instead of only timestamps, also support any string[] labels.
ag/19238586	Add interpolation for the history data since last full charge loaded from database.
ag/19331746	Return raw history map in function getHistoryMapSinceLastFullCharge.
ag/19308838	In BatteryChartViewV2, use levels.length-1 to replace mTrapezoidCount. So the chartview could show any number of slots as the given levels length-1.
ag/19332266	Add class BatteryDiffData used to parcel battery usage data
ag/19331467	Refactor Battery Chart View State Controll
ag/19358207	Add DataProcessor to process raw history map for UI.
ag/19332276	Add battery chart view model.
ag/19394744	Update trapezoid validation in battery chart view.
ag/19379730	Support daily and hourly battery chartview.
ag/19428426	Improve X axis labels in battery chart (1)
ag/19446215	Improve X axis labels in battery chart (2)
ag/19394745	Add the async task to compute diff usage data and load labels and icons.
ag/19447624	Support showing app usage list for two battery charts
ag/19500907	Updates battery usage messages from last 24hr to last full charge. (Part1: V2 files)
ag/19505324	Update the selected period message in battery chart
ag/19500905	Updates battery usage messages from last 24hr to last full charge. (Part2: non-V2 files)
ag/19510363	Update usage data for EBS app usage list and App usage detail from 24 hours to last full charge.
ag/19523184	Update usage data for EBS app usage list and App usage detail from 24 hours to last full charge.
ag/19534864	Add margin between battery daily and hourly charts
ag/19491093	Always do interpolation for battery level data in daily chart.
ag/19565630	Avoid NullPointerException when batteryLevelData is null.
ag/19561239	Fix b/241872474 Battery usage page will crash when selecting the last hour chart bar, going to app detail page, and going back
ag/19565633	Fix b/241885070: Unexpected texts moving when going back to battery usage page
ag/19534850	New way to draw battery chart axis labels
ag/19561240	Switch Battery Usage Chart from V1 to V2.
ag/19561338	Switch Battery Usage Chart from V1 to V2.
ag/19600174	Fix b/242254055 Battery usage initial screen improvements (long data loading time)
ag/19600284	Fix b/242252080: Add padding space on the top of the battery chart
ag/19647338	Consider usage map valid even if [all][all] is null.
ag/19634227	Use new content uri everytime to avoid cache
ag/19600177	Fix b/242009481: Refine the battery usage chart timestamp label rule
ag/19647337	Fix b/242809981 Charge battery to 100% when battery usage page opened, the chart will refresh, but the app list isn't refreshed in that case.

Test: manual
Bug: 239491373
Bug: 236101166
Bug: 236101687
Fix: 236101166
Change-Id: I7de8d9dcee14627da10752534991f1ec9f616020
Merged-In: I9142c0d4e00dea3771777ba9aedeab07b635fa1a
parent 1215a5df
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -29,14 +29,24 @@
        android:layout_marginVertical="16dp"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:textColor="?android:attr/textColorSecondary"
        android:text="@string/battery_usage_chart_graph_hint" />
        android:text="@string/battery_usage_chart_graph_hint_last_full_charge" />

    <com.android.settings.fuelgauge.batteryusage.BatteryChartView
        android:id="@+id/battery_chart"
        android:id="@+id/daily_battery_chart"
        android:layout_width="match_parent"
        android:layout_height="170dp"
        android:layout_marginBottom="6dp"
        android:visibility="invisible"
        android:layout_marginBottom="16dp"
        android:visibility="gone"
        android:contentDescription="@string/battery_usage_chart"
        android:textAppearance="?android:attr/textAppearanceSmall"
        settings:textColor="?android:attr/textColorSecondary" />

    <com.android.settings.fuelgauge.batteryusage.BatteryChartView
        android:id="@+id/hourly_battery_chart"
        android:layout_width="match_parent"
        android:layout_height="170dp"
        android:layout_marginBottom="16dp"
        android:visibility="visible"
        android:contentDescription="@string/battery_usage_chart"
        android:textAppearance="?android:attr/textAppearanceSmall"
        settings:textColor="?android:attr/textColorSecondary" />
+6 −0
Original line number Diff line number Diff line
@@ -6744,10 +6744,16 @@
    <!-- [CHAR_LIMIT=NONE] Battery percentage: Description for preference -->
    <string name="battery_percentage_description">Show battery percentage in status bar</string>
    <!-- [CHAR_LIMIT=NONE] Battery usage main screen chart graph hint since last full charge -->
    <string name="battery_usage_chart_graph_hint_last_full_charge">Battery level since last full charge</string>
    <!-- [CHAR_LIMIT=NONE] Battery usage main screen chart graph hint -->
    <string name="battery_usage_chart_graph_hint">Battery level for past 24 hr</string>
    <!-- [CHAR_LIMIT=NONE] Battery app usage section header since last full charge -->
    <string name="battery_app_usage">App usage since last full charge</string>
    <!-- [CHAR_LIMIT=NONE] Battery app usage section header for past 24 hour -->
    <string name="battery_app_usage_for_past_24">App usage for past 24 hr</string>
    <!-- [CHAR_LIMIT=NONE] Battery system usage section header since last full charge -->
    <string name="battery_system_usage">System usage since last full charge</string>
    <!-- [CHAR_LIMIT=NONE] Battery system usage section header for past 24 hour -->
    <string name="battery_system_usage_for_past_24">System usage for past 24 hr</string>
    <!-- [CHAR_LIMIT=NONE] Battery system usage section header -->
+3 −3
Original line number Diff line number Diff line
@@ -179,7 +179,7 @@ public class AppBatteryPreferenceController extends BasePreferenceController
                    return null;
                }
                final BatteryDiffEntry entry =
                        BatteryChartPreferenceController.getBatteryLast24HrUsageData(
                        BatteryChartPreferenceController.getAppBatteryUsageData(
                                mContext, mPackageName, mUserId);
                Log.d(TAG, "loadBatteryDiffEntries():\n" + entry);
                return entry;
@@ -200,10 +200,10 @@ public class AppBatteryPreferenceController extends BasePreferenceController
                mBatteryPercent = Utils.formatPercentage(
                        mBatteryDiffEntry.getPercentOfTotal(), /* round */ true);
                mPreference.setSummary(mContext.getString(
                        R.string.battery_summary_24hr, mBatteryPercent));
                        R.string.battery_summary, mBatteryPercent));
            } else {
                mPreference.setSummary(
                        mContext.getString(R.string.no_battery_summary_24hr));
                        mContext.getString(R.string.no_battery_summary));
            }
        }

+6 −9
Original line number Diff line number Diff line
@@ -539,15 +539,12 @@ public class AdvancedPowerUsageDetail extends DashboardFragment implements
            return null;
        }
        if (totalTimeMs == 0) {
            final int batteryWithoutUsageTime = consumedPower > 0
                    ? R.string.battery_usage_without_time : R.string.battery_not_usage_24hr;
            usageTimeSummary = getText(isChartGraphEnabled
                    ? batteryWithoutUsageTime : R.string.battery_not_usage);
            usageTimeSummary = getText(
                    isChartGraphEnabled && consumedPower > 0 ? R.string.battery_usage_without_time
                            : R.string.battery_not_usage);
        } else if (slotTime == null) {
            // Shows summary text with past 24 hr or full charge if slot time is null.
            usageTimeSummary = isChartGraphEnabled
                    ? getAppPast24HrActiveSummary(foregroundTimeMs, backgroundTimeMs, totalTimeMs)
                    : getAppFullChargeActiveSummary(
            // Shows summary text with last full charge if slot time is null.
            usageTimeSummary = getAppFullChargeActiveSummary(
                    foregroundTimeMs, backgroundTimeMs, totalTimeMs);
        } else {
            // Shows summary text with slot time.
+215 −263

File changed.

Preview size limit exceeded, changes collapsed.

Loading