ubuntu 在 R40e 上 還有 Debian 在 Sempron 2600 上

2012年2月6日 星期一

shortcut - Camera

CAMERA 按鍵在 android framework 中,要長按才會啟動,

順便可以看一下 LongPress 的 detection: if (event.getRepeatCount() == 0) { dispatcher.startTracking(event, this); } else if (event.isLongPress() && dispatcher.isTracking(event)) { dispatcher.performedLongPress(event); mDecor.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); sendCloseSystemWindows(); Broadcast an intent that the Camera button was longpressed Intent intent = new Intent(Intent.ACTION_CAMERA_BUTTON, null); intent.putExtra(Intent.EXTRA_KEY_EVENT, event); getContext().sendOrderedBroadcast(intent, null); } 大概就是... 第一次 down event (repeat()=0) 時,call startTracking( ) 叫 Input manager(?) tracking 這個 key。
這樣 input manager 就會持續嗔測 CAMERA Key, timeout 時 再送一個 down event,並且 event.isLongPress() 會是 1



在 ViewRoot.java 有關 CAMERA Key 的一段 code: private void dispatchKey(KeyEvent event, boolean sendDone) { //noinspection ConstantConditions if (false && event.getAction() == KeyEvent.ACTION_DOWN) { if (event.getKeyCode() == KeyEvent.KEYCODE_CAMERA) { if (Config.LOGD) Log.d("keydisp", "==================================================="); if (Config.LOGD) Log.d("keydisp", "Focused view Hierarchy is:"); debug(); if (Config.LOGD) Log.d("keydisp", "==================================================="); } } .... 如果把 false 拿掉,會印出有趣的 debug message,,,
D/keydisp ( 2642): =================================================== D/keydisp ( 2642): Focused view Hierarchy is: D/View ( 2642): + com.android.internal.policy.impl.PhoneWindow$DecorView@2ac72cc0 D/View ( 2642): frame={0, 0, 800, 480} scroll={0, 0} D/View ( 2642): mMeasureWidth=800 mMeasureHeight=480 D/Debug ( 2642): Contents of WM.LayoutParams{(0,0)(fillxfill) ty=1 fl=#790303 fmt=-2 wanim=0x1030001}: D/Debug ( 2642): ViewGroup.LayoutParams={ width=match-parent, height=match-parent } D/Debug ( 2642): WindowManager.LayoutParams={title=com.android.deskclock/com.android.deskclock.DeskClock} D/View ( 2642): flags={} D/View ( 2642): privateFlags={IS_ROOT_NAMESPACE HAS_BOUNDS DRAWN} D/View ( 2642): { D/View ( 2642): + android.widget.FrameLayout@2ac73900 (id=16908290) D/View ( 2642): frame={0, 0, 800, 480} scroll={0, 0} D/View ( 2642): mMeasureWidth=800 mMeasureHeight=480 D/View ( 2642): ViewGroup.LayoutParams={ width=match-parent, height=match-parent } D/View ( 2642): flags={} remain 0 unprocessed. D/View ( 2642): privateFlags={HAS_BOUNDS DRAWN} D/View ( 2642): { D/View ( 2642): + android.widget.FrameLayout@2ac74548 D/View ( 2642): frame={0, 0, 800, 480} scroll={0, 0} D/View ( 2642): mMeasureWidth=800 mMeasureHeight=480 D/View ( 2642): ViewGroup.LayoutParams={ width=match-parent, height=match-parent } D/View ( 2642): flags={} D/View ( 2642): privateFlags={HAS_BOUNDS DRAWN} D/View ( 2642): { D/View ( 2642): + android.widget.LinearLayout@2ac74bc0 (id=2131492882) D/View ( 2642): frame={0, 0, 800, 480} scroll={0, 0} D/View ( 2642): padding={0, 38, 0, 0} D/View ( 2642): mMeasureWidth=800 mMeasureHeight=480 D/View ( 2642): ViewGroup.LayoutParams={ width=match-parent, height=match-parent } 可以出來,目前的 Focuse App 是 com.android.deskclock/com.android.deskclock.DeskClock

沒有留言:

標籤

網誌存檔