capsule: Fix Facebook login bug.

When the Facebook app isn't open or fails to load data, it repeatedly
loads a splash screen and does not advance. This CL works around it by
clearing, closing, and reopening the app, then switching back to the
activity of the app we were crawling and clicking the Facebook login
button again.

I also fixed some other bugs in this cl, including making sure that the
previous path is accounted for in the return value of
find_shortest_path(), using device.shell() instead of using subprocess
to call adb shell, and turning on / unlocking the phone if necessary.

Change-Id: I2608b595d07cdf19cca51afa96e8a39a4946c347
2 files changed