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

来源:互联网 发布:手机股票行情大盘软件 编辑:程序博客网 时间:2024/06/05 00:29

Platform: Rockchip
OS: Android 6.0
Kernel: 3.10.92

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

kris@:~/rk3288/frameworks/native$ g df 07a894bb62e767f3409cf1434d69af69fc253485 b26fc08f30f44b68510c9281d1827f638bf12e20diff --git a/services/inputflinger/EventHub.cpp b/services/inputflinger/EventHub.cppindex 8c4c882..b4afad2 100644--- a/services/inputflinger/EventHub.cpp+++ b/services/inputflinger/EventHub.cpp@@ -846,6 +846,10 @@ size_t EventHub::getEvents(int timeoutMillis, RawEvent* buffer, size_t bufferSiz                 } else {                     int32_t deviceId = device->id == mBuiltInKeyboardId ? 0 : 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 = 0; i < count; i++) {                         struct input_event& iev = readBuffer[i];@@ -854,6 +858,18 @@ 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根据场景在需要的地方设置,例如:

kris@:~/rk3288/frameworks/base$  g df 8dde2be234962d89f70c1806d4a6af9bf67caca5 1ab6cbee6c99bece23a4e8f4f2079481e6d87cd8 diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systindex 827a2b2..c8d6e95 100755--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java@@ -1347,9 +1347,11 @@ 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");     }
阅读全文
1 0