android: Thu Dec 2 02:15:00 2010

Thu Dec 2 02:15:00 2010

I still love the G1 keyboard, but it's now way too underprovisioned for my day-to-day use (TouchDown, the activesync-in-isolation client that actually works with my new employer's Outlook 2007 install, takes up around 1/6th of the available memory all by itself, and that's just not really workable - especially since I treat it as a PDA first and a phone third) so I picked up a second-hand Nexus 1 (no keyboard at all, but it's not like any of the new keyboard-phones have decent 5-row keyboards anyway) and installed CyanogenMod 6 on it (so I get bluetooth keyboard use out-of-the-box, and can use Titanium Backup to get nightly incrementals and weekly full backups...)

In the last couple of weeks, though, I've been running in to a problem - sometimes, after running the battery into the ground (something relatively easy to do, as I leave 802.11 on, and noone is making jumbo batteries like they did for the G1) I'll charge it and power it back up and find that

The only way I've found to recover from this seems to be what the rest of the web has found - hard reset (and restore apps and data from backups.) With 170 apps installed (based on how Titanium Backup counts them, so this includes system apps and cyanogen stuff too) this takes a while, especially as I need to use the "classic" restore mode that requires two button presses per install (due to what appears to be some corrupted apks, something that needs more investigation.) Once I realized that all of the above complaints might be related, I found some useful links, mostly starting from http://code.google.com/p/android/issues/detail?id=4358 though http://groups.google.com/group/android-porting/browse_thread/thread/61baf6058966fe31 was particularly helpful in showing the actual repair technique:

$ adb shell
# sqlite3 /data/data/com.android.providers.settings/databases/settings.db
INSERT INTO "secure" (name, value) VALUES ('device_provisioned', 1);
.quit

and then reboot the phone for it to actually take effect. Apparently device_provisioned is used by inKeyguardRestrictedKeyInputMode in frameworks/base/core/java/android/view/WindowManagerPolicy.java as part of preventing the new phone user from stumbling out of the setup wizard, though a little more digging suggest it's screen-lock related as well; looking through the android tree for DEVICE_PROVISIONED seems to find the relevant code (which tells me it also turns off doing anything with the dock, based on frameworks/base/services/java/com/android/server/DockObserver.java though I can't test that since I've yet to find a source for a real Nexus 1 dock (one that uses the drop-in contacts and not just a generic fidget-with-the-connector microUSB one) and it also looks like it blocks incoming phone calls and SMSes as well.

In the meantime, I should probably write a little SL4A python app to make that change directly, see http://code.google.com/p/android-scripting/issues/detail?id=184#c15 for the first steps in getting the "run python scripts as root" part of the riddle trail. ( packages/apps/Provision/src/com/android/provision/DefaultActivity.java has the bare skeleton of how to do it from java, but doesn't include the root or UI parts at all.)