This also includes some changes to the window manager permission checks. Almost all of these are to make it most testable (through an exception on a permission failure), though there is one permission check that needed to be added: updateOrientationFromAppTokens().