There is no actual indication that the child knew the bear was behind him.
Most likely the bear was just 'escorting' the child of his territory - the child was lucky, if there was a cub around, the bear could have attacked him.
These beautiful creatures often arrive unexpectedly. Our Canadian friends were out berry picking when a big bear arrived. The husband spotted it - and hopped it - saying not a word to the wife. She got a bit of a surprise when she turned around to speak to him. He loves her really. :o)
Having spent a lot of time living in bear country one of the first things we learnt was to always be making a noise. Singing was suggested but after listening to me our friends decided that being chased by a bear was preferable though they did give me a bell to jangle.
If we were to spend any time in the mountains deodorants and toothpaste were banned. Baking soda became my friend... :-)