class HaloUtils {

    @Api(2.0)
    public static boolean isCharging(@NonNull Context context, @Nullable Intent intent) {
        Intent finalIntent = intent;
        if(finalIntent == null){
            finalIntent = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
            assert finalIntent != null;
        }
        int plugged = finalIntent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
        boolean isPlugged = plugged == BatteryManager.BATTERY_PLUGGED_AC ||
                plugged == BatteryManager.BATTERY_PLUGGED_USB;
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) {
            isPlugged = isPlugged || plugged == BatteryManager.BATTERY_PLUGGED_WIRELESS;
        }
        return isPlugged;
    }

    private  HaloUtils();

}