Current sensing for backup battery circuit with LiPo charger
You need to sense if there is 5v on the USB rail, and know where that voltage is coming from.
Here is my solution to your problem:



In summary, you need to provide a reference voltage using the Lipo battery. Compare this reference voltage to the USB 5v rail using an op amp to sense if there is 5v present on the rail. Also, use the output of the boost converter (before the diode) to sense if the boost converter is on. Feed the "boost converter on" signal and the "5v present" signal into a NAND gate to get an active low signal for the charger circuit. To enable the boost converter, feed the "5v present" signal into a not gate, and connect the output to the boost converter enable terminal.

The resistor dividers including R1, R2, R3, and R4, need to be set up so that the output voltage is 0.5v. (Or anything less than your reference voltage, the important part is that they are the same.)