this one is complicated.
I know a methode for switching it off but you have to work it out. Also, this one isn't the best methode to switch the phone off but when you connect pin 1 and 4 for just a moment the phone switches off not on the normal way but just off. I had it sometimes when I was soldering a new accesoires.
I think switching the phone on is more diffecult but I know that programs like swup can power on the phone. If somebody have this little peace of code you could make a little chip who does this when it have a little bit power (ex. when you turn your key).
I hope somebody else knows a better solution.
greetzz