Add batterysipper type check in PowerUsageFeatureProvider

This cl adds isTypeSystem to PowerUsageFeatureProvider and
changes isTypeService. After this cl, the following items will
be moved to advanced battery page:
1. Calendar Storage(Move to System)
2. MediaServer(Move to System)

Create this check in FeatureProvider to make sure this check
is flexible in different cases. Also refactor the PowerUsageSummary
to use same test fragment

Bug: 35629871
Bug: 35628690
Bug: 35317876
Test: RunSettingsRoboTest
Change-Id: I8c083cb2557a7e900aea01e682c13a000bacb7a9
This commit is contained in:
jackqdyulei
2017-02-23 17:31:00 -08:00
parent 0497ee9731
commit 238c1c000b
8 changed files with 267 additions and 99 deletions

View File

@@ -16,9 +16,40 @@
package com.android.settings.fuelgauge;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Process;
import com.android.internal.os.BatterySipper;
import com.android.internal.util.ArrayUtils;
public class PowerUsageFeatureProviderImpl implements PowerUsageFeatureProvider {
private static final String PACKAGE_CALENDAR_PROVIDER = "com.android.providers.calendar";
protected PackageManager mPackageManager;
public PowerUsageFeatureProviderImpl(Context context) {
mPackageManager = context.getPackageManager();
}
@Override
public boolean isTypeService(BatterySipper sipper) {
return false;
}
@Override
public boolean isTypeSystem(BatterySipper sipper) {
final int uid = sipper.uidObj == null ? -1 : sipper.getUid();
sipper.mPackages = mPackageManager.getPackagesForUid(uid);
// Classify all the sippers to type system if the range of uid is 0...FIRST_APPLICATION_UID
if (uid >= Process.ROOT_UID && uid < Process.FIRST_APPLICATION_UID) {
return true;
} else {
return ArrayUtils.contains(sipper.mPackages, PACKAGE_CALENDAR_PROVIDER);
}
}
@Override
public boolean isLocationSettingEnabled(String[] packages) {
return false;
@@ -39,11 +70,6 @@ public class PowerUsageFeatureProviderImpl implements PowerUsageFeatureProvider
return false;
}
@Override
public boolean isTypeService(String[] packages) {
return false;
}
@Override
public boolean isPowerAccountingToggleEnabled() {
return false;