The realization of thought:The Windowmanagerservice loop reads the following key information and distribution forms. Filtering of messages in the Phonewindowmanager.interceptkeybeforequeueing method.
Therefore, the implementation is to listen to the current key in the Interceptkeybeforequeueing method before the message is distributed to the volume key, assuming the current state is the lock screen state. And the key is the volume down key, and two times the key interval time is less than 800ms to send snapshot broadcast-"Com.bill.snapshot".
Detailed implementations such as the following:
/framework/base/policy/src/com/android/policy/impl/phonewindowmanager.java
Private long lasttime=0;
public int interceptkeybeforequeueing (keyevent event,int Policyflags,boolean isscreenon) {if (Event.getkeycode () ==Key Event.keycode_volume_down && Event.isdwon ()) {if (iskeyguardlocked ()) {if (system.currenttime Millis ()-lasttime) < () {Intent intent=new Intent ("Com.bill.snapshot"); Mcontext.sendbroadcast (Intent); } lasttime=system.currenttimemillis (); } }......}
Android lock screen or off status-screen, high Speed Press two volume down key to achieve the shooting function (1.1Framework in the form of the implementation of the layer broadcast)