长按 home 与 settings 中的设置功能联动
8.0 的长按home事件
com.android.systemui.statusbar.phone;
public class NavigationBarFragment extends Fragment implements Callbacks {
@VisibleForTesting
boolean onHomeLongClick(View v) {
if (shouldDisableNavbarGestures()) {
return false;
}
MetricsLogger.action(getContext(), MetricsEvent.ACTION_ASSIST_LONG_PRESS);
mAssistManager.startAssist(new Bundle() /* args */); -------- //可以在此方法中新加自己的需求
mStatusBar.awakenDreams();
if (mNavigationBarView != null) {
mNavigationBarView.abortCurrentGesture();
}
//-----------------可以在这里新加自己的需求
return true;
}
framework 层
package com.android.server.policy;
public class PhoneWindowManager implements WindowManagerPolicy {
@Override
public long interceptKeyBeforeDispatching(WindowState win, KeyEvent event, int policyFlags) {
// First we always handle the home key here, so applications
// can never break it, although if keyguard is on, we do let
// it handle it, because that gives us the correct 5 second
// timeout.
if (keyCode == KeyEvent.KEYCODE_HOME) {
....
....
8.0 实现长按和 settings -- 高级功能 -- 设置辅助应用程序 功能联动