通过包名使指定app不响应home按键事件
diff --git a/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java b/frameworks/base/services/core/java/com/android/server/pol
index 740f679..037f446 100755
--- a/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -247,6 +247,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
static public final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps";
static public final String SYSTEM_DIALOG_REASON_HOME_KEY = "homekey";
static public final String SYSTEM_DIALOG_REASON_ASSIST = "assist";
+
+ private static boolean isHomeGo = true;
/**
* These are the system UI flags that, when changing, can cause the layout
@@ -3325,10 +3327,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
WindowManager.LayoutParams attrs = win != null ? win.getAttrs() : null;
if (attrs != null) {
final int type = attrs.type;
+ final String curPackageName = attrs.packageName;
if (type == WindowManager.LayoutParams.TYPE_KEYGUARD_SCRIM
|| type == WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG
+ || curPackageName.equals("com.test.001")
|| (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) {
// the "app" is keyguard, so give it the key
+ isHomeGo=false;
return 0;
}
final int typeCount = WINDOW_TYPES_WHERE_HOME_DOESNT_WORK.length;
@@ -3928,6 +3933,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
}
void launchHomeFromHotKey() {
+ if (!isHomeGo)
+ {
+ isHomeGo = true;
+ return ;
+ }
launchHomeFromHotKey(true /* awakenFromDreams */, true /*respectKeyguard*/);
}