views:

856

answers:

1

On the Nexus One (at least in 2.1-update1, and I think in 2.1), there is a setting under Sound & Display: "Pulse notification light". This doesn't seem to be present on the "2.1 with Google APIs" emulator image. I've not yet checked any other devices.

Pulse notification light: Pulse trackball light repeatedly for new notifications

I want to set this programmatically without user interaction, in order to make a Locale plugin, so the device can grab my attention when I'm awake at my desk, without having it floodlighting the room when someone spams me at 4am. It's quite bright.

I didn't see it in android.provider.Settings.System where many other things on this screen live, so I had a look in the platform source. There are some relevant parts in NotificationManagerService, in enqueueNotificationWithTag and updateLightsLocked. That goes off into HardwareService which seems well past the point of caring about user settings. I've no idea where this setting is implemented or how I might influence it.

I fully expect the answer to be "there is no API for this" (perhaps related to it being Nexus One specific), and that the best I can do is to schedule (using Locale or something else) an Intent of ACTION_DISPLAY_SETTINGS to remind me to set the box manually, which would suck. I'm hoping that I've missed something, or that a Googler is reading this and can tell me that this is planned for addition to the API?

+1  A: 

I know I'm going to die painfully for using an undocumented API (or rather, undocumented system setting name), but here is the magic line:

android.provider.Settings.System.putInt(context.getContentResolver(),
        "notification_light_pulse", on ? 1 : 0);

Found using sqlite3 on my own device.

Here is this solution in a convenient Locale plugin: http://chris.boyle.name/projects/ptlp

Chris Boyle