Mean values of Hardy's Z-function and weak Gram's laws