Add whether app optimization mode mutable in BatteryUsageDiff proto.

Bug: 350657779
Test: atest ConvertUtilsTest
Flag: EXEMPT bug fix
Change-Id: I80a5e6513e1bee88f85caeed7661b10204df8a51
This commit is contained in:
mxyyiyi
2024-07-30 17:59:57 +08:00
parent 3a8ce3f970
commit 59e5dc720a
4 changed files with 33 additions and 16 deletions

View File

@@ -38,6 +38,8 @@ import android.os.BatteryUsageStats;
import android.os.LocaleList;
import android.os.UserHandle;
import androidx.core.util.Pair;
import com.android.settings.fuelgauge.batteryusage.db.AppUsageEventEntity;
import com.android.settings.fuelgauge.batteryusage.db.BatteryEventEntity;
import com.android.settings.fuelgauge.batteryusage.db.BatteryUsageSlotEntity;
@@ -384,8 +386,9 @@ public final class ConvertUtilsTest {
/* cachedUsageConsumePower= */ 1.5);
BatteryOptimizationModeCache optimizationModeCache =
new BatteryOptimizationModeCache(mContext);
optimizationModeCache.mBatteryOptimizeModeCacheMap.put(
(int) batteryDiffEntry.mUid, BatteryOptimizationMode.MODE_OPTIMIZED);
optimizationModeCache.mBatteryOptimizeModeCache.put(
(int) batteryDiffEntry.mUid,
Pair.create(BatteryOptimizationMode.MODE_OPTIMIZED, false));
final BatteryUsageDiff batteryUsageDiff =
ConvertUtils.convertToBatteryUsageDiff(batteryDiffEntry, optimizationModeCache);
@@ -408,6 +411,7 @@ public final class ConvertUtilsTest {
assertThat(batteryUsageDiff.getKey()).isEqualTo("key");
assertThat(batteryUsageDiff.getAppOptimizationMode())
.isEqualTo(BatteryOptimizationMode.MODE_OPTIMIZED);
assertThat(batteryUsageDiff.getIsAppOptimizationModeMutable()).isFalse();
assertThat(batteryUsageDiff.hasPackageName()).isFalse();
assertThat(batteryUsageDiff.hasLabel()).isFalse();
}