Add base phone state monitoring

Begun code with javascript for monitoring the phone state.