Note: As of December 2014, I no longer own the phone which had all of these problems (a Google-branded T-Mobile G2 purchased in late 2010). As a result, I don't expect to enhance this code except if requested by users. Feel free to file an issue here at BitBucket if there is something you need.
Cursed Car Home
My Android phone is "cursed" periodically by a phantom that repeatedly turns on the Car Home application as if the phone were being docked. (It's probably a hardware problem.) Besides the annoyance caused by the Car Home application itself, a bigger problem is that Car Home enables the speakerphone and never turns it back off.
I've tried several of the existing applications in the Android marketplace (such as Disable Car Home and Dock No-Op), but nothing has quite worked for me. This application is my attempt to solve the problem. It's a "big hammer" approach -- once a dock event is handled, dock mode is immediately disabled. Then, a background process starts. This process watches for future dock events and also kills Car Home if it's ever found running. Separately, I also hook into the phone call process to disable the speakerphone every time an inbound or outbound call is initiated.
Using the Application
Install the application from the Google Play Store.
By default, all features are disabled. I recommend enabling all features. Once you have enabled a feature, the default settings for the other options should work fine for most people. If you tend to see clusters of events over a period of time, you may want to change some values.
For instance, on my phone, I often get several to a dozen dock events over a 30 minute window (or sometimes even longer). When first started, the background process is very aggressive about how often it looks for problems. As the time between discovered problems grows, the background process gradually slows down and looks for problems less often.
If you are seeing clusters of events, you may find that it takes too long for the background process to notice problems and clean them up. You can adjust this behavior by decreasing the maximum delay. You may also want to increase the maximum lifetime of the background process.
I find the daily report useful, because it alerts me to problems that might have occurred when I was not looking at the phone (such as overnight when I am sleeping). However, you can disable the report if you want to. Even if the daily report is disabled, you can always run the report manually. Open the application and choose Menu > Run Daily Report.
Cursed Car Home requires a fairly intrusive set of device permissions. I wish I could do with less, but part of the reason Cursed Car Home works better for me is because it's different -- and the things it does require a lot of permissions. Below is a list of the required permissions and what they are needed for.
|RECEIVE_BOOT_COMPLETED||Schedule the daily report|
|KILL_BACKGROUND_PROCESSES||Kill the Car Home application|
|PROCESS_OUTGOING_CALLS||Check the speakerphone state when calls start|
|MODIFY_AUDIO_SETTINGS||Disable the speakerphone|
|READ_PHONE_STATE||Disable the speakerphone|