Use default package in BatteryEntry

Before this cl, we use the first package name if there is a name
list in BatterySipper.

We should use BatteryEntry.defaultPackageName instead, which could
describle the batterysipper more accurately.

Bug: 62417935
Test: RunSettingsRoboTests
Change-Id: I44fa151c0cf8f14cba305f179c7e94e5bc3ce434
diff --git a/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java b/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java
index 580eb1b..42b049a 100644
--- a/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java
+++ b/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java
@@ -119,7 +119,7 @@
             args.putString(EXTRA_PACKAGE_NAME, null);
         } else {
             // populate data for normal app
-            args.putString(EXTRA_PACKAGE_NAME, sipper.mPackages[0]);
+            args.putString(EXTRA_PACKAGE_NAME, entry.defaultPackageName);
         }
 
         args.putInt(EXTRA_UID, sipper.getUid());
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailTest.java b/tests/robotests/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailTest.java
index d6b758c..f4ed43e 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailTest.java
@@ -248,6 +248,7 @@
     @Test
     public void testStartBatteryDetailPage_NormalApp() {
         mBatterySipper.mPackages = PACKAGE_NAME;
+        mBatteryEntry.defaultPackageName = PACKAGE_NAME[0];
         AdvancedPowerUsageDetail.startBatteryDetailPage(mTestActivity, null, mBatteryStatsHelper, 0,
                 mBatteryEntry, USAGE_PERCENT);