天天看点

[RK3288][Android6.0] 调试笔记 --- 屏蔽Home/Back Key

Platform: Rockchip

OS: Android 6.0

Kernel: 3.10.92

有些特殊场景需求需要屏蔽系统key, 比如home/back key,可以直接从input framework下手,改动如下:

[email protected]:~/rk3288/frameworks/native$ g df a894bb62e767f3409cf1434d69af69fc253485 b26fc08f30f44b68510c9281d1827f638bf12e20
diff --git a/services/inputflinger/EventHub.cpp b/services/inputflinger/EventHub.cpp
index c4c882..b4afad2 
--- a/services/inputflinger/EventHub.cpp
+++ b/services/inputflinger/EventHub.cpp
@@ -, +, @@ size_t EventHub::getEvents(int timeoutMillis, RawEvent* buffer, size_t bufferSiz
                 } else {
                     int32_t deviceId = device->id == mBuiltInKeyboardId ?  : device->id;

+                    /*Kris, 170830, Mask home/back key when  app is running. {*/
+                    char property[PROPERTY_VALUE_MAX];
+                    /*Kris, 170830, Mask home/back key when  app is running. }*/
+
                     size_t count = size_t(readSize) / sizeof(struct input_event);
                     for (size_t i = ; i < count; i++) {
                         struct input_event& iev = readBuffer[i];
@@ -, +, @@ size_t EventHub::getEvents(int timeoutMillis, RawEvent* buffer, size_t bufferSiz
                                 (int) iev.time.tv_sec, (int) iev.time.tv_usec,
                                 iev.type, iev.code, iev.value);

+                        /*Kris, 170830, Mask home/back key when  app is running. {*/
+                       if (iev.code == KEY_HOMEPAGE || iev.code == KEY_BACK) {
+                           property_get("debug.app.running", property, "0");
+                           if (atoi(property)) {
+                               mPendingEventIndex--;
+                               continue;
+                           }
+                       }
+                       /*Kris, 170830, Mask home/back key when  app is running. }*/
+
                         // Some input devices may have a better concept of the time
                         // when an input event was actually generated than the kernel
                         // which simply timestamps all events on entry to evdev.
           

propetery根据场景在需要的地方设置,例如:

[email protected]:~/rk3288/frameworks/base$  g df dde2be234962d89f70c1806d4a6af9bf67caca5 ab6cbee6c99bece23a4e8f4f2079481e6d87cd8 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/syst
index a2b2..c8d6e95 
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -, +, @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,

     public void displayNavigation(){
         addNavigationBarInnerLocked();
+        SystemProperties.set("debug.app.running","0");
     }
     public void hideNavigation(){
         removeNavigationBar();
+        SystemProperties.set("debug.app.running","1");
     }
           

继续阅读