Verify that root digest of hashtree matches the one of APEX

In case it doesn't, hasthree will be regenerated. Also refactored code a
little bit to make it easier to unit test.

Test: apexservice_test
Test: apexd_verity_test
Bug: 145670581
Change-Id: Ibb41ac86222dbfeff2e2bd898dfe12c2aac9a271
8 files changed