Updater: do not use hidden field

BatteryManager#BATTERY_PLUGGED_ANY is hidden and actually just
a combination of all public available plugged values.
Recreate the hidden field instead of using it directly.

This unbreaks Android Studio builds.

Change-Id: I4754ce7544dab22306eeac03c3e9f26b650094d2
Signed-off-by: Alexander Martinz <amartinz@shiftphones.com>
This commit is contained in:
Alexander Martinz 2020-04-01 13:45:16 +02:00 committed by coderzstas
parent 9c406af28d
commit e9a046ff47

View File

@ -71,6 +71,10 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
private static final String TAG = "UpdateListAdapter";
private static final int BATTERY_PLUGGED_ANY = BatteryManager.BATTERY_PLUGGED_AC
| BatteryManager.BATTERY_PLUGGED_USB
| BatteryManager.BATTERY_PLUGGED_WIRELESS;
private final float mAlphaDisabledValue;
private List<String> mDownloadIds;
@ -618,7 +622,7 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
int percent = Math.round(100.f * intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 100) /
intent.getIntExtra(BatteryManager.EXTRA_SCALE, 100));
int plugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0);
int required = (plugged & BatteryManager.BATTERY_PLUGGED_ANY) != 0 ?
int required = (plugged & BATTERY_PLUGGED_ANY) != 0 ?
mActivity.getResources().getInteger(R.integer.battery_ok_percentage_charging) :
mActivity.getResources().getInteger(R.integer.battery_ok_percentage_discharging);
return percent >= required;