buglabs / android

This is the top-level git repo for the Android on BUG 2.0 project. Refer to the start page for further details:
http://buglabs.github.com/android/
5 stars 1 forks source link

Map BUG power button to Android power button #10

Closed kgilmer closed 13 years ago

kgilmer commented 13 years ago

Currently (as of build 47) the power button causes no change on an Android-booted BUG.

kgilmer commented 13 years ago

I had played around with enabling the TWL4030 power button but wasn't able to get it working. Kernel panics on boot saying that the button could not be registered twice.

kgilmer commented 13 years ago

After some more digging I've found that the power button is enabled via TWL4030 code in 2.6.32 that varies greatly from 2.6.31 BL kernel. Enabling the option in the defconfig naturally causes a conflict. It's unclear if the pre-existing button configuration yet works, but it is present here:

/sys/devices/platform/twl4030_pwrbutton

teknosalsero commented 13 years ago

Yes, power button would be nice!

teknosalsero commented 13 years ago

This should also trigger sleep mode.

kgilmer commented 13 years ago

Suspend will be addressed as a separate issue as it's more complex than just shutdown.

kgilmer commented 13 years ago

Matt Isaac's commit https://github.com/buglabs/android-froyo-kernel/commit/7c887e04f1147df4713f728b61e1166b609e2e5f has enabled the power button. Now, when holding down the power button, a shutdown menu is provided allowing the user to shut the device down. After some time the screen goes blank but the backlight and LEDs are still on. Logcat provides the following clues:

W/InputManagerService( 1001): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Pro0 D/StatusBar( 1001): DISABLE_EXPAND: yes I/dalvikvm( 1001): Jit: resizing JitTable from 8192 to 16384 I/ARMAssembler( 1001): generated scanline__00000077:03515104_00000000_00000000 [ 33 ipp](47 ins) at [0x3c55c0:0x3c567c] in 213623 s D/ShutdownThread( 1001): Notifying thread to start radio shutdown I/ShutdownThread( 1001): Sending shutdown broadcast... W/SyncManager( 1001): Writing sync state before shutdown... I/ShutdownThread( 1001): Shutting down activity manager... W/UsageStats( 1001): Writing usage stats before shutdown... W/BatteryStats( 1001): Writing battery stats before shutdown... W/ShutdownThread( 1001): Turning off radio... I/ShutdownThread( 1001): Waiting for Bluetooth and Radio... E/gralloc ( 1001): [unregister] handle 0xef148 still locked (state=40000001) I/ShutdownThread( 1001): Shutting down MountService I/MountService( 1001): Shutting down W/ShutdownThread( 1001): Shutdown wait timed out I/ShutdownThread( 1001): Performing low-level shutdown... E/gralloc ( 1001): ioctl OMAPFB_WAITFORVSYNC failed!! E/gralloc ( 1001): ioctl OMAPFB_WAITFORVSYNC failed!!

kgilmer commented 13 years ago

I tried commenting out the stanza generating the error in the omap3 framebuffer.cpp driver:

if (ioctl(m->framebuffer->fd, OMAPFB_WAITFORVSYNC, 0)) { LOGE("ioctl OMAPFB_WAITFORVSYNC failed!!\n"); //m->base.unlock(&m->base, buffer); return -errno; }

This results in different log data but the same situation: LEDs and backlight are on, system says "halted" but still response to serial console. Logcat contents:

I/ActivityThread( 1167): Publishing provider media: com.android.providers.media.MediaProvider V/MediaProvider( 1167): Attached volume: internal I/ActivityThread( 1167): Publishing provider downloads: com.android.providers.downloads.DownloadProvider I/ActivityThread( 1167): Publishing provider drm: com.android.providers.drm.DrmProvider I/ActivityManager( 998): Start proc com.android.providers.calendar for broadcast com.android.providers.calendar/.CalendarReceiver:} I/ActivityThread( 1181): Publishing provider com.android.calendar: com.android.providers.calendar.CalendarProvider2 I/ActivityManager( 998): Start proc com.android.bluetooth for broadcast com.android.bluetooth/.opp.BluetoothOppReceiver: pid=1193 } I/ActivityThread( 1193): Publishing provider com.android.bluetooth.opp: com.android.bluetooth.opp.BluetoothOppProvider I/ActivityManager( 998): Start proc com.android.email for broadcast com.android.email/com.android.exchange.BootReceiver: pid=1202 } D/MediaScannerService( 1167): start scanning volume internal D/KeyguardViewMediator( 998): pokeWakelock(5000) D/KeyguardViewMediator( 998): pokeWakelock(5000) D/MediaScanner( 1167): prescan time: 1111ms D/MediaScanner( 1167): scan time: 1513ms D/MediaScanner( 1167): postscan time: 1ms D/MediaScanner( 1167): total time: 2625ms D/MediaScannerService( 1167): done scanning volume internal I/ActivityThread( 1202): Publishing provider com.android.email.provider: com.android.email.provider.EmailProvider I/ActivityThread( 1202): Publishing provider com.android.email.attachmentprovider: com.android.email.provider.AttachmentProvider I/ActivityThread( 1202): Publishing provider com.android.exchange.provider: com.android.exchange.provider.ExchangeProvider D/Exchange( 1202): BootReceiver onReceive D/EAS SyncManager( 1202): !!! EAS SyncManager, onCreate I/ActivityManager( 998): Start proc com.android.mms for broadcast com.android.mms/.transaction.MmsSystemEventReceiver: pid=1218 ui} D/Calendar( 1181): missed alarms found: 0 D/EAS SyncManager( 1202): !!! EAS SyncManager, onStartCommand I/ActivityThread( 1218): Publishing provider com.android.mms.SuggestionsProvider: com.android.mms.SuggestionsProvider D/EAS SyncManager( 1202): !!! EAS SyncManager, stopping self D/Eas Debug( 1202): Logging: D/EAS SyncManager( 1202): !!! EAS SyncManager, onDestroy I/ActivityManager( 998): Start proc com.android.music for broadcast com.android.music/.MediaAppWidgetProvider: pid=1239 uid=10021 } D/dalvikvm( 998): GC_EXPLICIT freed 8344 objects / 387312 bytes in 96ms I/ActivityManager( 998): Start proc com.android.protips for broadcast com.android.protips/.ProtipWidget: pid=1248 uid=10023 gids={} D/StatusBar( 998): DISABLE_EXPAND: yes I/dalvikvm( 998): Jit: resizing JitTable from 4096 to 8192 I/ARMAssembler( 998): generated scanline__00000077:03515104_00000000_00000000 [ 33 ipp](47 ins) at [0x38f780:0x38f83c] in 305176 s E/gralloc ( 998): [unregister] handle 0x2ce718 still locked (state=40000001) I/ActivityManager( 998): Start proc com.android.quicksearchbox for broadcast com.android.quicksearchbox/.SearchWidgetProvider: pid} D/ShutdownThread( 998): Notifying thread to start radio shutdown I/ActivityThread( 1259): Publishing provider com.android.quicksearchbox.google: com.android.quicksearchbox.google.GoogleSuggestionPr I/ActivityThread( 1259): Publishing provider com.android.quicksearchbox.shortcuts: com.android.quicksearchbox.ShortcutsProvider I/ActivityManager( 998): Start proc com.cooliris.media for broadcast com.cooliris.media/com.cooliris.cache.BootReceiver: pid=1267 } I/ActivityThread( 1267): Publishing provider com.cooliris.picasa.contentprovider: com.cooliris.picasa.PicasaContentProvider D/dalvikvm( 1084): GC_FOR_MALLOC freed 10156 objects / 489024 bytes in 145ms I/ShutdownThread( 998): Sending shutdown broadcast... I/BootReceiver( 1267): Got intent with action android.intent.action.MEDIA_SCANNER_FINISHED W/SyncManager( 998): Writing sync state before shutdown... I/ShutdownThread( 998): Shutting down activity manager... W/UsageStats( 998): Writing usage stats before shutdown... W/BatteryStats( 998): Writing battery stats before shutdown... W/ShutdownThread( 998): Turning off radio... I/ShutdownThread( 998): Waiting for Bluetooth and Radio... I/ShutdownThread( 998): Shutting down MountService I/MountService( 998): Shutting down W/ShutdownThread( 998): Shutdown wait timed out I/ShutdownThread( 998): Performing low-level shutdown...

request_suspend_state: sleep (0->3) at 142172973614 (2011-04-04 21:36:04.001678379 UTC)

request_suspend_state: wakeup (3->0) at 142477203369 (2011-04-04 21:36:04.305877617 UTC) stop_drawing_early_suspend: timeout waiting for userspace to stop drawing request_suspend_state: sleep (0->3) at 148235412580 (2011-04-04 21:36:10.064117345 UTC) stop_drawing_early_suspend: timeout waiting for userspace to stop drawing request_suspend_state: wakeup (3->0) at 149412628162 (2011-04-04 21:36:11.241332927 UTC)

kgilmer commented 13 years ago

As of build 89 this feature works thanks to Matt's kernel fixes.

bcruskie commented 13 years ago

I confirmed the following functionality of the power button in build 89:

Press and release: lockscreen Press and hold for 1 second: Phone options menu displays, user can select Power off to shutdown

teknosalsero commented 13 years ago

I confirmed too. How awesome!