Merge "Skip load app name from PackageManager while init the BatteryEntry." into main
This commit is contained in:
@@ -22,7 +22,6 @@ import android.content.pm.ApplicationInfo;
|
|||||||
import android.content.pm.IPackageManager;
|
import android.content.pm.IPackageManager;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
|
||||||
import android.content.pm.UserInfo;
|
import android.content.pm.UserInfo;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.BatteryConsumer;
|
import android.os.BatteryConsumer;
|
||||||
@@ -176,18 +175,7 @@ public class BatteryEntry {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mDefaultPackageName != null) {
|
if (mDefaultPackageName != null) {
|
||||||
PackageManager pm = context.getPackageManager();
|
mName = mDefaultPackageName;
|
||||||
try {
|
|
||||||
ApplicationInfo appInfo =
|
|
||||||
pm.getApplicationInfo(mDefaultPackageName, 0 /* no flags */);
|
|
||||||
mName = pm.getApplicationLabel(appInfo).toString();
|
|
||||||
} catch (NameNotFoundException e) {
|
|
||||||
Log.d(
|
|
||||||
TAG,
|
|
||||||
"PackageManager failed to retrieve ApplicationInfo for: "
|
|
||||||
+ mDefaultPackageName);
|
|
||||||
mName = mDefaultPackageName;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
mTimeInForegroundMs =
|
mTimeInForegroundMs =
|
||||||
uidBatteryConsumer.getTimeInProcessStateMs(
|
uidBatteryConsumer.getTimeInProcessStateMs(
|
||||||
|
@@ -132,7 +132,7 @@ public class BatteryEntryTest {
|
|||||||
createBatteryEntryForApp(null, APP_DEFAULT_PACKAGE_NAME, HIGH_DRAIN_PACKAGE);
|
createBatteryEntryForApp(null, APP_DEFAULT_PACKAGE_NAME, HIGH_DRAIN_PACKAGE);
|
||||||
|
|
||||||
assertThat(entry.getDefaultPackageName()).isEqualTo(APP_DEFAULT_PACKAGE_NAME);
|
assertThat(entry.getDefaultPackageName()).isEqualTo(APP_DEFAULT_PACKAGE_NAME);
|
||||||
assertThat(entry.getLabel()).isEqualTo(LABEL_PREFIX + APP_DEFAULT_PACKAGE_NAME);
|
assertThat(entry.getLabel()).isEqualTo(APP_DEFAULT_PACKAGE_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -152,7 +152,7 @@ public class BatteryEntryTest {
|
|||||||
|
|
||||||
BatteryEntry entry = createBatteryEntryForApp(null, null, HIGH_DRAIN_PACKAGE);
|
BatteryEntry entry = createBatteryEntryForApp(null, null, HIGH_DRAIN_PACKAGE);
|
||||||
|
|
||||||
assertThat(entry.getLabel()).isEqualTo(LABEL_PREFIX + HIGH_DRAIN_PACKAGE);
|
assertThat(entry.getLabel()).isEqualTo(HIGH_DRAIN_PACKAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -163,7 +163,7 @@ public class BatteryEntryTest {
|
|||||||
null,
|
null,
|
||||||
HIGH_DRAIN_PACKAGE);
|
HIGH_DRAIN_PACKAGE);
|
||||||
|
|
||||||
assertThat(entry.getLabel()).isEqualTo(LABEL_PREFIX + HIGH_DRAIN_PACKAGE);
|
assertThat(entry.getLabel()).isEqualTo(HIGH_DRAIN_PACKAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Reference in New Issue
Block a user