Theory of piezotronics and piezo-phototronics