代码路径:
frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
在PhoneWindowManager.java文件中添加长按和抬起功能
volatile boolean mRecordOkKeyHandled;
private void interceptRecordOkLongKeyDown(boolean handled){
mRecordOkKeyHandled = handled;
if (!handled) {
mHandler.postDelayed(mRecordOkLongPress, LONG_PRESS_POWR_DELAY_MILLIS);
}
}
private void interceptRecordOkLongKeyUp(){
if (!mRecordOkKeyHandled) {
mHandler.removeCallbacks(mRecordOkLongPress);
}
}
private final Runnable mRecordOkLongPress = new Runnable() {
@Override
public void run() {
mRecordOkKeyHandled = true;
//这里通过广播发送出去做一些功能实现
}
};
private void sendBroadCast(String action,String type) {
Intent intent = new Intent();
intent.setAction(action);
intent.putExtra("Type", type);
mContext.sendBroadcast(intent);
}