Merge "Fix uninstalled app original uid should not be 0" into main

This commit is contained in:
YK Hung
2023-10-19 09:12:38 +00:00
committed by Android (Google) Code Review
3 changed files with 21 additions and 1 deletions

View File

@@ -74,6 +74,7 @@ import java.util.List;
* Utils for battery operation
*/
public class BatteryUtils {
public static final int UID_ZERO = 0;
public static final int UID_NULL = -1;
public static final int SDK_NULL = -1;
/** Special UID value for data usage by removed apps. */

View File

@@ -283,7 +283,9 @@ public class BatteryDiffEntry {
/** Whether the current BatteryDiffEntry is uninstalled app or not. */
public boolean isUninstalledEntry() {
final String packageName = getPackageName();
if (TextUtils.isEmpty(packageName) || isSystemEntry()) {
if (TextUtils.isEmpty(packageName) || isSystemEntry()
// Some special package UIDs could be 0. Those packages are not installed by users.
|| mUid == BatteryUtils.UID_ZERO) {
return false;
}