Init PowerWhitelistbackend to stop crash

Also update text to "unavailable" to reflect its current status.

Fixes: 129955147
Test: Manual
Change-Id: Ib80d68d6d2b6bc4ced4a72483859e675b7e7e61c
This commit is contained in:
Lei Yu
2019-04-04 12:53:55 -07:00
parent 254afc0da0
commit 033fe6eec0
3 changed files with 27 additions and 4 deletions

View File

@@ -173,10 +173,18 @@ public class HighPowerDetail extends InstrumentedDialogFragment implements OnCli
}
public static CharSequence getSummary(Context context, String pkg) {
PowerWhitelistBackend powerWhitelist = PowerWhitelistBackend.getInstance(context);
return context.getString(powerWhitelist.isSysWhitelisted(pkg) ? R.string.high_power_system
: powerWhitelist.isWhitelisted(pkg) ? R.string.high_power_on
: R.string.high_power_off);
return getSummary(context, PowerWhitelistBackend.getInstance(context), pkg);
}
@VisibleForTesting
static CharSequence getSummary(Context context, PowerWhitelistBackend powerWhitelist,
String pkg) {
return context.getString(
powerWhitelist.isSysWhitelisted(pkg) || powerWhitelist.isDefaultActiveApp(pkg)
? R.string.high_power_system
: powerWhitelist.isWhitelisted(pkg)
? R.string.high_power_on
: R.string.high_power_off);
}
public static void show(Fragment caller, int uid, String packageName, int requestCode) {