修改framework/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -686,8 +688,20 @@ public class PhoneWindowManager implements WindowManagerPolicy {
private long mScreenshotChordVolumeDownKeyTime;
private boolean mScreenshotChordVolumeDownKeyConsumed;
private boolean mScreenshotChordVolumeUpKeyTriggered;
private boolean mScreenshotChordPowerKeyTriggered;
private long mScreenshotChordPowerKeyTime;
+
+ long presstime =0;
+ int i = 0;
/* The number of steps between min and max brightness */
private static final int BRIGHTNESS_STEPS = 10;
@@ -1332,6 +1346,32 @@ public class PhoneWindowManager implements WindowManagerPolicy {
}
}
}
+
+ private void customsendbroadcast() {
+ Intent intent = new Intent();
+ intent.setAction("com.back3.broadcast");
+ mContext.sendBroadcast(intent);
+ Log.d(TAG,"customsendbroadcast Action end");
+ }
private long getScreenshotChordLongPressDelay() {
if (mKeyguardDelegate.isShowing()) {
@@ -5536,10 +5620,27 @@ public class PhoneWindowManager implements WindowManagerPolicy {
&& (policyFlags & WindowManagerPolicy.FLAG_VIRTUAL) != 0
&& event.getRepeatCount() == 0;
- // Handle special keys.
+ // Handle special keys.
switch (keyCode) {
case KeyEvent.KEYCODE_BACK: {
+ Log.d(TAG,"BACK start");
if (down) {
+ Log.d(TAG,"down");
+ long nowtime = System.currentTimeMillis();
+ Log.d(TAG,"nowtime="+nowtime+" presstime="+presstime);
+ if (nowtime - presstime < 1000) {
+ presstime = nowtime;
+ i = i + 1;
+ Log.d(TAG,"if:i = "+i);
+ if (i == 2){
+ Log.d(TAG,"customsendbroadcast start");
+ customsendbroadcast();
+ }
+ } else {
+ presstime = nowtime;
+ i = 0;
+ Log.d(TAG,"else:i = "+i);
+ }
mBackKeyHandled = false;
if (hasLongPressOnBackBehavior()) {
Message msg = mHandler.obtainMessage(MSG_BACK_LONG_PRESS);
此功能基于对按键间隔时间的判断,如果按键时间大于1秒,则判断重置。