“窗口管理器崩溃”关于调度“Down”三星 Galaxy S 上的按键

发布于 2025-01-01 06:29:03 字数 2487 浏览 1 评论 0原文


我正在使用 Instrumentation 在各种 Android 设备上运行单元测试。测试用例在模拟器和模拟器上运行良好除 Samsung Galaxy S 之外的所有设备。 在 Samsung Galaxy S 上,它在使用仪器注入大约 30 个关键事件后显示窗口管理器崩溃,这里是完整的崩溃日志:

D/dalvikvm(11862): GC_EXPLICIT freed 6800 objects / 374040 bytes in 54ms
D/dalvikvm(11862): GC_EXPLICIT freed 780 objects / 71856 bytes in 39ms
W/dalvikvm(11862): threadid=9: thread exiting with uncaught exception (group=0x4001d7d0)
E/WindowManager( 2472): Window Manager Crash
E/WindowManager( 2472): java.lang.NullPointerException
E/WindowManager( 2472):         at com.android.server.WindowManagerService$KeyWaiter.waitForNextEventTarget(WindowManagerService.java:5844)
E/WindowManager( 2472):         at com.android.server.WindowManagerService.injectKeyEvent(WindowManagerService.java:5565)
E/WindowManager( 2472):         at android.view.IWindowManager$Stub.onTransact(IWindowManager.java:110)
E/WindowManager( 2472):         at com.android.server.WindowManagerService.onTransact(WindowManagerService.java:692)
E/WindowManager( 2472):         at android.os.Binder.execTransact(Binder.java:288)
E/WindowManager( 2472):         at dalvik.system.NativeStart.run(Native Method)
E/AndroidRuntime(11862): FATAL EXCEPTION: Instr: com.myapp.test.ImpInstrumentation
E/AndroidRuntime(11862): java.lang.NullPointerException
E/AndroidRuntime(11862):        at android.os.Parcel.readException(Parcel.java:1266)
E/AndroidRuntime(11862):        at android.os.Parcel.readException(Parcel.java:1248)
E/AndroidRuntime(11862):        at android.view.IWindowManager$Stub$Proxy.injectKeyEvent(IWindowManager.java:830)
E/AndroidRuntime(11862):        at android.app.Instrumentation.sendKeySync(Instrumentation.java:859)
E/AndroidRuntime(11862):        at android.app.Instrumentation.sendKeyDownUpSync(Instrumentation.java:872)
E/AndroidRuntime(11862):        at com.myapp.test.util.ListUtil.<b>arrowDownToPosition</b>(ListUtil.java:69)

这是通常崩溃的代码片段:

    private void arrowDownToPosition(int position) {
          int maxDowns = 50;
        while(mListView.getSelectedItemPosition() < position && --maxDowns > 0) {
             mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_DOWN);
        }

//Crashes on below line dispatching enter key
      mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_ENTER);
    }

欢迎所有解决方案/建议。

I am running my Unit tests on various android devices using Instrumentation . Testcases works fine on emulator & all devices except Samsung Galaxy S.
On Samsung Galaxy S it displays a Window Manager crash after injecting some 30 key events using instrumentation here is the complete crash log:

D/dalvikvm(11862): GC_EXPLICIT freed 6800 objects / 374040 bytes in 54ms
D/dalvikvm(11862): GC_EXPLICIT freed 780 objects / 71856 bytes in 39ms
W/dalvikvm(11862): threadid=9: thread exiting with uncaught exception (group=0x4001d7d0)
E/WindowManager( 2472): Window Manager Crash
E/WindowManager( 2472): java.lang.NullPointerException
E/WindowManager( 2472):         at com.android.server.WindowManagerService$KeyWaiter.waitForNextEventTarget(WindowManagerService.java:5844)
E/WindowManager( 2472):         at com.android.server.WindowManagerService.injectKeyEvent(WindowManagerService.java:5565)
E/WindowManager( 2472):         at android.view.IWindowManager$Stub.onTransact(IWindowManager.java:110)
E/WindowManager( 2472):         at com.android.server.WindowManagerService.onTransact(WindowManagerService.java:692)
E/WindowManager( 2472):         at android.os.Binder.execTransact(Binder.java:288)
E/WindowManager( 2472):         at dalvik.system.NativeStart.run(Native Method)
E/AndroidRuntime(11862): FATAL EXCEPTION: Instr: com.myapp.test.ImpInstrumentation
E/AndroidRuntime(11862): java.lang.NullPointerException
E/AndroidRuntime(11862):        at android.os.Parcel.readException(Parcel.java:1266)
E/AndroidRuntime(11862):        at android.os.Parcel.readException(Parcel.java:1248)
E/AndroidRuntime(11862):        at android.view.IWindowManager$Stub$Proxy.injectKeyEvent(IWindowManager.java:830)
E/AndroidRuntime(11862):        at android.app.Instrumentation.sendKeySync(Instrumentation.java:859)
E/AndroidRuntime(11862):        at android.app.Instrumentation.sendKeyDownUpSync(Instrumentation.java:872)
E/AndroidRuntime(11862):        at com.myapp.test.util.ListUtil.<b>arrowDownToPosition</b>(ListUtil.java:69)

And here is the piece of code where it generally crashes:

    private void arrowDownToPosition(int position) {
          int maxDowns = 50;
        while(mListView.getSelectedItemPosition() < position && --maxDowns > 0) {
             mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_DOWN);
        }

//Crashes on below line dispatching enter key
      mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_ENTER);
    }

All solutions/suggestions are welcome.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

家住魔仙堡 2025-01-08 06:29:03

不确定这是否有帮助,但是在简要研究这个问题时,我发现了这个 。看一下,特别是第 175 行,有关 Galaxy S 上 DPAD_CENTER 的错误,以及如何解决该问题。

Not sure if this helps, but while briefly researching this issue, I found this source. Have a look, particularly from line 175 about a bug with DPAD_CENTER on the Galaxy S, and how the issue is resolved.

删除会话 2025-01-08 06:29:03

根据您的堆栈跟踪,您的变量 mInstrumentation 似乎为空。你是不是忘记初始化了?

试试这个:

while(mInstrumentation!=null && mListView.getSelectedItemPosition()>-1) {
    mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_DOWN);
}

according to your stacktrace it seems that your variable mInstrumentation is null. did you forget to initialize it?

try this:

while(mInstrumentation!=null && mListView.getSelectedItemPosition()>-1) {
    mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_DOWN);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文