capsule: Follow shortest path.

Previously for recrawls, we assumed that the app would launch with the
same root Layout as the first time we crawled it, and would not be able
to get to the intended Layout if this is not the case. However, often
there is an intro, agreement, or login screen that is only shown once.
This cl introduces a find_shortest_path method that uses BFS to find a
route between the starting Layout and intended Layout. It allows us to
go between any two Layouts using previously explored paths. If it finds
an unintended path, it removes that edge from the graph and adds the
new edge, and also tries to find a new path from the current layout.

Also, introduce a touch() method to improve readibility and always
catch exceptions for weird coordinates.

Change-Id: I6b65e6a79d6affe677d8ed4a8a08c0d525b4d885
3 files changed